PDA

View Full Version : how do i change an object at rendertime?


Etchy
06-27-2003, 12:59 PM
Im having a problem with a script im working at, where i can take an object in scene A and exchange it with an object from scene B..

for eksameple.. im having a scene of a street where i want cars in but they got to many vertex's, so i want to have a box in the street scene that i can change out with the car at render time..

i have tried to do it with a preRender but i get a string error cause i tryed to use merge, witch i also found out, just puts in the object at the place it have in the scene it came from, and dont inherit the x,y,z cordinats from the object its going to replace..

can somebody give me a hint how to get further.. im a little stuck.. thinking maybe i can use Xref, but can i do that in a preRender string and if so, how can i specify the file i want to get the (car) object from? I have been looking to see if i could find a script that did something in preRender put cant.. except the build in "howTo" excample but it just give a sphere more segments.. I also cant seem to find out how to have a string in a string..

Help!!!

Etchy

Bobo
06-29-2003, 12:28 AM
Originally posted by Etchy
Im having a problem with a script im working at, where i can take an object in scene A and exchange it with an object from scene B..

for eksameple.. im having a scene of a street where i want cars in but they got to many vertex's, so i want to have a box in the street scene that i can change out with the car at render time..

i have tried to do it with a preRender but i get a string error cause i tryed to use merge, witch i also found out, just puts in the object at the place it have in the scene it came from, and dont inherit the x,y,z cordinats from the object its going to replace..

can somebody give me a hint how to get further.. im a little stuck.. thinking maybe i can use Xref, but can i do that in a preRender string and if so, how can i specify the file i want to get the (car) object from? I have been looking to see if i could find a script that did something in preRender put cant.. except the build in "howTo" excample but it just give a sphere more segments.. I also cant seem to find out how to have a string in a string..

Help!!!

Etchy


First of all, you don't really need MAXScript for this (did *I* say that?!) as XRef Objects give you the option to use proxies in the scene and the full object in the Rendering.

Save a Hi-Res version and a Lo-Res version of your car (the real mesh and probably just a box).
Go to File > XRef Objects... and select the Hi-Res version file.
The real object will appear in the scene.
In the Modifier tab, check "XRef:Viewport Proxy > Use Proxy" and select the Lo-Res version file under File Name.
You will see the low resolution mesh in the scene, but if you hit render, you will see the Real Thing...

Now back to MAXscript - you could switch meshes on the fly using PreRender callback, but it would be more difficult to manage and might cause more problems in general. If the XRef method works for you, just use it.
If you really want to write a MAXScript that does what you described, you might want to start with a simpler one where the hi-res object is already in the scene but hidden.
You could copy a TriMesh snapshot from the one object to the .mesh property of the other (if it is EMesh) or use the ReplaceInstances method to switch MAXWrappers.
Note that the How To example does not replace the object but just alter it. Changing objects could be potentially dangerous!

Hope this helps...

CGTalk Moderation
01-15-2006, 12:00 PM
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.