Crystal Space
Welcome, Guest. Please login or register.
September 17, 2014, 02:54:14 pm

Login with username, password and session length
Search:     Advanced search
9018 Posts in 2051 Topics by 8471 Members
Latest Member: Jeffhogan
* Home Help Search Login Register
+  Crystal Space
|-+  Crystal Space Development
| |-+  General Crystal Space Discussion
| | |-+  Minimal code to use Emitter, Fountain, Fire, Snow, Rain, etc. mesh objects?
« previous next »
Pages: [1] Print
Author Topic: Minimal code to use Emitter, Fountain, Fire, Snow, Rain, etc. mesh objects?  (Read 4305 times)
kornerr
Full Member
***
Posts: 101


347968356
View Profile WWW Email
« on: March 31, 2006, 10:18:57 am »

How should I modify "simple" to create any of these mesh objects?
I can't get any of them working. I'm sure the problem is due to incorrect initializaion. But the manual provides NO example how to do it.
Can anyone help me?

Thanks.
Logged

jorrit
Administrator
Hero Member
*****
Posts: 1706


View Profile
« Reply #1 on: March 31, 2006, 10:33:54 am »

How should I modify "simple" to create any of these mesh objects?
I can't get any of them working. I'm sure the problem is due to incorrect initializaion. But the manual provides NO example how to do it.
Can anyone help me?

Thanks.

Did you check the mazetut tutorial in the manual? It gives an example on how to make a particles mesh object.

Greetings,
Logged
kornerr
Full Member
***
Posts: 101


347968356
View Profile WWW Email
« Reply #2 on: March 31, 2006, 10:52:13 am »

Can you please point me to the neccessary chapter in the manual?

Thanks.
Logged

jorrit
Administrator
Hero Member
*****
Posts: 1706


View Profile
« Reply #3 on: March 31, 2006, 10:53:45 am »

Can you please point me to the neccessary chapter in the manual?

Thanks.

Section 4.2.4. It is the 'Mazing' tutorial.

Greetings,
Logged
kornerr
Full Member
***
Posts: 101


347968356
View Profile WWW Email
« Reply #4 on: March 31, 2006, 02:59:29 pm »

Thanks, it works fine. But I can't create, e.g., snow. Can you give an example of how to create snow? There's no iSnowFactoryState or anything, so I'm at a loss (

Thanks.
Logged

jorrit
Administrator
Hero Member
*****
Posts: 1706


View Profile
« Reply #5 on: April 01, 2006, 02:30:54 pm »

Snow is one of the old particle systems and it works a bit differently. You have to create an empty snow factory and set the snow parameters (using iSnowState) on the mesh object.

Greetings,
Logged
kornerr
Full Member
***
Posts: 101


347968356
View Profile WWW Email
« Reply #6 on: April 16, 2006, 08:45:23 am »

Code:
- - - -
    if (!loader->LoadTexture ("rain_tex", "/lib/std/spark.png"))
        ReportError ("Failed to load \"rain\" texture");
    csRef<iMaterialWrapper> rain_tex_mw = engine->GetMaterialList ()->FindByName (
            "rain_tex");

    csRef<iMeshFactoryWrapper> rain_mfw = engine->CreateMeshFactory (
            "crystalspace.mesh.object.rain", "rain");
    if (!rain_mfw)
        cout << "no rain_mfw initialized!\n";
    csRef<iMeshWrapper> rain_itself = engine->CreateMeshWrapper (rain_mfw, "rain_itself",
            0, csVector3 (0, 0, 0));
    rain_itself->SetZBufMode (CS_ZBUF_TEST);
    cout << "aaa\n";
    csRef<iRainState> rain_state = csQueryRegistry<iRainState> (GetObjectRegistry ());
    if (!rain_state)
        cout << "no rain_state!\n";
    rain_itself->GetMeshObject ()->SetMaterialWrapper (rain_tex_mw);
    rain_state->SetMixMode (CS_FX_ADD);
    rain_itself->GetMeshObject ()->SetColor (csColor (0.5, 0.5, 0.8));
    rain_state->SetParticleCount (100);
    rain_state->SetDropSize (1, 1);
    rain_state->SetLighting (false);
    rain_state->SetBox (csVector3 (-5, 0, -5), csVector3 (5, 10, 5));
    rain_state->SetFallSpeed (csVector3 (0, -1, 0));
- - - -
So the app does say "no rain_state!". Why no rain_state? What am I missing?

Thanks.
Logged

jorrit
Administrator
Hero Member
*****
Posts: 1706


View Profile
« Reply #7 on: April 18, 2006, 07:46:38 am »

You are trying to get rain state from the object registry. That's wrong. You must get it from the mesh object using scfQueryInterface.

Greetings,
Logged
kornerr
Full Member
***
Posts: 101


347968356
View Profile WWW Email
« Reply #8 on: April 18, 2006, 10:13:05 am »

Thanks, I've made:
Code:
csRef<iRainState> rain_state = scfQueryInterface<iRainState> (rain_itself->GetMeshObject ());
all compiles ok, but I can't see any rain (
What's wrong?

Thanks.
Logged

jorrit
Administrator
Hero Member
*****
Posts: 1706


View Profile
« Reply #9 on: April 18, 2006, 10:19:01 am »

Try:

    rain_state->SetMaterialWrapper (rain_tex_mw);

instead of:

    rain_itself->GetMeshObject ()->SetMaterialWrapper (rain_tex_mw);

Greetings,
Logged
kornerr
Full Member
***
Posts: 101


347968356
View Profile WWW Email
« Reply #10 on: April 18, 2006, 11:34:19 am »

I've made
Code:
rain_state->SetMaterialWrapper (rain_tex_mw);
and even tried
Code:
rain_state->SetColor (csColor (0.5, 0.5, 0.8));
but still no rain (
Logged

jorrit
Administrator
Hero Member
*****
Posts: 1706


View Profile
« Reply #11 on: April 18, 2006, 11:36:34 am »

Sorry, no idea then. Check the code in apps/walktest/walkdemo.cpp. There is code there to create rain. Perhaps you can see what you did wrong there.

Greetings,
Logged
Pages: [1] Print 
« previous next »
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.2 | SMF © 2006-2007, Simple Machines LLC Valid XHTML 1.0! Valid CSS!
Page created in 5.442 seconds with 17 queries.