CaelumSharp - Precipitation + CameraMove?

iNuts

26-06-2009 19:23:01

I posted this also in caelum forum, to try to get some help, and its suitable to post it here (since I actually use caelumSharp), the trouble is:
- In the CaelumDemo if I turn precipitation on I lose camera motion throught the keyboard.


My code for the precipitation is:
this.cs.PrecipitationController = new PrecipitationController(sceneMgr);
//this.cs.PrecipitationController.CreateViewportInstance(cs.get); //I do not pass an viewport because it already is attached to caelum and renders correctly the rain
this.cs.PrecipitationController.PresetType = CaelumSharp.PrecipitationType.Rain;
this.cs.PrecipitationController.Intensity = 0.8f;
this.cs.PrecipitationController.Speed = 0.01f;
this.cs.PrecipitationController.SetManualCameraSpeed(Mogre.Vector3.ZERO);


As you can see, the SetManualCameraSpeed(Mogre.Vector3.ZERO) solution did not work for me because the avatar is not moving ( I read that solution in Caelum forum..).
I'm simply trying to build the CaelumDemo in a way that i can get raining effect with a precipitation controler and navigate normally trhough the scene but the movement is altering the Raindirection and not the camera movement as it should. That's exactly what I want to do in my app.

Its probably simple to solve this, but I'm trying and getting a tough time at it.

I also checked the Mogre.SceneManager.cameraIterator to see if there were any extra cameras created by the precipitation system, but its just the regular ones (user + shadows) as we can see on the screenshots:

As you can see the cameras are the same.




Any help?
Thanks for the time spend in reading this :D

smiley80

26-06-2009 20:52:38

You have to attach your viewport
this.cs.AttachViewport(this.viewport); // if AutoAttachViewportsToComponents is true
or
this.cs.PrecipitationController.CreateViewportInstance(this.viewport);
before calling SetManualCameraSpeed.

Or you can instead set PrecipitationController.CameraSpeedScale to Vector3.ZERO.

iNuts

26-06-2009 21:36:36

I have the viewport attached of course, the entire code is like this:

CaelumSharp.CaelumScript.Singleton.Initialise();
this.cs = new CaelumSharp.CaelumSystem(this.root, this.sceneMgr, CaelumSystem.CaelumComponent.Default);
this.cs.AutoAttachViewportsToComponents = true;
this.cs.AttachViewport(this.viewport);

this.cs.TimeScale = 5120;

this.cs.PrecipitationController = new PrecipitationController(sceneMgr);
this.cs.PrecipitationController.PresetType = CaelumSharp.PrecipitationType.Rain;
this.cs.PrecipitationController.Intensity = 0.8f;
this.cs.PrecipitationController.Speed = 0.01f;

this.cs.PrecipitationController.CameraSpeedScale = Vector3.ZERO;
this.cs.PrecipitationController.SetManualCameraSpeed(Vector3.ZERO);

this.window.PreViewportUpdate += cs.PreViewportUpdate;
this.root.FrameStarted += cs.FrameStarted;


And it still doesn't work (the keyboard still moves the rain_direction and not the camera in the terrain)... Any thoughts? (thanks a lot for the previous input, unfortunatly it didn't solve the issue.. you can move the camera with just that extra lines of code you supplyed?)

smiley80

26-06-2009 22:34:40

Okay, that's strange. I've c&p your code into the demo (both the 0.4 release and the svn version) and it works fine for me.

you can move the camera with just that extra lines of code you supplyed?)
I can even move the camera without that, but I get the effect you discribed.

Please replace Test.cs with the 0.4 release one and insert the code again.

iNuts

27-06-2009 00:05:10

Gonna try that, hang on one second and I'll post the result.

(thanks so much for the help so far, hope it does it)

iNuts

27-06-2009 00:13:48

With the file replacemente + code pasting: still not working.

The thing is: I use Caelum 4b (which is the Featured on on thedownload pages).

The other two ones (both 4.0 and 4.0a) appear as deprecated on the page... should I use 4.0 instead?

Thanks for all the help, I'm now downloading CaelumSharp 4.0 from the page and try with it... think that's the issue?

iNuts

27-06-2009 00:50:00

I'm absolutly out of ideas :? ... used with Caelum 4.0 (plain) directly from the download, opened the demo project, configure the missing dll's (mogre / caelumsharp and mois - I use the release ones from the exact same download) and build: no errors.

Place my code (the one you tested...) and bulid: no error.
But....It rains and no camera movement... I also tested in on another computer, same thing (I'm suspicious sometimes of my laptop 8) ).

smiley80

27-06-2009 01:19:17

The older versions had non-relating bugs (disposing).

You could try to load a script:
CaelumSharp.CaelumScript.Singleton.Initialise();
cs = new CaelumSharp.CaelumSystem(root, sceneMgr, CaelumSystem.CaelumComponent.None);
CaelumScript.Singleton.LoadCaelumSystemFromScript(cs, "RainWindScriptTest");

but I don't think that will make a difference.

Or try to debug it, check if HandleInput is called, etc.

Only to be absolutely sure: You do use shift + arrow keys to move the camera? And camera movement works without precipitation?

iNuts

27-06-2009 01:31:31

The older versions had non-relating bugs (disposing).
I see. I've been using 4.0b and now I'm using 4. just for trying this out, but if not I'll stick with 4.0b which is the recent one.


You could try to load a script:
CaelumSharp.CaelumScript.Singleton.Initialise();
cs = new CaelumSharp.CaelumSystem(root, sceneMgr, CaelumSystem.CaelumComponent.None);
CaelumScript.Singleton.LoadCaelumSystemFromScript(cs, "RainWindScriptTest");

but I don't think that will make a difference.

Or try to debug it, check if HandleInput is called, etc.

Okay, I'll try and get back to you. I was just reading the CaelumSharp to get the idea behind the Precipitation (its just a compositor, using the .compositor and material defined for the precipitation... all seems okay, should do the trick, I don't know "what grabs" the keyboard input even with the manual speed settings...)


Only to be absolutely sure: You do use shift + arrow keys to move the camera? And camera movement works without precipitation?

Yes, If I'm not running rain, everything works , camera yaw = moving arrows, or camera movment = shit+arrows.
Just done a cute test where I increase the rain until a certain amount and then turn the intensity off for a couple of frames and then on, so I can witness what happens with the rain on/off, WHAT I see is:
- the rendering of everything except the Rain, is stalled (i.e.:the sun/moon stops in the back) and when the rain is suddently stoped it I regain motion...
- do you think its something to do with the order of rendering, compositors, or viewport/camera settings done by the Precipitation?


I can show a video of this, If it helps.
Once again, thanks (a lot) for trying to figure this out with me... its strange that you can use it with no issues (wild thing: send me a rar of the demo that you can use.. maybe its my system... suspicious guess again 8) )

iNuts

27-06-2009 13:59:37

I've narrowed the problem:
- run the hdr compositor example from mogre in OpenGL, major problem. When you activate any compositor in OpenGl it freezes up... (maybe I should post this in a Mogre thread too no?)

- That's why it freezes on the rain (because it uses a Mogre compositor Instance underneath..)

Now you might think, well change to direct3d rendering, and I would but it crashes on Caelum Compositor:
" at CaelumSharp.PrecipitationInstance.CreateCompositor()\r\n at CaelumSharp.PrecipitationInstance..ctor(PrecipitationController parent, Viewport viewport)\r\n at CaelumSharp.PrecipitationController.CreateViewportInstance(Viewport vp)\r\n at CaelumSharp.CaelumSystem.set_PrecipitationController(PrecipitationController value)\r\n at iNuts.iNutsApplication.CreateScenario(String scenarioName) in I:\\iNuts\\v3\\src\\iNutsApplication.cs:line 917\r\n at iNuts.iNutsApplication.StartSimulation()

Simley80, do you use OpenGl Rendering or Direct in Caelum Example?

smiley80

27-06-2009 14:48:01

What graphics card do you use? Seems you have problems with PS 2.0.

Simley80, do you use OpenGl Rendering or Direct in Caelum Example?
I can use both (DirectX needs the floating_point_mode set to consistent).

iNuts

27-06-2009 17:21:32

What graphics card do you use? Seems you have problems with PS 2.0.
I can use both (DirectX needs the floating_point_mode set to consistent).

We have two ATI's: a Radeon X1200 (laptop one) that supports PS2.0, and a X1950 (on desktop) supports even PS3.0 (this is a much better card).

Also just tested with another laptop that has a Nvidia card and the results are different:
- I'm able to move in both examples.

Is it possible to be a ATI/Mogre imcompatibility?

smiley80

27-06-2009 18:00:27

Might be an ATI related bug, I'm only using Nvidia cards. Make sure you have the latest drivers installed.
You can also try Mogre 1.6.2 and the svn version.

If this doesn't help, you should make a post in the main Ogre forum, because this bug isn't caused by the wrapper.

iNuts

27-06-2009 20:49:10

Might be an ATI related bug, I'm only using Nvidia cards.

Yeah, I was suspicious of this (ATI stuff...)

Make sure you have the latest drivers installed.
They are.


You can also try Mogre 1.6.2 and the svn version
[/quote]
I can try updating to the newest Mogre.

[quote="smiley80"]
If this doesn't help, you should make a post in the main Ogre forum, because this bug isn't caused by the wrapper.[/quote][/quote]
I'm gonna post there, shouldn't be Mogre as the wrapper only uses Ogre underlying code obviously, so Its probably a conflict with Ogre compositors v.s ATI hardware card ('cause all operations of Compositors reside on hardware compositors).

Thanks a lot for the help, and for the time spent on this :)
I'll have to move on the application without compositors/rain for now, which makes me hugely sad.

smiley80

09-07-2009 11:15:05

There was an update committed to svn that might fix the issue:
http://caelum.svn.sourceforge.net/viewv ... athrev=448
(right click on 'download', save it in the media/caelum folder)