Car Wheels

Blitz3D Forums/Blitz3D Beginners Area/Car Wheels

Kid(Posted 2005) [#1]
Can anybody help me by showing me how to turn a car wheel by the center of it.

kid


Stevie G(Posted 2005) [#2]
You need to be clearer .. the steering wheel or the car wheel?


Rook Zimbabwe(Posted 2005) [#3]
rotateentity??? I agree you need to be clearer... Steering wheel use rotateentity front wheel I would use turnentity after making sure the centerpoint of the wheel was at the center of the X, Y, and Z axis...


Shambler(Posted 2005) [#4]
Yes, when you model the wheel make sure that the centre of the wheel is positioned at 0,0,0 in your modelling package.

Do this and turn/rotate will then rotate the wheel around it's centre.


WolRon(Posted 2005) [#5]
...showing me how to turn a car wheel ...

You need to be clearer .. the steering wheel or the car wheel?

How is what you wrote, any clearer? He called it a 'car wheel', and so did you...


Stevie G(Posted 2005) [#6]
Oops .. noticed my mistake shortly after posting!!


Stevie G(Posted 2005) [#7]
Unless there's any other wheel on a car , other than steering / tires then I think it's an obvious assumpion to make that by car wheel I was referring to the tire ..

Why the pettiness .. you got nowt better to do?


Kid(Posted 2005) [#8]
No i didnt edit my post stevie G u got wrong because u are a muppet


Stevie G(Posted 2005) [#9]
Kind words Kid!! You'll get no help from me in future!! Good luck with your GT4 beater...


Kid(Posted 2005) [#10]
So wot theres nothing like being wrong is there!!!!!!


WolRon(Posted 2005) [#11]
Well, I can see that the Kid will go far in the Blitz community...

Great start!


Stevie G(Posted 2005) [#12]
Well, to be honest it was my fault Wolron .. I did edit my second post. Now the guilt got the better of me ... here's a bit of very simple code old code I had to get you started ... Now this isn't a GT4 beater ;)

Graphics3D 640,480,16,1

Global plane = CreatePlane():EntityColor plane, 50,50,100:EntityAlpha plane, .75
texture = CreateTexture( 16,16)
SetBuffer TextureBuffer( texture )
Color 0,0,0:Rect 0,0,16,16,1
Color 50,50,200:Rect 0,0,16,16,0
SetBuffer BackBuffer()
ScaleTexture texture,20,20
EntityTexture plane, texture
FreeTexture texture

Global camera = CreateCamera():PositionEntity camera, 0, 50, -100
Global mirror = CreateMirror()

Global light = CreateLight():RotateEntity light , 15,-45,0

Type Car
	Field Model
	Field Wheel[3]
	Field WheelRotation#
	Field Wheelradius#
	Field TopSpeed#
	Field Drag#
	Field Acceleration#
	Field Brakes#
	Field Speed#
	Field Vx#, Vy#, Vz#
End Type

Global MyCar.car = CARcreate( 4, 3, 6, 2, 3 )

While Not KeyDown(1)

	CARupdate( MyCar )
	PointEntity camera, MyCar\model
	CameraZoom camera, EntityDistance( camera, MyCar\model ) / 100
	RenderWorld()
	Flip

Wend

;==========================================
;==========================================
;==========================================

Function CARupdate( c. car )
	
	;user input
	jx# = KeyDown(203) - KeyDown(205 )
	jb#  = KeyDown( 200)
	
	TurnEntity c\Model, 0, jx * 3.0,0
	For w = 0 To 1
		RotateEntity c\wheel[w], 0 , jx*45, 0
	Next
	
	c\Speed = LIMIT ( c\Speed + ( jb * c\Acceleration ) - ( (Not jb ) * c\Brakes ) , 0, c\TopSpeed )
	TFormVector 0,0,(1.0 - c\drag ), c\Model, 0
	c\Vx = ( c\Vx * c\drag ) + ( TFormedX() * c\Speed )
	c\Vz = ( c\Vz * c\drag ) + ( TFormedZ() * c\Speed )
	c\Vy = ( c\Vy * c\drag ) + ( TFormedY() * c\Speed ) 
	speed# = Sqr( c\Vx*c\Vx + c\Vy*c\Vy + c\Vz*c\Vz )

	TranslateEntity c\Model, c\Vx, c\vy , c\Vz
	
	c\WheelRotation = c\WheelRotation + Speed * 90.0 / ( Pi * c\WheelRadius )  
	For w = 0 To 3
		RotateEntity c\wheel[ w] , c\WheelRotation, EntityYaw( c\wheel[w] ) , 0
	Next

End Function

;==========================================
;==========================================
;==========================================

Function CARcreate.car( w#, h#, d# , tw# , tr# )

	c.car = New car
	c\Acceleration = .0075
	c\Brakes = .005 
	c\Drag = .95
	c\Speed = 0.0
	c\TopSpeed = 1.25
	c\Wheelradius = tw
		
	c\Model = CreateCube()
	FitMesh c\Model , -w,-h,-d, w*2,h*2,d*2
	UpdateNormals c\Model
	EntityColor c\Model,255,255,0
	
	Wheel = CreateCylinder( 5 )
	RotateMesh Wheel,0,0,90
	ScaleMesh Wheel , tw,tr,tr
	UpdateNormals Wheel
	EntityColor Wheel, 64,64,64

	For l= 0 To 3
		dx = ( l >0 And l<3 ) - ( l = 0 Or l = 3 )
		dz = ( l < 2 ) - ( l > 1 )
		c\wheel[l] = CopyEntity(wheel , c\Model )
		PositionEntity c\wheel[l], w*dx , -h , d*dz
	Next
	
	PositionEntity c\Model, 0 , tr+h, 0
	
	FreeEntity Wheel
	
	Return c
	
End Function

;==========================================
;==========================================
;==========================================

Function LIMIT#(n#,n1#,n2#)
	
	If n>n2 Then n=n2
	If n<n1 Then n=n1	
	Return n

End Function



Rook Zimbabwe(Posted 2005) [#13]
StevieG That is a fantastic example!!! I am impressed.
RZ


Kid(Posted 2005) [#14]
Thanks 4 the example Stevie G thats great


WolRon(Posted 2005) [#15]
StevieG, do you mind if I add this bit of code you posted, to my programming tutorial?


Stevie G(Posted 2005) [#16]
Of course not .. feel free. I know it's not very good but the fundimentals are there for simple control.

I'm using much a more advanced system now .. my own verlet vehicle physics engine ( unbreakable and super fast with physically accurate body/body collisions... much more realistic .. just wait until you see that ;) Stick your tokomak and ode up your arse !!!