Gamestudio Links
Zorro Links
Newest Posts
Trading Journey
by howardR. 04/28/24 09:55
Zorro Trader GPT
by TipmyPip. 04/27/24 13:50
Help with plotting multiple ZigZag
by M_D. 04/26/24 20:03
Data from CSV not parsed correctly
by jcl. 04/26/24 11:18
M1 Oversampling
by jcl. 04/26/24 11:12
Why Zorro supports up to 72 cores?
by jcl. 04/26/24 11:09
Eigenwerbung
by jcl. 04/26/24 11:08
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (AndrewAMD, Nymphodora), 485 guests, and 3 spiders.
Key: Admin, Global Mod, Mod
Newest Members
wandaluciaia, Mega_Rod, EternallyCurious, howardR, 11honza11
19049 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
[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
M
msl_manni Offline OP
Senior Member
msl_manni  Offline OP
Senior Member
M

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
M
msl_manni Offline OP
Senior Member
msl_manni  Offline OP
Senior Member
M

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: msl_manni] #153904
09/14/07 06:50
09/14/07 06:50
Joined: May 2002
Posts: 7,441
ventilator Offline
Senior Expert
ventilator  Offline
Senior Expert

Joined: May 2002
Posts: 7,441
i didn't test this earlier but now i noticed it too.

the problem is in newton_addentity():

printf("%d", body);
entity->skill99 = (long)body; // save body pointer with entity
printf("%d", entity->skill99);

lite-c does some strange automatic var conversion. you have to remove the (long).

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
M
msl_manni Offline OP
Senior Member
msl_manni  Offline OP
Senior Member
M

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: msl_manni] #153906
09/14/07 07:04
09/14/07 07:04
Joined: May 2002
Posts: 7,441
ventilator Offline
Senior Expert
ventilator  Offline
Senior Expert

Joined: May 2002
Posts: 7,441
please try:

NewtonDestroyBody(nworld, (NewtonBody*)my->skill99);
ent_remove(my);

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
M
msl_manni Offline OP
Senior Member
msl_manni  Offline OP
Senior Member
M

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 Offline
Senior Expert
ventilator  Offline
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] #153909
09/14/07 08:02
09/14/07 08:02
Joined: Dec 2005
Posts: 478
India
M
msl_manni Offline OP
Senior Member
msl_manni  Offline OP
Senior Member
M

Joined: Dec 2005
Posts: 478
India
Quote:


you can download a cleaned up version of my newton example





Thanks, your cleaned up version works perfectly. Just dont know why the previous version is giving errors .
Well thanks for the support.

A couple of things more if have them.

1. Player or enemy that can be controlled via newton so that they are always standing upright, only pan and gravity is affected of the newton body.

2. Ragdoll example.

Thanks again for your support.


My Specialities Limited.
Re: [NEWTON] Lite-C - How to destroy dynamic objec [Re: msl_manni] #153910
09/14/07 08:13
09/14/07 08:13
Joined: May 2002
Posts: 7,441
ventilator Offline
Senior Expert
ventilator  Offline
Senior Expert

Joined: May 2002
Posts: 7,441
for a player you have to use the up-vector joint. i will do examples for things like that but i don't know yet when i will have enough time.

for ragdolls i would wait for the next newton version. it will have a very cool physics driven character animation system. this won't only be useful for ragdolls but it also will automatically adapt the feet when walking up a slope or stair or rebalance the character when it gets pushed and so on.

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
M
msl_manni Offline OP
Senior Member
msl_manni  Offline OP
Senior Member
M

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.
Page 1 of 2 1 2

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1