Game Development Community

Mounting a spotlight to mount1

by Katrina Rose · in Torque Game Engine · 02/18/2005 (3:57 pm) · 6 replies

Hey all,

This is an effort by a graphics grunt to pitch in and assist some waaaaaay overworked programmers.

I am trying to mount a SgUniversal spotlight to a node labeled mount1....the effect I'm striving for is a simplistic flashlight. Nothing fancy, nothing great. Function before form.

I've looked at the flashlight & laser resource that's posted here on the site but, for a variety of reasons, I would rather mount the spotlight without going in and modifying the engine code.

Does anyone have a way to accomplish this? I think the fix is probably pretty simplistic...I just can't wrap my graphics-oriented brain around it.

Any wisdom you can spare would really help me out.

cheers,
k

#1
02/18/2005 (4:16 pm)
FxLights/sgUniversal lights have a script function you can use called attachToObject/detachFromObject.

You can use these to attach to the mount of the object. Something like so:
%light.attachToObject(%shape);

Unfortunately you can't specify a mount node. However you could create a very small shape and mount this to your flashlight at the specific mount, and then mount the light to this object. Like this:
%flashLight.mountObject(%smallShape, 0);
%light.attachToObject(%smallShape);
#2
02/18/2005 (8:22 pm)
Well !!if you have tried it successful??????????? could give me a picture to show your effot??very very thank!
#3
04/17/2005 (9:13 am)
I didn't see anything in the sgLight Pack about attachToObject. The one in fxLight will attach but at the feet of the character and the orientation is down when I select flashlight. If the light is attached does the orientation change with the movement of the player?
#4
06/04/2005 (12:09 pm)
Hey - I thought I'd chime in here and see if anybody has already fixed this issue yet. Volume Lights and the light halos are based on the center of the object (currently) and do not rotate with the object. It looked like this was solved in the Warzone Demo, so I wanted to ask before reinventing the wheel.
#5
06/04/2005 (12:33 pm)
Yes, the Warzone demo has some interesting light mounting which I am also curious how that was done.
#6
06/04/2005 (1:00 pm)
I've got the lights positioning themselves themselves properly around an object right now. That part is simple - it's done in FXLight.cc - I save off their transformation matrix at the point when attachToObject() is called, and assume that's now object relative. Then when I calculate mAnimationPosition, I pull out their position information from the stored matrix, and multiply it by the mpAttachedObject's rotation matrix.

I then add mpAttachedObject->getPosition() to the mAnimationPosition, and we seem to be pretty good. This works for positioning the flare and so forth for point-lights, but Volume Lights are still pointing in their original directions.

I may tackle that one later if I don't get any response, but what I've got is good enough for what I'm dealing with today.