Gamestudio Links
Zorro Links
Newest Posts
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/22/24 13:41
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
Change chart colours
by 7th_zorro. 05/11/24 09:25
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (AndrewAMD), 1,486 guests, and 10 spiders.
Key: Admin, Global Mod, Mod
Newest Members
AemStones, LucasJoshua, Baklazhan, Hanky27, firatv
19055 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Pendelumn #188423
03/14/08 16:36
03/14/08 16:36
Joined: Aug 2006
Posts: 96
Netherlands
P
Polypfreak1987 Offline OP
Junior Member
Polypfreak1987  Offline OP
Junior Member
P

Joined: Aug 2006
Posts: 96
Netherlands
Hello everybody,

I am trying to make a pendelumn with physics. I am almost ready. But the problem is that the axis is very weird. The axis is not at the top, but at the bottom. How do I set the axis at the top? Now it swings not to the top, but to the ground.

This is the code of the pendelumn:

Code:

var earthGravity[3] = 0,0,190;
var klepel1;

action klepel {
klepel01 = my;
my.passable = on;
my.z = 190;
my.x = 0;
my.y = -10;
my.scale_x = 0.560;
my.scale_y = 0.560;
my.scale_z = 0.560;

//Physics on
phent_settype(my,PH_RIGID,PH_BOX);
//Set a weight
phent_setmass(my,23,PH_BOX);
//Set a friction
phent_setfriction(my,25);
//Set a damping
phent_setdamping(my,0,0);
//Set a gravity
ph_setgravity(earthGravity);

klepel1 = phcon_add(PH_HINGE,my,steun1);
phcon_setparams1(klepel1,my.y,vector(0,190,0),nullvector);
phcon_setparams2(klepel1,vector(-120,120,0),nullvector,nullvector);

while(my) {
vec_for_vertex(temp,steun1,588);
phcon_setmotor(klepel1,vector(0,190,0),nullvector,nullvector);
//phent_addvelcentral(my,vector(my.x,my.y,my.z));

if(key_cur == 1)//right key is pressed
{
phent_addtorquelocal (my,vector(0,100,0));
}
if(key_cul == 1)//left key is pressed
{
phent_addtorquelocal (my,vector(0,-100,0));
}
/*my.tilt += swing;
if(key_cur == 1) {
if(swing < 120) {
swing += 1*time_step;
}
}
if(key_cul == 1) {
if(swing > -120) {
swing -= 1*time_step;
}
}*/

wait(1);
}
}



Thanks in advance.

Re: Pendelumn [Re: Polypfreak1987] #188424
03/14/08 19:36
03/14/08 19:36
Joined: Oct 2002
Posts: 799
Germany->Bavaria->Nuremberg
C
Christian__A Offline
User
Christian__A  Offline
User
C

Joined: Oct 2002
Posts: 799
Germany->Bavaria->Nuremberg
It looks like the "center" or your klepel1-mdl is not where i should be (the point, where it should be fixed). You can correct this easy in MED by moving the whole model.

Last edited by Christian__A; 03/14/08 19:37.

MfG, Christian__A. Visit my Site: www.chris-a.de


Re: Pendelumn [Re: Christian__A] #188425
03/16/08 20:00
03/16/08 20:00
Joined: Aug 2006
Posts: 96
Netherlands
P
Polypfreak1987 Offline OP
Junior Member
Polypfreak1987  Offline OP
Junior Member
P

Joined: Aug 2006
Posts: 96
Netherlands
Quote:

It looks like the "center" or your klepel1-mdl is not where i should be (the point, where it should be fixed). You can correct this easy in MED by moving the whole model.



Thanks, that was the problem

Re: Pendelumn [Re: Polypfreak1987] #188426
03/17/08 19:22
03/17/08 19:22
Joined: Aug 2006
Posts: 96
Netherlands
P
Polypfreak1987 Offline OP
Junior Member
Polypfreak1987  Offline OP
Junior Member
P

Joined: Aug 2006
Posts: 96
Netherlands
Sorry for the double post, but I encounter a new problem. It is about the same simulation.

But I had add a new entity to it. And I want to move it with the end (underside of the model that swings) "klepel"-model. It is going quite good now. But if the "klepel" is coming 90 degrees, the attached model is rotating away. The "klepel"-model swings to a maximum of 120 degrees.

This is the code untill now (the attached model is named "kruis"):
Code:

// level.wdl
string level_str = <level.WMB>;

var swing;
var video_mode = 7;
var video_depth = 32;
var earthGravity[3] = 0,0,-368;
var klepel1;

function main()
{
bg_color.red = 10;
bg_color.green = 10;
bg_color.blue = 10; // Achtergrondkleur lichtzwart
//laad het level
level_load(level_str);
}

entity* steun1;
entity* klepel01;
entity* kruis1;

action kruis {
kruis1 = my;
my.passable = on;
my.scale_x = 0.600;
my.scale_y = 0.600;
my.scale_z = 0.600;

while(my) {
vec_for_vertex(temp,klepel01,567);

my.x = temp.x;
my.y = temp.y;
my.z = temp.z;
my.tilt = klepel01.tilt;

//c_rotate(my,vector(0,0,0),USE_AXIS);

wait(1);
}
}

action klepel {
klepel01 = my;
my.passable = on;

vec_for_vertex(temp,my,567);
ent_create("gondelkruis.mdl",temp,kruis);

//my.x = temp.x-10;
my.scale_x = 0.600;
my.scale_y = 0.600;
my.scale_z = 0.600;

//Physics on
phent_settype(my,PH_RIGID,PH_BOX);
//Set a weight
phent_setmass(my,23,PH_BOX);
//Set a friction
phent_setfriction(my,100);
//Set a damping
phent_setdamping(my,45,10);
//Set a gravity
ph_setgravity(earthGravity);

klepel1 = phcon_add(PH_HINGE,my,steun1);
phcon_setparams1(klepel1,vector(0,190,190),vector(0,190,0),nullvector);
phcon_setparams2(klepel1,vector(-120,120,0),nullvector,nullvector);

while(my) {
vec_for_vertex(temp,steun1,588);
phcon_setmotor(klepel1,vector(10,50,0),nullvector,nullvector);

if(key_cur == 1)//right key is pressed
{
phent_addtorquelocal (my,vector(0,-45,0));
}
if(key_cul == 1)//left key is pressed
{
phent_addtorquelocal (my,vector(0,45,0));
}

wait(1);
}
}

action steun01 {
steun1 = my;
vec_for_vertex(temp,my,588);
ent_create("draaiarm.mdl",temp,klepel);
}



Thanks in advance for help.

Last edited by Polypfreak1987; 03/17/08 19:23.

Moderated by  HeelX, Spirit 

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