Game Development Community

GuiObjectView

by Matt Huston · in Torque Game Engine Advanced · 04/10/2006 (5:20 pm) · 26 replies

I've noticed that GuiObjectView isn't in MS3. Is anyone working on getting it into TSE? I've read that it once worked but with MS2 it was broken, I don't even see it in the code anymore.
Page «Previous 1 2
#1
04/10/2006 (5:56 pm)
Yeah it worked in MS2 but doesn't work at all now. It'd be nice if someone converted it.
#2
04/11/2006 (5:43 am)
I've added GuiObjectView in MS3 and it works but with the well known lighting problem (the model is completly dark)...has someone figured out how to fix the lighting?
#3
04/11/2006 (5:56 am)
*looks for John Kabus* :P
#4
04/11/2006 (6:16 am)
Here is a GuiObjectView for TSE that I just ganked from some past GID that Brian Richardson and I worked on. I have no idea if it works in MS3, or if it even works at all. I also have no idea who got it working. It was probably a combination of Brian, me and some forum posts somewhere.

It might save you some time, it might lose you some hair ... just don't come crying to me (or Brian) if you can't get it working ;-)

T.
#5
04/11/2006 (6:39 am)
I tried it out, didn't seem to work. Compiled clean and script didn't give any errors but model did not show up in GuiObject window.
#6
04/11/2006 (6:41 am)
Ah, I just tried it too, doesnt seem to work at all. Oh well. Maybe someone can get it working and post a working one ;-)

T.
#7
04/11/2006 (7:41 am)
try this one...I don't remember where I get this from but this let you try the control but with the bugged rendering code...hope some one can solve it because actually I can't...
#8
04/11/2006 (8:30 am)
I have a feeling it requires OpenGL, but I'm probably wrong.
#9
04/12/2006 (5:04 am)
Well obviously the old version was coded for OpenGL and sometimes (like here), it isn't a matter of just changing dgl functions to the new DX functions.
#10
04/12/2006 (6:54 am)
Here is the rendering code for GuiBjectView...can sameone tell what is missing there?
//------------------------------------------------------------------------------
void GuiObjectView::renderWorld( const RectI &updateRect )
{
   if (!(bool)mMeshObjects.mMainObject)
	   return; 
   GFX->clear( GFXClearZBuffer, ColorI(0,0,0), 1.0f, 0);
   GFX->setZEnable(true);
   GFX->setZWriteEnable(true);
   GFX->setZFunc(GFXCmpLessEqual);
   GFX->setLightingEnable(true);
   GFX->setAmbientLightColor(ColorF(1.0f, 1.0f, 1.0f));

   LightManager *lightManager = gClientSceneGraph->getLightManager();

   LightInfo light;
   if(lightManager) 
   {
	   light.mType      = LightInfo::Ambient;
	   light.mDirection = VectorF(0.57735f, 0.57735f, -0.57735f);

	   light.mColor     = ColorF(1.0f,1.0f,1.0f);
	   light.mAmbient   = ColorF(1.0f, 1.0f, 1.0f);

	   lightManager->setMaxGLLights(1);
	   lightManager->addLight(&light);
	   lightManager->installGLLights(Box3F(-1, -1, -1, 1, 1, 1));
   }
   // Determine the camera position, and store off render state...
   MatrixF modelview;
   MatrixF mv;
   Point3F cp;
   modelview = GFX->getWorldMatrix();
   mv = modelview;
   mv.inverse();
   mv.getColumn(3, &cp);
   // Set up the base SceneState.
   F32 left, right, top, bottom, nearPlane, farPlane;
   RectI viewport;
   GFX->getFrustum( &left, &right, &bottom, &top, &nearPlane, &farPlane );
   //viewport = GFX->getViewport();
   SceneState* pBaseState = new SceneState(NULL,
	   0,//mCurrZoneEnd,
	   left, right,
	   bottom, top,
	   nearPlane,
	   farPlane,
	   //F64(getVisibleDistanceMod()),
	   updateRect, 
	   cp,
	   modelview,
	   2000,
	   //getFogDistanceMod(),
	   2000,
	   //getVisibleDistanceMod(),
	   ColorF(0.1,0.1,0.1),
	   //mFogColor,
	   0,
	   //mNumFogVolumes,
	   NULL,
	   //mFogVolumes, 
	   1);
   //smVisibleDistanceMod);
   pBaseState->mFlipCull = false;
   TSMesh::setSceneState( pBaseState );
   TSMesh::setRefract(false);
   for (S32 i=0; i<33; i++)
   {
	   if (mMeshObjects.mMesh[i].mesh)
	   {
		   // Animate and render
		   if(mMeshObjects.mMesh[i].mode == 1)
		   {
			   S32 time = Platform::getVirtualMilliseconds();
			   S32 dt = time - mMeshObjects.mMesh[i].lastRenderTime;
			   mMeshObjects.mMesh[i].lastRenderTime = time;
			   F32 fdt = dt;
			   mMeshObjects.mMesh[i].mesh->advanceTime( fdt/1000.f, mMeshObjects.mMesh[i].thread );
			   mMeshObjects.mMesh[i].mesh->animate();
		   }
		   // If this is a mounted object transform to the correct position
		   if (mMeshObjects.mMesh[i].parentNode != -1)
		   {
			   MatrixF mat;
			   getObjectTransform( &mat, i );
			   GFX->pushWorldMatrix();
			   GFX->multWorld(mat);
			   mMeshObjects.mMesh[i].mesh->render();
			   GFX->popWorldMatrix();
		   }
		   else
		   {
			   mMeshObjects.mMesh[i].mesh->render();
		   }
	   }
   }
   TSMesh::setSceneState( NULL );
   delete pBaseState;  
   if (lightManager)  {
	   lightManager->uninstallGLLights();
	   lightManager->removeLight(&light);
   }

   GFX->setLightingEnable(false);
   GFX->setZEnable(false);
   GFX->setClipRect( updateRect);

   GFX_Canonizer("GuiObjectView", __FILE__, __LINE__);
}
#11
04/13/2006 (1:56 am)
Finally my objectView showed my model...with materials too! ...I'm really happy...even if I really don't understand why this is working...btw if you want a functional GuiObjectView control use this code
else
		   {
			   //test
			   gClientSceneGraph->renderScene();
			   mMeshObjects.mMesh[i].mesh->render();
		   }


instead of this one

else
		   {
			   mMeshObjects.mMesh[i].mesh->render();
		   }


it seem that render scene sets up the environment for correcly drawing the models...I'm still investigating in the code...
#12
04/14/2006 (11:26 am)
Cool BBS, I will try it out tonight when I get a chance to look at some code again. If it works, you da man :)
#13
04/17/2006 (8:33 am)
The gClientSceneGraph->renderScene(); call will draw the skybox behind the model as well. If you don't want that, then Markus Neubel's suggestion from www.garagegames.com/mg/forums/result.thread.php?qt=33605 draws only the model and not the sky box. So, in case you don't want to scroll down to the 43rd post in that thread, add gClientSceneGraph->buildFogTexture(pBaseState); after the setup of the scene state.
#14
04/17/2006 (9:11 am)
If you guys get it working, please post the full .cpp and .h code. I can never seem to get a guiObjectView to load without a crash. Hopefully the fixes will stop that. :)
#15
04/17/2006 (6:55 pm)
@C2

I got it working. Do you still need the src?
#16
04/17/2006 (7:10 pm)
Definitely. I'd appreciate it.
#17
04/18/2006 (12:17 am)
Hi,
thanks Jon Wilson for the advice!

If someone still needs the src can get it from here
#18
04/18/2006 (8:16 am)
Well, it works, however the model is all black, though the
gClientSceneGraph->buildFogTexture(pBaseState);
is where it should be. (I'm on MS2)
#19
04/18/2006 (8:32 am)
Are you using the sources that I have provided?
Are you using this control while a mission is loaded or in a "pure GUI environment"? I haven't tested it during game action but only at startup to let the user select his/her model.
#20
04/18/2006 (9:14 am)
Your source, 100% GUI to let user select player model.

Are you using milestone 3? I'm using a head based from Milestone 2.
Page «Previous 1 2