Показать сообщение отдельно
Старый 19.02.2011, 15:54   #18
}{@KeR
ПроЭктировщик
 
Регистрация: 01.02.2011
Сообщений: 148
Написано 7 полезных сообщений
(для 8 пользователей)
Ответ: Управление камерой:

А тут скажи что не так ....выделить выделяется но не передвигается

Graphics3D 1024,768,32,2
SetBuffer BackBuffer
()

CreateWorld()

Global 
movepiv
Global centpiv
Global campiv
Global camera
Global mic
Global speed#
Global deltaT
Global userTime
Global newTime
Global wLog

Global f_key=17
Global b_key=31
Global l_key=30
Global r_key=32

Global CubSelect 
Global Ramkax1Ramkay1,Ramkax2Ramkay2
Global pick,cub

Global ox#,oy#,cx#,cy#,tx#,ty#

Const  playertype=1,poltype=2

CreatePlayer
(0,3,0)

cub=CreateCube()
ScaleEntity cub,2,4,2
;CameraProject(camera,EntityX(cub),EntityY(cub),EntityZ(cub)) 
 

Repeat 
If MouseX()<5 Then TranslateEntity camera,-0.5,0,0
If MouseX()>1000 Then TranslateEntity camera,0.5,0,0
If MouseY()<5 Then TranslateEntity camera,0,0,0.5
If MouseY()>766 Then TranslateEntity camera,0,0,-0.5 


        dvigok
()

        
PositionEntity cub,EntityX#(movepiv,1),EntityY#(movepiv,1),EntityZ#(movepiv,1)
        
RotateEntity cub,0,EntityYaw(movepiv,1),0
        
        
;mouselook(camera)               
        
UpdateWorld()
        
RenderWorld()
        
Ramka()  
If 
sel=1 Then 
        
If MouseHit(2Then 
            PositionEntity centpiv
,PickedX#(),PickedY#()+2,PickedZ#()  
        
EndIf      
EndIf

        
Flip()
        
Until KeyHit(1)=1
End

Function CreateWorld()
        
wtex=CreateTexture(256,256)
        
SetBuffer TextureBuffer(wtex)
        
Color 10,100,10
        Rect  15
,15,226,226
        SetBuffer BackBuffer
()
        
ScaleTexture wtex,10,10
        plane
=CreatePlane()
        
EntityTexture plane,wtex
        EntityType plane
,poltype
        EntityPickMode plane
,2,1
        FreeTexture wtex
End 
Function

Function 
CreatePlayer(x#=0,y#=0,z#=0)
        
movepiv=CreatePivot() 
        
PositionEntity movepiv,x#,y#+4,z# 
        
EntityRadius movepiv,3,4.5 
        EntityType movepiv
,playertype 
        centpiv
=CreatePivot() 
        
PositionEntity centpiv,x#+4,y#+2,z#+4  
        
camera=CreateCamera() 
        
PositionEntity camera,0,100,-70 
        TurnEntity camera
,45,0,0,
        CameraClsColor camera
,10,10,150 
        mic
=CreateListener(camera,0.05,0.05,0.08
        
Collisions playertype,poltype,2,
End 
Function

Function 
dvigok()
        ;
PositionEntity campiv,EntityX#(movepiv,1),EntityY#(movepiv,1),EntityZ#(movepiv,1) 
        
If KeyHit(60Then wLog=Not wLog Wireframe wLog 
        
If userTime=0 userTime=MilliSecs() 
        
newTime=MilliSecs()  
        
deltaT=newTime-userTime 
        userTime
=newTime 
        speed
#=0.04*deltaT
 
        
If KeyDown(f_keyThen 
                TranslateEntity camera
,0,0,speed
        
Else 
                If 
KeyDown(b_keyThen TranslateEntity camera,0,0,-speed#
        
EndIf 
        If 
KeyDown(l_keyThen 
                TranslateEntity camera
,-speed#,0,0 
        
Else
                If 
KeyDown(r_keyThen TranslateEntity camera,speed#,0,0 
        
EndIf
  
         
        
pick=CameraPick(camera,MouseX(),MouseY()) 
        
                ;If 
MouseHit(2)=1 Then 
                
;        PositionEntity centpiv,PickedX#(),PickedY#()+2,PickedZ#()  
                
;EndIf 
        
        If 
EntityDistance(movepiv,centpiv)>3 Then 
                PointEntity movepiv
,centpiv 
                MoveEntity movepiv
,0,0,
        
EndIf 
        
TranslateEntity movepiv,0,-1,

End 
Function

Function 
Ramka() 
    If 
MouseDown(1)
        
cx#=MouseX()
        
cy#=MouseY()
        
        
If ox>cx Then minx=cx:maxx=ox Else minx=ox:maxx=cx
        
If oy>cy Then miny=cy:maxy=oy Else miny=oy:maxy=cy
        
        Rect minx
,miny,maxx-minx,maxy-miny,0
        
            CameraProject
(camera,EntityX(cub),EntityY(cub),EntityZ(cub))
            If 
ProjectedX()>minx And ProjectedX()<maxx And ProjectedY()>miny And ProjectedY()<maxy Then sel=Else sel=0
            
    
If sel=1 Then 
        EntityColor cub
,255,255,0
     
Else
        
EntityColor cub,0,0,0
    
EndIf 
    
        Else
        
ox#=MouseX()
        
oy#=MouseY()
    
EndIf
 
Oval MouseX()-3,MouseY()-3,5,5,0       
End 
Function 
__________________
Ученье свет, а не ученье тень!
(Offline)
 
Ответить с цитированием