MSkyX 0.3

mightygoose

03-06-2012 21:52:27

Hello fellow mOgres!

This is my first first post and also (I'm proud to say) my first contribution to the Mogre community. I've been working on a game (typical, I know) for the past year and a half alone. I've kept to myself and haven't made contact with the community yet.

Why:
I noticed Boyamer's wrapper is pretty outdated and missing a lot of things I needed. So I decided I would try to update his p/invoke wrapper... No success. Besides, Xavyiy apparent restructured SkyX a bit. The next thing I tried was to write my own p/invoke wrapper... No Luck (C++ kept fussing and it seemed to ignore Extern "C" and calling the functions by ordinal did not work). Almost got Autowrap to convert it all automatically, but alas STILL no success (Doxygen worked great but cpp2java failed on multiple levels of failure and I didn't want to spend time on it). SWIG... well you know.

What:
I ended writing a C++/CLI wrapper (SkyX with additional Managed classes) for the latest SkyX (0.3). The wrapper DOES not have all of classes wrapped by far, but I'm going to finish wrapping it by the end of the next couple of weeks (its Finals week for me). The classes I have wrapped, I wrapped so that they were stylized to my liking (gets and sets are now properties, camel casing for arguments, proper casing for public elements, and full descriptive parameter names). I'm not a C++ programmer, so please take some time to make sure things work properly before using this commercially.

How:
To build the wrapper yourself, you basically need to be able to build SkyX. All you need to do is build Mogre (I HIGHLY RECOMMEND MogreBuilder http://www.ogre3d.org/tikiwiki/MogreBuilder) and then update the paths in the project to the corresponding paths of the MogreBuilder output. Then you just need to reference the SkyX.dll in your .net projects.

License:
Since MSkyX is basically a modification of SkyX, it follows the same licensing as defined by Xavyiy. Same license.txt is included in the source directory.

Examples:
Will be included soon.

This really is a rushed release, so don't expect much from it yet; however, I will updated over the next couple of weeks so it is complete.

Where:
Google source page: http://code.google.com/p/mogre-skyx/
I'll add you if you have contributions, just ask :)
Binaries included in bin folder of source are built against Mogre 1.7.4 and .Net 4.0.

Feedback appreciated, Thanks,
Jon (mightygoose)

Tubulii

21-06-2012 12:44:50

Thanks for sharing,

I myself had to wrap c++ projects with C++/cli and had no experience, too. But I managed it and I am quite happy with the result, although a have to refactor it a bit (camel casing, properties).

Do you want to edit the wiki? You could add some links to the wiki, so the rest of the community can look it up.

mightygoose

21-06-2012 18:59:29

Thanks for the feedback! I didn't even think to edit the wiki, I'll go ahead and do that now.

tafkag

24-06-2012 11:32:00

Thanks so much for sharing this wrapper! I compiled it successfully after using the MogreBuilder to build Mogre. Haven't tested it yet but will do so tomorrow. :)

mightygoose

24-06-2012 20:57:47

Thanks so much for sharing this wrapper! I compiled it successfully after using the MogreBuilder to build Mogre. Haven't tested it yet but will do so tomorrow. :)

Yay! I can't wait to hear how it works out for you! I'm still working on it, so make sure to keep an eye on the SVN copy. It's pretty straight forward, I had some trouble getting the atmospheric pass applied to my terrain without flickering. But it turns out all I had to do was adjust the depth bias of the SkyX terrain pass (if you need help with that I can show you how). I'll keep an eye on my email so I can reply promptly to any problems you have (I'm based in the US -> California though, so I think we are on a totally different time zone).

Beauty

01-09-2012 14:10:22

Hi Mightygoose,

thank you very much for creating and sharing your great wrapper. :D

I will updated over the next couple of weeks so it is complete.
What's the current state? Did you add some improvements?
If yes, it would be nice if you submit them to your repository.

Examples: Will be included soon.
This would be very useful. Even if it's a quick and dirty one. So people can see how it works in general.

To build the wrapper yourself [...] I HIGHLY RECOMMEND MogreBuilder
I got the idea to include an option to the MogreBuilder to build your wrapper automatically.
As you write it could be relative easy. So I created a task for this in the issue tracker of the MogreBuilder.
https://bitbucket.org/mogre/mogrebuilde ... yx-wrapper

If anybody wants to help on it and needs knowledge, just ask in the MogreBuilder forum topic.

Tubulii

19-09-2012 19:46:51

I just saw a "TODO" in your code:
The getCamera function of SkyX.

This is actually very easy:

property Mogre::Camera^ Camera
{
Mogre::Camera^ get() {
return _SkyX->getCamera();
}
}

Ogre and Mogre classes have an implicit conversion operator ;) .

And something about value structs:
If you use handles on these kind of types, they get boxed and they only get reconized as "ValueType".
See here for an example.
Some of your value structs have these "problem", e.g. in "MAtmosphereManager.h" ('property OptionsStruct^ Options' and 'GetColorAt').

Zakor

31-12-2012 12:20:55

I have troubles using MSkyX :/
I built it successfully with Mogre Components Builder. Then I copied the Mogre.dll and SkyX.dll in my Release directory.
Here is my code for creating the sky :

this.mSkyX = new MSkyX(this.mStateMgr.SceneManager, new MBasicController(true));
this.mSkyX.Create();


After reading some posts I modified skyx.material and replaced "param_named uRadius 30000" by "param_named uRadius float 30000".
If I compile with OpenGL, I got an exception and the program crashes. With Direct3D9, I haven't any errors neither any sky...

My log file wit OpenGL:

Can't assign material _NULL_ to SubEntity of SkyXMeshEnt because this Material does not exist. Have you forgotten to define it in a .material script?
WARNING: material SkyX_Skydome_STARFIELD_LDR has no supportable Techniques and will be blank. Explanation:
Pass 0: Vertex program SkyX_Skydome_VP cannot be used - not supported.

OGRE EXCEPTION(2:InvalidParametersException): Named constants have not been initialised, perhaps a compile error. in GpuProgramParameters::_findNamedConstantDefinition at C:\MCB\WorkingDirectory\Mogre\Builder\Main\OgreSrc\ogre\OgreMain\src\OgreGpuProgramParams.cpp (line 1425)

My log file with Direct3D9:

Can't assign material _NULL_ to SubEntity of SkyXMeshEnt because this Material does not exist. Have you forgotten to define it in a .material script?
Texture: SkyX_Starfield.png: Loading 1 faces(PF_A8R8G8B8,512x512x1) with hardware generated mipmaps from Image. Internal format is PF_A8R8G8B8,512x512x1.
Texture: SkyX_Moon.png: Loading 1 faces(PF_A8R8G8B8,512x512x1) with hardware generated mipmaps from Image. Internal format is PF_A8R8G8B8,512x512x1.

Thanks for any help.

Tubulii

31-12-2012 13:56:08

You could try to use the latest shaders from SkyX 0.3.1. They worked for me.

Zakor

01-01-2013 14:39:34

You mean I have to compile the ogre version of SkyX and use one of its dll ? That's weird ...
Anyway, even with the Cmake files I downloaded with the source code of SkyX 0.3.1 I can't manage to build it :x
Cmake can't locate the following packages : boost, ogre and IOS yet I'm giving the directories path in the entries such as :
BOOST_DIR = ...\Main\OgreSrc\ogre\Dependencies\src\boost_1_52_0 (by the way I didn't find anything with boost when I built Mogre so I had to download and move it here myself)
OGRE_DIR = ...\Main\OgreSrc\ogre
OIS_DIR =...\Main\OgreSrc\ogre\Dependencies\src\ois

Please what am I doing wrong ?

Tubulii

01-01-2013 14:57:54

I mean you could use the shaders/Materials/Textures (*.material, *.cg, ...) from the latest official SkyX version and replace them with the old ones from the wrapper.
Just copy the SkyX 0.3.1 media folder content and use it instead of the MSkyX media folder content.

Zakor

01-01-2013 15:45:07

Well now it doesn't crash anymore with OpenGL but still no sky :|
I have the same log than with direct3D9 :

Can't assign material _NULL_ to SubEntity of SkyXMeshEnt because this Material does not exist. Have you forgotten to define it in a .material script?
Texture: SkyX_Starfield.png: Loading 1 faces(PF_A8R8G8B8,512x512x1) with  hardware generated mipmaps from Image. Internal format is PF_A8R8G8B8,512x512x1.
Texture: SkyX_Moon.png: Loading 1 faces(PF_A8R8G8B8,512x512x1) with  hardware generated mipmaps from Image. Internal format is PF_A8R8G8B8,512x512x1.


The problem would come from my code ?

Tubulii

01-01-2013 16:38:07

I guess that this is not an error (the "_null_" material seems just to be a dummy material).

Have you set up SkyX correctly?
In the native example there is this line:
// Add a basic cloud layer
mSkyX->getCloudsManager()->add(SkyX::CloudLayer::Options(/* Default options */));

Do you call SkyX.Update each frame?

Zakor

01-01-2013 20:06:13

Do you call SkyX.Update each frame?
Yes I do.


Have you set up SkyX correctly?

Actually I'm not sure I have the right dll file ! I mean I linked SkyX.dll I found in C:\MCB\Output\Release but I get some weird things when I want to use it.
I wanted to translate your given line in C# doing something like :

mSkyX.CloudsManager.AddLayer(SkyX.CloudLayer.Options.DEFAULT);

But I have a problem with the accessor CloudsManager. This accessor returns a variable of type SkyX.MCloudsManager yet there is no such type in the namespace SkyX :o


Instead there is a class MVCloudsManager so I tried :
SkyX.MVCloudsManager cloudMgr = (SkyX.MVCloudsManager)mSkyX.CloudsManager;
But I have the errors :

'SkyX.MSkyX.CloudsManager' is inaccessible due to its protection level
The property or indexer 'SkyX.MSkyX.CloudsManager' cannot be used in this context because the get accessor is inaccessible


Don't know what to do :/

Tubulii

01-01-2013 20:29:54

Mm, maybe this is a bug?
mightygoose could answer this for sure, until when just change the class modifier (of CloudManager) to public and recompile MSkyX with MCB.
If it still does not work, I could give you my own SkyX wrapper which is working out of the box but untested.

Actually I'm not sure I have the right dll file ! I mean I linked SkyX.dll I found in C:\MCB\Output\Release but I get some weird things when I want to use it.
This is the right one.

Zakor

06-01-2013 16:08:54

Ok I added a public, I can now access to the MCloudsManager but I have no methods with this class (except the ToString(), GetType(), ...).
I'd really appreciate if you could send me your dll :D

Tubulii

06-01-2013 19:16:52

Here it is, but its a debug build: It only works with debug dlls (i.e. OgreMain_d.dll, ...).
Debug build
Release build
(it uses an slightly modified Mogre 1.7.4 version, but the API is still the same, there should be no erros with the "official" Mogre 1.7.4)

I am rebuilding the release build right now.

Download the media files and the example source code from here (links at the bottom, latest version). Don't forget to modfiy resources.cfg, too.

First you should try to convert the native example, which is really simple. Then try to integrate it into your current project.

Zakor

08-01-2013 16:48:50

Thanks a lot for these dll's.
Unfortunately it's still not working. I really don't see what I'm doing wrong :shock: I translated exactly what's given in Demo.
Never mind, I think I'll use Caelum instead (I tested it and it is working at least).
Thanks again for all your help Tubulii ;)

Tubulii

08-01-2013 17:59:42

Mm, I would like to give it one last try:
Download these two zips
Media
and
Bin folder and extract them like this:

Media
|_Bin
|_Debug
|_files and dlls

(Or edit resources.cfg).
It contains my test project for both SkyX and Hydrax. It works on my machine.

Zakor

08-01-2013 22:28:23

Ok. I've got an ogre exception.
Here is the full Ogre.log : http://justpaste.it/Ogrelog
It seems I have the error "OGRE EXCEPTION(2:InvalidParametersException): Named constants have not been initialised, perhaps a compile error." when parsing Example.material

Tubulii

09-01-2013 12:38:10

I've never checked, if it works with the OpenGL, so I did a few tests:

Hydrax and SkyX works with DirectX,
but only SkyX with OpenGL.

I removed Hydrax from the example project and uploaded the new version. This will work with both Directx and Opengl (at least on my machine).
Note: No Shadows and the island is colored white, only the sky is "fine".

Zakor

09-01-2013 20:09:15

Okay actually the version with Hydrax is working with DirectX (I had to change the rendering Device by myself :roll: )
But with OpenGL, there is no rendering device options so it is still crashing with Hydrax and working without it. Just as you expected.

Then I wanted to use your dll's but my project doesn't compile in debug mode :? I rebuilt Mogre in debug mode to try but nothing works.

Tubulii

10-01-2013 15:29:31

If you want to use the Mogre debug dll, you have to take ALL Ogre debug dlls. And don't forget to change the plugin names (== dll names without ext) in "plugins.cfg".
If you get any "one or more dependency not found" exception, download the dependency walker and open the dll file with it. If shows you all imported (and missing) libraries of the openend dll.

Then I wanted to use your dll's but my project doesn't compile in debug modePlease explain

Zakor

10-01-2013 17:25:35

Yes I replaced the dll with the _d ones and I changed the plugins' name in plugin.cfg. I also checked the "Enable unmanaged code debugging" option as advised in the FAQ.
When compiling my project in debug - with or without the SkyX dlls - I have an Ogre exception and don't understand why ... My log file isn't very useful :/ http://justpaste.it/1r95

Though I'd also like to understand why I can't compile in debug, this must be another problem ...
The problem I have with SkyX must come from my code don't you think ?

Tubulii

11-01-2013 12:24:40

Just an idea: Disable the Ogre options dialog (=load (/"restore") settings from file, without config dialog). For some reasons, some compiled Mogre (ogre) dlls have problems with embedded resources (like my ones :evil: )

If that does not work:
I have an Ogre exception and don't understand why The standard Mogre Framework wrapps the whole project into a Try..Catch block. Remove this block, use debug dlls, enable native(/unmanaged) debugging and make sure that you have the ogre source code. This should allow you to debug the ogre source code when the exception occurs. It should give you some hints.

And yes, I think it has to do something with your project. Did you try to setup a fresh Mogre test project? If you confirmed, that Mogre runs fine without any modifications (= plain mogre demo project, e.g. from Tutorial 1), then try to integrate SkyX again step by step. I used this several times and it really helps to find the problem.

Zakor

21-01-2013 09:56:04

Thanks for your advice. I managed to compile in debug mode but I still don't know I have no sky.
Never mind I have no time for trying to use SkyX since I integrated Caelum well.