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.

Look! Some falling boxes! Part Deux!

Postby 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.
User avatar
gfm
Gnoblar
 
Posts: 17
Kudos: 0
Joined: 11 Oct 2004
Location: Oregon

Postby sinbad » Wed Apr 20, 2005 1:38 pm

Excellent!

I really think this should be an ogreaddon - interested?
User avatar
sinbad
OGRE Retired Team Member
OGRE Retired Team Member
 
Posts: 19261
Kudos: 69
Joined: 06 Oct 2002
Location: Guernsey, Channel Islands

Postby gfm » Wed Apr 20, 2005 5:03 pm

Sounds good. Does that require me to do anything? :wink:
User avatar
gfm
Gnoblar
 
Posts: 17
Kudos: 0
Joined: 11 Oct 2004
Location: Oregon

Postby 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:
/* Less noise. More signal. */
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.
User avatar
jacmoe
OGRE Retired Moderator
OGRE Retired Moderator
 
Posts: 20570
Kudos: 181
Joined: 22 Jan 2004
Location: Denmark

Postby 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?)
User avatar
Telamon
Kobold
 
Posts: 26
Kudos: 0
Joined: 28 Feb 2005

Postby 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?
User avatar
gfm
Gnoblar
 
Posts: 17
Kudos: 0
Joined: 11 Oct 2004
Location: Oregon

Postby 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.
User avatar
batonrye
Halfling
 
Posts: 52
Kudos: 0
Joined: 17 Apr 2005
Location: Michigan, US

Postby 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?
User avatar
gfm
Gnoblar
 
Posts: 17
Kudos: 0
Joined: 11 Oct 2004
Location: Oregon

Sensational work!!!

Postby MrBigs » Thu Apr 21, 2005 4:54 am

That's great work gfm :)
MrBigs
Halfling
 
Posts: 45
Kudos: 0
Joined: 24 Mar 2005
Location: Australia

Postby 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
User avatar
gfm
Gnoblar
 
Posts: 17
Kudos: 0
Joined: 11 Oct 2004
Location: Oregon

Postby Sputnick » Tue Apr 26, 2005 8:53 am

Good to know.
Great job !!

- Sput
User avatar
Sputnick
Greenskin
 
Posts: 110
Kudos: 0
Joined: 08 Sep 2004
Location: Lausanne, Switzerland

Closed?

Postby 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?
Emil
Gnoblar
 
Posts: 2
Kudos: 0
Joined: 25 Apr 2005

Re: Closed?

Postby 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.
User avatar
gfm
Gnoblar
 
Posts: 17
Kudos: 0
Joined: 11 Oct 2004
Location: Oregon

Postby Meddten » Thu May 05, 2005 4:59 pm

It doesn't start with ogre 1.1.0. Windows error :(
Meddten
Halfling
 
Posts: 71
Kudos: 0
Joined: 09 Aug 2004
Location: Austria

Postby 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 ;)
User avatar
Shtong
Gnoblar
 
Posts: 23
Kudos: 0
Joined: 23 Apr 2005
Location: Paris, France

Postby 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
Engineers aren't boring people, but they got excited over boring things and they make it fun.
www.freewebs.com/gpkfontys
User avatar
darkmaster
Halfling
 
Posts: 67
Kudos: 0
Joined: 09 Mar 2005
Location: Netherland

Postby 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.
User avatar
Shtong
Gnoblar
 
Posts: 23
Kudos: 0
Joined: 23 Apr 2005
Location: Paris, France

Postby darkmaster » Sun May 08, 2005 10:49 pm

Great, thanks for the answer :lol:


Dark
Engineers aren't boring people, but they got excited over boring things and they make it fun.
www.freewebs.com/gpkfontys
User avatar
darkmaster
Halfling
 
Posts: 67
Kudos: 0
Joined: 09 Mar 2005
Location: Netherland

Postby 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.
MrBigs
Halfling
 
Posts: 45
Kudos: 0
Joined: 24 Mar 2005
Location: Australia

Postby 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
Engineers aren't boring people, but they got excited over boring things and they make it fun.
www.freewebs.com/gpkfontys
User avatar
darkmaster
Halfling
 
Posts: 67
Kudos: 0
Joined: 09 Mar 2005
Location: Netherland

Postby 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
Wraithdrit
Halfling
 
Posts: 64
Kudos: 0
Joined: 29 Jul 2004

Postby 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.
/* Less noise. More signal. */
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.
User avatar
jacmoe
OGRE Retired Moderator
OGRE Retired Moderator
 
Posts: 20570
Kudos: 181
Joined: 22 Jan 2004
Location: Denmark

Postby 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.
Wraithdrit
Halfling
 
Posts: 64
Kudos: 0
Joined: 29 Jul 2004

Postby 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
Wraithdrit
Halfling
 
Posts: 64
Kudos: 0
Joined: 29 Jul 2004

Postby 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
Wraithdrit
Halfling
 
Posts: 64
Kudos: 0
Joined: 29 Jul 2004

Next

Return to General Discussion

Who is online

Users browsing this forum: No registered users and 1 guest