ferris wheel

Blitz3D Forums/Blitz3D Programming/ferris wheel

Oiduts Studios(Posted 2010) [#1]
I can't seem to get this one right. I am making a ferris wheel and I need the cars (18 of them) to always face forward but still spend around the wheel. I have set up pivots at the points I want the cars. I do understand that by using MoveEntity the object that is parented resets it's global coordinates to the parents position but it just wont work. Somehow I came up with this...
For t=1 To 1296 Step 36
	
	c.cars = New cars
	c\carpiv=CreateSphere(16,ferris)
	ScaleEntity c\carpiv,.2,.2,.2
	TurnEntity c\carpiv,0,0,t
	MoveEntity c\carpiv,0,2,0
	EntityParent c\carpiv,0
	c\carmesh=CopyMesh(car1)
	ScaleEntity c\carmesh,1,1,1
	
Next


I have tried tonnes of different parenting options and other sorts of goodies but I usually end up with the pivots spinning with the wheel but the cars are sitting across the map, and not moving at all.
	For c.cars = Each cars
		;PointEntity c\carpiv,merry
		EntityParent c\carpiv,0
		PositionEntity c\carmesh,EntityX(c\carpiv),EntityY(c\carpiv),EntityZ(c\carpiv)
	Next


This is the movement, once again I have tried many different options. What I would like help on is if there is another option to do this or just anyway you could help really. Thanks for the help!


Jiffy(Posted 2010) [#2]
I'll bite:

1. Not enough code
2. Not sure what you mean by "but the cars are sitting across the map"
3. For t=1 To 1296 Step 36: why 1296?.
4. EntityParent c\carpiv,0 : you do this twice- once is normally enough.

Can't suggest anything properly without seeing what you're doing better.

Um, use a physics engine?
Other than that, post more code- preferably something that can be run & fixed.


Drak(Posted 2010) [#3]
Did you try
PositionEntity c\carmesh,EntityX(c\carpiv,1),EntityY(c\carpiv,1),EntityZ(c\carpiv,1)


Throwing the "1" in after the entityXYZ may help.

Edit: EntityParent c\carpiv,0 sets the parent to 0, or nothing.

Edit 2: Did some quick brainstorming. I have an idea I'll knock together quick to see if it works.


Oiduts Studios(Posted 2010) [#4]
Ya, I probably should of stated that the code I posted was just showing the way I was going, not exactly how I would do it. Its just i got to the point of trial and error. Thanks for the understanding Drak, I tried the globalizing thing and it didn't seem to help but I have an idea I will try out tomorrow. Thanks again for the help!

Edit : by the way, the "For t=1 To 1296 Step 36" is there because I somehow got the numbers from my handy dandy calculator and it gave me 18 objects and the turn radius I needed. (I need some sleep)

edit 2 : opps, I get 10 cars, not 18, oh well.


Oiduts Studios(Posted 2010) [#5]
Well I seemed to have got it workin, thanks Drak, that was the issue, goodnight people.


Drak(Posted 2010) [#6]
Aw man.. just got this done. Ima post it anyway :)

This may or may not help you but this is the way I would try to do it. The cars are not actually "attached" to the wheel per se, but the program makes it appear so.

Tip: Turn the degrees turned in the main loop from .1 to 1 and it makes you dizzy!




Oiduts Studios(Posted 2010) [#7]
This is very well documented, thank you.


Heliotrope(Posted 2010) [#8]
Maybe this will work.

if entityxyz car <>0 then rotateentity car,1,1,1


Ross C(Posted 2010) [#9]
Dunno if you've solved it, but surely creating pivots where the car attach to the wheel, and parent the pivots to the wheel, then parent the cars to the pivots, and rotate the pivots at the same rotation as the main wheel.


Oiduts Studios(Posted 2010) [#10]
Yes I solved it thanks to Drak's suggestion. What I did was load the cars and the wheel sepparatly. I used
For t=1 To 1296 Step 36
to copy the cars and then parented them to the wheel. I used
TurnEntity c\carpiv,0,0,t and MoveEntity c\carpiv,0,2,0
to position them. Then I used
For c.cars = Each cars
		PositionEntity c\carmesh,EntityX(c\carpiv,1),EntityY(c\carpiv,1),EntityZ(c\carpiv,1),1
	Next

to position them in the main loop.


Midimaster(Posted 2010) [#11]
another possibility:

Graphics3D 800,600
wheel=CreateCylinder(18,1,0)
TurnEntity wheel,90,0,0
ScaleEntity Wheel,6,.7,6


car0=CreateCube()
HideEntity car0


World= CreateSphere(16)
EntityColor world,111,111,255
FlipMesh world
ScaleEntity World,200,50,200

camera=CreateCamera()
CameraFogColor camera,111,111,255
CameraFogRange camera ,1,250
CameraFogMode camera,1
MoveEntity camera,0,0,-25





light=CreateLight()
LightColor light, 255,222,0
MoveEntity Light,-20,20,-10
RotateEntity light,75,40,0

sun=CreateSphere(16)
EntityColor sun,255,255,111
MoveEntity sun,-100,20,110
ScaleEntity sun,11,11,11

light2=CreateLight()
LightColor light2, 5,55,22
MoveEntity Light2,20,20,-10
RotateEntity light2,-90,45,0


Plane=CreatePlane(16)
MoveEntity Plane, 0,-15,0
EntityColor Plane ,0,55,110



Dim car(20)
For i=0 To 17
   car(i)=CopyEntity(car0)
   ScaleEntity car(i),0.1,.2,1
   MoveEntity car(i),Sin(i*20)*2,0,Cos(i*20)*2	
   EntityParent car(i),wheel,0
Next


Repeat
	TurnEntity wheel, 0,.1,0
	PointEntity camera, wheel
	For i=0 To 17
		RotateEntity car(i),0,0,0,True
	Next 
	RenderWorld
	Flip 0
Until KeyHit(1)