TGE: small bugfix & improvements in rendering spawnSpheres
by Orion Elenzil · in Torque Game Engine · 08/04/2007 (12:58 pm) · 6 replies
This is present in both the TGE 1.3 and 1.4 codebase; not sure about 1.5.
in editTSCtrl.cc,
change this line (renderSphere):
and change this line (renderCircle):
the original code is fine when spawnspheres are huge,
but for tighter spawns such as inside a building,
it's nice to be able to visualize non-integral radii.
in editTSCtrl.cc,
change this line (renderSphere):
F32 radius = (F32)dAtoi(argv[3]);to this:
F32 radius = dAtof(argv[3]);
and change this line (renderCircle):
F32 radius = (F32)dAtoi(argv[4]);to this:
F32 radius = dAtof(argv[4]);
the original code is fine when spawnspheres are huge,
but for tighter spawns such as inside a building,
it's nice to be able to visualize non-integral radii.
About the author
#2
here's the original.
note that there's three spawnspheres in the back that you can't see what size they are.

improved:
08/04/2007 (1:52 pm)
Edited previous to add highlighting of the equatorial disk.here's the original.
note that there's three spawnspheres in the back that you can't see what size they are.

improved:
#3

08/04/2007 (2:15 pm)
Another example showing the advantage of not truncating the rendered radius to an integer:
#4
08/04/2007 (3:42 pm)
Good! thanks :)
#5

All of that functionality seems pointless when the spawn sphere really needs nothing more than that provided by GameBase and GameBaseData.
Changing SpawnSpheres over is pretty simple, load up missionMarker.cc/h and change it to inherit from GameBaseData and GameBase and change the parent typedef accordingly. Adjust the typemask in the constructor, add a mHidden bool and then in OnNewDataBlock set the mObjBox to something useful like
Markers will still work the same, but without all the extra fluff that just isn't needed. Unless your want spawn spheres that fight back :)
08/04/2007 (4:02 pm)
Funny you should mention spawn spheres, I was playing around with them earlier and realised they're inherited from ShapeBase. From what I could tell, the only reason for this is to allow rendering of the octogon, which really serves no purpose, and results in spawn spheres that can have mounted objects, guns, fire bullets, eject shell casings, play sounds, use dts and animations, energy/repair managment,additional networking.... 
All of that functionality seems pointless when the spawn sphere really needs nothing more than that provided by GameBase and GameBaseData.
Changing SpawnSpheres over is pretty simple, load up missionMarker.cc/h and change it to inherit from GameBaseData and GameBase and change the parent typedef accordingly. Adjust the typemask in the constructor, add a mHidden bool and then in OnNewDataBlock set the mObjBox to something useful like
mObjBox = Box3F(Point3F(-1, -1, -1), Point3F(1, 1, 1)); resetWorldBox();
Markers will still work the same, but without all the extra fluff that just isn't needed. Unless your want spawn spheres that fight back :)
Associate Orion Elenzil
Real Life Plus
here are my other recommended changes for spawnspheres.
1. enable rendering more than just the currently selected spawnsphere:
editorRender.cs
change this:
function SpawnSphere::onEditorRender(%this, %editor, %selected, %expanded) { if(%selected $= "true") { %editor.consoleFrameColor = "255 0 0"; %editor.consoleFillColor = "0 15 0 15"; %editor.renderSphere(%this.getWorldBoxCenter(), %this.radius, 1); } }to this:function SpawnSphere::onEditorRender(%this, %editor, %selected, %expanded) { %editor.consoleLineWidth = 1; %editor.consoleFrameColor = "255 0 0 50"; %editor.consoleFillColor = "0 0 90 10"; %editor.renderSphere(%this.getWorldBoxCenter(), %this.radius, 2); %editor.consoleLineWidth = 5; %editor.consoleFrameColor = "255 200 0 60"; %editor.consoleFillColor = "0 100 190 60"; %pos = %this.getWorldBoxCenter(); %pos = vectorSub(%pos, "0 0 0.005"); // prevent z-fighting with the selection grid plane %editor.renderCircle(%pos, "0 0 1", %this.radius); }2. disable writing to the z-buffer when rendering the spawnsphere polygongs.
this makes it so that you can see spawnspheres thru spawnspheres etc.
editTSCtrl.cc
change this:
if(object->mConsoleFillColor.alpha) { glColor4ub(object->mConsoleFillColor.red, object->mConsoleFillColor.green, object->mConsoleFillColor.blue, object->mConsoleFillColor.alpha); glBegin(GL_TRIANGLES); for(U32 i = 0; i < mesh->numPoly; i++) { Sphere::Triangle & tri = mesh->poly[sortInfos[i].idx]; for(S32 j = 2; j >= 0; j--) glVertex3f(tri.pnt[j].x * radius + pos.x, tri.pnt[j].y * radius + pos.y, tri.pnt[j].z * radius + pos.z); } glEnd(); }to this: (just adding glDepthMask())if(object->mConsoleFillColor.alpha) { glDepthMask(GL_FALSE); glColor4ub(object->mConsoleFillColor.red, object->mConsoleFillColor.green, object->mConsoleFillColor.blue, object->mConsoleFillColor.alpha); glBegin(GL_TRIANGLES); for(U32 i = 0; i < mesh->numPoly; i++) { Sphere::Triangle & tri = mesh->poly[sortInfos[i].idx]; for(S32 j = 2; j >= 0; j--) glVertex3f(tri.pnt[j].x * radius + pos.x, tri.pnt[j].y * radius + pos.y, tri.pnt[j].z * radius + pos.z); } glEnd(); glDepthMask(GL_TRUE); }