- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
hello,
I'm just getting started with MAXscript.
I want to reflect a line about a surface normal to create a new line to simulate light bouncing. The line is defined by the location of a point helper named lineOrigin01. The end of the line is at the center of an editable mesh object named reflectSurface01. I want to create a new line that is 100m long at the reflected direction.
Below is the best I could come up with, with chatGPT helping (or not helping but helping me learn). Get the objects, get the normal vector, reflect function, draw the line. If anyone has ANY tips or ideas they would be gladly received!
-- Define the start point of the line as the location of sunORIGIN object
startPoint = sunORIGIN.pos
-- Define the surface object to reflect off of as reflectSURFACE
surfaceObj = $reflectSURFACE
-- Get the center point of the surface object
surfaceCenter = (surfaceObj.max + surfaceObj.min) * 0.5
-- Get the normal vector of the surface object
surfaceNormal = normalize((surfaceObj.normal * surfaceObj.transform) as vector3)
-- Calculate the end point of the line using the reflect() function
endPoint = reflect(startPoint - surfaceCenter, surfaceNormal) + surfaceCenter
-- Create the line object with a length of 100 units
lineObj = createLine start:endPoint end:(endPoint + surfaceNormal * 100.0)
Solved! Go to Solution.