Physics Exporter (3D Max) + Loader App - Take One

NoodlesOnMyBack

10-10-2008 20:19:17

Ogre + NxOgre + 3D Max + OgreMax = NxOgreMax

I need people to test it, it has some bugs here and there so its not completely usable, and may not work at all.
There is no source of the loaded provided just yet, if the binary works, i release it.
So... take one!




Instructions to setup and run the Maxscript and loader:

Prerequisites:
--------------

1.OgreMax plugin installed http://www.ogremax.com/OgreMax-1.6.22.rar
2.3D Max 9 (and a wallet full of money)
3.The NxOgreLoaderDemo

http://rapidshare.com/files/152749068/NxOgreLoaderDemo.rar.html
Mirror:
http://www.mediafire.com/?sharekey=8d68082f31cc5738d2db6fb9a8902bda
Mirror:
http://www.megaupload.com/?d=JC5U2N04

This includes the loader binary, the Maxscript, and a test.max scene.

Optional:
4.You may also need PhysX 2.8.0 Silent installer, VC++ 2005 redistributable, and Dx9 redist.
http://rapidshare.com/files/152724080/Redistributables.rar.html
Mirror:
http://www.mediafire.com/?sharekey=8d68082f31cc5738d2db6fb9a8902bda


Install & Config:
-----------------

Open Max, goto OgreMax->Scene Settings->Directories, should be like this:


Copy the PhysicsExporter.ms file to the 3D Max startup folder:
C:\Program Files\Autodesk\3ds Max 9\Scripts\Startup

Close and open Max, the dialog of the Exporter should appear:


Never close the dialog window when editing a scene, you can re-run the script by going MaxScript->RunScript.

In the Physics Exporter dialog window set:
Scene Path->Browse: Select the path where the /Data folder of the loader is located
Loader Path->Browse: Select the path where the .exe of the loader is located

The script create a txt file where stores all the data, this file is placed whenever you Save or Load a Scene from Max,
so when you do this you are also saving the Physics data.

Creating a Scene:
-----------------

You can open the provided test.max scene or create a new one.
To edit the properties of the objects, click an object, go to the Modify Tab and you should see a Physics rollout menu there:



Once you are done, click Generate Physics Data in the Dialog window.
This commits the changes and you are ready to export the scene.


Exporting the Scene:
-----------------

Now you have to export the .scene file to the path specified in the Scene Path, name the file 'test.scene' and replace the previous:


Now click 'Run Scene!', this first cook the meshes with a batch file, you will see this window appear:



You have to wait until its all done, then run the demo.

Please report any error so i can fix them as soon as possible, any tip, suggestion or whatever are very welocme.
Hope its usefull, cheers...
Pablo.


Side Notes:

1.I know the batch thing its not nice, but for the moment works for me...
2.If you want to export Triangle or Convex shapes, first right click the object,select Convert to->'Editable Mesh' or 'Editable Poly'
Otherwise a message will popup when Generating, since it couldnt be recognized as a valid shape.

Prophet

11-10-2008 09:10:11

Haven't tried it (I'm enjoying a Mac at the moment), but I have four questions;
First, in the instructions, why do you want to open 3ds Max, check the OgreMax directories just to close it?
Secondly, I see that if you haven't got a custom shape, you still have the options to select Convex/Triangle? (I suppose this has something to do with below?)
Thirdly, why do you convert boxes to .nxs-files? (Spheres and capsules as well?)
Fourtly, I'm thinking about the directories. I figure that the Loader Dir Path is where you have your .exe so it can find the position relative to Scene path, but what exactly gets in the scene path? .nxs? .mesh? .scene? Does this change the settings you've set in OgreMax, and if so, which?

Lastly, the Run Scene-button is confusing. I'd say Create Scene would be more describing.
I'm looking forward to test this once I have time (will take weeks though, I'm in deep shit with stuff to do).

NoodlesOnMyBack

11-10-2008 16:01:04

Thanks for the input

Haven't tried it (I'm enjoying a Mac at the moment), but I have four questions;
First, in the instructions, why do you want to open 3ds Max, check the OgreMax directories just to close it?


Because by default config OgreMax had a subfolder to put the meshes, and i didnt wanted that.


Secondly, I see that if you haven't got a custom shape, you still have the options to select Convex/Triangle? (I suppose this has something to do with below?)


Yes, i didnt disabled these options, i will change that.


Thirdly, why do you convert boxes to .nxs-files? (Spheres and capsules as well?)


Next version will convert only needed files, i did it like this because i get an error when if i call flour directly from maxscript.


Fourtly, I'm thinking about the directories. I figure that the Loader Dir Path is where you have your .exe so it can find the position relative to Scene path, but what exactly gets in the scene path? .nxs? .mesh? .scene?


Yes, all that,the scene path its just the folder where OgreMax dump the .scene and media.


Does this change the settings you've set in OgreMax, and if so, which?


I dont change any settings of OgreMax.

[EDIT]
Most of theese things are fixed already, i will upload soon the changes.
Im trying to add Joints now :) Its complicated because i will have to create an object with shapes to represent the the joint, something like Scythe Editor do...

Prophet

18-10-2008 10:50:42

How's it coming along? I'm thinking whether we should use it or not, but I need to know that all is working and that it is stable.
Also, would be great if you could but Ogre meshes and NxOgre meshes in different folders.

zelion

18-10-2008 11:13:51

hello to everyone.

I'm testing the script in 3d max, but every time I create an object that I get a message with an error.

msg:

MAXScript Callback script Exception

Type error: custAttributes.add requires MSCustAttribDef, got: undefined


What can I do?

I'm using 3dmax 9 SP2
thanks

zelion

20-10-2008 18:38:51

ok, and work for me, I just have to close the window that created the script and re-open it from the menu MaxScript-> runscript

a good job.

NoodlesOnMyBack

20-10-2008 22:07:30

ok, and work for me, I just have to close the window that created the script and re-open it from the menu MaxScript-> runscript

a good job.


Yeah sorry i didnt mentioned that hack, but i was trying to solve this problem wich is anoying me for some time now, but as you did you can re-open the script, also you can put a try catch in the lines of the problems so you avoid the messages like: try(custAttributes.add yada yada...) catch ()
But its a little like hinding dirt under the carpet :)

zelion

21-10-2008 18:10:54

hello again.

What can I do to load data from the scene created?

Is this available the source code of the loader?

thanks.

Prophet

21-10-2008 19:34:48

And I'd like to know how stable it is and if you can put Ogre-meshes and NxOgre-meshes in separate folders. Also, does it work with the latest bleeding?

NoodlesOnMyBack

21-10-2008 20:08:16

I'd like to know how stable it is and if you can put Ogre-meshes and NxOgre-meshes in separate folders. Also, does it work with the latest bleeding?

The Maxscript itself its pretty stable, excluding the error that zelion reported, the data is exported fine.
The issues you mentioned in the firts post are solved most of them, but right now i want to keep working on my engine (wich uses the loader of course) and as soon as i have something i'll post the source here, i just want to put some usefull and 'ready to use' code, not just something that will need a lot of modification.
Soon i'll post back some news.

zelion

21-10-2008 20:36:14

I have been doing tests.

put 2 bodies to the same height, one with more mass and density, but the 2 fall at the same time. I tried to change parameters and do not get a drop faster than another.

Am I doing something wrong?
What has proven it?

ppClarity

21-10-2008 21:26:00

I have been doing tests.

put 2 bodies to the same height, one with more mass and density, but the 2 fall at the same time. I tried to change parameters and do not get a drop faster than another.

Yep. This is basic physics. Drop a bowling ball and a feather in a vacuum chamber and they will both accellerate at 9.8m/s2.

Am I doing something wrong?
Assuming you are trying to model observed behavior in a non-vacuum, you need to add air-friction and [bouyancy]. Unless you need to accurately model bouyancy, you're much better off faking it or ignoring it outright.

NoodlesOnMyBack

22-10-2008 02:24:43

I have been doing tests.

put 2 bodies to the same height, one with more mass and density, but the 2 fall at the same time. I tried to change parameters and do not get a drop faster than another.

Am I doing something wrong?
What has proven it?


In case you have any doubts about the output data of the Maxscript, select the object in question, goto OgreMax-> User Data and you'll see there the values exported inside the .scene file.

NoodlesOnMyBack

22-10-2008 03:09:40

I've tested the script with a .max building (almost without touching the model) and im surprised that its exported very nicely.
The next demo im preparing will have a Character Controller (my implementation, no NxOgre) to walk and jump around the building :)
Heres a screen from the debuger:



Also, even its a raw .h and .cpp, here you can get the source for the loader, you can wait until i finish the final demo or start creating your own:

http://pablosn.googlepages.com/loaderSource.rar

zelion

22-10-2008 07:36:33

who are doing great work.

Sorry for the previous question, it was logical, I have the physics a little rusted, jejeje.

While just the final version and the demo, will do testing, not long ago that working with physical and I have to remember and read a lot.

xadh00m

22-10-2008 08:46:49

The next demo im preparing will have a Character Controller (my implementation, no NxOgre) to walk and jump around the building :)


Cool! I look forward to see an uptodate character controller. We are still holding on NxOgre0.9 because of this... :cry:

NoodlesOnMyBack

22-10-2008 09:38:23

The next demo im preparing will have a Character Controller (my implementation, no NxOgre) to walk and jump around the building :)


Cool! I look forward to see an uptodate character controller. We are still holding on NxOgre0.9 because of this... :cry:


Yeah, i freaked out a little when i saw the empty Character class in NxOgre code... :lol: So i jumped to make my own.
Another thing my Character class will include its a very small .h i made (based from a Physics book) to handle the Character physics (ie: jumping in different angles depending on speed), my intention also is to let the user select different States for the character, like Walking, Running, Swimming, or others like been blown away by a rocket (like Quake) or been pushed by objects.
For the moment there is only jumping or falling.

zelion

22-10-2008 20:35:50

I have tried to use the loader, but I fail to find the file 'PhysX_wrapper.h'.

NoodlesOnMyBack

22-10-2008 21:14:56

I have tried to use the loader, but I fail to find the file 'PhysX_wrapper.h'.

Yes, thats why i said it was a 'raw' version, you just have to change the parameters, PhysX_wrapper was just a class i made to test things.


mSceneCallbacks = new OgreMaxSceneCallbacks(mPW,startingPosition);

OMscene = new OgreMax::OgreMaxScene ();
OMscene->Load(sceneFileName, mRoot->getAutoCreatedWindow(),
OgreMax::OgreMaxScene::NO_OPTIONS, NULL, NULL, mSceneCallbacks);


OgreMaxSceneCallbacks(mPW,startingPosition);
Here pass your World and Scene instances of NxOgre instead of a PhysX_wrapper instance.
Thats the only thing the loader needs i believe.

zelion

27-10-2008 18:23:45

Hello.

I've been testing the loader and the script for 3dmax.

Some questions:

I charge the loader like this:


// sobrecarga del metodo que carga la escena
void createScene(void)
{


// create NxWorld, a main physic object
// log: yes/no
// ogre time controller means rhat ogre will care about it
m_Nxworld = new NxOgre::World("time-controller:ogre, log:yes");

// create scene, you can have maximum 32 scenes, object from one scene can't
// collide with objects from another (maybe in another versions :D )
// gravity: yes/no/0 -9.788 0
// floor: create infinity floor, yes/no
// ogre will be used as debug renderer
mNxScene = m_Nxworld->createScene("NxOgreScene", mSceneMgr, "gravity: yes, controller: accumulator, floor:yes, renderer:ogre");

// Loader NxOgre
m_physX = new LoaderPhysX(m_Nxworld, Ogre::Vector3::ZERO);


// escena OgreMax
m_maxScene = new OgreMax::OgreMaxScene();

// crear el sceneManager con toda la escena y la clase callback para crear las fisicas mediante el loader
m_maxScene->Load("test.scene",
mWindow,
OgreMax::OgreMaxScene::NO_OPTIONS,
mSceneMgr,
NULL,
m_physX
);
}


but I skip a mistake to create the 'NxOgre:: Body * mBody' being duplicated at the scene.

as you say if I use this code:


// sobrecarga del metodo que carga la escena
void createScene(void)
{

...

// crear el sceneManager con toda la escena y la clase callback para crear las fisicas mediante el loader
m_maxScene->Load("test.scene",
mWindow,
OgreMax::OgreMaxScene::NO_OPTIONS,
NULL,
NULL,
m_physX
);
}



OgreMax creates a scene and generic NxOgre creates another scene, the scenes are duplicated right?.

that if I use the check in the script 3dmax 'no export' to a plane in the file. scene this level, but since there is no data to NxOgre, the plane does not appear on the scene.

To what extent is this true I mean?.
Am I doing something wrong?
as you can use the same scene for all?

Thank you

zelion

27-10-2008 19:20:26

ok, I've settled in the following way.

to create the firstparam you add '_physx' to the chain and thus, not duplicate node.

Ogre::String LoaderPhysX::getFirstParam (Ogre::String param)
{
//Return empty if it is empty
if (param != "")
{
Ogre::String firstParam = "";
Ogre::String::iterator it = param.begin ();

//Get first param
for (; it != param.end(); ++it)
{
/*****************************
/* add '_physx' *******/
if (';' == *it) firstParam += "_physx";

if (*it != '\n')
firstParam += *it;
else
{
if (firstParam != "")
{
//Get rid of the junk-character
firstParam.erase(--firstParam.end());
firstParam.erase(--firstParam.end());
}
break;
}
}
return firstParam;
}
else
return param;
}



now they are shown the cameras, lights and all objects of ogremax

Will this be right?

jamere

07-01-2009 08:58:56

Hi,
I was wondering if the OgreMax-1.6.23.rar is ok with the physcs exporter, because, the 22 is not aymore available...
Or maybe some of you can give me the rar?
Thanks

jamere

08-01-2009 09:09:56

Actually it works fine with the new version.
Thanks for your work.

Just a little question, I would like to try to add a simple cone but i got :

Physics exporter failed to recognize objet Cone01 not possible to export

What i'm suppose to do ?
thanks

j7th

12-08-2009 22:18:25

Hello, anyone have sources of NxOgreSceneLoader? I need source code

artn3r

10-09-2009 21:16:33

Can you make this working in 3dsmax 2010? every time i start creating an object
it says:



Would be great!

Regards,
Christian

corn

29-09-2009 18:59:10

I'd love to take a look at the source as well. Unfortunately, the old link is no longer available. Anyone still have the archive and can post it somewhere for us to check out?

Also, has an updated version of the Physics Exporter Max Script since the original release been developed?

This was a pheonominal idea, and a much needed addition for the community to rapidly develop shapes for their physics simulations.

carlosmorcerf

05-10-2009 03:55:17

where sources? new versions?