darkking
Member
|
Destructible Objects
Hi !
How to do any object destructible ?
I load all destructible objects with this:
Code:
.setObjType(Items,OBJ_DESTRUCTIBLE)
But, what next ?
|
|
12-26-2010 07:36 PM |
|
Esenthel
Administrator
|
RE: Destructible Objects
you need to use Game::Destructible class, and pre-generate destructible mesh in Model Editor\Destructible mode
|
|
12-26-2010 07:52 PM |
|
darkking
Member
|
RE: Destructible Objects
But, how to load all elements to this class ?
|
|
12-26-2010 08:01 PM |
|
Esenthel
Administrator
|
RE: Destructible Objects
there is an available World "destructible.world", run it in World Editor
|
|
12-26-2010 08:17 PM |
|
darkking
Member
|
RE: Destructible Objects
I create custom scene with destructible object but how to load it in my project ?
I wrote this:
In head of code:
Code:
Game::ObjMemx<Destructible> Items;
In Init:
Code:
.setObjType(Items,OBJ_DESTRUCTIBLE)
But what in Update ? Sory, but I don't know.
|
|
12-26-2010 09:02 PM |
|
Esenthel
Administrator
|
RE: Destructible Objects
no need to do anything, just check that provided world has custom parameter for destructible object - path for .destruct file
|
|
12-26-2010 09:09 PM |
|
darkking
Member
|
RE: Destructible Objects
Objects has this parameters but i have error:
Quote:error C2065: 'Destructible' : undeclared identifier
This is it:
Game::ObjMemx<Destructible> Items;
|
|
12-26-2010 09:34 PM |
|
Harton
Member
|
RE: Destructible Objects
Code:
Game::ObjMemx<Game::Destructible> Items;
|
|
12-26-2010 09:42 PM |
|
darkking
Member
|
RE: Destructible Objects
Ok, it's works thx
|
|
12-26-2010 10:01 PM |
|
darkking
Member
|
RE: Destructible Objects
Sory... bu I have again problem :/
How to do this:
Mesh must change to destructible object when any physic i active on him.
PL:
Mesh musi zamienić się w zniszczalny wtedy gdy jakaś siła na niego działa.
|
|
12-28-2010 09:52 PM |
|
Harton
Member
|
RE: Destructible Objects
hmm...
In function ' create' set object as static and when you detect collision set as destructible. Use the functions:
Code:
Game::Destructible barrel;
barrel.toStatic();
barrel.toPieces();
(This post was last modified: 12-28-2010 10:39 PM by Harton.)
|
|
12-28-2010 10:38 PM |
|
darkking
Member
|
RE: Destructible Objects
It works but when I create new world:
Code:
if(Kb.b(KB_R ))Game::World.New("world/game.world");
it doesn't work.
My code in function Update:
Code:
REPA(Items)
{
Items[i].toStatic();
}
|
|
12-29-2010 11:20 AM |
|
Harry
Member
|
RE: Destructible Objects
I think that toStatic you should put in Create not Update as Harton wrote.
(This post was last modified: 12-29-2010 01:00 PM by Harry.)
|
|
12-29-2010 12:59 PM |
|
Harton
Member
|
RE: Destructible Objects
Harry Wrote:I think that toStatic you should put in Create not Update as Harton wrote.
Harton Wrote:In function 'create' set object as static
Code:
// in MyDestructible.h
class MyDestructible : public Game::Destructible
{
virtual void create (Game::ObjParams &obj);
virtual Bool update ();
// other functions
};
// in MyDestructible.cpp
void MyDestructible::create(Game::ObjParams &obj)
{
__super::create(obj);
T.toStatic();
}
Bool MyDestructible::update()
{
// probably
REPA(T.actors)
if(T.actors[i].collision())
T.toPieces();
}
I checked my code and found error...
I have :
Code:
class Spell : public PhysCutsCallback
{
public:
Bool hit (Int group, Ptr user, Game::Obj *obj);
Bool update ()
Actor tester_shape;
//...
};
Bool Spell::hit(Int group, Ptr user, Game::Obj *obj)
{
// ...
if(obj && (obj->type() == OBJ_DESTRUCTIBLE))
{
G::Destruct* target = static_cast<G::Destruct*>(obj);
target->toPieces();
}
// ...
return true;
}
Bool Spell::update()
{
switch(type)
{
case E::SPELL_1:
particle.matrix = tester_shape.matrix();
particle.update();
particle2.matrix = tester_shape.matrix();
particle2.update();
tester_shape.cuts(*this);
break;
}
// ...
}
and I have a class MyDestructible presented in the post above.
When I add line:
in function create in class MyDestructible, game is crashs and debugger shows error in line
Code:
tester_shape.cuts(*this);
in function update, in class Spell.
When I remove line
everything run very well...
(This post was last modified: 12-29-2010 02:05 PM by Harton.)
|
|
12-29-2010 01:10 PM |
|
Harton
Member
|
RE: Destructible Objects
Anyone knows what is wrong in my code? Because for me it is correct...
(This post was last modified: 12-30-2010 12:47 AM by Harton.)
|
|
12-30-2010 12:46 AM |
|