Using the GMK with the BG Cliff Kit
by Ronald J Nelson · in Game Mechanics Kit · 08/23/2009 (2:42 pm) · 5 replies
This for those of you that own both the GMK and are using the Physics pack and also own the BG Cliff Kit. You have probably noticed the new physics objects do not react to the cliffs. Here is a couple of small changes to each to make it all work. Yes, I asked both Yuri and Konrad Kiss for permission to release this.
Lets start with the GMK code.
In tsSTatic.h at the bottom where you added the other code for the Physics Pack right after
add:
Now in tsStatic.cpp at about line 125, change all of this:
to this:
OK now onto the additions for the Cliff Kit.
In fxBGCliffReplicator.cpp around line 693, right after:
add this:
Then in tsBGCliffStatic.cpp around line 138, right after:
add this:
You have to do both because if you choose to only make one cliff, or replicate the cliffs, makes a difference on which of those two additions will be needed.
Well that's it, pretty simple stuff but after doing a clean and compile you should see GMK Physics pack object collisions with BG Cliffs.
Lets start with the GMK code.
In tsSTatic.h at the bottom where you added the other code for the Physics Pack right after
Vector<U32> mIndexBuffer;
add:
void prepGMKCollision();
Now in tsStatic.cpp at about line 125, change all of this:
//.logicking >>
//create physic object
Physics* physics = Physics::getPhysics(isServerObject());
if(physics)
{
mPhysPolyList = new ConcretePolyList();
Box3F box = getWorldBox();
bool res = buildPolyList(mPhysPolyList, box, SphereF());
if(res && mPhysPolyList->mPolyList.size()>0)
{
for(U32 i = 0; i < mPhysPolyList->mPolyList.size() ; i++)
{
ConcretePolyList::Poly& poly = mPhysPolyList->mPolyList[i];
for (int i = 0;i<poly.vertexCount-2;i++)
{
mIndexBuffer.push_back(mPhysPolyList->mIndexList[poly.vertexStart]);
mIndexBuffer.push_back(mPhysPolyList->mIndexList[poly.vertexStart+i+2]);
mIndexBuffer.push_back(mPhysPolyList->mIndexList[poly.vertexStart+i+1]);
}
}
Point3F* vBuffer = mPhysPolyList->mVertexList.address();
int vNum = mPhysPolyList->mVertexList.size();
U32* iBuffer = mIndexBuffer.address();
int iNum = mIndexBuffer.size();
mPhysGeom = physics->createPhysShape(vBuffer, vNum, sizeof(Point3F), iBuffer, iNum,3*sizeof(U32));
}
}
//.logicking <<
addToScene();
return true;
}to this:
prepGMKCollision();
addToScene();
return true;
}
void TSStatic::prepGMKCollision()
{
//.logicking >>
//create physic object
Physics* physics = Physics::getPhysics(isServerObject());
if(physics)
{
mPhysPolyList = new ConcretePolyList();
Box3F box = getWorldBox();
bool res = buildPolyList(mPhysPolyList, box, SphereF());
if(res && mPhysPolyList->mPolyList.size()>0)
{
for(U32 i = 0; i < mPhysPolyList->mPolyList.size() ; i++)
{
ConcretePolyList::Poly& poly = mPhysPolyList->mPolyList[i];
for (int i = 0;i<poly.vertexCount-2;i++)
{
mIndexBuffer.push_back(mPhysPolyList->mIndexList[poly.vertexStart]);
mIndexBuffer.push_back(mPhysPolyList->mIndexList[poly.vertexStart+i+2]);
mIndexBuffer.push_back(mPhysPolyList->mIndexList[poly.vertexStart+i+1]);
}
}
Point3F* vBuffer = mPhysPolyList->mVertexList.address();
int vNum = mPhysPolyList->mVertexList.size();
U32* iBuffer = mIndexBuffer.address();
int iNum = mIndexBuffer.size();
mPhysGeom = physics->createPhysShape(vBuffer, vNum, sizeof(Point3F), iBuffer, iNum,3*sizeof(U32));
}
}
//.logicking <<
}OK now onto the additions for the Cliff Kit.
In fxBGCliffReplicator.cpp around line 693, right after:
mCurrentShapeCount = mReplicatedShapes.size();
add this:
for(U32 i = 0; i < mReplicatedShapes.size(); i++)
{
TSStatic * replicatedStatic = dynamic_cast<TSStatic*>(mReplicatedShapes[i]);
if(replicatedStatic)
{
replicatedStatic->prepGMKCollision();
}
}Then in tsBGCliffStatic.cpp around line 138, right after:
addToScene();
add this:
TSStatic * cliffStatic = dynamic_cast<TSStatic*>(this);
if(cliffStatic)
{
cliffStatic->prepGMKCollision();
}You have to do both because if you choose to only make one cliff, or replicate the cliffs, makes a difference on which of those two additions will be needed.
Well that's it, pretty simple stuff but after doing a clean and compile you should see GMK Physics pack object collisions with BG Cliffs.
#2
08/25/2009 (1:43 pm)
Hey no problem. Both are awesome products and it would be a shame not to have them work together.
#3
08/29/2009 (10:53 pm)
What is the BG Cliff Kit? I do not see it on the list of add-ons.
#4
www.garagegames.com/community/forums/viewthread/80642
08/29/2009 (10:58 pm)
Its an exceptional product made by Konrad Kiss. He is in the middle of updating some things right now but it will be back. You can read about it and see a few videos here:www.garagegames.com/community/forums/viewthread/80642
#5
Now just need that Build my Game button add-on.
08/31/2009 (11:35 pm)
WoW! Very nice add-on. I look forward to buy it whenit is ready fo T3D :)Now just need that Build my Game button add-on.
Torque Owner TheGasMan
G.A.S. [+others]
T3D v1, bgcliff for T3D and GMK for T3D v1.
- All are bought, just waiting on those versions to be released.