Render light ray and reflected light ray as spline

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

Thread Tools Display Modes
  06 June 2012
Render light ray and reflected light ray as spline

I am looking for a way to view the light ray and reflection ray as a spline. The goal is to animate the position of the sun over time and see the path of the reflected light rays.

I found this code that will get the vector of a reflected ray from but am unsure about how to draw the spline that would represent that reflected ray. For clarity, I know how to draw a spline with maxscript but not sure about where to place the points.

-- Get tangent vector halfway Line01
pathVec = tangentCurve3D $Line01 1 .5

-- Get vector from Line02
rayVec = normalize ((getKnotPoint $Line02 1 2) - (getKnotPoint $Line02 1 1))

-- Calculate reflection vector
reflectionVec = 2 * (dot -rayVec pathVec) * pathVec + rayVec

  03 March 2013
how funny, searching for something else and I find this. Turns out I had solved the issue but forgot I made a post about it.

To draw a spline you need the two points (xyz coords) OR the vector (direction) of the future spline which in this example is derived from subtracting the positions of each object. In this example we have the plane's position value as a point3 (x,y,z) value and the sphere's position which I have manually set. We can get the normalized vector (direction) that the spline is oriented as a byproduct of both of these points.

If you're not confused enough I can keep going.

fn drawthespline pointA pointB =

local ss = SplineShape pos:pointA
addNewSpline ss
addKnot ss 1 #corner #line PointA
addKnot ss 1 #corner #line PointB
updateShape ss

p = plane lengthsegs:1 widthsegs:1
s = sphere pos:[30,50,12] radius:2
p1 = p.pos
p2 = s.pos 
v1 = normalize p2-p1 --direction of spline
s1 = drawthespline p1 (p1+(v1)*100) --draws a spline along a vector multiplied by 10
s1.wirecolor = color 255 13 14
s2=drawthespline p1 p2 --draw the spline from plane position to the sphere position
s2.wirecolor = color 0 255 28

Last edited by em3 : 03 March 2013 at 04:58 PM.
  03 March 2013
Thread automatically closed

This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
CGTalk Policy/Legalities
Note that as CGTalk Members, you agree to the terms and conditions of using this website.
Thread Closed share thread

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Society of Digital Artists

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump

All times are GMT. The time now is 11:51 AM.

Powered by vBulletin
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.