Crystal Space
Welcome,
Guest
. Please
login
or
register
.
May 25, 2013, 08:36:05 pm
1 Hour
1 Day
1 Week
1 Month
Forever
Login with username, password and session length
Search:
Advanced search
9224
Posts in
2230
Topics by
5390
Members
Latest Member:
Okvepkke6
Crystal Space
Crystal Space Development
General Crystal Space Discussion
csColliderActor
« previous
next »
Pages:
1
[
2
]
Author
Topic: csColliderActor (Read 6897 times)
jorrit
Administrator
Hero Member
Posts: 1703
Re: csColliderActor
«
Reply #15 on:
April 03, 2006, 03:19:45 pm »
Quote from: kornerr on April 03, 2006, 03:06:06 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
Re: csColliderActor
«
Reply #16 on:
April 03, 2006, 03:22:34 pm »
Emm... what?
Logged
OSRPG (Open Source RPG)
CS Manual in Ru (will not be continued)
Open Source all the way, baby
jorrit
Administrator
Hero Member
Posts: 1703
Re: csColliderActor
«
Reply #17 on:
April 03, 2006, 03:27:01 pm »
Quote from: kornerr on April 03, 2006, 03:22:34 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
Re: csColliderActor
«
Reply #18 on:
April 03, 2006, 03:36:27 pm »
Can't find how to do it...
Logged
OSRPG (Open Source RPG)
CS Manual in Ru (will not be continued)
Open Source all the way, baby
jorrit
Administrator
Hero Member
Posts: 1703
Re: csColliderActor
«
Reply #19 on:
April 03, 2006, 03:41:14 pm »
Quote from: kornerr on April 03, 2006, 03:36:27 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
Re: csColliderActor
«
Reply #20 on:
April 03, 2006, 03:54:35 pm »
I added
Code:
csColliderHelper::InitializeCollisionWrappers (cd_sys, engine);
in CreateRoom with no result (
Logged
OSRPG (Open Source RPG)
CS Manual in Ru (will not be continued)
Open Source all the way, baby
jorrit
Administrator
Hero Member
Posts: 1703
Re: csColliderActor
«
Reply #21 on:
April 03, 2006, 03:55:58 pm »
Quote from: kornerr on April 03, 2006, 03:54:35 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
Re: csColliderActor
«
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
OSRPG (Open Source RPG)
CS Manual in Ru (will not be continued)
Open Source all the way, baby
kornerr
Full Member
Posts: 101
Re: csColliderActor
«
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
OSRPG (Open Source RPG)
CS Manual in Ru (will not be continued)
Open Source all the way, baby
jorrit
Administrator
Hero Member
Posts: 1703
Re: csColliderActor
«
Reply #24 on:
April 04, 2006, 07:21:14 am »
Quote from: kornerr 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?
Well give me a chance to sleep from time to time
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
]
« previous
next »
Jump to:
Please select a destination:
-----------------------------
Crystal Space Development
-----------------------------
=> General Crystal Space Discussion
=> Support
-----------------------------
Crystal Space Project Development
-----------------------------
=> Feature Requests
=> Plugins
=> Bug Reports
-----------------------------
Crystal Space Development
-----------------------------
=> Game Content Creation
-----------------------------
Miscellaneous
-----------------------------
=> Article/Tutorial Requests
=> Article/Tutorial Discussion
-----------------------------
Crystal Space Project Development
-----------------------------
=> Development Discussion
-----------------------------
Crystal Space Projects
-----------------------------
=> Project Discussion
=> WIP Projects
=> Finished Projects
-----------------------------
Associate Projects
-----------------------------
=> CEL Discussion
=> Crystal Core Discussion
=> CrystalBlend Discussion
-----------------------------
Crystal Space Project Development
-----------------------------
=> Google Summer of Code
-----------------------------
Associate Projects
-----------------------------
=> Apricot (Open Game)
=> Ares Project
Loading...