About Store Forum Documentation Contact



Post Reply 
[solved] cskel doesn't exist
Author Message
PRG3D Offline
Member

Post: #1
[solved] cskel doesn't exist
Hi,

I've a problem. In my game is turrent, and car. Turrent have weapon, and fire to player. Weapon is animated when shoot. When I drive far away and then back my game is crashed, because don't have pooint in cskel. I understand object is deleted, but when is created again, why cskel does not exist?

Code in turrent.create()
Code:
__super::create(obj);
    cskel.create(Skeletons("obj/Mechs/turrent/0.skel")).clear().updateMatrix(MatrixIdentity).updateVelocities();

//bron
weapon.create(WEAPON_SIMPLE,0);

in turrent.animate()
Code:
// ...
OrientP *point;
point = cskel.findPoint("wep0");
trans*=Matrix().setPos(point->pos);
weapon.animate(trans);

and in weapon create and animate
Code:
Bool Weapon::create(WEAPON_TYPE type,Int whereMount)
{
    mount = whereMount;

    mesh = Meshes    ("Obj/Weapons/0.mesh");
    cskel.create    (mesh->skeleton());

    return true;
}

void Weapon::animate(Matrix transform)
{
    //transformacja
    cskel.clear();

    cskel.animate(L"Anim/Weapons/0.anim",(Time.time()-fireLast));

    cskel.updateMatrix(transform);
    cskel.updateVelocities();
}
(This post was last modified: 06-04-2011 03:32 PM by PRG3D.)
06-03-2011 09:52 AM
Find all posts by this user Quote this message in a reply
Driklyn Offline
Member

Post: #2
RE: cskel doesn't exist
Objects do not get created again. You need to execute the same code in Game::Obj::load() method.

PHP Code:
void Turret::create(Game::ObjParams &obj)
{
    
__super::create(obj);
    
create();
}

void Turret::create()
{
    
cskel.create(Skeletons("obj/Mechs/turrent/0.skel")).clear().updateMatrix(MatrixIdentity).updateVelocities();

    
//bron
    
weapon.create(WEAPON_SIMPLE,0);
}

void Turret::save(File &f)
{
    
__super::save(f);
    
// optionally save anything here that needs to be saved
}

Bool Turret::load(File &f)
{
    if (!
__super::load(f)) return false;

    
create();
    return 
true;

06-03-2011 08:43 PM
Find all posts by this user Quote this message in a reply
PRG3D Offline
Member

Post: #3
RE: cskel doesn't exist
Wow, I'm so stupid.. Thanks smile.
06-04-2011 09:16 AM
Find all posts by this user Quote this message in a reply
Post Reply