Game Development Community

Mounting lights to a vehicle

by Brian M · in Torque 3D Professional · 07/06/2010 (8:17 am) · 8 replies

Has anyone mounted lights to a vehicle, and if so, how is this done any help would be much appreciated.

#1
07/06/2010 (9:42 am)
Vehicles in torque has a special light# node for this. Not sure if it works, neither am i sure how to set it up. But as an alternative solution you could use mount# nodes for this, just use
%obj.mountObject(light, node);
to mount the lights.

Also, know that there are some threads out there that asks approximately the same. Do a search ;).
#2
07/06/2010 (9:59 am)
Thanks Marcus, I have searched lots for how to setup lights on a vehicle, there is a great example for this for 1.5.2, but the lighting system has changed for T3D, and there is not a lot of examples for mounting lights using T3D. I am using the line you gave me, I do not get any errors but the light shows up a position 0 0 0 in the level instead of on the vehicle

So What I have now is:
%shuttlelight = new PointLight(pLight) {
      radius = "25";
      isEnabled = "1";
      color = "1 1 0 1";
      brightness = "1";
      castShadows = "0";
      priority = "1";
      animate = "1";
      animationType = "SubtlePulseLightAnim";
      animationPeriod = "2";
      animationPhase = "1";
      flareScale = "1";
      attenuationRatio = "0 1 1";
      shadowType = "DualParaboloidSinglePass";
      texSize = "512";
      overDarkFactor = "2000 1000 500 100";
      shadowDistance = "400";
      shadowSoftness = "0.15";
      numSplits = "1";
      logWeight = "0.91";
      fadeStartDistance = "0";
      lastSplitTerrainOnly = "0";
      splitFadeDistances = "10 20 30 40";
      representedInLightmap = "0";
      shadowDarkenColor = "0 0 0 -1";
      includeLightmappedGeometryInShadow = "0";
      mountpoint = 2;
      offset = "0 0 0";
      eyeOffset = "0.0 0.0 0.0";
      mountposition = "0 0 0";
      mountrotation = "1 0 0 0";
      canSaveDynamicFields = "1";
   };

And in the vehicle onAdd:

echo("NOW MOUNTING LIGHT ON SHUTTLE...");
      %obj.mountObject( %shuttlelight,2);

This should be a lot simpler, and with more documentation it probably would.
#3
07/06/2010 (10:46 am)
Strange, tried your spotlight block and it worked for me. Is your spotlight created in onAdd as well? Also, a lot of the variables in the datablock you are using is really unnecessary, use this instead:
%shuttlelight = new PointLight(pLight) {
      radius = "25";
      color = "1 1 0 1";
      brightness = "1";
      castShadows = "0";
      priority = "1";
      animate = "1";
      animationType = "SubtlePulseLightAnim";
      animationPeriod = "2";
      animationPhase = "1";
      flareScale = "1";
      lastSplitTerrainOnly = "0";
      splitFadeDistances = "10 20 30 40";
      shadowDarkenColor = "0 0 0 -1";
   };
At first i thought it could be the offset that caused the light to appear at "0 0 0" but i tried with it and it still worked.
#4
07/06/2010 (10:56 am)
Ok I tried it, still the same, at position 0 0 0, I think my problem is with the OnAdd, I do not create the light there just in the %shuttlelight. What do you have in the OnAdd?
#5
07/06/2010 (11:15 am)
If you don't want to make your lights in onAdd, then you have to make some other system, for example global names or variables. If you want to make your lights at onAdd then place the light block the one you posted in the onAdd function before the mountObject function.

Reason: The reason you need to have the light block in the same function as your mountObject is because %shuttlelight is a local variable this is indicated by the % mark, meaning that its only accessible form the same function as you are referring to it.
#6
07/06/2010 (11:26 am)
That did it, I had the %shuttlelight outside of the onAdd Function, once I moved it inside it worked. I now have a light on my shuttle.

Thanks Marcus, should we ever meet, the beer is on me.
#7
07/06/2010 (11:38 am)
Off topic comment
Quote:
Thanks Marcus, should we ever meet, the beer is on me.
Dude, I'm too young :D (i should probably post a blog clearing this for people).
Don't panic, after all i have been torquing for two years. And just FYI, this community actually has some teenagers, just see this blog for example.
#8
07/06/2010 (12:03 pm)
Ya it is hard to tell a persons age from their text, all the same you ended a real fustration for me, so big thanks and wish of success in what ever project you are working on.