Crystal Space
Welcome, Guest. Please login or register.
November 28, 2014, 09:58:13 am

Login with username, password and session length
Search:     Advanced search
9026 Posts in 2046 Topics by 9152 Members
Latest Member: Macinej
* Home Help Search Login Register
  Show Posts
Pages: 1 [2] 3 4 ... 6
16  Crystal Space Development / Support / Re: Multidimensional csArray ? on: February 22, 2008, 01:37:19 pm
Ah OK,

So it's not so much as a two dimensional array as it really is an array within an array huh.

Code:
enemyHealth.Push("40");
enemies.Push(enemyHealth.GetIndex(0));

Oh well, I can get it to compile but it crashes on an assertion when it runs. Guess I'll just stick to the tried and true normal array syntax Sad
17  Crystal Space Development / Support / Re: Multidimensional csArray ? on: February 22, 2008, 12:37:15 am
Thanks Smiley

Although now i'm having trouble putting data into the columns. where:
Code:
string column;
enemies.Push(column);

worked before, it says cannot convert parameter 1 from string to const array &

This works, but is just like normal array syntax:

Code:
enemies[1][0] = enemyName;

Is there anyway to still use the CS convenience functions of a csArray with a multidimensional array?
18  Crystal Space Development / Support / csRef<iPcLinearMovement>->SetFullPosition not placing the mesh correctly on: February 22, 2008, 12:32:06 am
It doesn't place the mesh at the passed in csVector3, it doesn't always seem to place the mesh at the same miscalculation either.

Any ideas?
19  Crystal Space Development / Support / Multidimensional csArray ? on: February 21, 2008, 08:13:18 pm
Is it possible to create a multidimensional csArray, like int array[][2] ? It looks like they were designed to be single dimensional only.

thanks!
20  Associate Projects / CEL Discussion / Re: Load between maps in CEL on: February 16, 2008, 12:13:58 am
Answer here:
http://www.crystalspace3d.org/forum/index.php/topic,1586.0.html
21  Crystal Space Development / Game Content Creation / Re: Rotate sprite 3d mesh in the factory file? on: February 13, 2008, 07:56:15 pm
Well it doesn't seem to exist, this will do it in code:

Code:
...
        muck1_entity = pl->FindEntity("box1");
csRef<iPcMesh> pcmesh = CEL_QUERY_PROPCLASS_ENT (muck1_entity, iPcMesh);
iMeshWrapper* mesh = pcmesh->GetMesh ();
csXRotMatrix3 x_muck2_rot (4.7f);
mesh->GetMovable ()->Transform(x_muck2_rot);
...
22  Crystal Space Development / Support / Re: Loading between maps and back again in CEL on: February 13, 2008, 07:17:46 pm
Figured it out!

Load the initial map:
Code:
bool Phage::LoadLevel ()
{
  LevelFlag = true;

  level_entity = pl->CreateEntity ("level", bl, "level_behave",
    "pcworld.zonemanager",
    CEL_PROPCLASS_END);
  if (!level_entity)
    return ReportError ("Error creating level entity!");

  // Now get the iPcZoneManager interface so we can setup the level.
  csRef<iPcZoneManager> zonemgr = CEL_QUERY_PROPCLASS_ENT (level_entity,
  iPcZoneManager);
  iCelZone* zone = zonemgr->CreateZone ("main");
  iCelRegion* region = zonemgr->CreateRegion ("main");
  zone->LinkRegion (region);

  iCelMapFile* mapfile = region->CreateMapFile ();
  mapfile->SetPath ("/lev/Phage_map1");
  mapfile->SetFile ("world");

  iCelMapFile* entitiesfile = region->CreateMapFile ();
  entitiesfile->SetPath ("/cellib/lev");
  entitiesfile->SetFile ("walktut_entities");

  return true;
}

Load the second map:
Code:
bool Phage::LoadLevel_Battle1()
{
float yrot;
iSector* sector;
LevelFlag = true;

#ifdef CS_DEBUG
Report (CS_REPORTER_SEVERITY_NOTIFY, "Attempting to load Battle 1 Map level ...");
#endif

// Create an entity for the battle map
battle_entity = pl->CreateEntity ("level", bl, "level_behave",
    "pcworld.zonemanager",
    CEL_PROPCLASS_END);

if (!battle_entity)
return ReportError ("Error creating level entity!");

  // Create a 2nd iPcZoneManager interface so we can setup the battle map
  csRef<iPcZoneManager> battle_zonemgr = CEL_QUERY_PROPCLASS_ENT (battle_entity,
  iPcZoneManager);
  iCelZone* battle_zone = battle_zonemgr->CreateZone ("Battle");
  iCelRegion* battle_region = battle_zonemgr->CreateRegion ("Battle");
  battle_zone->LinkRegion (battle_region);

// Create and load the battle map
iCelMapFile* battle_mapfile = battle_region->CreateMapFile ();
battle_mapfile->SetPath ("/lev/Phage_battle1");
battle_mapfile->SetFile ("world");

CamStartPos();

// Get the zone manager from the battle level entity
csRef<iPcZoneManager> pczonemgr = CEL_QUERY_PROPCLASS_ENT (battle_entity,
  iPcZoneManager);

// Set the camera to the new region in the battle map
pccamera->SetZoneManager(pczonemgr, true, "Battle", "Camera");

// Position our mesh in the new sector
pclinmove->GetLastPosition(pos, yrot, sector);
sector = engine->FindSector("Scene2");
pclinmove->SetPosition(pos, yrot, sector);

return true;
}

CamStartPos:
Code:
// Find a starting position
void Phage::CamStartPos()
{
  if (engine->GetCameraPositions ()->GetCount () > 0)
  {
  // There is a valid starting position defined in the level file.
iCameraPosition* campos = engine->GetCameraPositions ()->Get (0);
room = engine->GetSectors ()->FindByName (campos->GetSector ());
pos = campos->GetPosition ();
  }
  else
  {
// csPrintf("no start position");
// We didn't find a valid starting position. So we default
// to going to room called 'room' at position (0,0,0).
room = engine->GetSectors ()->FindByName ("room");
pos = csVector3 (0, 0, 0);
  }
  #ifdef CS_DEBUG
   if (!room)
ReportError("Can't find a valid starting position!");
#endif
}
23  Crystal Space Development / Support / Re: Loading between maps and back again in CEL on: February 13, 2008, 02:05:08 pm
OK, well I think I'm close.

Load the CEL map with code from walktut:

Code:
bool Phage::LoadLevel ()
{
  LevelFlag = true;

  level_entity = pl->CreateEntity ("level", bl, "level_behave",
    "pcworld.zonemanager",
    CEL_PROPCLASS_END);
  if (!level_entity)
    return ReportError ("Error creating level entity!");

  // Now get the iPcZoneManager interface so we can setup the level.
  csRef<iPcZoneManager> zonemgr = CEL_QUERY_PROPCLASS_ENT (level_entity,
  iPcZoneManager);
  iCelZone* zone = zonemgr->CreateZone ("main");
  iCelRegion* region = zonemgr->CreateRegion ("main");
  zone->LinkRegion (region);

  iCelMapFile* mapfile = region->CreateMapFile ();
  mapfile->SetPath ("/lev/Phage_map1");
  mapfile->SetFile ("world");

  iCelMapFile* entitiesfile = region->CreateMapFile ();
  entitiesfile->SetPath ("/cellib/lev");
  entitiesfile->SetFile ("walktut_entities");

  return true;
}

Create the player (consequently this creates the sector as well):

Code:
bool Phage::CreatePlayer ()
{
  player_entity = pl->CreateEntity ("player", bl, "player_behave",
    "pccamera.old",
    "pcobject.mesh",
    "pcmove.linear",
    "pcmove.actor.standard",
    "pcinput.standard",
    "pctools.inventory",
    CEL_PROPCLASS_END);
  if (!player_entity)
    return ReportError ("Error creating player entity!");

  // Get the iPcCamera interface so that we can set the camera.
  pccamera = CEL_QUERY_PROPCLASS_ENT (player_entity, iPcCamera);
  // Get the zone manager from the level entity which should have been created
  // by now.
  csRef<iPcZoneManager> pczonemgr = CEL_QUERY_PROPCLASS_ENT (level_entity,
  iPcZoneManager);
  pccamera->SetZoneManager (pczonemgr, true, "main", "Camera");

  // Get the iPcMesh interface so we can load the right mesh
  // for our player.
  csRef<iPcMesh> pcmesh = CEL_QUERY_PROPCLASS_ENT (player_entity, iPcMesh);
  pcmesh->SetPath ("/cellib/objects");
  pcmesh->SetMesh ("test", "cally.cal3d");
  if (!pcmesh->GetMesh ())
    return ReportError ("Error loading model!");

  if (pczonemgr->PointMesh ("player", "main", "Camera"))
return ReportError ("Can't find region or start position in region!");
 

  // Get iPcLinearMovement so we can setup the movement system.
  pclinmove = CEL_QUERY_PROPCLASS_ENT (player_entity,
  iPcLinearMovement);
  pclinmove->InitCD (
  csVector3 (0.5f,0.8f,0.5f),
  csVector3 (0.5f,0.4f,0.5f),
  csVector3 (0,0,0));

  // Get the iPcActorMove interface so that we can set movement speed.
  pcactormove = CEL_QUERY_PROPCLASS_ENT (player_entity, iPcActorMove);
  pcactormove->SetMovementSpeed (3.0f);
  pcactormove->SetRunningSpeed (5.0f);
  pcactormove->SetRotationSpeed (1.75f);
  pcactormove->SetMouseMoveSpeed(0.5f, 0.25f);

  // Get iPcCommandInput so we can do key bindings. The behaviour layer
  // will interprete the commands so the actor can move.
  csRef<iPcCommandInput> pcinput = CEL_QUERY_PROPCLASS_ENT (player_entity,
  iPcCommandInput);
  // We read the key bindings from the standard config file.
  pcinput->Bind ("w", "forward");
  pcinput->Bind ("s", "backward");
  pcinput->Bind ("q", "rotateleft");
  pcinput->Bind ("e", "rotateright");
  pcinput->Bind ("m", "cammode");
  pcinput->Bind ("d", "drop");
  pcinput->ScreenCoordinates(false);

  return true;
}

Attempt to load a new map and place the player within the new region:
Code:
bool Phage::LoadLevel_Battle1()
{
LevelFlag = true;
#ifdef CS_DEBUG
Report (CS_REPORTER_SEVERITY_NOTIFY, "Attempting to load Battle 1 Map level ...");
#endif

// Create an entity for the battle map
battle_entity = pl->CreateEntity ("level", bl, "level_behave",
    "pcworld.zonemanager",
    CEL_PROPCLASS_END);

if (!battle_entity)
return ReportError ("Error creating level entity!");

  // Create a 2nd iPcZoneManager interface so we can setup the battle map
  csRef<iPcZoneManager> battle_zonemgr = CEL_QUERY_PROPCLASS_ENT (battle_entity,
  iPcZoneManager);
  iCelZone* battle_zone = battle_zonemgr->CreateZone ("Battle");
  iCelRegion* battle_region = battle_zonemgr->CreateRegion ("Battle");
  battle_zone->LinkRegion (battle_region);

// Create and load the battle map
iCelMapFile* battle_mapfile = battle_region->CreateMapFile ();
battle_mapfile->SetPath ("/lev/Phage_battle1");
battle_mapfile->SetFile ("world");

// Get the zone manager from the level entity which should have been created
  // by now.
  csRef<iPcZoneManager> pczonemgr = CEL_QUERY_PROPCLASS_ENT (battle_entity,
  iPcZoneManager);

// Set the camera to the new region in the battle map
pccamera->SetZoneManager(pczonemgr, true, "Battle", "Camera");

// Position the 'player' entity in the new region in the battle map
if (pczonemgr->PointMesh ("player", "Battle", "Camera"))
return ReportError ("Can't find region or start position in region!");

return true;
}

It all works and loads up runs ok, but it doesn't look the new sector in the region is ever created. The mesh is never moved to the new map. I also saw some code in Planeshift similar to:
Code:
pclinmove->GetLastPosition(pos, yrot, sector);

sector = engine->FindSector("room1");
pclinmove->SetPosition(csVector3(2,5,0), yrot, sector);

But again, the new sector is never loaded so this doesn't work either.

Any ideas?
24  Crystal Space Development / Game Content Creation / Re: Loading CEL entities into a non-CEL level. on: February 13, 2008, 02:01:03 pm
Hmm OK, that makes more sense. I'll look through it later a bit and try to break into it. I think I'm actually pretty close to switching levels in CEL and I have it down pat for CS, I would be happy to post the code if you'd like.

Thanks for the help Smiley

EDIT - most of the code is actually here: http://www.crystalspace3d.org/forum/index.php/topic,1577.0.html

The only addition is to add

Code:
  view->GetCamera ()->SetSector (room);
  view->GetCamera ()->GetTransform ().SetOrigin (pos);

In the function that loads the second map so the camera is updated.
25  Crystal Space Development / Game Content Creation / Re: Loading CEL entities into a non-CEL level. on: February 12, 2008, 05:02:32 pm
Quote
i do create the level entity first:

Oh, well thank you for all the help so far Smiley I was able to get the monster entity to load but it wasn't sending any messages. I don't know if I didn't read the CEL doc's well enough or if it isn't explained in them. I'm trying to get around having to load a level entity or I need to figure out how to switch between levels using level entities. I don't know if the level entity causes entities to send messages or a player entity or the combination of both. Both when I load up a CEL entity into a CS level it doesn't send any messages.

Basically, in CS I load my player to a csColliderActor and initialize it to a camera, in this way when I use iLoader to load another map file, I just get the camera position in that level and set the camera at that point and I'm in the new level.

In CEL, I don't know how to unload the level entity, unload the monster entites, reload the level entity and set the CEL camera to the new map that is loaded.

Have any ideas on either lol ?

And thanks again Smiley
26  Crystal Space Development / Game Content Creation / Re: Loading CEL entities into a non-CEL level. on: February 12, 2008, 12:52:36 am
Wow this sounds great! Thanks Smiley I was able to get the monster to load properly but because my hero isn't a CEL entity it didn't receive any messages.

How are you creating the actor entity without a pre-existing level entity?

Thanks so much!
27  Crystal Space Development / Support / Loading between maps and back again in CEL on: February 08, 2008, 03:02:06 pm
Thanks Jorrit for the camera help on loading between maps in CS, is it possible to do the same in CEL without iLoader?

I load a map similar to the walktut, then later I try to remove that mapfile from the region, remove the regions and zone and create new ones to a new map file like so:

Code:
// Now get the iPcZoneManager interface so we can setup the level.
  region->RemoveMapFile(mapfile);
  zonemgr->RemoveAllRegions();
  zonemgr->RemoveAllZones();


  iCelZone* zone = zonemgr->CreateZone ("main");
  region = zonemgr->CreateRegion ("main");
  zone->LinkRegion (region);

iCelMapFile* battle_mapfile = region->CreateMapFile ();
battle_mapfile->SetPath ("/lev/phage_battle1");
battle_mapfile->SetFile ("world");



But the new map doesn't load, the old map doesn't unload for that matter as well.

What am I missing?

Thanks Smiley
28  Associate Projects / CEL Discussion / Load between maps in CEL on: February 07, 2008, 12:51:45 am
With the help of posters on the forums I have a good way of moving between maps in CS but I haven't gotten it yet with CEL.

I load a map similar to the walktut, then later I try to remove that mapfile from the region, remove the regions and zone and create new ones to a new map file like so:

Code:
// Now get the iPcZoneManager interface so we can setup the level.
  region->RemoveMapFile(mapfile);
  zonemgr->RemoveAllRegions();
  zonemgr->RemoveAllZones();


  iCelZone* zone = zonemgr->CreateZone ("main");
  region = zonemgr->CreateRegion ("main");
  zone->LinkRegion (region);

iCelMapFile* battle_mapfile = region->CreateMapFile ();
battle_mapfile->SetPath ("/lev/phage_battle1");
battle_mapfile->SetFile ("world");

But the new map doesn't load, the old map doesn't unload for that matter as well.

What am I missing?

Thanks Smiley
29  Crystal Space Development / Game Content Creation / Re: Loading CEL entities into a non-CEL level. on: February 05, 2008, 12:00:01 am
OK, well this works:
Code:
muck1_entity = pl->CreateEntity("Muck_ent", bl, "box_behave",
"pcobject.mesh",
//"pcmove.linear",
//"pcmove.actor.standard",
CEL_PROPCLASS_END);


pl->AttachEntity(muck1->QueryObject(), muck1_entity);
bl->CreateBehaviour(muck1_entity, "box_behave");
return true;

But for some reason, the entities don't seem to be sending messages. I'm trying to interact with a mesh but when I click on it, nothing happens like it does in the walktut tutorial. When are entity messages sent?

Thanks!
30  Crystal Space Development / Game Content Creation / Re: Loading CEL entities into a non-CEL level. on: February 04, 2008, 03:13:16 pm
Well it compiles ok now, but it crashes on trying to set the behaviour to the entity.

Create entity:
Code:
...
// Load Muck library
if(!loader->LoadLibraryFile  ("/lib/Muck/library"))
ReportError("Error loading 'Muck' library!");

csRef<iMeshFactoryWrapper> imeshfact_muck = engine->FindMeshFactory  ("spr3dSphere");
if(!imeshfact_muck)
{
csReport(object_reg, CS_REPORTER_SEVERITY_ERROR,
"crystalspace.Phage",
"Error loading mesh object factory!");
ReportError("Error loading mesh factory '%s' !");

return false;
}

csVector3 rot = (0,0,0);
csVector3 mot = (0,0,0);

csRef<iMeshWrapper> muck1 = (engine->CreateMeshWrapper (imeshfact_muck, "Muck A", room, csVector3(1,1,5)));
muck1->GetMovable ()->UpdateMove ();
muck1->SetZBufMode (CS_ZBUF_USE);
muck1->SetRenderPriority (engine->GetObjectRenderPriority ());

collider_muck1.SetCollideSystem (cdsys);
collider_muck1.SetEngine (engine);
csVector3 legs1 (.2f, .3f, .2f);
csVector3 body1 (.2f, 1.2f, .2f);
csVector3 shift1 (0, -2, 0);
collider_muck1.InitializeColliders (muck1,
legs1, body1, shift1);
//collider_muck1.EnableHitMeshes(true);
collider_muck1.SetOnGround(false);

muck_state1 = scfQueryInterface<iSprite3DState> (
muck1->GetMeshObject());

muck_state1->SetAction("Idle", true, 1.0f);
csVector3 muck1_rotate;
muck1_rotate = muck1->GetMovable()->GetFullPosition();
csXRotMatrix3 x_muck1_rot (4.7f);
muck1->GetMovable ()->Transform(x_muck1_rot);

collider_muck1.Move (((unsigned)time(0) / 1000.0f), 1.0f,
    (CS_VEC_FORWARD * 1.0f), rot);

// Attempt to create an entity from a mesh, per CEL manual:
iCelEntity* entity = pl->FindAttachedEntity (muck1->QueryObject ());
..

Which runs ok but when this runs to set the behaviour:
Code:
...
bl->CreateBehaviour(entity, "box_behave");
...

behave.cpp crashes on

Code:
iCelBehaviour* BehaviourLayer::CreateBehaviour (iCelEntity* entity,
const char* name)
{
  iCelBehaviour* behave = 0;

...
  if (behave)
  {
// Crashes on this line below
    entity->SetBehaviour (behave);
    // There is now a reference in the entity. We destroy
    // our own reference here.
    behave->DecRef ();
 

and the entity has a memory address of 0, so while it is initialized it seems like it isn't properly created, or fully created? Not sure how else to get a CEL entity from a standard CS mesh as the way above is how its described in the manual.

Thanks!
Pages: 1 [2] 3 4 ... 6
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 8.343 seconds with 16 queries.