Shapebaseimage lights
by Daniel Eden · in Torque Game Engine · 08/08/2003 (6:31 pm) · 2 replies
This will have to be relatively short and sweet (at least for me), because it's now 12:00-ish and I haven't sleep in nearly 36 hours. So...
Before we get too carried away, however. It'd be nice to actually have some verification of this possible bug. You can do this by getting a nice, fresh, clean copy of 1.1.2 or HEAD of TGE from the CVS and building a debug exe. Then find crossbow.cs in the fps/server/scripts/ directory and in the CrossbowImage datablock, add a constant light using the following script snippet:
Once you've done that, host a server using a map that has the crossbow in it (such as WaterWorld) and then connect to it with another client (either on another machine or on the same machine by making a copy of the example directory and running from there).
As soon as you have two clients in the game, get each of the players to pick up a crossbow. The crossbow images should both generate a lit area around the player model, but they don't always work properly (if at all). From what I can tell, the following are the symptoms caused by this bug:
- Light position, direction, radius, intensity, etc. are identical if more than one player currently has the same shapebaseimage mounted.
- Point light intensity from shapebaseimages is incorrect (too bright).
- Lighting sometimes doesn't appear when a shapebaseimage is mounted/ unmounted.
Assuming that someone else actually manages to verify this bug, I'll post the fixes I've written...
Before we get too carried away, however. It'd be nice to actually have some verification of this possible bug. You can do this by getting a nice, fresh, clean copy of 1.1.2 or HEAD of TGE from the CVS and building a debug exe. Then find crossbow.cs in the fps/server/scripts/ directory and in the CrossbowImage datablock, add a constant light using the following script snippet:
lightType = "ConstantLight"; lightColor = "1.0 1.0 1.0"; lightRadius = "5.0";
Once you've done that, host a server using a map that has the crossbow in it (such as WaterWorld) and then connect to it with another client (either on another machine or on the same machine by making a copy of the example directory and running from there).
As soon as you have two clients in the game, get each of the players to pick up a crossbow. The crossbow images should both generate a lit area around the player model, but they don't always work properly (if at all). From what I can tell, the following are the symptoms caused by this bug:
- Light position, direction, radius, intensity, etc. are identical if more than one player currently has the same shapebaseimage mounted.
- Point light intensity from shapebaseimages is incorrect (too bright).
- Lighting sometimes doesn't appear when a shapebaseimage is mounted/ unmounted.
Assuming that someone else actually manages to verify this bug, I'll post the fixes I've written...
About the author
Recent Threads
#2
First, the LightInfo variable for the mounted images was in ShapeBaseImageData. Given that this is static data for all mounted images using a particular datablock, having two mounted images setting light positions would invariably (no pun intended) overwrite one of the values with the other. Solution: Moved the LightInfo variable into the MountedImage structure so that each image can store its own position, intensity, etc.
Second, the mounting of ShapeBaseImages onto a shapebase was being performed incorrectly.
The ShapeBase::mountImage function was responsible for including the object (and thus its light) to the LightSet list. This function simply wasn't being called on the client (since the client has to wait till it gets an update from the server and when it does it calls ShapeBase::setImage, skipping ShapeBase::mountImage altogether). Solution: Move the code adding (and removing) the object from the LightSet list into ShapeBase::setImage.
I've included the changes to the current HEAD in the following zip file. There are a few other changes included in the source files in the zip -- things like removing/ moving some functions (notably the registerLights function from ShapeBaseImageData to ShapeBase), having a separate named node for the weapon light, and so on. If you don't like them, don't use them. No patch files here so just diff it and apply the changes manually.
08/13/2003 (5:41 am)
As far as I can tell, the problems were caused by two things:First, the LightInfo variable for the mounted images was in ShapeBaseImageData. Given that this is static data for all mounted images using a particular datablock, having two mounted images setting light positions would invariably (no pun intended) overwrite one of the values with the other. Solution: Moved the LightInfo variable into the MountedImage structure so that each image can store its own position, intensity, etc.
Second, the mounting of ShapeBaseImages onto a shapebase was being performed incorrectly.
The ShapeBase::mountImage function was responsible for including the object (and thus its light) to the LightSet list. This function simply wasn't being called on the client (since the client has to wait till it gets an update from the server and when it does it calls ShapeBase::setImage, skipping ShapeBase::mountImage altogether). Solution: Move the code adding (and removing) the object from the LightSet list into ShapeBase::setImage.
I've included the changes to the current HEAD in the following zip file. There are a few other changes included in the source files in the zip -- things like removing/ moving some functions (notably the registerLights function from ShapeBaseImageData to ShapeBase), having a separate named node for the weapon light, and so on. If you don't like them, don't use them. No patch files here so just diff it and apply the changes manually.
Torque Owner Chris \"Hobbiticus\" Weiland