## Drawing an OBJ from structs

Moderator
Posts: 3,567
Joined: 2003.06
Post: #46
mikey Wrote:Have you ever played Ghost Recon (PC,PS2,XBOX) ? It's physics are what I'd quite like.

I haven't played the original Ghost Recon, but I played a later version on the 360. The video that you linked reminds me of the motion in Delta Force. Yeah, I like that movement too.

You really don't need to worry too much about accuracy in collision detection for movement with that kind of FPS. The only thing you'll want to be fairly accurate with is the shots. For shots, you'll want to cast a ray and do triangle collisions eventually, but even spheres will work at first. For movement it's really easy, all you need to do is find the height of the terrain that your player is on at any given moment. When moving to lower terrain you can simply add in a little gravity calc so the player doesn't drop instantly, and for going up you might be able to just follow the terrain height directly. For staying out of walls, sphere-plane is plenty good enough I think.

As for getting into the geometry loaded by my obj loader, it is really simple. The "mesh" is a linked list of meshes for each model, where each mesh uses a different material. If you have a model that only uses one material (probably just a single texture), it'll only have one mesh. To loop through all the meshes of any given model, if you don't understand linked lists yet, just look at the while loop in the drawMesh function. In the mesh, there are verts, normals and tex coords. They are each a simple array. Each vertex is three coordinates stored sequentially -- xyz. So mesh->verts[0], mesh->verts[1], mesh->verts[2] would be the first vertex, and mesh->verts[3], mesh->verts[4], mesh->verts[5] would be the second vertex, and so on. Each three vertices represents one triangle in the model.
Member
Posts: 227
Joined: 2008.08
Post: #47
I would suggest you use full triangle-triangle detection, a set of functions for this can be found as a file called tritri.c, or use ray-triangle detection.
This will be much more accurate, easier to scale, and possibly faster (provided you do optomizations with pre-checks).
(Believe me, I went through the exact thing as you 3 months earlier)
Member
Posts: 281
Joined: 2009.04
Post: #48
OK, thanks Oddity007 and AnotherJake. I will implement simple collision detection (I need to come up with an acronym, that's long ) and look at tritri.c. I'll do a Happy Balanceâ„¢.

~ Bring a Pen ~
Member
Posts: 260
Joined: 2005.05
Post: #49
Just a few thoughts on collision detection.

Sphere-sphere is indeed the first thing to try. Smallest effort to get rolling.

AABB's (axis aligned bounding boxes) are useful in some special cases. Also, cylinder-cylinder.

Going down to polygon level will make a lot of hard problems surface. Ray-triangle checks is just the start. Optimizing it to check the right triangles is important when the models get big (and they do). Fast-moving objects may move inside each other, etc. The hardest part comes when you want to handle the collision. Making things bounce and slide, then you get into game physics. A physics engine may help, but simplifications and approximations may be better.

Certainly a good triangle-triangle intersection detector will help, as a start. I found one that is written by "Tomas Moller", I guess that means prof Akenine-MÃ¶ller. Is that the one?

http://my-svn.assembla.com/svn/room/coldet/tritri.cpp
Member
Posts: 281
Joined: 2009.04
Post: #50
Just quickly, that file format doesn't sound good...
See y'all in the marnin'!

~ Bring a Pen ~
Moderator
Posts: 3,567
Joined: 2003.06
Post: #51
Ingemar Wrote:Certainly a good triangle-triangle intersection detector will help, as a start. I found one that is written by "Tomas Moller", I guess that means prof Akenine-MÃ¶ller. Is that the one?

http://my-svn.assembla.com/svn/room/coldet/tritri.cpp

That looks good!

Yeah, I wonder if that's the same guy from the book: Real-Time Rendering?
Member
Posts: 281
Joined: 2009.04
Post: #52
I think I'll use my method, and use tritri for player/bullet/model CD.

~ Bring a Pen ~