Using Mogre with Particle Universe

mstoyke

16-02-2011 18:09:28

For those who bought a license of Particle Universe and want to use it from Mogre/.NET projects, here is as quick-and-dirty solution:
Grab the code from the wiki and have some fun. It's very simplistic, not a real wrapper of the API, more a kind of binding to the plug-in. I will not have time to support this in any way, but I think I should at least share it with you in case somebody find it useful.

tafkag

16-02-2011 18:40:25

Thank you very much! I'll look into it tomorrow.

tafkag

17-02-2011 18:48:39

No particle luck so far... :(

What I did (using VS2008):
* get Ogre-SDK 1.7.1
* build PU 1.3 using Ogre 1.7.1
* make a few small changes to the wrapping class to get it to compile (current version attached to posting)
* add resulting dll as reference to Mogre 1.7.1 project and copy ParticleUniverse.dll into the respective bin folder

Result:
As soon as the assembly gets loaded, the app crashes with an infamous

System.BadImageFormatException was unhandled
Message=" is not a valid Win32 application. (Exception from HRESULT: 0x800700C1)"


I checked all the projects for being compiled with x86/Win32 setting (and I'm on a 32bit machine).
I'm kind of running out of ideas, so if any c++ and/or wrapping expert has any hint what could be causing this... :?

Beauty

17-02-2011 22:28:02

Thanks, mstoyke.
I add some additional information and links to the wiki page of your published code.

Can you tell us, with which Mogre and PU version you did use it?

Does we have to add it to the Mogre (or Ogre?) source code and then run the autowrapper?
It's C++ code, so I suppose I need to build something before I can use it by C#. (Or is it managed C++?)

tafkag

17-02-2011 23:26:22

It's C++ code, so I suppose I need to build something before I can use it by C#. (Or is it managed C++?)
It's a c++/CLI wrapper for some of the fuctions of Particle Universe. So you have to build Particle Universe up front, which is not free but with 10€ you can't do much wrong.

Beauty

18-02-2011 01:00:29

Ah, ok. So I suppose I have to put this code together with the PU library file and then somehow I can compile it.
Maybe it would be useful if someone offers a complete Visual Studio project, which contains all needes settings (and maybe the source code). So that you just have to add the PU library and hit the compile button.
Just as an idea for easy usage. (I hope the download package size isn't so huge. Maybe the whole Mogre source code is needed for compilation?)

tafkag

18-02-2011 08:12:51

(I hope the download package size isn't so huge. Maybe the whole Mogre source code is needed for compilation?)

To build PU you need to build ogre (or download the respective ogre sdk). To build the wrapper, no Mogre sources are needed, just the Mogre.dll added as reference. But, as I wasn't very successful in getting it to work, maybe I'm wrong. ;) :(

mstoyke

18-02-2011 11:53:27

Sorry that I released the code with no information about how to use it. It was created for PU 1.2, but should also work with newer versions. You need to link against the Mogre version of the Ogre libraries when building PU, otherwise it will not work.

I'll soon add more information about it and maybe set up a sample project.

tafkag

18-02-2011 12:04:53

Sorry that I released the code with no information about how to use it. It was created for PU 1.2, but should also work with newer versions. You need to link against the Mogre version of the Ogre libraries when building PU, otherwise it will not work.

Ah, ok, this makes sense. I'll try it again with the Mogre version then. Thanks again...and no need to apologize. :wink:

Beauty

18-02-2011 16:38:23

Thanks for your additions.
You need to link against the Mogre version of the Ogre libraries
In the first moment I was confused and did not understand. Now I do So I describe it in other words:
You need to link against the modified Ogre source code. (Special modifications are needed for compiling Mogre.)

I suppose this is the way to get the modified Ogre source code:
* Grabb the Ogre source code
* Apply a "code patch file" of the Mogre repository (this must be related to a specific Ogre repository revision.)

tafkag

28-02-2011 16:13:08

One step further but not quite there yet...

After building Mogre, I used the patched includes/libs to build PU and the wrapper.
The good news: the app doesn't crash any more when loading the wrapper assembly.
The bad news: the IsDisposed property of a created PUManager ...
PUManager puMgr = new PUManager(mySceneMgr);
... is always true, which means, looking at the wrapper code, the pointer to the ParticleSystemManager ...
ParticleUniverse::ParticleSystemManager* mPUMgr
... is always NULL. Accordingly, the next call to puMgr throws an ObjectDisposedException.

tafkag

01-03-2011 14:49:49

A word of advice: if you want to use an ogre plugin, add the damn thing to the plugins.cfg!! :roll:

I attached my current wrapper version for PU 1.4 to this post. As a quick test I loaded a fire script from the PU media pack into mstoyke's Quickstart project and the ogre is burning as expected. :twisted: :D

Beauty

02-03-2011 22:44:16

Good note.
Can you tell us the exact line entry for the file plugins.cfg?

Is this right?
Plugin=PUDotNet

tafkag

02-03-2011 23:12:18

Is this right?
Plugin=PUDotNet


You have to insert the actual plugin, so
Plugin=ParticleUniverse
in Release or the respective debug dll
Plugin=ParticleUniverse_d
in debug mode.

Beauty

03-03-2011 00:38:53

Well done.
I updated the wiki page.
The sources for PU 1.2 and 1.4 are attached to the wiki page as zip files.

tafkag

04-03-2011 10:03:41

Thanks for updating the wiki page and for you hard wiki work in general. :)

koirat

28-04-2011 11:53:06

For those who bought a license of Particle Universe and want to use it from Mogre/.NET projects, here is as quick-and-dirty solution:
Grab the code from the wiki and have some fun. It's very simplistic, not a real wrapper of the API, more a kind of binding to the plug-in. I will not have time to support this in any way, but I think I should at least share it with you in case somebody find it useful.


Thanks for your effort.
I'm reconsidering using ParticleUniverse in my Mogre project.
What do you mean by "Quick and Dirty" ? - Is all the functionality supported ?

Beauty

28-04-2011 12:04:25

I suppose quick and dirty means:
* not everything is wrapped
* no documentation
* not optimized for maximum performance

I hope it's stable.

Proposal:
When we build and publish a Mogre binary package, then we could add the wrapped PU wrapper file, too. (without the original PU dll, which )
So if somebody needs to add Partice Universe, he just need to add the licenced PU file and can use it by the wrapper.
Then the Mogre users doesn't need to compile CPP code, which could cause trouble if they have less C++ knowledge or don't find out the needed build settings.

koirat

28-04-2011 12:06:53

* not everything is wrapped
This one is the only one that is bugging me.

Yes I also think that adding wrapper for PU to the Mogre package is a nice idea.

TeaBag

03-05-2011 10:13:40

Hi,

this one is for those that were able to build PU 1.4 against the Mogre 1.7.1 libs and include files (I am using mogre from the latest SDK version).

I was considering starting to continue the already done work and perhaps someday have a full PU wrapper for Mogre.
So, I started by compiling the PU sources VS2010 and got the usual errors regarding missing libs and include files. I added the include and lib folders to the project definitions but I still have a strange problem.
I still get this error:
ParticleUniverseEmitterTokens.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) protected: static bool __cdecl Ogre::ScriptTranslator::getColour(class std::_List_const_iterator<class std::_List_val<class Ogre::SharedPtr<class Ogre::AbstractNode>,class std::allocator<class Ogre::SharedPtr<class Ogre::AbstractNode> > > >,class std::_List_const_iterator<class std::_List_val<class Ogre::SharedPtr<class Ogre::AbstractNode>,class std::allocator<class Ogre::SharedPtr<class Ogre::AbstractNode> > > >,class Ogre::ColourValue *,int)" (__imp_?getColour@ScriptTranslator@Ogre@@KA_NV?$_List_const_iterator@V?$_List_val@V?$SharedPtr@VAbstractNode@Ogre@@@Ogre@@V?$allocator@V?$SharedPtr@VAbstractNode@Ogre@@@Ogre@@@std@@@std@@@std@@0PAVColourValue@2@H@Z)

As far as I know that class and method is in OgreMain so I don't understand what is happening here.

Does anyone knows?

Thanks.

GaanDjin

15-06-2011 18:03:29

I've decided to make a .Net wrapper for Particle Universe.
You can find my project in Source Forge https://sourceforge.net/projects/mpu/
It's not complete and I'd still call it pre-alpha but you can create, add, and modify particle systems using it.
It requires recompiling the plugin for mogre but I put some base instructions in the Help section that should get anyone rolling.

Tyler

tafkag

27-06-2011 14:44:46

I've decided to make a .Net wrapper for Particle Universe.
You can find my project in Source Forge https://sourceforge.net/projects/mpu/
It's not complete and I'd still call it pre-alpha but you can create, add, and modify particle systems using it.
It requires recompiling the plugin for mogre but I put some base instructions in the Help section that should get anyone rolling.


Cool, if I find some spare time I'll definitely take a look at this.

Beauty

06-07-2011 23:33:43

I've decided to make a .Net wrapper for Particle Universe.
I'm a little bit sad that mstoyke didn't answer the questions yet.
Nice to see that you (GaanDjin) try to develop/publish an alternative wrapper.

Beauty

17-09-2011 22:43:21

A word of advice: if you want to use an ogre plugin, add the damn thing to the plugins.cfg!! :roll:

I attached my current wrapper version for PU 1.4 to this post. As a quick test I loaded a fire script from the PU media pack into mstoyke's Quickstart project and the ogre is burning as expected. :twisted: :D

Would you like to try to compile the wrapper with Cygons Mogre 1.7.3 build?
He also published the *.lib files. So I suppose it's possible to compile the PU wrapper without building Mogre itself.

tafkag

24-02-2012 16:52:00

I added three small scaling methods to the wrapper:
  1. SetScale[/*:m]
  2. SetScaleVelocity[/*:m]
  3. SetScaleTime[/*:m][/list:u]
    I updated the wiki page and attached the new code version. I'm using PU 1.5 now, but it would probably work with 1.4, too.

tafkag

14-01-2013 18:26:03

I've decided to make a .Net wrapper for Particle Universe.
You can find my project in Source Forge https://sourceforge.net/projects/mpu/
It's not complete and I'd still call it pre-alpha but you can create, add, and modify particle systems using it.
It requires recompiling the plugin for mogre but I put some base instructions in the Help section that should get anyone rolling.


Cool, if I find some spare time I'll definitely take a look at this.


Finally... :?
I got it to compile just fine but the ParticleUniverseTest fails in retrieving the ParticleSystemManager.Singleton which is always null. No idea why yet...