Game Development Community

dev|Pro Game Development Curriculum

fun porting space related resources into T3D

by Jeff Yaskus · 02/18/2012 (1:50 pm) · 21 comments

I've been working on trying to decipher and port over the space related resources ... into T3D v1.2

So far, its been a challenge as the code examples are all 5-10 years old. Since T3D doesn't have a "Sky" object anymore, I started with trying to add the "stars" code into "SkyBox".

The function to loadStars() had to be updated, replacing ResourceManager-> with FileStream:: and its loading the star data file properly now.
(see here for the details: www.garagegames.com/community/resource/view/3252 )

However, I have little experience with the OpenGL graphics and such ... so my version of the code to draw the stars is not working as hoped. In the openGL version, he just displayed an array of points ...

original TGE code ... in Sky::renderObject()
// JL: Draw stars on top of everything else.
   if( mRenderStars )
   {
       // Blend with the background.
       glEnable(GL_BLEND);
       glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );

       // Send, render, clean. Repeat as necessary.
       glEnableClientState( GL_VERTEX_ARRAY );
       glVertexPointer(3, GL_FLOAT, 0, &mStarPoints );
       glEnableClientState( GL_COLOR_ARRAY );
       glColorPointer(4, GL_FLOAT, 0, &mStarColors );

       glDrawArrays( GL_POINTS, 0, mNumStars );

       glDisableClientState( GL_VERTEX_ARRAY );
       glDisableClientState( GL_COLOR_ARRAY );
   }

But couldn't find any example of how it would be done in T3D v1.2 "syntax". Here is my "hack" so far, which ... I'll admit is likely way off.

// STARS >>>
   if( mRenderStars )
   {
       GFXDrawUtil *drawer = GFX->getDrawUtil();  

       const MatrixF &objectMat = getRenderTransform();  
       const Point3F &objectPos = objectMat.getPosition();  

       GFXStateBlockDesc starDesc;
       starDesc.setBlend( true );
       
       if ( mNumStars == 0 )  
         return;        
           
       ColorI pntColor;  
       F32 mPointRenderSize =  0.03f;
       F32 mRadius =  1.0f;
       const Point3F pntSize( mPointRenderSize, mPointRenderSize, mPointRenderSize );  

       // Send, render, clean. Repeat as necessary.
       for ( U32 i = 0; i < mNumStars; i++ )  
       {           
          Point3F pnt;
          pnt.set( mStarPoints[i][0], mStarPoints[i][1], mStarPoints[i][2] );
          
          pntColor.set( (U8) mStarColors[i][0], (U8)mStarColors[i][1], (U8)mStarColors[i][2], (U8)mStarColors[i][3] );

          drawer->drawSphere( starDesc, mRadius, pnt, pntColor, true,true,0);
   }

   // <<< STARS

and dumping to the console, shows the first star info as such;
***  XYZ ( 0.023161,-0.099450,0.994773 ) RGBA( 1.000000,1.000000,1.000000,0.487477 ) ***

I'm not sure if (a) my stars are not being drawn because of errors in my code or (b) they are, but not visible because it needs an "offset" or something ?

ie. all the stars are relatively close to (0,0,0) ... just fractions off from 0.

Has anyone ported any of the space related resources over to T3D yet ?

Encountered these issues when converting stuff to T3D ?

Any help or suggestions would be appreciated.






LINKS to old space related resources ... that might be helpful to this effort;

Space Sim ~ TGE ; posted 2007
www.garagegames.com/community/blogs/view/13214

Space Sim ~ TGE - gravity mods ; posted 2007
www.garagegames.com/community/blogs/view/13221

Skysphere ~ TGE/A ; posted ~2005
www.garagegames.com/community/forums/viewthread/35841

Skysphere code ~ TGE ; posted ~2004
www.garagegames.com/community/resource/view/6644/2#comments

fxStarFieldReplicator ~ TGE ; posted 2003
www.garagegames.com/community/blogs/view/4924

"Stars" code from TGE ; posted ~2002
www.garagegames.com/community/resource/view/3252

About the author

Long time gamer, hacker and programmer. With dreams of making video games -

Page«First 1 2 Next»
#21
04/07/2013 (5:43 pm)
grab it from my site: jyaskus.com/misc/3252_starpatch.zip

Feel free to upload to the big hole, as well.

If I recall, it plugs into the skybox and had some weird issues with drawing order, but have at it. good luck.

And let the community know if/when you get it working. :)
Page«First 1 2 Next»