[request] Cline from Camera Eye to Sun
-
Hy, I need to position a Light Emitting plane for my scene, to replace SUN for rendering, but I want to position it exactly in place of sun (to have same shadows). For that, I need an axis to point from Camera View to Sun direction. Any plugin for that? Or is possible with some code directly from ruby console?
-
Untried.
model=Sketchup.active_model sdir=model.shadow_info["SunDirection"] Vector3d(0.259928, -0.492601, 0.830531) cama=model.active_view.camera ceye=cama.eye ctar=cama.target vec2=ctar.vector_to(ceye) vect=Geom::Vector3d.linear_combination(0.5, sdir, 0.5, vec2)
Perhapsvectis the vector from the eye to the sun ?
OR perhaps justsdiris the vector ? Test it and see... -
Just for fun, this one-line command creates a guide line from eye to sun.
Sketchup.active_model.entities.add_cline(Sketchup.active_model.active_view.camera.eye,Geom;;Vector3d.linear_combination(0.5,Sketchup.active_model.shadow_info["SunDirection"],0.5,Sketchup.active_model.active_view.camera.target.vector_to(Sketchup.active_model.active_view.camera.eye))) -
@didier bur said:
Just for fun, this one-line command creates a guide line from eye to sun.
Sketchup.active_model.entities.add_cline(Sketchup.active_model.active_view.camera.eye,Geom;;Vector3d.linear_combination(0.5,Sketchup.active_model.shadow_info["SunDirection"],0.5,Sketchup.active_model.active_view.camera.target.vector_to(Sketchup.active_model.active_view.camera.eye))) >Thanks Didier, I knew it was some permutation of those things

-
Thank you very much for this, but it seems to be some problem. See the images.
If I look from downside, the line is mirrored. Instead of ascending from camera eye to back, where is the sun, it goes in opposite direction.


-
Since the sun is assumed to be infinitely far away you can make a cline 'ray' from the eye in the direction of its vector thus...
model=Sketchup.active_model svec=model.shadow_info["SunDirection"] peye=model.active_view.camera.eye clin=model.active_entities.add_cline(peye, svec) clin.end=nil clin.start=peyemakes a ray extending from the eye to infinity...
Here it is in one line
model=Sketchup.active_model;svec=model.shadow_info["SunDirection"];peye=model.active_view.camera.eye;clin=model.active_entities.add_cline(peye, svec);clin.end=nil;clin.start=peye -
Thank you TIG, this is exactly what I wanted.

Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better π
Register LoginAdvertisement