Game Development Community

PolySoup with projectiles question

by Ronald J Nelson · in Torque Game Engine · 01/05/2007 (7:48 pm) · 6 replies

I realize this is one probalby best for Ben Garney or Tom Spilman so here is hoping they read it.

I am trying to use the polysoup code they released to allow my projectiles to locate the surface of the dts mesh through a raycast. I need to be able to read rInfo data from the surface of the dts object and polysoup looks like it was the fix for me.

Here is my code so far. Lots of console statements since I am just trying to get workable data at this point from my work.

else if( rInfo.object->getTypeMask() & PlayerObjectType )
		 {
			 RayInfo dInfo;
			 Player* pBlock = static_cast<Player*>(rInfo.object);
			 TSShapeInstance* playerShape = pBlock->getShapeInstance();
			 mPolyCheckPosition = mCurrPosition + mCurrVelocity * (F32(TickMs) / 1000.0f);
			 if (playerShape->castRayOpcode(0, mPolyCheckPosition, mCurrPosition, &dInfo) == true)
			 {
				 Con::errorf(ConsoleLogEntry::General, "Projectile hit the Player Poly Mesh!");
				 Con::errorf(ConsoleLogEntry::General, "This is pBlock %d", pBlock);
				 Con::errorf(ConsoleLogEntry::General, "This is playerShape %d", playerShape);
				 Con::errorf(ConsoleLogEntry::General, "This is pBlock->getShapeInstance() %d", pBlock->getShapeInstance());
				 Con::errorf(ConsoleLogEntry::General, "This is dInfo.face %d", dInfo.face);
				 Con::errorf(ConsoleLogEntry::General, "This is dInfo.faceDot %d", dInfo.faceDot);
				 Con::errorf(ConsoleLogEntry::General, "This is dInfo.normal.x %d", dInfo.normal.x);
				 Con::errorf(ConsoleLogEntry::General, "This is dInfo.normal.y %d", dInfo.normal.y);
				 Con::errorf(ConsoleLogEntry::General, "This is dInfo.normal.z %d", dInfo.normal.z);
				 Con::errorf(ConsoleLogEntry::General, "This is dInfo.object %d", dInfo.object);
				 Con::errorf(ConsoleLogEntry::General, "This is dInfo.point.x %d", dInfo.point.x);
				 Con::errorf(ConsoleLogEntry::General, "This is dInfo.point.y %d", dInfo.point.y);
				 Con::errorf(ConsoleLogEntry::General, "This is rInfo.point.z %d", rInfo.point.z);
				 Con::errorf(ConsoleLogEntry::General, "This is rInfo.t %d", rInfo.t);
			 }
			 
		 }

Now with my if statement in place it locks up my game as soon as a shoot a player. However if I comment out the if statement and respective brackets I do get my data for my console stements. However it is not the information I am looking for since I need the rInfo from the visible mesh. What I get in my console log shows some pretty crazy results after the crash however. I looks like it is out hitting random objects all over until it finally crashes.

Any suggestions on how to make this work in the manner I would like would be really helpful. Oh yeah this code is in my projectile.cc processTick function.

#1
01/06/2007 (8:59 am)
Two things. First i'm pretty sure the player shape wasn't initialized for use with opcode collision. Look at the source code in the polysoup and you'll see that the TSStatic initializes the collision system special for polysoup. Second polysoup will not work on skinned shapes... it only looks at the initial non-animated shape and doesn't look any of the skinning results. Depending on what your trying to do this may be an issue.
#2
01/06/2007 (12:35 pm)
Well it not working for the player is really not that big of a deal, I was only testing that intially. So as of right now this really only works on static objects, correct? What about rigidshape?
#3
01/06/2007 (12:43 pm)
I'm not familiar off the top of my head how RigidShape works... you'll have to investigate yourself. I only worked on this with TSStatic in mind.
#4
01/06/2007 (4:34 pm)
ATM, it's currently only ever loaded for TSstatic, and it is somewhat picky about the shapes it turns to collisions. Add some logic to the loading (I'm using only meshes labeled 'walkmesh' ala NWN). You could concievably add hitboxes to your players, using opCode on those meshes only. Once you've gotten this to work as you need it to, its very easy to add to ANY shape that is loaded. Your logic should/will filter out whats not needed.
Thinking of rigidshape, I'm looking forward to seeing how this collision system will improve the ODE implementations, as that product is designed with opCode in mind. RSN, I'll get to it...
#5
01/09/2007 (5:17 pm)
Where do i start working on the polysoup code to get it working on the player ?
So he stops falling :)
#6
01/09/2007 (7:03 pm)
I'm no programmer, but I remember seeing Kork walking around on a donut shape as an example of polysoup posted here by GG. I would assume that the polysoup was applied to the donut (or in your case terrain). I wonder if you could have dts terrain? ...did anybody say caves or over hangs? ...ahhh yeah..