Bake your triangle/convex in runtime with libFlour [mirror]

nargil

16-11-2008 14:45:38

1. Simply download http://get.nxogre.org/flour/libFlour32b.zip (use 7-zip if you have trouble extracting this archive)
2. Compile the project
3. Add libFlour.lib (or equivalent for debug/static) to your linker
4. If using DLL: copy libFlour.dll (or equivalent for debug) to your app bin dir (where you have nxogre.dll ogremain.dll and the physx dlls)
5. include libFlour.h to your projects cpp file

now you can use the following code

//create a triangle mesh
NxOgre::Resources::Mesh* mymesh = libFlour::BakeTriangleMesh(mSceneMgr, "robot.mesh");
NxOgre::Actor* a = mScene->createActor("robotmesh", new NxOgre::TriangleMesh(mymesh), NxOgre::Pose(0,0,0), "static: yes");

//create a triangle mesh with a certain scale
NxOgre::Resources::Mesh* mymesh = libFlour::BakeTriangleMesh(mSceneMgr, "robot.mesh", Ogre::Vector3(0.2,0.2,0.2));
NxOgre::Actor* a = mScene->createActor("robotmesh", new NxOgre::TriangleMesh(mymesh), NxOgre::Pose(0,0,0), "static: yes");

//create a triangle mesh and save it as OgreMeshName.mesh.nxs
NxOgre::Resources::Mesh* mymesh = libFlour::BakeTriangleMesh(mSceneMgr, "robot.mesh", Ogre::Vector3(0.2,0.2,0.2), true);
NxOgre::Actor* a = mScene->createActor("robotmesh", new NxOgre::TriangleMesh(mymesh), NxOgre::Pose(0,0,0), "static: yes");

//create a triangle mesh and save it as a specified filename
NxOgre::Resources::Mesh* mymesh = libFlour::BakeTriangleMesh(mSceneMgr, "robot.mesh", Ogre::Vector3(0.2,0.2,0.2), true , "file://yourfile.nxs");
NxOgre::Actor* a = mScene->createActor("robotmesh", new NxOgre::TriangleMesh(mymesh), NxOgre::Pose(0,0,0), "static: yes");

//create a convex mesh
NxOgre::Resources::Mesh* mymesh = libFlour::BakeConvexMesh(mSceneMgr, "robot.mesh", ...);
NxOgre::Actor* a = mScene->createActor("robotmesh", new NxOgre::Convex(mymesh), NxOgre::Pose(0,0,0), "static: yes");


The lib is a copy&paste&edit form betajeans flour (0.3.2).
You still should use betajeans flour for baking things for you game. This lib is meant for editors where you need to scale & bake things in realtime.

License: MIT

It has been tested with:
- NxOgre 1.0.22'T5
- Ogre 1.6
- PhysX 2.8.1 SDK & 8.09.04 System software

Have fun.

betajaen

16-11-2008 15:01:04

Good man.

It would have to be LGPL because Flour is LGPL due to Ogre/NxOgre being statically linked.

However you could get away making it MIT or GPL; by just copying the flour code out. I'll even give you a waiver for doing that. Only under the condition it's called libFlour. :)

nargil

16-11-2008 16:49:26

Ok - made it MIT.

There is one "but" though:
I had to add "NxOgreMeshParams.cpp" to the project. Without it gives linker errors
1>libFlour.obj : error LNK2001: unresolved external symbol "public: virtual void __thiscall NxOgre::Resources::MeshParams::MeshFlags::fromNxU32(unsigned int)" (?fromNxU32@MeshFlags@MeshParams@Resources@NxOgre@@UAEXI@Z)
1>libFlour.obj : error LNK2001: unresolved external symbol "public: virtual unsigned int __thiscall NxOgre::Resources::MeshParams::MeshFlags::toNxU32(void)const " (?toNxU32@MeshFlags@MeshParams@Resources@NxOgre@@UBEIXZ)
1>libFlour.obj : error LNK2001: unresolved external symbol "public: virtual void __thiscall NxOgre::Resources::MeshParams::MeshFlags::parse(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?parse@MeshFlags@MeshParams@Resources@NxOgre@@UAEXABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z)
I think this is a bug of 1.0.22'T5

betajaen

16-11-2008 16:56:48

Must be.

Zach Griffin

17-02-2009 06:07:28

The download has been removed from the share site. Is it still available elsewhere or is there another method to convert meshes at runtime?

nargil

18-02-2009 12:56:31

mirror: http://www.speedyshare.com/784979493.html

if you know any good fileshare: upload it and post the mirrors here

Zach Griffin

19-02-2009 04:51:07

Thanks very much Nargil

betajaen

19-02-2009 09:18:34

http://get.nxogre.org/flour/libFlour32b.zip

Zach Griffin

20-02-2009 06:52:19

I'm getting a strange error when I try and compile it with the NxOgre code:

1>.\src\NxOgreMeshParams.cpp(76) : error C2679: binary '=' : no operator found which takes a right-hand operand of type 'NxOgre::Container<TI,TT>' (or there is no acceptable conversion)

the actual line:
std::vector<NxString> str_flags;
str_flags = NxStringTokenize(flag_str, "+", true);


Any ideas?

nargil

20-02-2009 10:25:00

Which nxogre are you using ? What compiler ?

does the functions declaration (in NxOgreHelpers.h) look like
NxPublicFunction std::vector<NxString> NxStringTokenize(const NxString& string, const NxString& pattern, bool trim = true);?

Maybe if using other version than 1.0.22T5 try excluding NxOgreMeshParams.cpp from your build.

Zach Griffin

20-02-2009 10:36:25

I compiled it in VC2008 Express originally. Im using the latest 1.0 branch off the nxOgre.org svn. If I used the OgreMeshParams from the nxOgre solution it compiled, but I take it there is a reason for the differences between the nxOgre file and the one you included in libFlour?

nargil

20-02-2009 10:48:34

Didn't modify anything in NxOgreMeshParams. I just needed to include it to the build to solve linker errors with 1.0.22T5.

plonga

20-11-2009 16:08:00

I have to convert OgreXML -> .mesh -> .nxs in runtime.

So for the last step (mesh to nxs) I wanted to use libflour, but I didn't manage to compile it. I have to admit that I don't know much about compiling stuff with Visual Studio / C++.

I am using Ogre 1.6.3, PhysX 2.8.1 and Visual Studio 2008.

So I downloaded the old version of NxOgre(1.0.22'T5) and tried to add all the required Include Paths and Linker directories, but I got stuck when nxOgre_d.lib was required and I couldn't find it anywhere. So I tried to compile NxOgre 1.0.22'T5 but got stuck there again with the error "error C4716: 'NxShapeDesc::operator=': must return a value".

Are there maybe precompiled dlls for libflour that I could use, or could someone upload them for me, so I don't have to compile it on my own?