Показать сообщение отдельно
Старый 25.04.2009, 22:01   #9
ELIAS
Знающий
 
Аватар для ELIAS
 
Регистрация: 31.08.2008
Адрес: Arrakis
Сообщений: 234
Написано 6 полезных сообщений
(для 6 пользователей)
Ответ: Кротчайшее направление плавного разворота!

Graphics3D 640, 480, 32, 1

cam=CreateCamera()
CameraClsColor cam, 0, 100,255
CameraRange cam, 1, 1000
MoveEntity cam,0,0,-50
lit=CreateLight()
PositionEntity cam, 2, 10,-2



cube=CreateWCone()
EntityColor cube, 255,0,0

PointEntity cam, cube


pivot=CreateWCone()
PositionEntity pivot, 5,0,0
RotateEntity pivot, 0, Rand(0,360), 0

o1=0

Repeat
	
	
	If Abs(EntityYaw(cube)-EntityYaw(pivot))<1
		o1=EntityYaw(cube)
		RotateEntity pivot,0,  Rand(-180,180),0
	EndIf
	
	
	
	;SmoothTurn4(cube, pivot, 0.01)
	gh#=AngleLerp(EntityYaw(cube), EntityYaw(pivot), 1)
	RotateEntity cube, 0,  AngleLerp(EntityYaw(cube), EntityYaw(pivot), 0.04),0 
	
	If KeyDown(200)=1 Then MoveEntity cam, 0,0,0.5
	If KeyDown(208)=1 Then MoveEntity cam, 0,0,-0.5
	
	RotateEntity cam, EntityPitch(cam)+MouseYSpeed()*0.2, EntityYaw(cam)-MouseXSpeed()*0.2 ,0
	
	MoveMouse GraphicsWidth()/2,GraphicsHeight()/2
	
	
	
	
	UpdateWorld
    RenderWorld
	
	
	Text 20,20, "povorot = " + (EntityYaw(cube)-o1)
	
    Flip 60
	
	
	
	
Until KeyHit(1)
End

Function AngleDist#(a1#,a2#)
	If a1-a2>180 Then Return  360 - (a1-a2)
	
	If a1-a2<-180 Then Return 360 + (a1-a2)
	
	If a1-a2>-180 And a1-a2<180 Then Return a1-a2
End Function

		
		
		
Function AngleLerp#(a1#,a2#,scalar#)
	Return a1+AngleDist(a2,a1)*scalar
End Function


Function CreateWCone()
	f=CreateCone(4) 
	RotateMesh f,0,0,90
	ScaleMesh f, 1,2,2
	RotateMesh f, 45,90,0
	ScaleMesh f,1.2,1,1
	Return f
End Function

Function SmoothTurn4#(ent1,ent2,speed# = 1)
	
	smx#=(EntityPitch(ent2)-EntityPitch(ent1))*speed
	smy#=(EntityYaw(ent2)-EntityYaw(ent1))*speed
	smz#=(EntityRoll(ent2)-EntityRoll(ent1))*speed
	TurnEntity ent1, smx, smy, smz
	
End Function
Вот HolyDel, пока только это есть. Тут какбы используются твои алгоритмы. Результатов не дают.....((((
(Offline)
 
Ответить с цитированием