CGTalk > Software > Autodesk 3ds max > 3dsMax SDK and MaxScript
Login register
Thread Closed share thread « Previous Thread | Next Thread »  
 
Thread Tools Search this Thread Display Modes
Old 07-08-2004, 02:08 PM   #1
JPixel
Frequenter
Jhem Murray
United Kingdom
 
Join Date: Jun 2003
Posts: 228
when car reverses i want red lights to come on

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,

jpixel
 
Old 07-08-2004, 07:59 PM   #2
Flipped_Normal
Just call me Eric
 
Flipped_Normal's Avatar
Student
 
Join Date: Apr 2004
Posts: 175
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.
 
Old 07-09-2004, 05:17 AM   #3
Flipped_Normal
Just call me Eric
 
Flipped_Normal's Avatar
Student
 
Join Date: Apr 2004
Posts: 175
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).


Code:
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]
 
Old 07-09-2004, 08:20 AM   #4
JPixel
Frequenter
Jhem Murray
United Kingdom
 
Join Date: Jun 2003
Posts: 228
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
 
Old 07-09-2004, 08:27 AM   #5
JPixel
Frequenter
Jhem Murray
United Kingdom
 
Join Date: Jun 2003
Posts: 228
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?
 
Old 07-09-2004, 08:03 PM   #6
Flipped_Normal
Just call me Eric
 
Flipped_Normal's Avatar
Student
 
Join Date: Apr 2004
Posts: 175
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?
 
Old 07-12-2004, 09:57 AM   #7
JPixel
Frequenter
Jhem Murray
United Kingdom
 
Join Date: Jun 2003
Posts: 228
thanks a lot works great! very clever
 
Old 01-18-2006, 03:00 PM   #8
CGTalk Moderation
Lord of the posts
CGTalk Forum Leader
 
Join Date: Sep 2003
Posts: 1,066,480
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


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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
CGSociety
Society of Digital Artists
www.cgsociety.org

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

All times are GMT. The time now is 02:04 AM.


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