Inside Sabertooth
Learn how Sabertooth uses 3ds Max to create 3D interactive projects, including HBO Go’s Game of Thrones interactive experience
  • 1/3
You are here: Forum Home / Autodesk 3ds® Max® / MaxScript / Rotate colliding trees
  RSS 2.0 ATOM  

Rotate colliding trees
Rate this thread
 
37551
 
Permlink of this thread  
avatar
  • kuatto
  • Posted: 08 December 2009 04:57 AM
  • Total Posts: 1
  • Joined: 08 December 2009 12:53 PM

This is my first undertaking with maxscript, and I need some help. I’m converting a scene for a game which has ~17k trees (2 plane objects). The problem is that the game’s engine doesn’t handle intersecting trees very well and I get flickering and other z-buffer issues. I mashed together a script that compares two trees and if they collide it rotates one of them on the x-axis. (not very useful when you have this many trees)

fn SetRotation obj rx ry rz =
(
    local translateMat 
transMatrix obj.transform.pos
     local scaleMat 
scaleMatrix obj.transform.scale
    obj
.transform scaleMat translateMat
 
    rotate obj (angleaxis rx [1
,0,0])
    rotate obj (angleaxis ry [0
,1,0])
    rotate obj (angleaxis rz
[0
,0,1])
)
 
------------------------------------------------------
objs selection as array
for 
1 to objs.count do
(
for i+1 to objs.count do
(
    
if (intersects objs[i] objs[j]) then
SetRotation objs[i] 30 0 0 

)

Is there a way to make something like this work if I multiple objects are selected? What I mean is, if I select say 1000 trees, have the script find the colliding trees and then rotate them?

Thanks for helping out a noob.



Replies: 0