Bounding Box Coordinate Question
by Ronald J Nelson · in Torque Game Engine · 10/05/2007 (9:33 am) · 3 replies
I need to find the opposite side of a collision with a player bounding box from a projectile. I can figure out everything but this one thing that I can't seem to get my head around.

Thanks in advance.

Thanks in advance.
#2
those are in there to account for some weirdness with the coordinate system of Triggers.
i guess those functions should really be split up into
SceneObject::worldToLocalPoint()
and
Trigger::worldToLocalPoint()
10/05/2007 (10:09 am)
Actually, you might need to get rid of the lines commented "bummer about this" in worldToLocal -those are in there to account for some weirdness with the coordinate system of Triggers.
i guess those functions should really be split up into
SceneObject::worldToLocalPoint()
and
Trigger::worldToLocalPoint()
#3
This is what I have so far in the projectile.cc processTick just before the explode and OnCollision calls:
I have tested this with console log entires in several different places and have made the following observations:
1. it makes the collision with the player object just fine
2. While it says it detects an interior object behind the player, it doesn't place a decal.
3. It claims that the interior object is server side only.
4. It works perfectly on interiors and terrain when they are the primary contact.
5. Anything more than a couple projectiles at the player will crash the game as well.
Now what the wierd looking stuff there like addWrap decal and the hitboxes, well yeah a lot of my stuff has hitboxes and I managed to get the majority of DavidRM's wrapping decal code working (still working out how to get it to cooperate with batched decals).
I have done this with regular decals, a seperate function for placeing the decals, and SEVERAL different methods of trying to get the coordinates I need, with about the same results each time.
So, thanks a ton Orion, but my method will require a bit of conversions since I am not script based on this. But thanks, you always have great advice.
10/06/2007 (12:19 am)
Interesting. Unfortunately I am trying to accomplish the majority of this in code.This is what I have so far in the projectile.cc processTick just before the explode and OnCollision calls:
if( rInfo.object->getTypeMask() & TerrainObjectType )
{
TerrainBlock* tBlock = static_cast<TerrainBlock*>(rInfo.object);
S32 mapIndex = tBlock->getTerrainMapIndex(rInfo.point);
if (mapIndex != -1)
{
MaterialPropertyMap* pMatMap = static_cast<MaterialPropertyMap*>(Sim::findObject("MaterialPropertyMap"));
const MaterialPropertyMap::MapEntry* pEntry = pMatMap->getMapEntryFromIndex(mapIndex);
if(pEntry)
{
pMatType = pEntry->matType;
}
}
}
else if( rInfo.object->getTypeMask() & InteriorObjectType )
{
MaterialPropertyMap* pMatMap = static_cast<MaterialPropertyMap*>(Sim::findObject("MaterialPropertyMap"));
const MaterialPropertyMap::MapEntry* pMatEnt = pMatMap->getMapEntryFromIndex(rInfo.material);
if (pMatEnt)
{
pMatType = pMatEnt->matType;
}
}
else if( rInfo.object->getTypeMask() & PlayerObjectType )
{
Point3F playerRearPosition = mCurrPosition + savedCurrVelocity * (F32(TickMs) / 1000.0f);
if (getContainer()->castRay(savedOldPosition, playerRearPosition, csmStaticCollisionMask, &pInfo) == true)
{
Point3F impactNormalB(pInfo.point);
impactNormalB-=savedOldPosition;
impactNormalB.normalize();
if(mDataBlock->NumBS > 0)
{
// randomly choose a decal between 0 and (decal count - 1)
U32 idx = (U32)(mCeil(mDataBlock->NumBS * Platform::getRandom()) - 1.0f);
// this should never choose a NULL idx, but check anyway
if(mDataBlock->bloodSplatter[idx] != NULL)
{
DecalManager *decalMngr = gClientSceneGraph->getCurrentDecalManager();
if(decalMngr)
{
decalMngr->addWrapDecal(pInfo.point, pInfo.normal, impactNormalB, mDataBlock->bloodSplatter[idx]);
}
}
}
}
}
else
{
//Going to do more here when we figure out or acquire DTS painting
Con::errorf(ConsoleLogEntry::General, "Projectile hit a Shapebase Object");
}
//Hitbox code Start RJN
Point3F impactNormal(mCurrPosition);
impactNormal-=oldPosition;
impactNormal.normalize();I have tested this with console log entires in several different places and have made the following observations:
1. it makes the collision with the player object just fine
2. While it says it detects an interior object behind the player, it doesn't place a decal.
3. It claims that the interior object is server side only.
4. It works perfectly on interiors and terrain when they are the primary contact.
5. Anything more than a couple projectiles at the player will crash the game as well.
Now what the wierd looking stuff there like addWrap decal and the hitboxes, well yeah a lot of my stuff has hitboxes and I managed to get the majority of DavidRM's wrapping decal code working (still working out how to get it to cooperate with batched decals).
I have done this with regular decals, a seperate function for placeing the decals, and SEVERAL different methods of trying to get the coordinates I need, with about the same results each time.
So, thanks a ton Orion, but my method will require a bit of conversions since I am not script based on this. But thanks, you always have great advice.
Associate Orion Elenzil
Real Life Plus
i think something like this is close to what you want:
if you don't want the altitude to change, then you could implement vectorConvolve()
and change the vectorScale() line to: