I have downloaded a car model from this web site. The car is the old Ford located at: panda3d.org/artinfo.php?cat=vehi … 4–fordcar
I would like to be able to add some backlights to the car, so when I press the key “l” the lights will go on and off.
Well, you could just set a different texture where the lights are yellow (ooohh Yellow )
I am talking about the rear lights… breaks.
how do I add red lights to it ?
The easiest way is to modify the texture. Get a texture editor that can open and save .png files and paint in your best guess for the back lights. Otherwise you have to edit the geometry and then re-export it out, and you would still have to change the texture.
as russ said, open paint or any other 2d gfx program and paint the lights red/yellow/purple or whatever. Then add something like:
# load both textures
self.texLightsOn = loader.loadTexture("textures/car_lights_on.png")
self.texLightsOff = loader.loadTexture("textures/car_lights_off.png")
# we use this variable to check for lights on/off status
self.lightStatus = 0
# when you press l , switch lights on or off
if self.lightStatus = 0:
# if lights are off, set the lights on texture to the car
# set the lights status to on
self.lightStatus = 1
# if the light status is not 1, we asume lights are out
# so we turn them on
Hi, thanks for your comments.
I need to understand something:
You said “ope your texture and paint the lights red, yellow, etc…”
If I do that, then my model will always have the “red lights” in the rear of the car, and there is no way that panda will know about the rear lights. Panda will only know that there is a model.
Am I missing something there ?
You’ll have two textures, one with bright red “on” lights, another with dark yellow “off” lights. See this page of the manual: https://www.panda3d.org/manual/index.php/Simple_Texture_Replacement
By the way, most of these questions you’ve posted recently really belong in the “scripting issues” section, rather than here in the “general discussion” session.
I don’t know if this answer is too late. I’m new here (Hi all waves)
Why don’t you use Spotlight?
Then you can set the color to red using setColor:
rearlight = Spotlight( “rearlight”)
Remember the upcastToLensNode() part (see the manual on spotlight)
If you wanna use the solution with the changing textures, you might wanna check out the Tut-Carousel.py in the samples: \Panda3D-1.0.5\samples\Basic-Tutorials–Lesson-2-Intervals
There the same thing is shown on a carousel.
What is a good way to know the position of the spotlight? Put a joint there in the modelling software just to serve as an attachement point? Or is there some better way?
Well, part of the problem of the original poster is that there were no rear lights on the car to begin with. They had to be created and placed on the back. So the position was wherever one wanted them to be.
Yes, you can add joints in maya (I think the model comes with a .mb file) and then expose them in panda and it would work just as well as any solution. You should remember to export the model out as a character model if you do this. You could also use locators to do the same thing for positioning and export out as a static model if no animations will be used on the car. You could also use direct tools to position the spotlights to where you want them and save that information in some constants file, or code somewhere.