View Full Version : when car reverses i want red lights to come on
07-08-2004, 03:08 PM
Hi, I am building a 3d model of a car, so far I have wired the parameters of the body to the wheels etc so when the car moves forward or back the wheels spin accordingly. However, i would like the red lights at the back to come on while the car is reversing (travelling back along the x-axis, material diffuse color changes to red) and then turn off (diffuse color to black) when it stops...any ideas on how to do this? if possible just with wiring parameters
thanks in advance,
07-08-2004, 08:59 PM
I don't have max in front of me, but I think you would be better off using a script controller for the diffuse color instead of wiring the parameters. Just make it depend on your car's x position. It would just have to check the position the car was at the frame before (I think you can script a check for that, perhaps through the curve editor), and if the current x position is less than the last frame's x position, the car is moving backwards, so it would return red. If not, it would return black. If no one has helped you by this evening I will try it out and see if it works. Or you could just try scripting it yourself ;)
Just for your refrence, I would not use a wired parameter because of the way it has to check the position of the frame before. It just logically makes more sense to think of that as a controller, since the x-position does not actually influence the color, only the change in x-position. It could be done that way, but especially when scripting, keeping the logic clean is always important.
07-09-2004, 06:17 AM
Ok, here is your basic script. It goes in a point3 script controller in your material's diffuse channel (do it from the curve editor). Edit as you need (eg object name needs changing for sure, probably colors).
y = currentTime.frame
if (at time (y-1) $box01.pos.x) > (at time y $box01.pos.x) then [0.749019, 0.0, 0.0]
else [0.588235, 0.588235, 0.588235]
07-09-2004, 09:20 AM
thanks man, thats great. I'm not much of a programmer but I have just completed a degree in software programming lol and I want to create better animations using Maxscript and MEL(i use Maya too)...thanks again
07-09-2004, 09:27 AM
oh by the way, the lights is simply a box called 'lights' attached to the main body of the car, how can i get this to object to change color?
07-09-2004, 09:03 PM
1. Make a new material (name it 'taillights'), and set it up however you want. Copy down the two colors that you choose in RGB, the one for 'on' lights (red) and the one for 'off' lights (dark red? gray? whatever you choose. Apply this material to the lights.
2. Open the curve editor, and then go to materials (second from bottom I think, right above objects). Open that, and find 'taillights'. Open taillights, and click the diffuse slot. Right click and hit assign controller (I think that is what it is called...at work again ;)). Choose a 'point3 script', and paste the script there.
3. change $box01 to the name of your car (change it in every place).
4. Then you have to calculate the numbers for the point 3. Remember those RGB's you took down? Time to use them. divide each segment of the red one by 256, and put into the first set of braces . So 192, 0, 0 becomes [0.75, 0.0, 0.0].
5. Do the same for your other (off) color.
Now when you close the script, you should see the graph of the diffuse color jumps up and down with your animation...if you have an animation. Close the editor, and play your scene. If it is animated along the x axis, every time the car goes backwards, the color should change. Make sense?
07-12-2004, 10:57 AM
thanks a lot works great! very clever
01-18-2006, 03: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.
vBulletin v3.0.5, Copyright ©2000-2015, Jelsoft Enterprises Ltd.