Rotate Object Newbie Question

Blitz3D Forums/Blitz3D Beginners Area/Rotate Object Newbie Question

Al Meyer(Posted 2008) [#1]
I have several meshes inside a 3DS. I need to rotate a mesh in your own Y axis, not relative to the parent or world. Please, how to do that? Creating a pivot?


Stevie G(Posted 2008) [#2]
By Y-axis I assume you mean Yaw axis.

turnentity MyEntity, 0 , Angle, 0 , 1


OR

rotateentity entity, entitypitch( entity )  , entityyaw( entity ) + Angle , entityroll( entity ), 1


The first is best as will avoid gimbal lock as uses quarternions internally. Remember the global paramater if it's a child entity.


Al Meyer(Posted 2008) [#3]
Iīm doing this, but the rotation is relative to the global parent, not the object it self, that is the question. My object is a 3DS Mouth, with 32 teeth. I need to rotate each tooth in their own axis, not relative to the axis of the mouth.


Stevie G(Posted 2008) [#4]
So you are already using the GLOBAL parameter for turnentity?


Al Meyer(Posted 2008) [#5]
I have tried BOTH.


Stevie G(Posted 2008) [#6]
Well that should have worked just fine ... can you show a picture of what you mean as maybe I'm not understanding you.


Al Meyer(Posted 2008) [#7]
I have tried with a single mesh or a primitive. Itīs working. Itīs not working with child meshes.

The object is orbiting the parent object, not rotating in its own axis. The ideia is rotate the tooth to simulate a orthodontic treatment.


Stevie G(Posted 2008) [#8]
Well, it looks more like your mesh is set up incorrectly and the teeth are not centered on their own axis of rotation.

For example - this works :

Graphics3D 1024,768,32,2

camera = CreateCamera()
PositionEntity camera, 0,0,-50

AmbientLight 128,128,128
light = CreateLight() : RotateEntity light, 30,-45,0

gum = CreateCube()
EntityColor gum, 250,200,200
EntityFX gum, 4

tooth = CreateCube()
ScaleMesh tooth, .1, 1, .1
EntityFX tooth, 4
For l# = -1 To 1 Step .5
	copy = CopyEntity( tooth , gum )
	ScaleEntity copy, 1,Rnd(1,2),1
	PositionEntity copy, l*.75, -1,0
	RotateEntity copy, 0 , Rand(-180,180), 0
Next
FreeEntity tooth

ScaleEntity gum, 10,2,2



While Not KeyHit(1)

	For c = 1 To CountChildren( gum )
		TurnEntity GetChild( gum, c ) , 0 , 1 , 0
	Next

	RenderWorld()
	Flip
	
Wend



Al Meyer(Posted 2008) [#9]
Thanks a lot Stevie. Yes, I think itīs is my 3DS not correct. Thank you again.