Game Development Community

Bigger, Fatter, Faster ...

by Melv May · in Torque Game Engine · 05/18/2002 (7:04 pm) · 155 replies

Hi Folks,

To start with, here are some images of my latest light object in action (animation difficult to show!) ...
www.melv.may.btinternet.co.uk/garagegames/fxflare1.jpg
www.melv.may.btinternet.co.uk/garagegames/fxflare2.jpg
www.melv.may.btinternet.co.uk/garagegames/fxflare3.jpg
www.melv.may.btinternet.co.uk/garagegames/fxflare4.jpg *lost from FTP site*
www.melv.may.btinternet.co.uk/garagegames/fxflare5.jpg
www.melv.may.btinternet.co.uk/garagegames/fxflare6.jpg
www.melv.may.btinternet.co.uk/garagegames/fxflare7.jpg
www.melv.may.btinternet.co.uk/garagegames/fxflare8.jpg

I improved my fxLight last week in many areas but I never got around to packaging it up. I have now done so and here it is for you.

For those who don't know about this, it is a dynamic light that with an animation system built-in to allow you to create a huge range of effects. I have now coupled it with a lens-flare effect which can also be animated to produce some spectacular effects. The lens-flare effect uses a pretty accurate line-of-sight test coupled with a fade-in/out effect to produce a very realistic flare.

There is also a version that has full datablock support plus the ability to be attached to any GameBase object. This includes things like the player, lightning, items, projectiles etc.

The version I host on my personal site has an addition of a terrain/mission file as an example of how to use this object effectively. Use F8 to move around the level, go inside the building and look up. You should see the lens-flare as it appears through the slats in the roof! Cool!

I have updated the resource here www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=2660.

You can also find it hosted at www.melv.may.btinternet.co.uk/garagegames/light.zip (which includes the bonus terrain/mission files).

A previous post regarding this object can be found at www.garagegames.com/index.php?sec=mg&mod=forums&page=result.thread&qt=5042

Hopefully, there are not many problems with it. Jeez, it's 3:14am here now ... must sleep. !)

Enjoy.

- Melv.
#121
05/24/2002 (3:56 pm)
Everyone,

It looks now like I'm going to get this thing finished by Saturday. These are the new commands (the script ones will have identical names) that I am laboriously entering now ...

// Light.
	void setEnable(bool Status);
	void setLightOn(bool Status);
	void setRadius(F32 Radius);
	void setBrightness(F32 Brightness);
	void setColour(ColorF Colour);

	// Sunlight.
	void setSunLightOn(bool Status);
	void setSunAzimuth(F32 Azimuth);
	void setSunElevation(F32 Elevation);

	// Flare.
	void setFlareOn(bool Status);
	void setFlareBitmap(const char* FlareName);
	void setFlareColour(ColorF Colour);
	void setConstantSizeOn(bool Status);
	void setConstantSize(F32 Size);
	void setNearSize(F32 NearSize);
	void setFarSize(F32 FarSize);
	void setNearDistance(F32 NearDistance);
	void setFarDistance(F32 FarDistant);
	void setFadeTime(F32 FadeTime);
	void setBlendMode(U32 BlendMode);
	void setLinkFlare(bool Status);
	void setLinkFlareSize(bool Status);

	// Animation.
	void setMinColour(ColorF Colour);
	void setMaxColour(ColorF Colour);
	void setMinBrightness(F32 Brightness);
	void setMaxBrightness(F32 Brightness);
	void setMinRadius(F32 Radius);
	void setMaxRadius(F32 Radius);
	void setStartOffset(Point3F Offset);
	void setEndOffset(Point3F Offset);
	void setMinRotation(F32 Rotation);
	void setMaxRotation(F32 Rotation);
	void setSingleColourKeys(bool Status);
	void setRedKeys(const char* Keys);
	void setGreenKeys(const char* Keys);
	void setBlueKeys(const char* Keys);
	void setBrightnessKeys(const char* Keys);
	void setRadiusKeys(const char* Keys);
	void setOffsetKeys(const char* Keys);
	void setRotationKeys(const char* Keys);
	void setColourTime(F32 Time);
	void setBrightnessTime(F32 Time);
	void setRadiusTime(F32 Time);
	void setOffsetTime(F32 Time);
	void setRotationTime(F32 Time);
	void setLerpColour(bool Status);
	void setLerpBrightness(bool Status);
	void setLerpRadius(bool Status);
	void setLerpOffset(bool Status);
	void setLerpRotation(bool Status);
	void setUseColour(bool Status);
	void setUseBrightness(bool Status);
	void setUseRadius(bool Status);
	void setUseOffsets(bool Status);
	void setUseRotation(bool Status);

All these settings can be changed in realtime on the server and will take effect immediately. 8)

I will post when I have completed it.

- Melv.

EDIT: 25/05/02. Amended names.
#122
05/24/2002 (4:07 pm)
Sweeeeeet!! Can't wait to get it :-))
#123
05/24/2002 (5:12 pm)
Melv, little off-topic here, but anyhow... ;-)
Given your knowledge of various Torque aspects now, especially the lighting, can you think of an effective way to simulate seamless day-/night transitions?
This is bugging me for weeks now and I can't think of any easy way... cause you'd have to change the generated lightmaps at runtime to use the current lighting system, i guess... and I also guess you'd have to change/overlay the skyboxes, and do a million other things to make it really realistic... Morrowind is doing these transitions amazingly, they have beautiful nightly settings, etc. but I've got no idea how it's done... any thoughts?
#124
05/25/2002 (3:30 am)
Stefan,

Wow, that's a big ball you've just tossed over the net. 8)

As you've mentioned there are so many things that would need to change, all of which I could see methods of achieving but the one that I'm not that familiar with is the terrain.

The cheapest/quickest way I could see for the terrain is to remove the lightmaps completely! Yes, I know I'm probably treading on tender ground (sorry for the pun) with some but it would be feasible to remove the light (or more to the point the shadow) maps and bung in a normal dynamic omni light when rendering.

Hey, I just got up and I've not really thought this through but I would suggest that we start another thread dedicated to the discussion of this if everyone wants it. I'd be glad to join in but I'm sure there are others who know alot more about this subject than I do.

- Melv.
#125
05/25/2002 (4:49 am)
Hey Melv, thanks for catching the ball ;-)
We should indeed start another thread for this, this one is pretty long anyhow ;-), and there seems to be some public interest in getting this feature into Torque - and it's on the official "GG TO DO List", hehe...
so here it goes... see ya there ;-)
#126
05/25/2002 (7:23 am)
One more thing concerning this fxLightDB problem I have... these strange effects seem to appear only if I add new files to the VC project and recompile...
then I have to take the fxLightDB stuff out of the project, CLEAN and rebuild, add them again and compile (as described above) to get it to work again... isn't that strange?
#127
05/25/2002 (7:26 am)
... and the dates of the files are not in the future are they?

- Melv.
#128
05/25/2002 (7:44 am)
Nope, neither the fxLightDB files nor the other ones I've added lately... all of them are ordinary files from the past... ;-) well, at least they are a couple of minutes old... but this problem really doesn't kill me, so there is no need for you to spend your time on this phenomenon... and it doesn't sound it's specifically related to your light code, I think... seems to be some weird Torque problem somewhere in the depths of the engine ;-) ... I just wanted to point it out, maybe some old GG / Tribes fellow jumps in and says: "Ah, now I know what's going on, you simply have to this and that..."
Btw., how is it going with the mirror/reflection stuff? Any news?
#129
05/25/2002 (7:47 am)
Everyone,

Before I begin, I got up early this morning so that I could get this thing finished like I promised. I'm going out boozing tonight and I didn't want to do it on Sunday with a hangover!

I've added *all* the configuration commands for C++ / Script that I said I would.

There is a problem, which I need to sort out, in that attachment no longer works and may cause it to bomb! I will sort that out on Sunday.

Anyway, here are the new commands:-

// *********************************
// Script entries ....
// *********************************

// Light.
fxobj.setEnable(status)
fxobj.setLightOn(status)
fxobj.setRadius(radius)
fxobj.setBrightness(brightness)
fxobj.setColour(r,g,b)

// Sunlight.
fxobj.setSunLightOn(status)
fxobj.setSunAzimuth(azimuth)
fxobj.setSunElevation(elevation)

// Flare.
fxobj.setFlareOn(status)
fxobj.setFlareTP(status)
fxobj.setFlareBitmap(bitmap)
fxobj.setColour(r,g,b)
fxobj.setConstantSizeOn(status)
fxobj.setConstantSize(size)
fxobj.setNearSize(size)
fxobj.setFarSize(size)
fxobj.setNearDistance(distance)
fxobj.setFarDistance(distance)
fxobj.setFadeTime(time)
fxobj.setBlendMode(mode)
fxobj.setLinkFlare(status)
fxobj.setLinkFlareSize(status)

// Animation.
fxobj.setMinColour(r,g,b)
fxobj.setMaxColour(r,g,b)
fxobj.setMinBrightness(brightness)
fxobj.setMaxBrightness(brightness)
fxobj.setMinRadius(radius)
fxobj.setMaxRadius(radius)
fxobj.setStartOffset(x,y,z)
fxobj.setEndOffset(x,y,z)
fxobj.setMinRotation(rotation)
fxobj.setMaxRotation(rotation)
fxobj.setSingleColourKeys(status)
fxobj.setRedKeys(keys)
fxobj.setGreenKeys(keys)
fxobj.setBlueKeys(keys)
fxobj.setBrightnessKeys(keys)
fxobj.setRadiusKeys(keys)
fxobj.setOffsetKeys(keys)
fxobj.setRotationKeys(keys)
fxobj.setColourTime(time)
fxobj.setBrightnessTime(time)
fxobj.setRadiusTime(time)
fxobj.setOffsetTime(time)
fxobj.setRotationTime(time)
fxobj.setLerpColour(status)
fxobj.setLerpBrightness(status)
fxobj.setLerpRadius(status)
fxobj.setLerpOffset(status)
fxobj.setLerpRotation(status)
fxobj.setUseColour(status)
fxobj.setUseBrightness(status)
fxobj.setUseRadius(status)
fxobj.setUseOffsets(status)
fxobj.setUseRotation(status)

// Misc.
fxobj.reset()
fxobj.attachToObject(object)
fxobj.detachFromObject(object)

// *********************************
// C++ entries ....
// *********************************

// Light.
void setEnable(bool Status);
void setLightOn(bool Status);
void setRadius(F32 Radius);
void setBrightness(F32 Brightness);
void setColour(ColorF Colour);

// Sunlight.
void setSunLightOn(bool Status);
void setSunAzimuth(F32 Azimuth);
void setSunElevation(F32 Elevation);

// Flare.
void setFlareOn(bool Status);
void setFlareTP(bool Status);
void setFlareBitmap(const char* Name);
void setFlareColour(ColorF Colour);
void setConstantSizeOn(bool Status);
void setConstantSize(F32 Size);
void setNearSize(F32 Size);
void setFarSize(F32 Size);
void setNearDistance(F32 Distance);
void setFarDistance(F32 Distance);
void setFadeTime(F32 Time);
void setBlendMode(U32 Mode);
void setLinkFlare(bool Status);
void setLinkFlareSize(bool Status);

// Animation.
void setMinColour(ColorF Colour);
void setMaxColour(ColorF Colour);
void setMinBrightness(F32 Brightness);
void setMaxBrightness(F32 Brightness);
void setMinRadius(F32 Radius);
void setMaxRadius(F32 Radius);
void setStartOffset(Point3F Offset);
void setEndOffset(Point3F Offset);
void setMinRotation(F32 Rotation);
void setMaxRotation(F32 Rotation);
void setSingleColourKeys(bool Status);
void setRedKeys(const char* Keys);
void setGreenKeys(const char* Keys);
void setBlueKeys(const char* Keys);
void setBrightnessKeys(const char* Keys);
void setRadiusKeys(const char* Keys);
void setOffsetKeys(const char* Keys);
void setRotationKeys(const char* Keys);
void setColourTime(F32 Time);
void setBrightnessTime(F32 Time);
void setRadiusTime(F32 Time);
void setOffsetTime(F32 Time);
void setRotationTime(F32 Time);
void setLerpColour(bool Status);
void setLerpBrightness(bool Status);
void setLerpRadius(bool Status);
void setLerpOffset(bool Status);
void setLerpRotation(bool Status);
void setUseColour(bool Status);
void setUseBrightness(bool Status);
void setUseRadius(bool Status);
void setUseOffsets(bool Status);
void setUseRotation(bool Status);

// Misc,
void reset(void);
void attachToObject(const char* ObjectName);
void detachFromObject(void);


Sorry for the attachement thing but I just ran out of time today.

Enjoy!

- Melv.
#130
05/25/2002 (7:48 am)
Stefan,

Assuming I can get the attachment stuff working again without a hitch then I can crack on with it Sunday. 8)

- Melv.
#131
05/27/2002 (1:43 am)
Everyone,

Right, everything seems to be working fine with this now. LOS tests are working for 1st/3rd person (with the exception of the mounted weapon). You can set multiple objects as the sun with the change of a field.

The *only* problem I've got now is the attachment case. I spent nearly all of Sunday trying to figure this one out and I would appreciate any insight that anyone can provide.

What I'm trying to do is as soon as the command for attachment is issued I send a packet to the client informing that it has happened.

This packet comprises of the GhostIndex of the object that I'm attaching to (say, a Projectile). I do this with:-
S32 ghostIndex = con->getGhostIndex(AttachObj);
stream->writeRangedU32(U32(ghostIndex), 0, NetConnection::MaxGhostCount);

... and resolving on the client with ...
S32 ObjectID = stream->readRangedU32(0, NetConnection::MaxGhostCount);
NetObject* pObject = con->resolveGhost(ObjectID);

When the client gets this it then starts tracking the objects' position each frame. This way I don't need to send any information over the wire to be attached, neat!

Now this code works fine if I stick something in the scene using the editor and issue the attach. I can drag around the attached object and the fxLightDB tracks it.

Do this by attaching to a projectile (using the code way above) and I find that the 'getGhostIndex' call on the server with the projectile object returns -1. Debugging this determines that the objects' GhostInfo structure flag has the 'Ghosting' flag set which seems to indicate that it is currently ghosting to the client? Looking around the Torque codebase reveals a similar thing e.g. a check for -1 when using this function.

I decided to start a process on the server which means that the server object repeatedly tries to get the ghost index of the attached object each time frame. The damn thing is that the object always seems to be 'ghosting'.

If all this above is techno-babble then I'm sorry but there must be someone who can help me out there. I've just sent an email to Mark F to see if he's got time to help.

- Melv.
#132
05/28/2002 (1:00 pm)
Ok,

I had a brain-child tonight and it now appears that the attachment case is fixed. The attachment now runs with a *much* better performance than before. The attachment only generates an initial attachment command to the client but nothing after that so you get no crap across the wire...cool!

Enjoy.

- Melv.

I couldn't help playing a little ...

www.objectheaven.dial.pipex.com/garagegames/fxflare6.jpg
www.objectheaven.dial.pipex.com/garagegames/fxflare7.jpg
www.objectheaven.dial.pipex.com/garagegames/fxflare8.jpg

Most of these projectiles have two fxLightDBs attached to them for effect.
#133
05/28/2002 (1:05 pm)
Melv, you rock, man!! :-)

What was the problem with the attachement?
As always, thanks for your efforts!! Updating right now ... :-))
#134
05/28/2002 (1:10 pm)
Well,

I've not had a chance to test this properly so I really do hope that you don't have any problems with it. I won't be able to test the remote networking side until Wednesday night. If it does not work over a non-local connection then I think I know how to fix it but as I said, I won't be in a position until Wednesday.

The problem was a git! When using the 'OnFire' routine in the scripts for the projectile and calling the 'attachToObject' command, the fxLightDB would look for the GhostID of the projectile object. Now it turns out that the ghost had not been created yet so I was stumped. The reason I needed this was so that I could transmit it to the client as an instruction to track it.

I've put in some code that defers the send until the selected object has been ghosted. When this happens I send the details as usual and the client(s) take up the baton and track the object, err .. simple.

Hope it works else I will definately nail it tomorrow night. :)

- Melv.

p.s. I took out the terrain/mission files so that the download from my web-site is quicker. I have packaged these as www.objectheaven.dial.pipex.com/garagegames/disco.zip if you still want them.
#135
05/29/2002 (1:25 pm)
Stefam,

It appears that there is a problem like I suspected. This projectile case is really driving me nuts. :(

I've got to sort it otherwise this kind of problem will come back to haunt me I just know it.

- Melv.
#136
05/29/2002 (2:35 pm)
Ouch!! Feeling with you, Melv... hunt it down, this sucka!! ;-))
#137
06/07/2002 (3:48 pm)
Did you ever figure out that projectile bug?
#138
06/08/2002 (3:23 am)
Andrew,

Yes, I found out what the problem is but I have not had much time on GG stuff in the last week but I'm hoping to be able to get back to it on Sunday and next week.

I think it just requires a little more investigation into the network code, specifically on how to get around my ghosting delay I mentioned earlier in this thread.

Not too long to wait hopefully. 8)

- Melv.
#139
06/10/2002 (10:33 am)
Maybe I missed it somewhere, but were you ever able to get a spot light to work correctly? Just curious.
#140
06/10/2002 (10:56 am)
Sorry Kevin,

Never got time to look at that fully although I've got a good idea now what needs to be done to sort it.

There's never enough time it seems. :(

- Melv.