Crystal Space
Welcome, Guest. Please login or register.
August 22, 2014, 02:58:37 pm

Login with username, password and session length
Search:     Advanced search
9005 Posts in 2043 Topics by 8333 Members
Latest Member: Deminagomez76
* Home Help Search Login Register
+  Crystal Space
|-+  Crystal Space Development
| |-+  General Crystal Space Discussion
| | |-+  csColliderActor
« previous next »
Pages: 1 [2] Print
Author Topic: csColliderActor  (Read 7718 times)
jorrit
Administrator
Hero Member
*****
Posts: 1706


View Profile
« Reply #15 on: April 03, 2006, 03:19:45 pm »

Well, I've looked into simpmap tut. Added csColliderActor and... I'm falling down all the way in my app (based on simple1).
Why?
I have this:
Code:
- - - -
    room = engine->CreateSector ("room");
    /*csRef<iMeshWrapper>*/ walls = engine->CreateSectorWallsMesh (room, "walls");
    csRef<csColliderWrapper> col_walls = csColliderHelper::InitializeCollisionWrapper
        (cd_sys, walls);
- - - -
Doesn't it create room with a "solid" floor?
How to do things the right way?

Thanks.

Are you initializing colliders for the world objects?

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


347968356
View Profile WWW Email
« Reply #16 on: April 03, 2006, 03:22:34 pm »

Emm... what?
Logged

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


View Profile
« Reply #17 on: April 03, 2006, 03:27:01 pm »

Emm... what?

Check out the csColliderHelper class. You have to create colliders for the world too (after loading the world).

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


347968356
View Profile WWW Email
« Reply #18 on: April 03, 2006, 03:36:27 pm »

Can't find how to do it...
Logged

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


View Profile
« Reply #19 on: April 03, 2006, 03:41:14 pm »

Can't find how to do it...

Just check the API ref manual on csColliderHelper. You have to use the InitializeCollisionWrappers() function. Do a grep/find on some of the apps in CS. This function is also used there.

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


347968356
View Profile WWW Email
« Reply #20 on: April 03, 2006, 03:54:35 pm »

I added
Code:
csColliderHelper::InitializeCollisionWrappers (cd_sys, engine);
in CreateRoom with no result (
Logged

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


View Profile
« Reply #21 on: April 03, 2006, 03:55:58 pm »

I added
Code:
csColliderHelper::InitializeCollisionWrappers (cd_sys, engine);
in CreateRoom with no result (

Show me the complete code.

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


347968356
View Profile WWW Email
« Reply #22 on: April 03, 2006, 04:05:24 pm »

Code:
- - - -
void Simple::CreateRoom () {
        if (!loader->LoadTexture ("wall", "/this/images/wall.png"))
                ReportError ("Failed to load \"wall\" texture");
        if (!loader->LoadTexture ("wooden_floor", "/this/images/wooden_floor.png"))
                ReportError ("Failed to load \"wooden_floor\" texture");
        if (!loader->LoadTexture ("ceiling", "/this/images/ceiling.png"))
                ReportError ("Failed to load \"ceiling\" texture");

        iMaterialWrapper *wall_mw = engine->GetMaterialList ()->FindByName ("wall");
        iMaterialWrapper *wooden_floor_mw =
                engine->GetMaterialList ()->FindByName ("wooden_floor");
        iMaterialWrapper *ceiling_mw = engine->GetMaterialList ()->FindByName ("ceiling");

        room = engine->CreateSector ("room");
        /*csRef<iMeshWrapper>*/ walls = engine->CreateSectorWallsMesh (room, "walls");
        csRef<csColliderWrapper> col_walls = csColliderHelper::InitializeCollisionWrapper
                (cd_sys, walls);
        csRef<iMeshObject> walls_object = walls->GetMeshObject ();
        csRef<iMeshObjectFactory> walls_factory = walls_object->GetFactory ();
        csRef<iThingFactoryState> wfs = scfQueryInterface<iThingFactoryState> (walls_factory);
        //csRef<iThingState> ws = SCF_QUERY_INTERFACE (walls->GetMeshObject (), iThingState);
        //csRef<iThingFactoryState> wfs = ws->GetFactory ();
        wfs->AddInsideBox (
                        csVector3 (-10, 0, -10),
                        csVector3 (10, 10, 10)
                        );

        // Texture mapping the walls

        wfs->SetPolygonMaterial (csPolygonRange (0, 0), wall_mw);
        wfs->SetPolygonTextureMapping (csPolygonRange (0, 0),
                        csVector2 (1, 1),
                        csVector2 (0, 1),
                        csVector2 (0, 0)
                        );
        wfs->SetPolygonMaterial (csPolygonRange (1, 1), wall_mw);
        wfs->SetPolygonTextureMapping (csPolygonRange (1, 1),
                        csVector2 (0, 1),
                        csVector2 (1, 1),
                        csVector2 (1, 0)
                        );
        wfs->SetPolygonMaterial (csPolygonRange (2, 2), wall_mw);
        wfs->SetPolygonTextureMapping (csPolygonRange (2, 2),
                        csVector2 (1, 1),
                        csVector2 (0, 1),
                        csVector2 (0, 0)
                        );
        wfs->SetPolygonMaterial (csPolygonRange (3, 3), wall_mw);
        wfs->SetPolygonTextureMapping (csPolygonRange (3, 3),
                        csVector2 (0, 1),
                        csVector2 (1, 1),
                        csVector2 (1, 0)
                        );

        // Texture mapping the floor and the ceiling

        wfs->SetPolygonMaterial (csPolygonRange (4, 4), wooden_floor_mw);
        wfs->SetPolygonTextureMapping (csPolygonRange (4, 4),
                        csVector2 (1, 1),
                        csVector2 (0, 1),
                        csVector2 (0, 0)
                        );
        wfs->SetPolygonMaterial (csPolygonRange (5, 5), ceiling_mw);
        wfs->SetPolygonTextureMapping (csPolygonRange (5, 5),
                        csVector2 (1, 1),
                        csVector2 (1, 0),
                        csVector2 (0, 0)
                        );

        if (!loader->LoadTexture ("ball_tex", "/this/images/grass_1_pre.jpg"))
                ReportError ("Failed to load \"earth\" texture");
        if (!loader->LoadTexture ("cube_tex", "/this/images/washing_machine.png"))
                ReportError ("Failed to load \"cube\" texture");
        iMaterialWrapper *cube_tex_mw = engine->GetMaterialList ()->FindByName ("cube_tex");
        if (!loader->LoadTexture ("cube_tex_wall", "/this/images/washing_machine_wall.png"))
                ReportError ("Failed to load \"cube wall\" texture");
        iMaterialWrapper *cube_tex_wall_mw = engine->GetMaterialList ()->FindByName (
                        "cube_tex_wall");
        iMaterialWrapper *earth_map_mw = engine->GetMaterialList ()->FindByName (
                        "ball_tex");

        // It's training in using mesh obj and creating genmesh

        fact = engine->CreateMeshFactory ("crystalspace.mesh.object.genmesh", "ball_fact");        csRef<iGeneralFactoryState> fact_state = scfQueryInterface<iGeneralFactoryState> (
                        fact->GetMeshObjectFactory ());
        fact_state->GenerateSphere (csEllipsoid (csVector3 (0, 0, 0), csVector3 (1, 1, 1)), 50);
        //cout << fact_state->GetTriangleCount () << endl;
        fact_state->CalculateNormals ();
        const int NUM_OF_BALLS = 20;
        csRefArray<iMeshWrapper> array_of_balls (NUM_OF_BALLS);
        csRefArray<iGeneralMeshState> array_of_ball_states (NUM_OF_BALLS);
        for (int i = 0; i < NUM_OF_BALLS; i++) {
                csRef<iMeshWrapper> tmp;
                if (i < 10)
                        tmp = engine->CreateMeshWrapper (fact, "one_of_the_balls", room,
                                        csVector3 (-2 * i + 9, 5, 5));
                else
                        tmp = engine->CreateMeshWrapper (fact, "one_of_the_balls", room,
                                        csVector3 (-2 * i + 29, 8, 5));

                array_of_balls[i] = tmp;
                csRef<iGeneralMeshState> ttmp;
                ttmp = scfQueryInterface<iGeneralMeshState> (array_of_balls[i]->GetMeshObject ());
                array_of_ball_states[i] = ttmp;
                array_of_ball_states[i]->SetMaterialWrapper (earth_map_mw);
        }

        // It's training in using thing mesh obj
        csRef<iMeshWrapper> cube = engine->CreateThingMesh (room, "cube");
        csRef<iMeshObject> cube_object = cube->GetMeshObject ();
        csRef<iMeshObjectFactory> cube_factory = cube_object->GetFactory ();
        csRef<iThingFactoryState> cube_state = scfQueryInterface<iThingFactoryState> (
                        cube_factory);

        cube_state->AddOutsideBox (csVector3 (7, 0, 7), csVector3 (9, 3, 9));

        cube_state->SetPolygonMaterial (csPolygonRange (1, 5), cube_tex_wall_mw);
        cube_state->SetPolygonTextureMapping (csPolygonRange (1, 5), 1);

        cube_state->SetPolygonMaterial (csPolygonRange (0, 0), cube_tex_mw);
        cube_state->SetPolygonTextureMapping (csPolygonRange (0, 0),
                        csVector2 (0, 0),
                        csVector2 (1, 0),
                        csVector2 (1, 1)
                        );

        // It's training in moving a mesh

        csRef<iMovable> cube_movable = cube->GetMovable ();
        /*
        csReversibleTransform empty_one;
        empty_one.RotateThis (csVector3 (0, 1, 0), 0.7853);
        cube_movable->SetTransform (cube_movable->GetTransform ().This2Other (
                                &csVector3 (0, 1, 0)));

        */
        /*
        cube_movable->GetTransform ().RotateThis (
                        cube_movable->GetTransform ().Other2This (csVector3 (0, 1, 0)), 0.7853);
        */
        cube_movable->UpdateMove ();

        // Add lights to be able to see something

        csColliderHelper::InitializeCollisionWrappers (cd_sys, engine);

        csRef<iLight> light;
        iLightList *light_list = room->GetLights ();
        light = engine->CreateLight (0, csVector3 (0, 8, 0), 50, csColor (1, 1, 1));
        light_list->Add (light);
}
- - - -
Logged

kornerr
Full Member
***
Posts: 101


347968356
View Profile WWW Email
« Reply #23 on: April 04, 2006, 05:46:21 am »

jorrit, why do you ask me to show the entire code and don't say a word then? :)

The problem was in
Code:
csRef<csColliderWrapper> col_walls = csColliderHelper::InitializeCollisionWrapper (cd_sys, walls);
There's no need to do it, since later in code I do
Code:
csColliderHelper::InitializeCollisionWrappers (cd_sys, engine);
Logged

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


View Profile
« Reply #24 on: April 04, 2006, 07:21:14 am »

jorrit, why do you ask me to show the entire code and don't say a word then? Smiley

Well give me a chance to sleep from time to time smiley

Quote
The problem was in
Code:
csRef<csColliderWrapper> col_walls = csColliderHelper::InitializeCollisionWrapper (cd_sys, walls);
There's no need to do it, since later in code I do
Code:
csColliderHelper::InitializeCollisionWrappers (cd_sys, engine);

Ok.

Greetings,
Logged
Pages: 1 [2] 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 4.155 seconds with 15 queries.