Funfair Simulation

Posted By: Dreher

Funfair Simulation - 04/07/09 22:59

Hello, I'm new here, and also new to scripting!

Alrightio! - I've been modelling 'Fun Fair Attracties' for a few months now (Within SketchUp), and I want to script them within 3D Game Studio (A7).

Ok, so, it seems nothing *too* advanced probably, but thats all I want to do, so no RPG's or shooters or anything complicated! wink

Here is a link to a YouTube clip I recorded within SketchUp:

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

What I want to do is, let my model do the same thing it does within SketchUp with SketchyPhysics! (Seen in the clip), and then make it a application.

Is it easy to script these kind of things, or is it still pretty much complicated?

Thanks in advance! laugh
Posted By: Nicotin

Re: Funfair Simulation - 04/07/09 23:10

I think it is relativly easy. For a beginner pretty hard thought, because you have to use vector calculations.
Posted By: silencer

Re: Funfair Simulation - 04/07/09 23:20

I like the idea, and I don't think it would be extremely difficult to do.
Posted By: Dreher

Re: Funfair Simulation - 04/07/09 23:21

Originally Posted By: Nicotin
I think it is relativly easy. For a beginner pretty hard thought, because you have to use vector calculations.


I see, well I'm totally new but I don't want to give up before I even tried, and I want to get this done anyway
Posted By: Nicotin

Re: Funfair Simulation - 04/07/09 23:46

Okay, some tips (I can't give you more right now because I'd have to look a long time myself smile )

Look for "c_rotate" in the manual for the rotating platform and the single cars.
Then look for vec_rotate to rotate the cars around the center of the platform.

Sorry, my englisch isn't that good. I hope you can unserstand me thought.
I'll take a look after it now thought smile
Posted By: Dreher

Re: Funfair Simulation - 04/08/09 00:00

Originally Posted By: Nicotin
Okay, some tips (I can't give you more right now because I'd have to look a long time myself smile )

Look for "c_rotate" in the manual for the rotating platform and the single cars.
Then look for vec_rotate to rotate the cars around the center of the platform.

Sorry, my englisch isn't that good. I hope you can unserstand me thought.
I'll take a look after it now thought smile


I'm from holland so a bit of german isn't too bad either, but I do understand you in any way!

Thanks alot for helping me getting started, as this is all i want to do, and once I get to know it properly, I'm happy!

I will look into the manuals, looking for 'c_rotate' and 'vec_rotate' and see what I can do with it, then test it out whenever I'm far enough to do so. Atleast I've gotta start with a simpel model, nothing complicated yet.

Thanks again and we'll see how things go! wink
Posted By: Nicotin

Re: Funfair Simulation - 04/08/09 00:07

Ok, I made it to get a simple one working. If you want it here is the code: You can work with it smile I hope it helps you at least a little bit
It was much easyer then I thought xD
Click to reveal..

Code:


action platform_action()
{
	var platform_rotation_speed = 0.1;//Rotation Speed of the platform
	var car_rotation_speed = 0.5;//rotation speed of the car
	
	ENTITY* car1;//Pointer to all the cars
	ENTITY* car2;
	ENTITY* car3;
	ENTITY* car4;
	
	//Create the cars at 4 edges of the platform
	car1 = ent_create("car.mdl",vector(my.x + 50,0,0),NULL);//Place the car 50 quands over 0
	car2 = ent_create("car.mdl",vector(my.x - 50,0,0),NULL);//Place the car 50 quands under 0
	car3 = ent_create("car.mdl",vector(0,my.y + 50,0),NULL);//Place the car 50 quands right from 0
	car4 = ent_create("car.mdl",vector(0,my.y - 50,0),NULL);//Place the car 50 quands left from 0
	
	while(1)
	{
		my.pan += platform_rotation_speed*time_step;//Rotate platform
		
		car1.pan += car_rotation_speed*time_step;//rotate cars around themselfes
		car2.pan += car_rotation_speed*time_step;
		car3.pan += car_rotation_speed*time_step;
		car4.pan += car_rotation_speed*time_step;
		
		vec_rotate (car1.x,vector(platform_rotation_speed,0,0));//rotate the cars around the vector(0,0,0)
		vec_rotate (car2.x,vector(platform_rotation_speed,0,0));
		vec_rotate (car3.x,vector(platform_rotation_speed,0,0));
		vec_rotate (car4.x,vector(platform_rotation_speed,0,0));
				
		wait(1);
	}
}

function main()
{
	level_load(NULL);
	wait(3);
	
	camera.z = 200;
	camera.x = -200;//Move camera
	camera.tilt = -45;
	
	ent_create("platform.mdl",vector(0,0,0),platform_action);//create Platform
	
}



EDIT: I didn't used c_rotate because it isn't necessary here. Just rotated with my.pan

EDIT2: I forgot the time_step wink
Posted By: Dreher

Re: Funfair Simulation - 04/08/09 00:18

I'll check it out right away after I configured it ^^
Posted By: Pappenheimer

Re: Funfair Simulation - 04/08/09 00:30

You can attach the different objects, which are rotating quite independently, with vec_for_vertex to each other.
Posted By: Dreher

Re: Funfair Simulation - 04/08/09 00:38

Hmm, I got the model already, but i'm totally UNKNOWN within script editor and model editor LOL

Model is imported from sketchup as a .3DS file, and thats it.

And I can't seem to find a way to use the code you gave me (within the Model Editor, to test it out) ><
Posted By: Nicotin

Re: Funfair Simulation - 04/08/09 00:41

You just have to copy mine code into the script editor. Then save is as "main.c" or whatever.c you like. Then convert your models into ".mdl" and copy them into the same dir as the main.c. And rename them to "car.mdl" and "platform.mdl" then just run the script
Posted By: Dreher

Re: Funfair Simulation - 04/08/09 01:03

Ok that's clear.

Do I have to run the script within script editor, or within model editor? laugh
Posted By: Nicotin

Re: Funfair Simulation - 04/08/09 01:08

In the script editor smile
Posted By: Dreher

Re: Funfair Simulation - 04/08/09 01:51

Got the main part to rotate, now I've gotta get the 4 cars to be .mdl and stuff

Also gravity involved but we should take it easy, and I've gotta learn doing this myself aswell instead of taking code of other people!
Posted By: Gumby22don

Re: Funfair Simulation - 04/08/09 06:51

You need to create "Objects" that have an Action attached to them, in Nic's code, the action is platform_action(), and it serves to rotate the object it is attached to, referred to within that code as "me" or "my".

The code also creates 4 "car" entities around the rotating main model, which are placed by the code, so don't need to be put in in WED - just place the main circle, and attach the Action, with the Properties (bottom left of WED - select the object, find Behaviour, then use the Open icon for the action to use.)

You assign a Script file to the world, in WED under File-Map Properties -> Script, and then actions in that Script file will be accessible to objects in WED.

Have fun, and if you need help, PM me - I'd be very interested in this sort of project. I use sketchup alot and am thinking of setting up a "simple" procedural town generator with sketchup models.

edit - oops, didn't see the second page - you might be past this advice.

Don
have a great day
Posted By: Dreher

Re: Funfair Simulation - 04/08/09 13:29

I got this part working too now!

Main part is rotating, even though it doesn't rotate correctly.

The main part is now rotating as if it is horizontally, but it's standing like 12 degrees upwards?! (Not sure how to explain this one^^)

Other then that, we've got alot more to do, but first I would have to start getting to know HOW to use all of these script commands which can be found in the online manual (i guess?) smile
Posted By: Nicotin

Re: Funfair Simulation - 04/08/09 13:40

Yeah I know that it is only a little bit of the same work. But these are all commands you need to know to make the same thing. If you want I still can help you with that
Posted By: Dreher

Re: Funfair Simulation - 04/08/09 13:47

Well,

Next part is getting the main part to rotate like in the sketchup movie, you can see it doesn't stand horizontally, then also the the cars schould stick to the 2 small black rotating parts etc etc.. ALOT of work probably lol ><
Posted By: Henning

Re: Funfair Simulation - 04/09/09 12:35

Hi Dreher,

it is a lot of work! First you need to rotate the main wheel which is best done by the new command vec_rotateaxis (VECTOR* vDir,VECTOR* vAxis,var angle), because you can get the 12 deg off vertical easily. Next you have to rotate the satellites (black parts) at a certain relation to the main rotation. This relation of rotation speeds is fixed. And last you need to implement the cars and their inclined axis using the 3DGS Physics Functions, because they have no forced movement, they are accelerated by inertia of mass. Position of center of gravity is critical. Do not take the real mass in kg, Physics does not like mass > 60 approximately. Sorry, it is too much to just write the software for you.

Nice task
Henning
(former head of predevelopment at HUSS Maschinenfabrik, maker of BreakDancer)
Posted By: Dreher

Re: Funfair Simulation - 04/09/09 14:29

Lol, a husser here heh.. haha ^

What I want to make is Dreher's Break Dancer No.2

But I'd need to get this script done of course.

I know a guy that scripts gravity too (He made a Monster 3 simulation, properly simulated) but he says you'd need to let the main platform (main wheel as you say) to also rotate with physics, otherwise the gondelas (cars) won't work with physics??

Either he's doing something wrong, or.. ^^
© 2024 lite-C Forums