Gamestudio Links
Zorro Links
Newest Posts
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 05:41
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (AbrahamR, AndrewAMD), 1,278 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Wave Swinger gondela #260505
04/11/09 14:48
04/11/09 14:48
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,

I am making a fairground ride (Star Flyer (like a very big Wave Swinger)). Now I am at the gondela's. The center piece is rotating around his Z-axis. But now I have to swing the gondela's wich is depends on the speed of the rotation they need to swing at the X-axis. How do I do this?

I have the following code in my gondela action, but it doesn't work.

Code:
action gondel01 {
	gondel1 = my;
	my.passable = on;
	
	phent_settype(my,PH_RIGID,PH_SPHERE);
	phent_setmass(my,1,PH_SPHERE);
	phent_setdamping(my,0,30);
	phent_setfriction(my,10);
	
	phent_setgroup(my,2);
	
	cmolen = phcon_add(PH_HINGE,my,molen_arm);
	phcon_setparams1(cmolen,my.x,vector(1,0,0),nullvector);
	phcon_setparams2(cmolen,vector(-360,360,0),nullvector,nullvector);
	
	while(my) {
		vec_for_vertex(temp,molen_arm,460);
		
		
		my.x = temp.x;
		my.y = temp.y;
		my.z = temp.z;
	
		my.pan = molen_arm.pan+190;
		
		wait(1);
	}
}


Earth gravity is the following code:

Code:
var earthgravity[3] = 0,0, -386;


And this is the main function:

Code:
function main()
{
	//laad het level
	level_load(level_str);
	//video_set(sys_metrics(0),sys_metrics(1),32,1);
	ph_setgravity(earthgravity);
	ph_selectgroup(2);
}


If you don't know waht a Star Flyer is, just look at the following movie:

http://www.youtube.com/watch?v=oDZYJD460ss

It is about the gondela's wich are swinging out when the ride is going to rotate.

Thanks in advanace for your help.

Re: Wave Swinger gondela [Re: Polypfreak1987] #261232
04/16/09 13:40
04/16/09 13:40
Joined: Jun 2008
Posts: 151
Ukraine
XD1v0 Offline
Member
XD1v0  Offline
Member

Joined: Jun 2008
Posts: 151
Ukraine
Polypfreak1987 I have code, He does what you want to do, sorry I can not explain how it works because my english is bad.
Source
Code:
 ///////////////////////////////
#include <acknex.h>
#include <default.c>
///////////////////////////////

ENTITY* gondela_ph=NULL;
var gcon;

action gondela ()
{
	phent_settype (my,PH_RIGID,PH_BOX);
	phent_setmass(my,1,PH_SPHERE);
	gcon = phcon_add(PH_HINGE,my,NULL);
	phcon_setparams1(gcon,my.x,vector(0,0,1),nullvector);
	phcon_setparams2(gcon,vector(-360,360,0),nullvector,nullvector);
	gondela_ph = my;
}

action fun_sp ()
{
	var con;
	VECTOR aang;
	while(!gondela_ph) wait(1);
	phent_settype (my,PH_RIGID,PH_SPHERE);
	phent_setmass(my,1,PH_SPHERE);
	con = phcon_add(PH_HINGE,my,gondela_ph);
	
	//now find rotate axis 
	vec_set(aang,gondela_ph.x);vec_sub (aang,my.x);vec_normalize(aang,1);
	//
	phcon_setparams1(con,vector(my.x,my.y,gondela_ph.z),vector(aang.x,aang.y,0),nullvector);
	phcon_setparams2(con,vector(-360,360,0),nullvector,nullvector);
}
void main ()
{
	level_load ("map.wmb");
	ph_setgravity (vector(0,0,-300));
	while(!gondela_ph) wait(1);
	while (1)
	{
		phcon_setmotor (gcon,vector(3,50,0),nullvector,nullvector);
		wait(1);
	}
}



A7 Commercial cool
Celeron 1700, GeForce 5500 FX 256mb, 1 Gb Ram
Re: Wave Swinger gondela [Re: XD1v0] #261552
04/18/09 13:36
04/18/09 13: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,

Thank you. You help me to the right position. But I have a (small?) problem. I have made some little changes in you script. (also in the sample you gave to me wich is still working great). But I have the following problem.

When I want to rotate the arm-entity (at your sample gondela_ph) the gondela's don't swing out the right way (See this link). They don't swing to the outside, but backwards (looks like the X-axis). This is the script right now, I use C-Script, not C-Lite.

Swinging gondela code
Code:
function swing_gondela() {
	var con;
	var aang[3];
	while(!molen_arm) {
		wait(1);
	}
	
	phent_settype(my,PH_RIGID,PH_SPHERE);
	phent_setmass(my,1,PH_SPHERE);
	con = phcon_add(PH_HINGE,my,molen_arm);
	
	vec_set(aang,molen_arm.x);
	vec_sub(aang,my.x);
	vec_normalize(aang,1);
	
	phcon_setparams1(con,vector(my.x,my.y,molen_arm.z),vector(aang.x,aang.y,0),nullvector);
	phcon_setparams2(con,vector(-360,360,0),nullvector,nullvector);
}


Arm-code
Code:
action molen {
	
	my.passable = on;
	
	phent_settype(my,PH_RIGID,PH_BOX);
	phent_setmass(my,1,PH_SPHERE);
	gcon = phcon_add(PH_HINGE,my,NULL);
	phcon_setparams1(gcon,my.x,vector(0,0,1),nullvector);
	phcon_setparams2(gcon,vector(-360,360,0),nullvector,nullvector);
	molen_arm = my;
}


Main-code at the bottom of the script.
Code:
function main()
{
	//laad het level
	level_load(level_str);
	ph_setgravity(vector(0,0,-3000));
	while(!molen_arm) {
		wait(1);
	}
	while(1) {
		phcon_setmotor(gcon,vector(3,10,0),nullvector,nullvector);
		
		wait(1);
	}
	//video_set(sys_metrics(0),sys_metrics(1),32,1);
}


I hope you can help me.

Thanks in advance.

Kind regards,

Polypfreak1987

Re: Wave Swinger gondela [Re: Polypfreak1987] #261603
04/18/09 20:01
04/18/09 20:01
Joined: Jun 2008
Posts: 151
Ukraine
XD1v0 Offline
Member
XD1v0  Offline
Member

Joined: Jun 2008
Posts: 151
Ukraine
so you using C-Script smirk , for me very difficult write on C-Script, but i try
there we go

Code:
entity* molen_arm;
var gcon;

action swing_gondela {
	var con;
	var aang[3];
	while(molen_arm==null) {
		wait(1);
	}
	
	phent_settype(my,PH_RIGID,PH_SPHERE);
	phent_setmass(my,1,PH_SPHERE);
	con = phcon_add(PH_HINGE,my,molen_arm);
	
	vec_set(aang,molen_arm.x);
	vec_sub(aang,my.x);
	vec_normalize(aang,1);
	vec_rotate(aang,vector(90,0,0));// there is error, i just forget rotate axis in previous code :p
	
	phcon_setparams1(con,vector(my.x,my.y,molen_arm.z),vector(aang.x,aang.y,0),nullvector);
	phcon_setparams2(con,vector(-360,360,0),nullvector,nullvector);
	
	//debug
	var pos[3];
	vec_set(pos,vector(my.x,my.y,molen_arm.z));
	while (1)
	{
		vec_set(aang,pos);vec_rotate(aang,molen_arm.pan);
		draw_line3d(aang,NULL,100);draw_line3d(my.x,vector(0,0,255),100);
		wait(1);
	}
}


action molen {
	
	my.passable = on;
	
	phent_settype(my,PH_RIGID,PH_BOX);
	phent_setmass(my,1,PH_SPHERE);
	gcon = phcon_add(PH_HINGE,my,NULL);
	phcon_setparams1(gcon,my.x,vector(0,0,1),nullvector);
	phcon_setparams2(gcon,vector(-360,360,0),nullvector,nullvector);
	molen_arm = my;
	
	
}
function main ()
{
	level_load ("map.wmb");
	ph_setgravity (vector(0,0,-300));
	while(molen_arm==null) {wait(1);}
	while (1)
	{
		phcon_setmotor (gcon,vector(3,10,0),nullvector,nullvector);
		wait(1);
	}
}


Last edited by XD1v0; 04/18/09 20:17.

A7 Commercial cool
Celeron 1700, GeForce 5500 FX 256mb, 1 Gb Ram
Re: Wave Swinger gondela [Re: XD1v0] #261642
04/19/09 05:59
04/19/09 05:59
Joined: Aug 2006
Posts: 96
Netherlands
P
Polypfreak1987 Offline OP
Junior Member
Polypfreak1987  Offline OP
Junior Member
P

Joined: Aug 2006
Posts: 96
Netherlands
Thank you very much. That did it. It works. laugh


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