Help with port plz
by Skylar Kelty · in Torque Game Engine Advanced · 02/09/2008 (9:04 am) · 10 replies
Hullo,
Trying to port some grid-rendering code over and need TGEA's replacement for the following:
Help would be appreciated!
Thanks,
James
Trying to port some grid-rendering code over and need TGEA's replacement for the following:
glEnable(GL_BLEND); // needed? glBegin(GL_LINES); // needed? glColor4ub(...); glVertex3fv(...);
Help would be appreciated!
Thanks,
James
About the author
#2
02/09/2008 (10:01 am)
Yeh I need those opengl calls converted too TGEA's GFX layer
#3
This "PrimBuild::begin(GFXTriangleFan, 4);" may be wrong. I am not sure, but try that out and it should work.
02/09/2008 (12:11 pm)
GFX->setAlphaBlendEnable(true); PrimBuild::begin(GFXTriangleFan, 4); PrimBuild::color4f(....); PrimBuild::vertex3f(.....);
This "PrimBuild::begin(GFXTriangleFan, 4);" may be wrong. I am not sure, but try that out and it should work.
#5
Rendering 0.6million points makes the engine a bit laggy though :P
02/10/2008 (9:38 am)
Ok im done :DRendering 0.6million points makes the engine a bit laggy though :P
#6
Thx
02/10/2008 (9:44 am)
Please can you share your code or give some hints, I'm also tried to port pathfinding code to TGEA but no luck. Thx
#7
And if im honest, my code sucks ass anyway ^^
Here it is tho:
02/10/2008 (11:31 am)
I just been porting this over.And if im honest, my code sucks ass anyway ^^
Here it is tho:
bool iAIPathGrid::prepRenderImage(SceneState *state, const U32 stateKey, const U32 startZone, const bool modifyBaseZoneState)
{
// render if showing the node
if (this->mShow)
{
// return if last state
if (this->isLastState(state, stateKey)) return false;
// set last state
this->setLastState(state, stateKey);
// see if object rendered
if (state->isObjectRendered(this))
{
RenderInst *ri = gRenderInstManager.allocInst();
ri->obj = this;
ri->state = state;
ri->type = RenderInstManager::RIT_Object;
gRenderInstManager.addInst( ri );
}
}
return false;
}
void iAIPathGrid::renderObject(SceneState *state, RenderInst *image)
{
// Awfully laggy cuz we draw so many points (more than 0.6 million)
if(!this->mCompiled) return;
// save matrix to restore canonical state
GFX->pushState();
GFX->setAlphaBlendEnable(true);
// render the nodes
for (U32 i = 0; i < this->mNodes.size(); ++i)
{
PrimBuild::begin(GFXPointList, 2);
PrimBuild::color4f(IAIPATHGLOBAL_GRID_RENDER_NODE_COLOUR);
PrimBuild::color4f(this->mNodes[i]->mMoveModifier, this->mNodes[i]->mMoveModifier, this->mNodes[i]->mMoveModifier, 255);
PrimBuild::vertex3fv(this->mNodes[i]->mPosition + IAIPATHGLOBAL_GRID_RENDER_CLEARANCE);
PrimBuild::vertex3fv(this->mNodes[i]->mPosition + IAIPATHGLOBAL_GRID_RENDER_CLEARANCE + IAIPATHGLOBAL_GRID_RENDER_NODE_HEIGHT);
PrimBuild::end();
// render neighbour links
for (U32 j = 0; j < this->mNodes[i]->mNeighbours.size(); ++j)
{
if (this->mNodes[i]->mNeighbours[j])
{
PrimBuild::begin(GFXPointList, 2);
PrimBuild::color4f(IAIPATHGLOBAL_GRID_RENDER_COLOUR);
PrimBuild::vertex3fv(this->mNodes[i]->mPosition + IAIPATHGLOBAL_GRID_RENDER_CLEARANCE);
PrimBuild::vertex3fv(this->mNodes[i]->mNeighbours[j]->mPosition + IAIPATHGLOBAL_GRID_RENDER_CLEARANCE);
PrimBuild::end();
}
}
}
// render the gridbox, this is my equivilent (how do you spell that) of dglWireCube or whatever its called
const Point3F & extent = Point3F(this->mObjBox.len_x()/2, this->mObjBox.len_y()/2, this->mObjBox.len_z()/2);
const Point3F & center = this->getBoxCenter();
for (S32 i = 0; i < 6; i++)
{
PrimBuild::begin(GFXLineStrip, 4);
PrimBuild::color4f(IAIPATHGLOBAL_GRID_RENDER_BOX_COLOUR);
for(int vert = 0; vert < 4; vert++)
{
int idx = primCubeFaces[i][vert];
PrimBuild::vertex3f(primCubePoints[idx].x * extent.x + center.x,
primCubePoints[idx].y * extent.y + center.y,
primCubePoints[idx].z * extent.z + center.z);
}
PrimBuild::end();
}
// restore canonical rendering state
GFX->setAlphaBlendEnable(false);
GFX->setLightingEnable(false);
GFX->popState();
}
#8
Even if no same rersource,
(I'm using www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=13326)
I think I will figure out how to switch calls to GL_LINES to GFX using your code as tut.
02/10/2008 (1:37 pm)
Hey thanks James,Even if no same rersource,
(I'm using www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=13326)
I think I will figure out how to switch calls to GL_LINES to GFX using your code as tut.
#9
I know those ones are wrong.
Let me know what you find please ^^
02/10/2008 (11:17 pm)
GLBegin becomes PrimBuild::begin, but yeh im not too sure on the correct parameters too pass.I know those ones are wrong.
Let me know what you find please ^^
#10
02/11/2008 (12:12 am)
OK James, I'll post here.
Torque Owner Bobby Leighton
Imagn' Games