хз, у меня камера нормально крутится, вроде без сбоев...
чтоб сделать чтоб камера смотрела не на робота, нужно создать объект на который бы она смотрела, а еще лучше пивот (см код)
Код:
;tipy dlya kolliziy
Const robotType = 1
Const levelType = 2
Const boxType = 3
Const cameraType = 4
Graphics3D 1024,768,32,1
;shrift pokrupnee
font = LoadFont ("arial cyr",20)
SetFont font
l = CreateLight()
RotateEntity l, 0, 45, 45
level=LoadMesh ("MAPS\TUR.3ds")
grunt=LoadTexture("Panels.jpg")
EntityTexture level,grunt
FreeTexture grunt
PositionEntity level,0,-7,0
;typ dlya kollizii
EntityType level,levelType
robot = LoadAnimMesh( "ROBOT\robotic.3ds" )
LoadAnimSeq robot, ("ROBOT\running.3ds" )
ScaleEntity robot,0.5,0.5,0.5
;radius dlya kollizii
EntityRadius robot, 5
;typ dlya kollizii
EntityType robot,robotType
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
rcam=createpivot(robot)
positionentity rcam,0,60,0
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
cam = CreateCamera(rcam)
;radius dlya kollizii
EntityRadius cam,5
;typ dlya kollizii
EntityType cam,cameraType
CameraRange cam,0.01,2000
CameraFogColor cam, 0,128,255 *
CameraFogRange cam, 1,1000 *
PositionEntity cam, 0, 15, 120
;RotateEntity cam, 0, 5, 11
cub=CreateCube()
PositionEntity cub,30,5,10
cone=CreateCube()
PositionEntity cone,5,5,10
;bol'shoy kubik
cub3=CreateCube()
ScaleEntity cub3 ,10, 10, 10
PositionEntity cub3,20,5,-30
;typ dlya kollizii
EntityType cub3,boxType
;ystanovka pickov, eto dlya proverki pryamoy vidimosti
EntityPickMode cub,3
EntityPickMode cone,3
EntityPickMode cub3,2
EntityPickMode level,2
;ystanovka kolliziy
Collisions robotType,levelType,2, 3
Collisions robotType,boxType,2, 2
Collisions cameraType,levelType,2, 3
Collisions cameraType,boxType,2, 2
Repeat
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;povorot kamery na robota
PointEntity cam,rcam
angy#=MouseYSpeed()*0.002
TranslateEntity cam ,0,angy, 0
angx#=-MouseXSpeed()*0.5
TurnEntity robot,0,angx,0
angz#=MouseZSpeed()
MoveEntity cam,0,0,angz
MoveMouse GraphicsWidth()*0.5, GraphicsHeight()*0.5
;dvigaem kamery
If KeyDown(44) Then TranslateEntity cam,0,-0.5,0
If KeyDown(45) Then TranslateEntity cam,0,0.5,0
If KeyDown (46) Then MoveEntity cam,0,0,-1
If KeyDown(47) Then MoveEntity cam,0,0,1
;dvigaem robota
If KeyDown(208) Then MoveEntity robot,0,0,1
If KeyDown (200) Then MoveEntity robot,0,0,-1
If KeyDown (203) Then TurnEntity robot,0,1,0
If KeyDown (205) Then TurnEntity robot,0,-1,0
If KeyDown(17)
MoveEntity robot,0,0,-1
If KeyDown(17) If AnimSeq(robot)=0 Then Animate robot, 1, 0.5, 1, 10
Else
If AnimSeq(robot)=1 Then Animate robot, 2, 1, 0, 10
EndIf
If KeyDown(1) Then Exit
UpdateWorld
RenderWorld
;-----------------------------------------------------------------------------------------------
If EntityInView(cone,cam) And LinePick(EntityX(cam,True),EntityY(cam,True),EntityZ(cam,True),EntityX(cone)-EntityX(cam,True),EntityY(cone)-EntityY(cam,True),EntityZ(cone)-EntityZ(cam,True))=cone
;esli blize 100, to pishem imya
If (EntityDistance (robot,cone)<100)
*CameraProject(cam,EntityX(cone),EntityY(cone),EntityZ(cone))
*Color 0, 0, 128 :Text ProjectedX#(),ProjectedY#(),"Bordos",1
EndIf
End If *
;====================================================
If EntityInView(cub,cam) And LinePick(EntityX(cam,True),EntityY(cam,True),EntityZ(cam,True),EntityX(cub)-EntityX(cam,True),EntityY(cub)-EntityY(cam,True),EntityZ(cub)-EntityZ(cam,True))=cub
;esli blize 100, to pishem imya
If (EntityDistance (robot,cub)<100)
*CameraProject(cam,EntityX(cub),EntityY(cub),EntityZ(cub))
*Color 0, 208, 0:Text ProjectedX#(),ProjectedY#(),"Wiliams",1
EndIf
EndIf *
;===================================================== *
;gravitaciya
TranslateEntity robot,0,-1,0
Flip
Forever
End
на счет вперед-назад юзай команду RotateMesh и поворачивай на 180 градусов (скорее всего по оси Y)... (RotateMesh поворачивает информацию о расположении точек и плоскостей объекта, на угол положения самого объекта это не повлияет)
|