guiObjectView Spin Object doubt
by Edinson Mejia · in Torque Game Engine · 12/14/2009 (12:12 pm) · 1 replies
Hi I'm using guiObjectView resource to show some models in my game, In my situation I need to make this objects Spin by themself.
For example imagine you are doing a Car Race game, and you can buy cars, the cars appears in the GUI in this case through guiObjectView resourse, ok.... now you can show to the player the car rotating around to see how the car looks....
I try and try and try to understand the code internally to be able to rotate the object... I was so confuse about many things.. at the end I found a way to make it works... BUT I really don't know if this is the best way to do it..
in the class guiObjectView.cc I take this method and add the "//Code Added to Spin" block code
I found this bold code in item.cc which for my understand is the SINGLE object that can spin in the engine.
Using this workaround I make this show like the object is rotating very well, Is this the right way to do it? or exist an more efficient method?
Thanks :)
pd: sorry bad english :$
For example imagine you are doing a Car Race game, and you can buy cars, the cars appears in the GUI in this case through guiObjectView resourse, ok.... now you can show to the player the car rotating around to see how the car looks....
I try and try and try to understand the code internally to be able to rotate the object... I was so confuse about many things.. at the end I found a way to make it works... BUT I really don't know if this is the best way to do it..
in the class guiObjectView.cc I take this method and add the "//Code Added to Spin" block code
//------------------------------------------------------------------------------
void GuiObjectView::renderWorld( const RectI &updateRect )
{
if (!(bool)mMeshObjects.mMainObject)
return;
glClear( GL_DEPTH_BUFFER_BIT );
glMatrixMode( GL_MODELVIEW );
glEnable( GL_DEPTH_TEST );
glDepthFunc( GL_LEQUAL );
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 );
glPushMatrix();
dglMultMatrix( &mat );
mMeshObjects.mMesh[i].mesh->render();
glPopMatrix();
}
else
{
// Code Added to Spin
F32 t = Sim::getCurrentTime() * F32(1)/1000;
F32 r = (t / -100.0) * M_2PI;
Point3F pos;
MatrixF mat = mMeshObjects.mMesh[i].mesh->mNodeTransforms[mMeshObjects.mMesh[i].node];
mat.set(Point3F(0,0,r));
mat.setColumn(3,pos);
glPushMatrix();
dglMultMatrix( &mat );
// Code Added to Spin
mMeshObjects.mMesh[i].mesh->render();
glPopMatrix();
}
}
}
glDisable( GL_DEPTH_TEST );
dglSetClipRect( updateRect );
dglSetCanonicalState();
}I found this bold code in item.cc which for my understand is the SINGLE object that can spin in the engine.
Using this workaround I make this show like the object is rotating very well, Is this the right way to do it? or exist an more efficient method?
Thanks :)
pd: sorry bad english :$
Torque 3D Owner Edinson Mejia
After continous researching I found this:
http://www.torquepowered.com/community/forums/viewthread/4472/1#comment-401807
At the end was so easy to change the camera values to rotate around z axis, I'm learning jejeje... finaly you can rotate camera instead the object, I would like to know how to change Object rotation values instead camera values. I get this for homework.