Game Development Community

dev|Pro Game Development Curriculum

Happy Fun Squiggle Ball

by Orion Elenzil · 07/17/2008 (9:24 am) · 11 comments

The tutorial is a rather lengthy HTML page.

here's a video of the end results.


from the html:

This tutorial aims to go through the steps necessary to create an entirely new sceneObject in TGE.
It will demonstrate the basics of ghosting, how to get something rendered (and various options), demonstrate some fun OpenGL stuff, and using ghosting changing parameters from server to client.

What specifically does this tutorial touch on ?
* Creating a new class in the TGE class heirarchy.
* Adding a new class to the World Editor.
* The basics of render images / prepRenderImage().
* Some basics of OpenGL rendering.
* Fun with sine waves.
* Networking / Ghosting / Network Scope / PackUpdate / NetMasks.
* Exposing C++ fields to script as member fields.
* Exposing C++ fields to script via ConsoleMethods.

Who might profit from this tutorial ?

This is probably most useful for intermediate Torque programmers.


This is built on a clean TGE 1.4 codebase, but will work with TGE 1.3, and will very, very probably work with TGE 1.5 and beyond. The networking parts are almost surely applicable to TGEA, but i can't vouch for the relevance of the scenegraph and rendering stuff to TGEA.


#1
07/17/2008 (12:04 pm)
This is a cool tutorial if you want to learn how to add your own C++ objects to Torque. Check it out! The video is cool, too. :)
#2
07/17/2008 (11:17 pm)
Fricken Saweet
#3
07/19/2008 (12:12 pm)
minor updates complete.
#4
07/20/2008 (6:14 pm)
Very cool
#5
07/22/2008 (4:28 am)
hey orion.

Love the Happy Fun Squiggle Ball.
How would you recommend me change this to draw a dynamic 3d line. One end would be the where the cursor intersects a plane (done) so the line would have to update as the cursor moves!!
#6
07/22/2008 (7:52 am)
Completed your resource up to rendering the square. Brilliantly written. Worked first time
#7
07/22/2008 (8:27 am)
glad to hear it Aidan, thanks for the feedback.

re adapting this to render a line,
there's a couple approaches to the rendering -
you could write something like "dglLine(start, end)",
and replace the call "dglWireCube([1,1,1], [0,0,0])" with "dglLine([0,0,0],[0,1,0])",
and then adjust the object's position, extent, and orientation so that the earlier calls which set up the matrixes will thus stretch and move your unit line into position.
or,
you could get rid of the earlier matrix calls which set up position etc, and just call "dglLine(startPt, endPt)".
altho it seems like more of a hassle, i would actually recommend the former.
the advantage of the former is that the object will still have a meaningful bounding box,
so it will play nice with network and zone scoping.

i think a call to set the matrix and position and scale etc to stretch a unit Y line into place would look something like:
// pseudo code
void fitTransformToLine(Point3F start, Point3F end, Point3F up = (0, 0, 1))
{
   Vector3F vLine = end - start;
   
   // orientation
   Vector3F axisY = normalize(vLine);
   Vector3F axisX = up   .cross(axisY);
   Vector3F axisZ = axisY.cross(axisX);
   getTransform().setColumn(0, axisX);
   getTransform().setColumn(1, axisY);
   getTransform().setColumn(2, axisZ);
   
   // position
   getTransform().setColumn(3, start);
   
   // scale
   setScale(1, vLine.length(), 1);   
}
#8
07/22/2008 (9:49 am)
Thanks again Orion,

I have got my Line by
changing:
dglWireCube(Point3F(1,1,1),Point3F(0,0,0));
to:
glBegin(GL_LINES);
glVertex3f(0, 0, 0);
glVertex3f(0, 0, 100);
glEnd();


All I need to be able to do now is continously update one of the coordinates so the line moves ingame.

e.g glVertex3f(0, 0, 100); to glVertex3f(0, 0, 300);

Is this possible to do in script (console method)??
#9
07/23/2008 (5:40 am)
Prettty darn neat tutorial
#10
02/25/2009 (2:30 pm)
Orion...this tutorial is really awesome. I wish we had more tuts like this...thank you! Excellent job!!!
#11
02/25/2009 (2:44 pm)
right on, thanks J !