fxLightDB Update
by Brett Fattori · in Torque Game Engine · 05/01/2003 (9:38 pm) · 20 replies
Howdy all.. Spent about 8 hours total trying to get this to work, so here's a little addition to fxLightDB that y'all might find useful. I wanted to be able to add lights to my choppers, and fxLightDB almost satisfied this requirement. However, even with an offset, it still didn't attach properly to an object. Sooooo... I added some functionality that allows you to mount it to one of the mount-nodes from script.
You can grab my copy of fxLightDB2.zip which contains fxLightDB.h and fxLightDB.cc. You may want to go back and look at the original resource for additional information.
BACK YOUR CODE UP FIRST!! Cause I'm not gonna be responsible...
You need to make a small change to shapeBase.h after the stuff about cloaking and before the section about mounted objects (around line 763):
Replace fxLightDB.h and fxLightDB.cc with the ones in the zip (unless you've already made changes, then you might want to just grab the necessary updates).
Make sure you do a clean build and then go into your script where you define an fxLightDB datablock.
Many thanks to Melv May for making the original! I'm hoping to figure out why the lights don't occlude behind the object they're attached to shortly... unless someone else wants to pick this up.
- Cow
You can grab my copy of fxLightDB2.zip which contains fxLightDB.h and fxLightDB.cc. You may want to go back and look at the original resource for additional information.
BACK YOUR CODE UP FIRST!! Cause I'm not gonna be responsible...
You need to make a small change to shapeBase.h after the stuff about cloaking and before the section about mounted objects (around line 763):
// ### Add This Stuff Here ###
U32 getNumMountNodes() { return ShapeBaseData::NumMountPoints; }Replace fxLightDB.h and fxLightDB.cc with the ones in the zip (unless you've already made changes, then you might want to just grab the necessary updates).
Make sure you do a clean build and then go into your script where you define an fxLightDB datablock.
// Create strobe
%strobe1 = new fxLightDB() {
datablock = whiteStrobe;
};
// Attach the strobes to the object
// The call takes two params:
// fxLightDB.attachToObjectNode(<object>,<node_num>)
%strobe1.attachToObjectNode(%obj, 8);Many thanks to Melv May for making the original! I'm hoping to figure out why the lights don't occlude behind the object they're attached to shortly... unless someone else wants to pick this up.
- Cow
#3
Thanks ! I've just tryed this and it's working like a charm ! Did you find how to make them don't occlude behind the object ? :)
Question : Do your mounting lights are following exactly the nodes when you go fast a little ? Cause mine are going "ahead-back" a little all the time like if they were'nt updated with the nodes. But this is maybe the setting of my lights because there is a lot of stuff inthere :)
Melv,
Your ressource will be really appreciated again. Non-"MountXX" nodes and "multiple objects to the same node" will be really cool.
06/04/2003 (6:39 pm)
Brett,Thanks ! I've just tryed this and it's working like a charm ! Did you find how to make them don't occlude behind the object ? :)
Question : Do your mounting lights are following exactly the nodes when you go fast a little ? Cause mine are going "ahead-back" a little all the time like if they were'nt updated with the nodes. But this is maybe the setting of my lights because there is a lot of stuff inthere :)
Melv,
Your ressource will be really appreciated again. Non-"MountXX" nodes and "multiple objects to the same node" will be really cool.
#4
In the game our team is developing, we required various special-FX to be attached to our characters such as fxLights and particles etc. I made changes to the engine which allows me to pretty much mount anything object to any node, not just mount nodes but any node and as many objects on a node as you want. After we've released the game (hopefully in a couple of months), I will release this resource, amongst others, to the community rather than keep it exclusively in our game, promise.
Other than this, I have not taken any of my previous work further. That's not to say I'm dumping it but it's simply a matter of time available.
- Melv.
06/04/2003 (10:23 pm)
Hi,In the game our team is developing, we required various special-FX to be attached to our characters such as fxLights and particles etc. I made changes to the engine which allows me to pretty much mount anything object to any node, not just mount nodes but any node and as many objects on a node as you want. After we've released the game (hopefully in a couple of months), I will release this resource, amongst others, to the community rather than keep it exclusively in our game, promise.
Other than this, I have not taken any of my previous work further. That's not to say I'm dumping it but it's simply a matter of time available.
- Melv.
#5
This seems awesome and will be really usefull ! Can't wait to see all this in your game.
06/05/2003 (5:56 am)
Melv,This seems awesome and will be really usefull ! Can't wait to see all this in your game.
#6
-Ron
06/05/2003 (6:08 am)
How about a DSOTD Melv? I am sure that their are others around these parts that would love to get a pic or two...-Ron
#7
Also, so the light stay stable or are the jittery when you move?
06/05/2003 (7:51 am)
Cool resource, I wander how hard it would be to script a turning of the ligths on and off.Also, so the light stay stable or are the jittery when you move?
#8
@Adrian: You can turn them on/off. You can do absolutely loads with it from the scripts although most are related to animation of the light. Here's a list of commands from my old development notes (full instructions are in the resource)...
// Basics.
setEnable
setLightOn
setRadius
setBrightness
setColour
// Flare.
setFlareOn
setFlareTP
setFlareBitmap
setFlareColour
setConstantSizeOn
setConstantSize
setNearSize
setFarSize
setNearDistance
setFarDistance
setFadeTime
setBlendMode
setLinkFlare
setLinkFlareSize
// Animation.
setMinColour
setMaxColour
setMinBrightness
setMaxBrightness
setMinRadius
setMaxRadius
setStartOffset
setEndOffset
setMinRotation
setMaxRotation
setSingleColourKey
setRedKeys
setGreenKeys
setBlueKeys
setBrightnessKeys
setRadiusKeys
setOffsetKeys
setRotationKeys
setColourTime
setBrightnessTime
setRadiusTime
setOffsetTime
setRotationTime
setLerpColour
setLerpBrightness
setLerpRadius
setLerpOffset
setLerpRotation
setUseColour
setUseBrightness
setUseRadius
setUseOffsets
setUseRotation
// Misc.
reset
attachToObject
detachFromObject
- Melv.
06/05/2003 (8:01 am)
@Ron: We will be working on a DSOTD fairly shortly. Priority has been on the game but we need to start generating interest very soon.@Adrian: You can turn them on/off. You can do absolutely loads with it from the scripts although most are related to animation of the light. Here's a list of commands from my old development notes (full instructions are in the resource)...
// Basics.
setEnable
setLightOn
setRadius
setBrightness
setColour
// Flare.
setFlareOn
setFlareTP
setFlareBitmap
setFlareColour
setConstantSizeOn
setConstantSize
setNearSize
setFarSize
setNearDistance
setFarDistance
setFadeTime
setBlendMode
setLinkFlare
setLinkFlareSize
// Animation.
setMinColour
setMaxColour
setMinBrightness
setMaxBrightness
setMinRadius
setMaxRadius
setStartOffset
setEndOffset
setMinRotation
setMaxRotation
setSingleColourKey
setRedKeys
setGreenKeys
setBlueKeys
setBrightnessKeys
setRadiusKeys
setOffsetKeys
setRotationKeys
setColourTime
setBrightnessTime
setRadiusTime
setOffsetTime
setRotationTime
setLerpColour
setLerpBrightness
setLerpRadius
setLerpOffset
setLerpRotation
setUseColour
setUseBrightness
setUseRadius
setUseOffsets
setUseRotation
// Misc.
reset
attachToObject
detachFromObject
- Melv.
#9
06/05/2003 (8:07 am)
So melv your saying it wold be possible to script where a player driving a mecha lets say :) could turn off and on a head light for example?
#10
You can control the light itself with the functions above as you described but the attachment itself would be problematic as it never really worked correctly across the network. The new code that I developed for our game is not actually part of the objects but part of a much lower framework which manipulates the object transforms themselves and works perfectly.
If you guys can wait a few more months then I will be releasing a whole bunch of resources that I just don't want package-up until you've seen them in our game. :)
- Melv.
06/05/2003 (8:14 am)
Absolutely.You can control the light itself with the functions above as you described but the attachment itself would be problematic as it never really worked correctly across the network. The new code that I developed for our game is not actually part of the objects but part of a much lower framework which manipulates the object transforms themselves and works perfectly.
If you guys can wait a few more months then I will be releasing a whole bunch of resources that I just don't want package-up until you've seen them in our game. :)
- Melv.
#11
06/05/2003 (1:43 pm)
kewl, can't wait
#12
As for the jittery questions from everyone, yes.. They are updated in a complex cycle that is maintained by setting the "processAfter" state of the object. And because of streaming on the network, sometimes the data for the light arrives before and after the data for the object it's attached to. So, you'll see it ahead and behind the position of the object it's attached to quite often at higher speeds.
- Brett
06/06/2003 (2:04 pm)
Yes, very cool Melv. Was wondering where your latest resources were!!As for the jittery questions from everyone, yes.. They are updated in a complex cycle that is maintained by setting the "processAfter" state of the object. And because of streaming on the network, sometimes the data for the light arrives before and after the data for the object it's attached to. So, you'll see it ahead and behind the position of the object it's attached to quite often at higher speeds.
- Brett
#13
did anyone ever come up with a fix for this, I don't understand the way the network code is set up yet, but I'm seeing the same problem when things run slowly the light and lags a bit.
I'll keep searching through the forum
thanks for any tips.
11/09/2004 (12:56 pm)
Old thread yes...but..Quote:
Question : Do your mounting lights are following exactly the nodes when you go fast a little ? Cause mine are going "ahead-back" a little all the time like if they were'nt updated with the nodes.
did anyone ever come up with a fix for this, I don't understand the way the network code is set up yet, but I'm seeing the same problem when things run slowly the light and lags a bit.
I'll keep searching through the forum
thanks for any tips.
#14
The problem was that the fxlights function AnimateLight was only happening when registerLights was called.
I didn't trace back enough to see exactly when register lights was called but I don't think it's something that's called at the same time resolution as the clients rendering happens.
now, thanks to the helpful docs and their brief but telling discussion of advanceTime and processTick I knew that I wanted the lights position to be changing at the same resolution as advanceTime.
so I added the following to fxLight.h
and in fxlight.cc I removed the call to AnimateLight in the registerLights function
then I added the advanceTime function like so
so now, the lights animation is happening for every frame on the client side.
Can someone with more knowledge of the network setup give me some validation that I'm doing the correct thing here ?
thanks!
edit side note:
For anyone interested in the details, I'm using the fxlight from head, then I took the relevant parts of this fxlightdb that correspond to a node attachment and added them to the plane fxlight. The needed changes were very small
11/09/2004 (3:20 pm)
Ok, I have what I believe is the fix.The problem was that the fxlights function AnimateLight was only happening when registerLights was called.
I didn't trace back enough to see exactly when register lights was called but I don't think it's something that's called at the same time resolution as the clients rendering happens.
now, thanks to the helpful docs and their brief but telling discussion of advanceTime and processTick I knew that I wanted the lights position to be changing at the same resolution as advanceTime.
so I added the following to fxLight.h
void advanceTime(F32 dt);
and in fxlight.cc I removed the call to AnimateLight in the registerLights function
then I added the advanceTime function like so
void fxLight::advanceTime(F32 dt)
{
AnimateLight();
}so now, the lights animation is happening for every frame on the client side.
Can someone with more knowledge of the network setup give me some validation that I'm doing the correct thing here ?
thanks!
edit side note:
For anyone interested in the details, I'm using the fxlight from head, then I took the relevant parts of this fxlightdb that correspond to a node attachment and added them to the plane fxlight. The needed changes were very small
#15
I would really appreciate if someone could explain what happens with registerLights since it looks like it is getting called once per frame, but obviously something wasn't working quite right, and moving animation into advanceTime fixed it.
11/09/2004 (3:32 pm)
Just tried in debug mode where things are running at about 5 fps and the light stayed right on top of my node (which it didn't before) so things look like they are working, and no crazy assertions either.I would really appreciate if someone could explain what happens with registerLights since it looks like it is getting called once per frame, but obviously something wasn't working quite right, and moving animation into advanceTime fixed it.
#16
could someone with more knowledge of the engine validate that I'm doing the correct thing by moving things into advanceTime.
to recap, this was to fix the problem that when the fxlight is attached to a node on an object, it seemed to "lag forward" and not match the nodes position acurately. my 'fix' was to move the fxlight animation code that set the position of the light, into advanceTime and out of registerLights which seems to have fixed it.
I'm just worried it could come back to bite me.
thanks
11/11/2004 (2:14 pm)
Ping.could someone with more knowledge of the engine validate that I'm doing the correct thing by moving things into advanceTime.
to recap, this was to fix the problem that when the fxlight is attached to a node on an object, it seemed to "lag forward" and not match the nodes position acurately. my 'fix' was to move the fxlight animation code that set the position of the light, into advanceTime and out of registerLights which seems to have fixed it.
I'm just worried it could come back to bite me.
thanks
#17
11/14/2004 (1:03 pm)
AdvanceTime is an appropriate place for position update code to go. You might also want to do it in interpolateTick if you find things are still lagging. I suggest reading the engine reference for GameBase to understand the roles of the various time methods in Torque.
#18
11/15/2004 (11:17 am)
Thanks Ben.
#19
because link is dead. Could you send it to atuncatunc@gmail.com ?
Thanks
10/05/2005 (5:36 am)
Does anybody have a copy of this file http://www.renderengine.com/stuff/fxLightDB2.zipbecause link is dead. Could you send it to atuncatunc@gmail.com ?
Thanks
#20
The "normal" fxLight from the engine seems be broken.
Have tryed to mount a light to my player, i get no errors, but the light+flare will not move with the player ;)
PS: Ok, have ripped out fxLightDB from this ressource into fxLight 1.4 vers, but have still one linking error..
something like this here:
..."public: virtual class AbstractClassRep * __thiscall fxLightDB::getClassRep(void)const " (?getClassRep@fxLightDB@@UBEPAVAbstractClassRep@@XZ)"....
have tryed to include consoleObject.h, but it hasnt worked.
07/27/2006 (2:19 am)
Has someone get it to work/to compile with TGE 1.4?The "normal" fxLight from the engine seems be broken.
Have tryed to mount a light to my player, i get no errors, but the light+flare will not move with the player ;)
PS: Ok, have ripped out fxLightDB from this ressource into fxLight 1.4 vers, but have still one linking error..
something like this here:
..."public: virtual class AbstractClassRep * __thiscall fxLightDB::getClassRep(void)const " (?getClassRep@fxLightDB@@UBEPAVAbstractClassRep@@XZ)"....
have tryed to include consoleObject.h, but it hasnt worked.
Associate Melv May
Nice one.
For our game "Strategem", we created a new attachment routine that can pretty much attach anything to any node (even non-"MountXX" nodes). You can also attach multiple objects to the same node.
We'll release that snippet to the community soon after the release of our game and it should make stuff like this much easier.
- Melv.