|
3 registered members (Martin_HH, TipmyPip, Quad),
6,658
guests, and 5
spiders. |
|
Key:
Admin,
Global Mod,
Mod
|
|
|
[NEWTON] Lite-C - How to destroy dynamic objects.
#153902
09/13/07 15:50
09/13/07 15:50
|
Joined: Dec 2005
Posts: 478 India
msl_manni
OP
Senior Member
|
OP
Senior Member
Joined: Dec 2005
Posts: 478
India
|
Hi, I am having problems regarding removing dynamic objects in Newton. Please help. Bye, MSL.
My Specialities Limited.
|
|
|
Re: [NEWTON] Lite-C - How to destroy dynamic objects.
[Re: msl_manni]
#153903
09/14/07 06:05
09/14/07 06:05
|
Joined: Dec 2005
Posts: 478 India
msl_manni
OP
Senior Member
|
OP
Senior Member
Joined: Dec 2005
Posts: 478
India
|
Code:
void d_func() { my.skill10 = 100; while(my.skill10 > 0) { my.skill10 -= 1; wait(1); } NewtonDestroyBody(nworld, my.skill99); ent_remove(me); }
void fireentity() { you = ent_create("ball.mdl", &v, d_func); NewtonBody *body = newton_addentity(you, 10, currentcollisiontype, onforceandtorque); // register entity as physics entity } I try to remove the dynamic object from the Newton world after 100 waits, but it gives me crash error and the object is still there.
My Specialities Limited.
|
|
|
Re: [NEWTON] Lite-C - How to destroy dynamic objec
[Re: ventilator]
#153905
09/14/07 07:01
09/14/07 07:01
|
Joined: Dec 2005
Posts: 478 India
msl_manni
OP
Senior Member
|
OP
Senior Member
Joined: Dec 2005
Posts: 478
India
|
Changed
entity->skill99 = (long)body; // save body pointer with entity to entity->skill99 = body; // save body pointer with entity but it still crashes with the above code and the object is still there.
My Specialities Limited.
|
|
|
Re: [NEWTON] Lite-C - How to destroy dynamic objec
[Re: ventilator]
#153907
09/14/07 07:17
09/14/07 07:17
|
Joined: Dec 2005
Posts: 478 India
msl_manni
OP
Senior Member
|
OP
Senior Member
Joined: Dec 2005
Posts: 478
India
|
Error E1513 crash in d_func
It still crashes with the above error message when it tries to destroy the newton body.
My Specialities Limited.
|
|
|
Re: [NEWTON] Lite-C - How to destroy dynamic objec
[Re: msl_manni]
#153908
09/14/07 07:27
09/14/07 07:27
|
Joined: May 2002
Posts: 7,441
ventilator
Senior Expert
|
Senior Expert
Joined: May 2002
Posts: 7,441
|
hm... this works for me (after i have removed the (long)): Code:
void test_remove() { wait(-3); NewtonDestroyBody(nworld, (NewtonBody*)my->skill99); ent_remove(my); }
void fireentity() { var power = 0; while(mouse_left) // power depends on how long you hold the mouse button { power = clamp(power + time_step, 0, 25); draw_line(vector(10, 40, 0), 0, 100); draw_line(vector(10, 40, 0), vector(255,255,255), 100); draw_line(vector(10 + power * 5, 40, 0), vector(255,255,255), 100); wait(1); } VECTOR v; vec_set(&v, vector(100, 0, 0)); vec_rotate(&v, &camera->pan); vec_add(&v, &camera->x); switch(currentcollisiontype) { case NEWTON_SPHERE: you = ent_create("ball.mdl", &v, test_remove); break; case NEWTON_BOX: you = ent_create("crate.mdl", &v, NULL); break; [...]
i use the newest free lite-c version. btw. you can download a cleaned up version of my newton example here.
|
|
|
Re: [NEWTON] Lite-C - How to destroy dynamic objec
[Re: ventilator]
#153911
09/14/07 08:29
09/14/07 08:29
|
Joined: Dec 2005
Posts: 478 India
msl_manni
OP
Senior Member
|
OP
Senior Member
Joined: Dec 2005
Posts: 478
India
|
I will try to see the c-examples of Newton for up-vector examples, dont know if I will be able to translate it to LiteC. Please at-least do the up-vector example, for the ragdoll we can wait for the new addition.
One thing else is how do we know about collision response for an object when it is colliding. Say I fire a bullet and when it collides with anything then I would like it to be removed immediately and respond to colliding object also.
My Specialities Limited.
|
|
|
|