About Store Forum Documentation Contact



Post Reply 
Destructible Objects
Author Message
darkking Offline
Member

Post: #1
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
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #2
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
Find all posts by this user Quote this message in a reply
darkking Offline
Member

Post: #3
RE: Destructible Objects
But, how to load all elements to this class ?
12-26-2010 08:01 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #4
RE: Destructible Objects
there is an available World "destructible.world", run it in World Editor
12-26-2010 08:17 PM
Find all posts by this user Quote this message in a reply
darkking Offline
Member

Post: #5
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
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #6
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
Find all posts by this user Quote this message in a reply
darkking Offline
Member

Post: #7
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
Find all posts by this user Quote this message in a reply
Harton Offline
Member

Post: #8
RE: Destructible Objects
Code:
Game::ObjMemx<Game::Destructible> Items;
12-26-2010 09:42 PM
Visit this user's website Find all posts by this user Quote this message in a reply
darkking Offline
Member

Post: #9
RE: Destructible Objects
Ok, it's works smile thx smile
12-26-2010 10:01 PM
Find all posts by this user Quote this message in a reply
darkking Offline
Member

Post: #10
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
Find all posts by this user Quote this message in a reply
Harton Offline
Member

Post: #11
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
Visit this user's website Find all posts by this user Quote this message in a reply
darkking Offline
Member

Post: #12
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
Find all posts by this user Quote this message in a reply
Harry Offline
Member

Post: #13
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
Visit this user's website Find all posts by this user Quote this message in a reply
Harton Offline
Member

Post: #14
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:
Code:
T.toStatic();
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
Code:
T.toStatic();
everything run very well...
(This post was last modified: 12-29-2010 02:05 PM by Harton.)
12-29-2010 01:10 PM
Visit this user's website Find all posts by this user Quote this message in a reply
Harton Offline
Member

Post: #15
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
Visit this user's website Find all posts by this user Quote this message in a reply
Post Reply