Look! Some falling boxes! Part Deux!

Anything and everything that's related to OGRE or the wider graphics field that doesn't fit into the other forums.
User avatar
gfm
Gnoblar
Posts: 17
Joined: Mon Oct 11, 2004 7:05 am
Location: Oregon
Contact:

Look! Some falling boxes! Part Deux!

Post by gfm » Wed Apr 20, 2005 7:54 am

Image

I've made several improvements to the Nogredex framework so I thought this was worthy of a new thread.

* It works with Ogre 1.0.1!

* Better simulation reset support! Just call mNogredex->init() and everything is destroyed and re-initialized correctly.

* Load any mesh you want! Ogre meshes can now be physically simulated as either a box, capsule, or a triangle mesh.

Notes:

If you try out your own mesh and attempt to simulate it as a triangle mesh make sure that it is a CLOSED mesh. Novodex will return NULL when the actor is created if the mesh isn't closed... or simply crash.

Limitations (Bugs):

Meshes simulated as triangle meshes are limited to 64k indices or less, which means you can't have more than 64k/3 faces. Yes, this is probably a good thing. No, the code doesn't check this for you.

Meshes simulated as triangle meshes that have more than one sub-mesh aren't supported.

Download: here

I would greatly appreciate comments/feedback/code review.

-robert
robertwrose.com
Last edited by gfm on Wed Apr 20, 2005 4:59 pm, edited 1 time in total.
0 x

User avatar
sinbad
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 19261
Joined: Sun Oct 06, 2002 11:19 pm
Location: Guernsey, Channel Islands
Contact:

Post by sinbad » Wed Apr 20, 2005 1:38 pm

Excellent!

I really think this should be an ogreaddon - interested?
0 x

User avatar
gfm
Gnoblar
Posts: 17
Joined: Mon Oct 11, 2004 7:05 am
Location: Oregon
Contact:

Post by gfm » Wed Apr 20, 2005 5:03 pm

Sounds good. Does that require me to do anything? :wink:
0 x

User avatar
jacmoe
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 20570
Joined: Thu Jan 22, 2004 10:13 am
Location: Denmark
Contact:

Post by jacmoe » Wed Apr 20, 2005 5:30 pm

You should register as a developer @ sourceforge.net, if you're not already. Then give your sourceforge username to the Ogre team - and wait for you to get dev access to your corner of the ogreaddons. :wink:
0 x
/* Less noise. More signal. */
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.

User avatar
Telamon
Kobold
Posts: 26
Joined: Mon Feb 28, 2005 9:34 am
Contact:

Post by Telamon » Wed Apr 20, 2005 8:44 pm

I'm a huge fan of your first nogredex demos! Trimesh support is very exciting, though the limit on indices is kind of a downer since it prevents me from being able to do collision detection against any terrain larger than 256x256.

Anyways, I had two problems running this demo:

First, I didn't have d3dx9_24.dll (found it online someplace)

Second, it fails during startup. Here's the ogre log:

12:38:43: Parsing script sample.fontdef
12:38:43: Bad attribute line: glyph 0.152344 0.125 0.160156 0.1875 in font Ogre

I plan to look at the code and try to figure it out once I first some of my more mundane classwork (MIPS asm anyone?)
0 x

User avatar
gfm
Gnoblar
Posts: 17
Joined: Mon Oct 11, 2004 7:05 am
Location: Oregon
Contact:

Post by gfm » Wed Apr 20, 2005 8:59 pm

Telamon wrote: First, I didn't have d3dx9_24.dll (found it online someplace)

Second, it fails during startup. Here's the ogre log:

12:38:43: Parsing script sample.fontdef
12:38:43: Bad attribute line: glyph 0.152344 0.125 0.160156 0.1875 in font Ogre

I plan to look at the code and try to figure it out once I first some of my more mundane classwork (MIPS asm anyone?)
Ah. Yeah this was built on a system with the DirectX 9.0 Feb 2005 SDK installed. If you don't have that version of the SDK installed you'll get that error. Just rebuild it and you shouldn't have any problems. I shouldn't have released the executable so folks are tempted to just run it. :D

The fontdef thing I have no idea. You've got Ogre 1.0.1 installed, right?
0 x

User avatar
batonrye
Halfling
Posts: 52
Joined: Sun Apr 17, 2005 8:37 pm
Location: Michigan, US
Contact:

Post by batonrye » Thu Apr 21, 2005 2:50 am

Telemon wrote:the limit on indices is kind of a downer since it prevents me from being able to do collision detection against any terrain larger than 256x256
Well, you could set up a quad tree system where the terrain is subdivided into smaller quadrants, each individual trimeshes, and only the possibly effected sections (within a distance of an object) are considered for collisions.
0 x

User avatar
gfm
Gnoblar
Posts: 17
Joined: Mon Oct 11, 2004 7:05 am
Location: Oregon
Contact:

Post by gfm » Thu Apr 21, 2005 3:03 am

batonrye wrote:
Telemon wrote:the limit on indices is kind of a downer since it prevents me from being able to do collision detection against any terrain larger than 256x256
Well, you could set up a quad tree system where the terrain is subdivided into smaller quadrants, each individual trimeshes, and only the possibly effected sections (within a distance of an object) are considered for collisions.
I believe the index limitation is artificially imposed by my code. I gather the triangles of the ogre mesh by stepping through the hardware buffers ogre stores to represent these structures. When I grab the index buffer I'm smashing it to an unsigned short pointer. I know that ogre supports 32 bit index structures, but I'm not sure how to query this. Someone want to take a stab at it?
0 x

MrBigs
Halfling
Posts: 45
Joined: Thu Mar 24, 2005 5:49 am
Location: Australia

Sensational work!!!

Post by MrBigs » Thu Apr 21, 2005 4:54 am

That's great work gfm :)
0 x

User avatar
gfm
Gnoblar
Posts: 17
Joined: Mon Oct 11, 2004 7:05 am
Location: Oregon
Contact:

Post by gfm » Sat Apr 23, 2005 9:23 pm

Updates!

Thanks to Sinbad, Nogredex is now an OgreAddon. The latest source for Nogredex is now in the Ogre Sorceforge CVS repository.

I've also uploaded a stand-alone demo of Nogredex to my website, you can get it here.

I've removed the 16 bit index limitation on meshes. You should now be able to load any size mesh you want. (I wouldn't recommend it tho, in my testing I found that Novodex starts to bog down on meshes larger than 10,000 triangles).

Meshes with more than one sub-mesh are now fully supported and correctly simulated. I've also added some optional code that will even optimize these types of meshes by removing duplicate vertices.

Enjoy!

-robert
robertwrose.com
0 x

User avatar
Sputnick
Greenskin
Posts: 110
Joined: Wed Sep 08, 2004 11:49 pm
Location: Lausanne, Switzerland

Post by Sputnick » Tue Apr 26, 2005 8:53 am

Good to know.
Great job !!

- Sput
0 x

Emil
Gnoblar
Posts: 2
Joined: Mon Apr 25, 2005 9:56 am

Closed?

Post by Emil » Tue Apr 26, 2005 7:26 pm

If you try out your own mesh and attempt to simulate it as a triangle mesh make sure that it is a CLOSED mesh. Novodex will return NULL when the actor is created if the mesh isn't closed... or simply crash.
Then how do i close a mesh?
0 x

User avatar
gfm
Gnoblar
Posts: 17
Joined: Mon Oct 11, 2004 7:05 am
Location: Oregon
Contact:

Re: Closed?

Post by gfm » Tue Apr 26, 2005 10:55 pm

Emil wrote:
If you try out your own mesh and attempt to simulate it as a triangle mesh make sure that it is a CLOSED mesh. Novodex will return NULL when the actor is created if the mesh isn't closed... or simply crash.
Then how do i close a mesh?
If you want to physically simulate a mesh, it needs to have certain characteristics. I don't know exactly what they are, but I've found that non-closed meshes and large disjoint meshes sometimes cause failures in Novodex.

A "closed" mesh is simply a mesh with no holes. Some non-closed meshes I've experimented with seem to work fine with Novodex, others don't. I don't understand the rules, but I know that if your mesh is closed you won't have any problems.

A "disjoint" mesh (I can't think of a better name) is a mesh where you can't connect the dots between all of the vertices. This means there are pieces of the mesh that don't connect with other pieces. Again, I've had success getting some of these meshes to work, but then others don't.. I don't understand the rules, so just don't make disjoint meshes. :)

I think the reasons for these failures probably has something to do with calculating the mass and inertial tensor for the mesh. For instance, if there's a gaping hole in the mesh, do you fill it, or do you leave the object hollow? The choice you make will substantially effect the inertial tensor of the created object. I experimented with a few meshes that weren't closed and the results were just plain wacky--you throw the object up in the air with a topspin and it did not at all appear to conserve energy.
0 x

Meddten
Halfling
Posts: 71
Joined: Mon Aug 09, 2004 8:28 pm
Location: Austria

Post by Meddten » Thu May 05, 2005 4:59 pm

It doesn't start with ogre 1.1.0. Windows error :(
0 x

User avatar
Shtong
Gnoblar
Posts: 23
Joined: Sat Apr 23, 2005 1:46 pm
Location: Paris, France

Post by Shtong » Sat May 07, 2005 2:32 pm

Man, I was trying for 3 weeks to make a BspLevel mod who creates a trimesh for Novodex to make terrain collisions. Your addMesh function was a great helper to me. Thanks !
I've done the bigger part now, geometry is correctly defined and everything works fine, except that it's a bit laggy with more than 5 objects even in the Ogre's demo BSP map. I'm now looking for some way to rise the framerate up :) (maybe create one actor per node and activate only objects into visible nodes ?)

Keep up good work ;)
0 x

User avatar
darkmaster
Halfling
Posts: 67
Joined: Wed Mar 09, 2005 7:04 pm
Location: Netherland

Post by darkmaster » Sun May 08, 2005 9:28 pm

Hello, how bout the world metric used inside Novodex.
Is the world metrix used by Novodex also same with Ogre??

For example, If I make a box with dimension 0.5,0.5,0.5
would it be same if I scale a sceneNode by tht value also??

And what is the minimum number of vertice per mesh in Novodex? I think the normal amount is 3 isn't it??

or 4??(startPoint -> point1 ->point2 ->startagain)


THanks,


Dark
0 x
Engineers aren't boring people, but they got excited over boring things and they make it fun.
www.freewebs.com/gpkfontys

User avatar
Shtong
Gnoblar
Posts: 23
Joined: Sat Apr 23, 2005 1:46 pm
Location: Paris, France

Post by Shtong » Sun May 08, 2005 10:49 pm

The world metric is the same as in Ogre. You can set same scaling and position values without any problem. And Novodex uses 3 vertices per triangle.
0 x

User avatar
darkmaster
Halfling
Posts: 67
Joined: Wed Mar 09, 2005 7:04 pm
Location: Netherland

Post by darkmaster » Sun May 08, 2005 10:49 pm

Great, thanks for the answer :lol:


Dark
0 x
Engineers aren't boring people, but they got excited over boring things and they make it fun.
www.freewebs.com/gpkfontys

MrBigs
Halfling
Posts: 45
Joined: Thu Mar 24, 2005 5:49 am
Location: Australia

Post by MrBigs » Mon May 09, 2005 12:40 pm

With Nogredex can you have physics objects as a combination of novodex primitive objects - Say a sphere and a box?

I'm pretty sure this is a feature of Novodex.
0 x

User avatar
darkmaster
Halfling
Posts: 67
Joined: Wed Mar 09, 2005 7:04 pm
Location: Netherland

Post by darkmaster » Mon May 09, 2005 2:27 pm

Yes it would be. Basically, Nogredex is just Novodex made with Ogre for the graphical things. All the physic things is pure Novodex
:wink:

Dark
0 x
Engineers aren't boring people, but they got excited over boring things and they make it fun.
www.freewebs.com/gpkfontys

Wraithdrit
Halfling
Posts: 64
Joined: Thu Jul 29, 2004 6:30 pm

Post by Wraithdrit » Thu May 12, 2005 8:07 pm

I am so completely lost...

The project setup for this addon is really boggling my mind. I have my standard Ogre setup that works well, so I set one of those up and copied all the code from Nogredex into that project, added the right links to Novodex and compile just fine, but when I run, an exception hits here:

Code: Select all

		Overlay* o = (Overlay*) OverlayManager::getSingleton().getByName("Nogredex/Cursor");
        if (!o)
			Ogre::Exception( Exception::ERR_ITEM_NOT_FOUND, "Could not find overlay Nogredex/Cursor", "NogredexDemoFrameListener" );

        o->show();
		mCursor = o->getChild("Nogredex/CursorPanel");
To even get this far, I had to rename the 'copy of NogredexDemoFrameListener.h' file to 'NogredexDemoFrameListener.h'.

I downloaded this from gfm's site? Is that the wrong place to get it? Should I go to the CVS instead? Will it make any difference? Help!

- Wraith
0 x

User avatar
jacmoe
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 20570
Joined: Thu Jan 22, 2004 10:13 am
Location: Denmark
Contact:

Post by jacmoe » Thu May 12, 2005 8:21 pm

You could start by making sure that the app has all the media it needs - i.e. copy it to the media dir you are using.
I compiled it alright, but I was using the ogreaddons one.
0 x
/* Less noise. More signal. */
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.

Wraithdrit
Halfling
Posts: 64
Joined: Thu Jul 29, 2004 6:30 pm

Post by Wraithdrit » Thu May 12, 2005 8:48 pm

I blew away my resources.cfg file and the media directory and copied the ones from the addon (which I succesfully got from CVS compiled and tested) to my project.

Same error, same place.
0 x

Wraithdrit
Halfling
Posts: 64
Joined: Thu Jul 29, 2004 6:30 pm

Post by Wraithdrit » Thu May 12, 2005 8:59 pm

It was all in the project settings for my default project vs the nogredex one. Its all good now. Thanks for trying, and to the community thanks for Nogredex!

BTW... BigHugeGames announced recently that their new RTS (Rise of Legends) will support the Physics chip and they are using... Novodex.

- Wraith
0 x

Wraithdrit
Halfling
Posts: 64
Joined: Thu Jul 29, 2004 6:30 pm

Post by Wraithdrit » Mon May 16, 2005 10:00 pm

My next big hurdle is to get Nogredex and the Terrain Scene Manager talking and to make a mesh object for Nogredex for the terrain. Something like addTerrain() that reads in the terrain from the scene manager and builds the Novodex mesh from it.

Seems pretty straight forward according to the Novodex docs. Need to just create a mesh and set up the meshdesc with a couple extra fields.

Now I gotta research the Terrain Scene Manager and figure out how to read out the y value for any x,z value. Also reading from the manager the number of vertices and faces would be helpful in setting up the Novodex mesh object.

For anyone who tries to do this in the future (in case I fail) the nogrodex addon demo project has some of the plugins disabled, spent an hour chasing my tail trying to figure out why things were bombing, cause it was defaulting to the generic scene manager, and the terrain loading function was (of course) not support by that scene manager.

If I actually accomplish this, I'll be more than happy to share the code.

- Wraithdrit
0 x

Post Reply