Managed Hydrax

amirabiri

18-01-2011 22:48:41

Hi folks,

I've been spending some time lately learning how to wrap C++ with C++/CLI and I was thinking of having a go at wrapping Hydrax again. Or alternatively freshening up the previous wrapper if I could find the source code for it.

My questions are:
- Is anyone else currently working on a managed wrapper for Hydrax or was planning to?
- Does anyone know where I could find the previous wrapper's source code?

Beauty

19-01-2011 01:20:51

I saw, that the source download link of the wiki page Managed Hydrax Wrapper Edit Template was dead. (I suppose the old download file was replaced by a newer one with an other ID.)

But the source code is still available for Hydrax 0.5. :D
download/file.php?id=639

The related forum topic is here:
viewtopic.php?f=8&t=9229

The author raygeee wasn't online for 5 months now, but maybe he will help you (e.g. reply to specific questions) when you write a personal message to him (invate to a public discussion).


There was also an other Hydrax wrapper.
Most parts were wrapped, but some were missing. The wrapper wasn't finished. (Maybe because of the other one?)
Details are here:
viewtopic.php?f=8&t=7989


Also we should ask user boyamer. Maybe he wrote his own Hydrax wrapper for his Alimer Engine.
(In the past he published some very useful wrappers for our Mogre community.)
I will ask and invate him to this forum topic.

Beauty

19-01-2011 01:38:45

Ok, I invated boyamer and raygeee to this topic.

Also it would be useful to add the wrapper source code to a public repository.
(e.g. to the Mogre add-ons repository)
Then we have a lower chance of dead links and it's more easy to update the source (by different people).

The mogre add-ons repository is here:
https://bitbucket.org/mogre/mogreaddons

To get write access to the Mogre add-ons repository, look here:
viewtopic.php?p=74369#p74369


Of course the project can also have it's own (other) repository.
Maybe this is better for code management? Or if the developers prefere SVN.
In this case at least 2 people should have full account access. (If one is offline for longer time or ever, then we need somebody else as administrator to give write permissions to new users.)

CodeKrash

19-01-2011 11:58:35

I failed to modify raygeee wrapper for mogre 1.7.1, some kind of critical error when instantiating the main class

raygeee

19-01-2011 18:09:50

Hi everyone,

long time no see. :-)
I don't use Mogre anymore and switched to XNA mor than a year ago. Mostly because I was tired of wrapping all the available libraries and because I'm more knowledgable in the plain managed world.
But things don't always get easier... XNA doesn't have a lot of open libraries out, so I had to write a lot of basic stuff by myself. I really miss PagedGeometry! The community isn't that great too :(

I can see you have some problems getting MHydrax running with the current Mogre version?
I could take a look into it, but to be honest it's not the engine I'm using anymore.

Could someone provide me with an summary/update of the latest issues? The original source code of MHydrax 0.5 will be my starting point.

Cheers,
raygeee

edit: Just read about the issues, KodeCrash had with static/dynamic linkage and pinvoke. I'm not very good at c++ specific problems, somehow I got my version working earlier. What's the difference with pinvoke, how can one use it?

CodeKrash

19-01-2011 23:11:05

Holy Cow nice to see you!

I'm afraid that it's just as we've said, when making an instance of mhydrax there is a general error "invalid image format" I think it was

viewtopic.php?f=8&t=9229&start=60#p78068

everything compiled against X86 and not "any cpu type"

the error happens on runtime call to make the new instance

amirabiri

19-01-2011 23:33:54

Hi raygeee,

I would appreciate if you could send me the source code for MHydrax. I don't imagine I will use it as is because I will start from scratch with C++/CLI. However it would be a valuable reference for me to get ideas from etc.

amirabiri

19-01-2011 23:36:41

Of course the project can also have it's own (other) repository.
Maybe this is better for code management? Or if the developers prefere SVN.
In this case at least 2 people should have full account access. (If one is offline for longer time or ever, then we need somebody else as administrator to give write permissions to new users.)


I will start with my bitbucket repository and when the code is ready I will submit it to mstoyke or Ganz for inclusion in the official mogre repo.

This is the beauty of bitbucket - everybody can start a project and there is no need to give anyone else access or hand over the project! If the original author becomes inactive someone else can simply clone the project, and change wiki links to point to the new repository.

CodeKrash

20-01-2011 17:12:00

what approach will you use? Pinvoke or wrapper? I thought about doing this myself but I don't think I'm up to the task. Hopefully Raygee can make the latest mhydrax compat with 171

raygeee

20-01-2011 20:40:37

Hi again,

I managed to compile a working Release version of MHydrax (now with Hydrax v0.5.1, but I didn't update all the version texts) against Mogre 1.7.1.
Unfortunately I couldn't compile Hydrax in Debug mode and stopped trying after a while. The references all got mixed up and I got frustrated.

Anyway, here's how I compiled the Release version:
First thing to do is to get Hydrax compiled in C++. You've got to adjust some lines as listed here: viewtopic.php?f=20&t=11089
Then I switched off OGRE_USE_BOOST (to 0) in OgreBuildSettings.h because I don't have Boost and didn't want to bother.
One very important thing I stumbled upon is setting ALL projects to compile against x86 (or win32). Until then I always got a BadImageFormatException.
The other strange thing was, that the Samples project now needs the Hydrax.dll to run, otherwise it'll fail with a FileNotFoundException. I didn't have that issue last time...
Like I said, I'm not a C++ guy, so I might have set a lot of wrong compiler variables in my C++/CLI projects.

Here's the working version. You need the Media-folder from the original Hydrax and the following Release (!) files from the Mogre 1.7.1 SDK to run it:
Mogre.dll, OgreMain.dll, MOIS.dll, cg.dll, Plugin_CgProgramManager.dll, Plugin_OctreeSceneManager.dll, RenderSystemDirect3D9.dll, RenderSystem_GL.dll
This is due to the maximum upload size of 256KB.
[attachment=0]MHydrax 0.5.1 Release Sample.zip[/attachment]
I also added the current source code for MHydrax 0.5.1. I didn't really change the actual source code, I only updated all the references and compiler settings.
[attachment=1]MHydrax 0.5.1 source.zip[/attachment]
There's still one problem you'll see in the Sample which makes it unusable at the moment: scene flickering when moving the camera; sometimes the scene is alright, sometimes it's corrupted.
I guess it's only a minor camera issue (maybe only in the Sample code) which could be fixed by someone with experience. I don't remember having this issue with Mogre 1.4.x

I hope this helps and it'll be a new starting point, either to fix it or create a new wrapper for Hydrax.

Cheers,
raygeee

Beauty

20-01-2011 21:01:25

raygeee, thanks for your great work. :D
Also the compilation instructions are very important for others.

There's still one problem you'll see in the Sample which makes it unusable at the moment: scnene flickering when moving the camera, sometimes the scene is alright, sometimes it's corrupted.
I guess it's only a minor camera issue which could be fixed by someone with experience. I don't remeber having this issue with Mogre 1.4.x


I remember that such a problem was discussed many months ago. I suppose in the official Hydrax topic.
Maybe the reason was a wrong order of some internal update processes?
I can't remember details, but I think the problems were solved in the past. So (you or somebody else) can look for the related posts. Alternatively post your problems in the official Hydrax forum, because this is/was a common problem (independent of the wrapper).

Here's the working version. You need [...]
This is due to the maximum upload size of 256KB.

You can send the whole project with all depencies and needed files to my e-mail address (beautyod at gmx . de). Then I can upload it to a special directory of the MogreSDK (maybe I use the directory name "binary storage").

Beauty

21-01-2011 00:39:39

I got the complete binaries from raygeee.

Download:
MHydrax_0.5.1_binary_Release+Sample_(Mogre.1.7).zip

Note:
The media subdirectory is not included. (Copy it from the original Hydrax package.)

The sources I also added to the SVN of the MogreSDK:
MHydrax_0.5.1_source_(Mogre.1.7).zip

Pyritie

21-01-2011 01:38:53

I got the complete binaries from raygeee.

Download:
MHydrax_0.5.1_binary_Release+Sample_(Mogre.1.7).zip

Note:
The media subdirectory is not included. (Copy it from the original Hydrax package.)

The sources I also added to the SVN of the MogreSDK:
MHydrax_0.5.1_source_(Mogre.1.7).zip

Thank you!

CodeKrash

21-01-2011 08:56:42

I copied the media folder from Hydrax-v0.5.1.rar into the binary folder from MHydrax_0.5.1_binary_Release+Sample_(Mogre.1.7).zip

the top of the stack is setObjectIntersectionsEnabled(GodRaysManager*, Boolean* )

03:53:42: [Hydrax] Hydrax created.
03:53:42: OGRE EXCEPTION(2:InvalidParametersException): Named constants have not been initialised, perhaps a compile error. in GpuProgramParameters::_findNamedConstantDefinition at ..\..\ogre\OgreMain\src\OgreGpuProgramParams.cpp (line 1423)
03:53:45: [Hydrax] ProjectedGridVertex destroyed.
03:53:45: [Hydrax] Perlin destroyed.
03:53:45: [Hydrax] Hydrax object removed.


anyone know what's happening?

amirabiri

21-01-2011 10:58:14

It seems to me that the Hydrax shader code isn't compiling on your machine. If I'm right than you will get the same error using the native Hydrax.dll. To test that you can run the original Hydrax demo and see if you get the same result.

If this is indeed the case first update your DirectX runtime, and if that fails post your bug report on the Hydrax forum (the native Hydrax forum, not the managed MHydrax).

CodeKrash

21-01-2011 19:54:30

I had to inject d3dx9_38.dll into the hydrax demo folder, but it did work after i did that. I'll install the directx sdk and post back with the results

CodeKrash

21-01-2011 20:15:38

I deleted d3dx9_42.dll from the "MHydrax 0.5.1 Release Sample" folder, installed the directx SDK, and it now runs without d3dx9_42.dll, and it now runs! This isn't good for redistributable builds, but that's another subject. the MHydrax demo runs, but as raygeee mentioned, there is a weird issue regarding the camera angle. The artifacts change when changing the camera angle, but not the camera position.[attachment=0]3.jpg[/attachment][attachment=1]2.jpg[/attachment][attachment=2]1.jpg[/attachment]

CodeKrash

22-01-2011 00:23:08

some really wild patterns[attachment=0]4.jpg[/attachment]

McDonte

28-01-2011 17:11:30

I got a really nasty error. It didn't even run, but crashed before. The problem was about this line in the resources.cfg file:

Zip=../../Media/packs/SkyBoxes.zip

In the usual Mogre SDK there is only a skybox.zip. Also the Hydrax media doesn't contain anything like this. I replaced "SkyBoxes" by "skybox" but then the program crashes because it can't find a Club/Tropicana material. There is nothing like this neither in the original Hydrax media files nor in the Mogre SDK nor in the Ogre SDK. :?

Please, where can I find it? I really want to test MHydrax!

CodeKrash

30-01-2011 04:02:16

here you are: media folder

McDonte

31-01-2011 09:58:11

Thanks a lot, CodeKrash!

I will start playing around with some water :D

McDonte

31-01-2011 16:26:21

I got the sample working, but when I'm trying to create my own application it still crashs...
Is used an orginial version of the Tutorial Framework:
  1. Mogre crashs if I include the plugin CGProgramManager.[/*:m]
  2. Mogre crashs if I create an instance of MHydrax (same for Update(), Dispose())
    => "Imported function cannot be loaded"[/*:m][/list:u]

    Anyone who had the same problem?

    EDIT:

    I solved the first problem by using the CGProgramManager dll from the MogreSDK.

Beauty

31-01-2011 17:44:54

Thanks for your reports.
When MHydrax works fine, we could make a demo application for our MogreSDK.

McDonte

01-02-2011 12:44:31

Hi everybody,

I got it working now! I created a small sample scene with the Tutorial Framework and it's running fine without flickering!

I didn't use any special code:

hydrax = new MHydrax.MHydrax(mSceneMgr, mCamera, mWindow.GetViewport(0));

hydrax.Components = MHydraxComponent.HYDRAX_COMPONENTS_ALL;

MHydrax.MProjectedGrid m = new MProjectedGrid(hydrax,
new MPerlin(new MPerlin.MOptions(8, 0.085f, 0.49f, 1.4f, 1.27f, 2, new Vector3(0.5f, 50, 150000))),
new Plane(new Vector3(0, 1, 0), new Vector3(0, 0, 0)),
MMaterialManager.MNormalMode.NM_VERTEX,
new MHydrax.MProjectedGrid.MOptions(56, 35, 50, false, false, true, 3.75f));

hydrax.SetModule(m);
hydrax.LoadCfg("HydraxDemo.hdx");
hydrax.Create();


One problem is still there:
You can only use the dlls from the folder Beauty posted for us. So Debug Mode doesn't run and you cannot use any other version of the Mogre binaries (as for example the ones mstoyke posetd for use with MyGui etc.)

Thanks a lot to everybody who helped to make Managed Hydrax possible!

CodeKrash

01-02-2011 18:55:32

can anyone figure out why the sky is holy (full of holes) in the sample app?

McDonte

01-02-2011 19:46:30

can anyone figure out why the sky is holy (full of holes) in the sample app?

This seems to be a problem of the sample. When you create your own application the sky is displayed without holes (I used Mogre's skydome, nothing special)
I think it's somehow related to the camera movement in the sample...

amirabiri

01-02-2011 20:40:00

I'm still working on a new wrapper for Hydrax. I'm hoping it will prove more stable when its ready.

Beauty

01-02-2011 23:48:32

Are you shure that the problems are related to the wrapper?
Maybe it's related to mistakes in usage with Hydrax itself.
As far as I remember for Mogre 1.6 it was running fine. At least one C# game use it. I don't think the author (codo) would had used it when it's unstable.
So maybe the current wrapper just need a qualified update?

Just some thoughts to prevent probably redundant work which the same problems in the result. :wink:

CodeKrash

02-02-2011 17:38:19

it could very well be the way mhydrax is used that causes this. It happens in the app that I'm developing as well as the sample app. Maybe I should try implementing it using a different example.

CodeKrash

14-02-2011 03:11:00

just for the sake of compiling mhydrax, i just spent another 6 hours compiling ogre/mogre then hydrax/mhydrax and ran into the same bloody problems :evil:

Attempted to read or write protected memory. This is often an indication that other memory is corrupt.

at Hydrax.Hydrax.{ctor}(Hydrax* , SceneManager* , Camera* , Viewport* )
at MHydrax.MHydrax..ctor(SceneManager sceneMgr, Camera cam, Viewport vp)


Same problem I had my previous 2 attempts. I give up AGAIN! :|

Jo0oker

15-02-2011 20:51:57

Thank you, the new wrapper works great, as you can see here:
http://www.eggers-sw.de/index.php?optio ... &Itemid=77

I will test it more and more, if i found some bugs, i will report them.

Thank you,
Jo0oker

McDonte

17-02-2011 14:28:32

Thank you, the new wrapper works great, as you can see here:
http://www.eggers-sw.de/index.php?optio ... &Itemid=77


Could you tell us how you did it because many people are facing problems while trying to use MHydrax?

Would be great!
Thanks, McDonte

Jo0oker

19-02-2011 15:40:37

Ok,
here is my way of integration: http://eggers-sw.de/index.php/system/hydrax

I hope it will help some one.

McDonte

19-02-2011 17:45:20

here is my way of integration: http://eggers-sw.de/index.php/system/hydrax

Thanks Jo0oker! This is useful for the integration but I thought of the way how you got the binaries. When I tried to compile the wrapper on my own it never turned out to work. The binaries posted by Beauty are working fine but these are only the release ones.

Beauty

06-08-2011 10:30:09

Ok,
here is my way of integration: http://eggers-sw.de/index.php/system/hydrax

I hope it will help some one.

The link is dead. Can you give is the new link? Or re-publish it? I hope your created page content is still available on your hard drive.
Perhaps it's better to publish it in the Ogre wiki. So it can't become a dead page again.

Beauty

13-09-2011 00:16:12

Today I asked Jo0oker for the dead link again.
Unfortunately his report (or tutorial??) got lost.

But he gave me his code, which shows how to use MHydrax.
I added it to the Ogre wiki:
http://www.ogre3d.org/tikiwiki/MHydrax+code+example