Game Development Community

dev|Pro Game Development Curriculum

Merry Christmas, Community - Poly Soup

by Kyle Carter · 12/24/2006 (5:03 pm) · 143 comments

Wow - almost three months since my last .plan. I guess I should write these things more often. What have I been up to? Nothing that's quite ready to be talked about in depth, but in brief: developing ways for us to do more releases at a higher quality and with bigger feature sets.

And probably some smaller stuff that I'll be posting about in coming months, too. :)

Speaking of smaller stuff, I took a few days about a month ago and extended 3space and TSStatic in TSE to support more flexible collision scenarios. Or to speak more directly, polysoup collision. I've collaborated on this with Tom Spilman, who spent some time debugging it, integrating it into a project, and cleaning it up a bit, and the end result is a polysoup implementation that seems fairly usable.

So, here's a screenshot of an orc on a concave donut:

farm1.static.flickr.com/85/272842689_bb8f17c445_m.jpg

Now, some caveats: this is just the result of a few day's hacking, not an official announcement of GG support for polysoup in Torque. So while it's pretty easy to integrate, you do have to have some coding knowledge to use it.

It's also not bullet proof. We use OpCode, so it's pretty fast & efficient, but if you expect to drop ten orc models into a level and not have a performance hit when you run a buggy into them, you'll have to think again. But if you want to build a building in DTS, and don't go overboard in your model complexity, you should do just fine.

Finally, it collides against ALL the meshes in your model, including invisible ones. So if you want a model to work for polysoup you probably want to kill all your Col-1 meshes & so forth for proper results. Adding some sort of filtering rule wouldn't be hard but it was unclear the best way to do that so we left it a bit braindead.

You can get this at its page on TDN, if you're a TSE owner. Remember, you're on your own using it!

I figure I can't very well give you hearty Christmas cheer this holiday, so I may as well post up something nice and useful. :)
#61
01/26/2007 (6:40 pm)
TGEA ms 4.2 crashes with every static shape, except boxes, when "usePolysoup" is clicked in the Editor.
I followed all the steps mentioned above to incorporate this resource and compile it with VC8 Express.
When I debug TGEA, it breaks at line 3789 in tsMesh.cpp:

// Don't re init if we already have something...
right here -> if(mOptTree)
return;

"mOptTree CXX0030: Error: expression cannot be evaluated"
#62
02/06/2007 (7:49 pm)
I would have liked to be able to locate the position and orientation of the mesh (polygon) I'm pointing with my mouse on an animated object (like painting on the orc for instance).
Will that be possible with polysoup ?
#63
02/07/2007 (9:13 am)
If you're willing to burn CPU, you can update it every frame or casts and do that just fine.
#64
02/15/2007 (1:35 pm)
This is awesome! My vehicles are loving some very interesting surfaces, without the hassle of generating terrain!

However, I too am getting the player on foot colliding apparently with the insides of objects, and not so much the outsides. That's how it looks, anyway. I applied Tom Spillman's patch as well, although I don't know if that's relevant (you just gotta put code in front of me and I'll paste it in and compile it!).

Edit: I see the posts above about the animation of the player breaking the collision. I feel like I've just gotten 5 out of 6 numbers on my lottery ticket. I was wondering how this was resolved with terrain, which seems like a similar deal?
#65
03/02/2007 (2:00 pm)
FYI. My fix above isn't part of the RAR yet and TGEA 1.0 hasn't been merged... so inspect the changes carefully when applying to TGEA.
#66
06/20/2007 (9:31 am)
Does the Poly Soup resource work on the Mac platform (yet)? I'm just looking for some advice on how to start including it. In VS2005, I just add the opcode project, add the include path, and build. I'm not really sure how to do this in x-code. Any advice would be greatly appreciated.

Thanks
#67
06/20/2007 (1:52 pm)
If you can link the opcode lib into your XCode project then the polysoup code ought to work just fine. How to link the opcode lib? Not quite sure the details of that, but I'm sure it can be done. :)
#68
07/04/2007 (2:48 am)
I'm getting link errors trying to compile that on VS2005.

1>msvcrt.lib(ti_inst.obj) : error LNK2005: "private: __thiscall type_info::type_info(class type_info const &)" (??0type_info@@AAE@ABV0@@Z) already defined in LIBCMT.lib(typinfo.obj)
1>msvcrt.lib(ti_inst.obj) : error LNK2005: "private: class type_info & __thiscall type_info::operator=(class type_info const &)" (??4type_info@@AAEAAV0@ABV0@@Z) already defined in LIBCMT.lib(typinfo.obj)
1> Creating library ../../Projects/Golf/SilverKeyGameLauncher.lib and object ../../Projects/Golf/SilverKeyGameLauncher.exp
1>LIBCMT.lib(crt0init.obj) : warning LNK4098: defaultlib 'msvcrt.lib' conflicts with use of other libs; use /NODEFAULTLIB:library
1>tsMesh.obj : warning LNK4217: locally defined symbol ??1CollisionAABB@Opcode@@QAE@XZ (public: __thiscall Opcode::CollisionAABB::~CollisionAABB(void)) imported in function __unwindfunclet$?buildPolyListOpcode@TSMesh@@UAE_NHPAVAbstractPolyList@@ABVBox3F@@@Z$0
1>tsMesh.obj : warning LNK4217: locally defined symbol ??1Point@IceMaths@@QAE@XZ (public: __thiscall IceMaths::Point::~Point(void)) imported in function __unwindfunclet$?buildPolyListOpcode@TSMesh@@UAE_NHPAVAbstractPolyList@@ABVBox3F@@@Z$0
1>tsMesh.obj : warning LNK4217: locally defined symbol ??1AABB@IceMaths@@QAE@XZ (public: __thiscall IceMaths::AABB::~AABB(void)) imported in function __unwindfunclet$?buildPolyListOpcode@TSMesh@@UAE_NHPAVAbstractPolyList@@ABVBox3F@@@Z$0
1>tsMesh.obj : warning LNK4217: locally defined symbol ??1AABBCache@Opcode@@QAE@XZ (public: __thiscall Opcode::AABBCache::~AABBCache(void)) imported in function __unwindfunclet$?buildPolyListOpcode@TSMesh@@UAE_NHPAVAbstractPolyList@@ABVBox3F@@@Z$0
1>tsMesh.obj : warning LNK4217: locally defined symbol ??1AABBCollider@Opcode@@UAE@XZ (public: virtual __thiscall Opcode::AABBCollider::~AABBCollider(void)) imported in function "public: virtual bool __thiscall TSMesh::buildPolyListOpcode(int,class AbstractPolyList *,class Box3F const &)" (?buildPolyListOpcode@TSMesh@@UAE_NHPAVAbstractPolyList@@ABVBox3F@@@Z)
1>tsMesh.obj : warning LNK4217: locally defined symbol ??1OPC_Container@IceCore@@QAE@XZ (public: __thiscall IceCore::OPC_Container::~OPC_Container(void)) imported in function "public: virtual bool __thiscall TSMesh::buildPolyListOpcode(int,class AbstractPolyList *,class Box3F const &)" (?buildPolyListOpcode@TSMesh@@UAE_NHPAVAbstractPolyList@@ABVBox3F@@@Z)
1>tsMesh.obj : warning LNK4217: locally defined symbol ?Collide@AABBCollider@Opcode@@QAE_NAAUAABBCache@2@ABVCollisionAABB@2@ABVModel@2@@Z (public: bool __thiscall Opcode::AABBCollider::Collide(struct Opcode::AABBCache &,class Opcode::CollisionAABB const &,class Opcode::Model const &)) imported in function "public: virtual bool __thiscall TSMesh::buildPolyListOpcode(int,class AbstractPolyList *,class Box3F const &)" (?buildPolyListOpcode@TSMesh@@UAE_NHPAVAbstractPolyList@@ABVBox3F@@@Z)
1>tsMesh.obj : warning LNK4217: locally defined symbol ?SetMinMax@AABB@IceMaths@@QAEXABVPoint@2@0@Z (public: void __thiscall IceMaths::AABB::SetMinMax(class IceMaths::Point const &,class IceMaths::Point const &)) imported in function "public: virtual bool __thiscall TSMesh::buildPolyListOpcode(int,class AbstractPolyList *,class Box3F const &)" (?buildPolyListOpcode@TSMesh@@UAE_NHPAVAbstractPolyList@@ABVBox3F@@@Z)
1>tsMesh.obj : warning LNK4217: locally defined symbol ??0AABBCache@Opcode@@QAE@XZ (public: __thiscall Opcode::AABBCache::AABBCache(void)) imported in function "public: virtual bool __thiscall TSMesh::buildPolyListOpcode(int,class AbstractPolyList *,class Box3F const &)" (?buildPolyListOpcode@TSMesh@@UAE_NHPAVAbstractPolyList@@ABVBox3F@@@Z)
1>tsMesh.obj : warning LNK4217: locally defined symbol ??0AABBCollider@Opcode@@QAE@XZ (public: __thiscall Opcode::AABBCollider::AABBCollider(void)) imported in function "public: virtual bool __thiscall TSMesh::buildPolyListOpcode(int,class AbstractPolyList *,class Box3F const &)" (?buildPolyListOpcode@TSMesh@@UAE_NHPAVAbstractPolyList@@ABVBox3F@@@Z)
1>tsMesh.obj : warning LNK4217: locally defined symbol ??1IndexedTriangle@IceMaths@@QAE@XZ (public: __thiscall IceMaths::IndexedTriangle::~IndexedTriangle(void)) imported in function "public: void * __thiscall IceMaths::IndexedTriangle::`vector deleting destructor'(unsigned int)" (??_EIndexedTriangle@IceMaths@@QAEPAXI@Z)
1>tsMesh.obj : warning LNK4217: locally defined symbol ??1Ray@IceMaths@@QAE@XZ (public: __thiscall IceMaths::Ray::~Ray(void)) imported in function __unwindfunclet$?castRayOpcode@TSMesh@@UAE_NABVPoint3F@@0PAURayInfo@@@Z$0
1>tsMesh.obj : warning LNK4217: locally defined symbol ??1CollisionFaces@Opcode@@QAE@XZ (public: __thiscall Opcode::CollisionFaces::~CollisionFaces(void)) imported in function __unwindfunclet$?castRayOpcode@TSMesh@@UAE_NABVPoint3F@@0PAURayInfo@@@Z$0
1>tsMesh.obj : warning LNK4217: locally defined symbol ??1RayCollider@Opcode@@UAE@XZ (public: virtual __thiscall Opcode::RayCollider::~RayCollider(void)) imported in function "public: virtual bool __thiscall TSMesh::castRayOpcode(class Point3F const &,class Point3F const &,struct RayInfo *)" (?castRayOpcode@TSMesh@@UAE_NABVPoint3F@@0PAURayInfo@@@Z)
1>tsMesh.obj : warning LNK4217: locally defined symbol ??GPoint@IceMaths@@QBE?AV01@ABV01@@Z (public: class IceMaths::Point __thiscall IceMaths::Point::operator-(class IceMaths::Point const &)const ) imported in function "public: virtual bool __thiscall TSMesh::castRayOpcode(class Point3F const &,class Point3F const &,struct RayInfo *)" (?castRayOpcode@TSMesh@@UAE_NABVPoint3F@@0PAURayInfo@@@Z)
1>tsMesh.obj : warning LNK4217: locally defined symbol ?Collide@RayCollider@Opcode@@QAE_NABVRay@IceMaths@@ABVModel@2@PBVMatrix4x4@4@PAI@Z (public: bool __thiscall Opcode::RayCollider::Collide(class IceMaths::Ray const &,class Opcode::Model const &,class IceMaths::Matrix4x4 const *,unsigned int *)) imported in function "public: virtual bool __thiscall TSMesh::castRayOpcode(class Point3F const &,class Point3F const &,struct RayInfo *)" (?castRayOpcode@TSMesh@@UAE_NABVPoint3F@@0PAURayInfo@@@Z)
1>tsMesh.obj : warning LNK4217: locally defined symbol ??0OPC_Container@IceCore@@QAE@XZ (public: __thiscall IceCore::OPC_Container::OPC_Container(void)) imported in function "public: virtual bool __thiscall TSMesh::castRayOpcode(class Point3F const &,class Point3F const &,struct RayInfo *)" (?castRayOpcode@TSMesh@@UAE_NABVPoint3F@@0PAURayInfo@@@Z)
1>tsMesh.obj : warning LNK4217: locally defined symbol ??0RayCollider@Opcode@@QAE@XZ (public: __thiscall Opcode::RayCollider::RayCollider(void)) imported in function "public: virtual bool __thiscall TSMesh::castRayOpcode(class Point3F const &,class Point3F const &,struct RayInfo *)" (?castRayOpcode@TSMesh@@UAE_NABVPoint3F@@0PAURayInfo@@@Z)
1>tsMesh.obj : warning LNK4217: locally defined symbol ??0OPCODECREATE@Opcode@@QAE@XZ (public: __thiscall Opcode::OPCODECREATE::OPCODECREATE(void)) imported in function "public: void __thiscall TSMesh::prepOpcodeCollision(void)" (?prepOpcodeCollision@TSMesh@@QAEXXZ)
1>tsMesh.obj : warning LNK4217: locally defined symbol ??0Model@Opcode@@QAE@XZ (public: __thiscall Opcode::Model::Model(void)) imported in function "public: void __thiscall TSMesh::prepOpcodeCollision(void)" (?prepOpcodeCollision@TSMesh@@QAEXXZ)
1>tsMesh.obj : warning LNK4217: locally defined symbol ?SetPointers@MeshInterface@Opcode@@QAE_NPBVIndexedTriangle@IceMaths@@PBVPoint@4@@Z (public: bool __thiscall Opcode::MeshInterface::SetPointers(class IceMaths::IndexedTriangle const *,class IceMaths::Point const *)) imported in function "public: void __thiscall TSMesh::prepOpcodeCollision(void)" (?prepOpcodeCollision@TSMesh@@QAEXXZ)
1>tsMesh.obj : warning LNK4217: locally defined symbol ??0Point@IceMaths@@QAE@XZ (public: __thiscall IceMaths::Point::Point(void)) imported in function "public: void __thiscall TSMesh::prepOpcodeCollision(void)" (?prepOpcodeCollision@TSMesh@@QAEXXZ)
1>tsMesh.obj : warning LNK4217: locally defined symbol ??0IndexedTriangle@IceMaths@@QAE@XZ (public: __thiscall IceMaths::IndexedTriangle::IndexedTriangle(void)) imported in function "public: void __thiscall TSMesh::prepOpcodeCollision(void)" (?prepOpcodeCollision@TSMesh@@QAEXXZ)
1>tsMesh.obj : warning LNK4217: locally defined symbol ??0MeshInterface@Opcode@@QAE@XZ (public: __thiscall Opcode::MeshInterface::MeshInterface(void)) imported in function "public: void __thiscall TSMesh::prepOpcodeCollision(void)" (?prepOpcodeCollision@TSMesh@@QAEXXZ)
1>tsMesh.obj : warning LNK4217: locally defined symbol ??1Model@Opcode@@UAE@XZ (public: virtual __thiscall Opcode::Model::~Model(void)) imported in function "public: virtual void * __thiscall Opcode::Model::`scalar deleting destructor'(unsigned int)" (??_GModel@Opcode@@UAEPAXI@Z)
1>tsMesh.obj : error LNK2019: unresolved external symbol __imp__InitOpcode referenced in function "public: void __thiscall TSMesh::prepOpcodeCollision(void)" (?prepOpcodeCollision@TSMesh@@QAEXXZ)
1>../../Projects/Golf/SilverKeyGameLauncher.exe : fatal error LNK1120: 1 unresolved externals
1>Build log was saved at "file://d:\Game\SDK\engine\out.VC8.RELEASE\BuildLog.htm"
1>Torque Demo - 4 error(s), 26 warning(s)

can any one please tell me what's wrong ?

Thanks
#69
07/19/2007 (7:53 am)
I have TGEA indie license.
So what do I need to do, or who do I need to bribe to allow me to make commercial game with this? (Looking at Ben's Amazon wishlist)

I would like to know this before I get my modeller to start creating stuff.
#70
07/19/2007 (11:04 am)
E-mail me and I'll redirect you to the right biz dev person.

You can buy me stuff off my Amazon list but it won't get you commercial access - GG has to approve it, not me personally. :)
#71
07/19/2007 (11:04 am)
From the TDN article:


\"Please read the file readme_eula.txt for information on the private licensing of this code. Please contact Timothy Aste at [tima@garagegames.com] for information on the commercial licensing of this code for commercial works.\"

So actually, e-mail Tim Aste. :)
#72
07/31/2007 (12:04 am)
@Sorin Daraban
the fix for your problem is a step back in TSShapeInstance::prepCollision
for(S32 i=0; i<hShape->meshes.size(); i++)
    if(hShape->meshes[i])
        hShape->meshes[i]->prepOpcodeCollision();

And to fix player collision make this change in TSStaticPolysoupConvex::getPolyList
S32 base =  list->addPoint(verts[0]);
                    list->addPoint(verts[2]);
                    list->addPoint(verts[1]);
                    list->addPoint(verts[3]);

We have upgraded the version of ODE in our system and with some alterations for the memory manager linked with it's OPCODE. The new version also has GIMPACT for determining penetration information for polysoup, still has many bugs in ODE but maybe some one will give it a go in torque.
#73
08/02/2007 (2:44 am)
Hi, just wondered if anyone have tried this in latest TGEA and got it working? throws up a few problems compiling and unfortunately I don't do coding :)
#74
08/13/2007 (7:12 pm)
Not sure if this is right, I've just pasted together code snippets from other parts of the system but it works. This version of TSShapeInstance::prepCollision will load all collision meshes into the soup and if there aren't any it uses the visible meshes. More generally useful I think.
void TSShapeInstance::prepCollision()
{
// start ds - will load all collision meshes into the soup and if there aren't any it uses the visible meshes
/*
   // Iterate over all our meshes and call prepCollision on them...
   for(S32 i=0; i<hShape->meshes.size(); i++)
      hShape->meshes[i]->prepOpcodeCollision();
*/

   // step through all the details in the shape
   U32 count = 0;
   for (U32 dl = 0; dl < hShape->details.size(); dl++)
   {
      TSShape::Detail *detail = &(hShape->details[dl]);
      if(!detail)
         continue;

      // look for polysoup collision meshes
      char* name = (char*)hShape->names[detail->nameIndex];
      if (!dStrstr((const char*)dStrlwr(name), "collision-"))
         continue;

      // check meshes on this detail level...
      S32 ss = detail->subShapeNum;
      S32 od = detail->objectDetailNum;
      if (ss<0)
         continue; // this is a billboard detail level
      S32 start = hShape->subShapeFirstObject[ss];
      S32 end = hShape->subShapeNumObjects[ss] + start;
		
      // should only be one mesh but lets be safe
      for (U32 i=start; i<end; i++)
      {
         TSMesh * mesh = hShape->meshes[i];
         if (mesh)
         {
            mesh->prepOpcodeCollision();
            count++;
         }
      }
   }
   // we found collision meshes so no need to add any more meshes
   if (count!=0)
      return;

   // add the first LOD of the visible meshes
   TSShape::Detail *detail = &(hShape->details[0]);
   if (!detail)
      return;

   // check meshes on this detail level...
   S32 ss = detail->subShapeNum;
   S32 od = detail->objectDetailNum;
   if (ss<0)
      return; // this is a billboard detail level
   S32 start = hShape->subShapeFirstObject[ss];
   S32 end = hShape->subShapeNumObjects[ss] + start;
	
   // add all visible meshes for this detail level
   for (U32 i=start; i<end; i++)
   {
      TSMesh * mesh = hShape->meshes[i];
      if (mesh)
         mesh->prepOpcodeCollision();
   }
// end ds
}
#75
08/14/2007 (12:12 am)
Thanx Joti!

EDIT: Pity we need a Commercial license to use this.
#76
09/02/2007 (4:03 pm)
Quote:Pity we need a Commercial license to use this.

...check again! It has been changed:

TDN article

Share and enjoy!
#77
09/02/2007 (5:27 pm)
Hey that's totally sweet!

Thanks GG!
#78
09/03/2007 (12:33 am)
Fantastic!!! I already had it in and was hoping to pay for this with pre-orders... hehe...

Thanx you guys!
#79
09/07/2007 (3:06 am)
Uuurhm.... Can someone send me their vcproj/sln files? I broke something and cant seem to get it going again :-/

burningza _at_ gmail dot com

Plzzz
#80
09/19/2007 (1:47 am)
Got it working again.

Have a little more detailed description of how to get it installed, linked n all here.

There's also an include missing in the resource.