[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)
Perhapsvect
is the vector from the eye to the sun ?
OR perhaps justsdir
is 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=peye
makes 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.
Advertisement