Page 1 sur 1

[Résolu] Les loi de L'apesenteur et des collision

Publié : dim. 18/janv./2009 23:38
par guerrier001
Bonjour , je suis guerrier001 un apprentie de la 2d en formation , et comme je n'aimme pas laisser mes projet sans etre fini et que j'essai de le terminer moi meme en utilisant des tuto qui ne fonctionne que pour des cube et que c'est en DeaMotion 3D

Code : Tout sélectionner

; ------------------------------------------------------------
;   DreaMotion3D
;
;   Exemple     :   Base_Wotpath
;   Historique  :
;     18/09/06  00:00    DreaMotion3D Team
;     10/02/07  19:16    TMyke
;     18/01/07  18:33    Guerrier001
;
; ------------------------------------------------------------

; Include files
IncludePath "Include\"  :  IncludeFile "dreamotion3d.pbi"

;EnableExplicit


Declare FrameFind( *pframe.D3DXFRAME , *frame.D3DXFRAME)
; Globales
Global   anglex.f, angley.f, flagXDown.w
Global   mox.f, omx.f, moy.l, omy.l


  Global   *camera.CEntity
  Global *land.CEntity
  Global   Dim *tiny.CAnimX(30)
  Global *cube.CMesh
  Global   *font.CFont
 
  Global  val.l,Quit.b
  Global  i.l, flag.l
  Global  tab.l=0, *tFrame.D3DXFRAME
 
  DM_InitPhysic()
  ;  Init PB modules
  If InitSprite() = 0 Or InitKeyboard() = 0 Or InitMouse() = 0
    End
  EndIf

  ; set graphic window 3D
  *app = DM_Graphics3D(800,600, 32,  0, 1)
 
  ;load font
  *font = DM_LoadFont( "Tahoma",9 , 0)
  DM_TextColor (*font, 198,198,198,255)
  ; change directory for media
  SetCurrentDirectory("media/")
 

  ; Set lights
  DM_AmbientLight(150,  150,  150)
  DM_CreateLight(3)
 
  ; ---------------------------------------
  ;           meshs
  ; ---------------------------------------
  ; Charge le sol
  *land   = DM_LoadMesh("land.x")
 

  *tiny(0)  = DM_LoadAnimMesh("bones_all.x")
  DM_ScaleEntity(*tiny(0), 13,13,13)
  DM_AnimateSpeed(*tiny(0), 0.01)
  DM_MoveEntity(*tiny(0), -50,10,-300.0)
DM_RotateEntity(*tiny(0), 0,20,0)





 

;Debug DM_AnimFrameName(*tiny(0)\ g_pFrameRoot)
;Debug "-------"
;FrameFind( *tiny(0)\ g_pFrameRoot, #Null)



  ; ---------------------------------------
  ;          create camera
  ; ---------------------------------------
  *camera   = DM_CreateCamera(800,600,*tiny(0))
  DM_MoveEntity(*camera, 0,1,4) ; valeur initiale -34,25,-250 : nouvelle configuration -14,10,-200
  DM_TurnEntity(*camera, 0,180,0)
  DM_CameraClsColor(*camera, 125, 125, 125)
  ;if full screen...
  ;change_curseur( #IDC_ARROW  )
  ; ---------------------------------------
  ;           main loop
  ; ---------------------------------------
  Repeat
     ExamineKeyboard()
     ExamineMouse()
     ShowCursor_(1)
     
   ; if Escape Key, exit   
    If KeyboardReleased(#PB_Key_Escape) Or WindowEvent()=#PB_Event_CloseWindow
       Quit=1
    EndIf
     

   

    ; change  animation on Tiny 5
    If KeyboardReleased(#PB_Key_Up)
      DM_AnimateIndex(*tiny(0), 0)
    EndIf
    If KeyboardPushed(#PB_Key_Up)
      DM_AnimateIndex(*tiny(0), 1)
    EndIf
      If KeyboardReleased(#PB_Key_Down)
      DM_AnimateIndex(*tiny(0), 0)
    EndIf
    If KeyboardPushed(#PB_Key_Down)
      DM_AnimateIndex(*tiny(0), 1)
    EndIf
    If KeyboardPushed(#PB_Key_Down)
      DM_MoveEntity(*tiny(0), 0,0,4)
   
    EndIf
    If KeyboardPushed(#PB_Key_Up)
      DM_MoveEntity(*tiny(0), 0,0,-4)
    EndIf
     
If KeyboardPushed(#PB_Key_Right)
DM_TurnEntity(*tiny(0), 0,1,0)
EndIf

If KeyboardPushed(#PB_Key_Left)
DM_TurnEntity(*tiny(0), 0,-1,0)
EndIf



     If KeyboardReleased(#PB_Key_B) : flag=11 : EndIf
     If KeyboardReleased(#PB_Key_N) : flag=0 : EndIf
     
 

    If MouseButton(#PB_MouseButton_Left)
        If flagXDown=0
           omx = MouseX()
           omy = MouseY()
           flagXDown=11
        Else
           moy = MouseY()-omy
           angley=(0)
           omy= MouseY()
           mox = MouseX()-omx
           anglex=(mox/5.0)
           omx= MouseX()
           DM_TurnEntity(*tiny(0), angley,anglex,0)
        DM_TurnEntity(*camera, angley,anglex,0)
        EndIf
             Else
            flagXDown=0
    EndIf
 

 DM_UpdatePhysic()
     ; ---------------
     ;      Render
     ; ---------------
      If flag=0 : DM_UpdateWorld() : EndIf
     DM_BeginScene()
       DM_RenderWorld(*camera)

       ; draw texte
       DM_DrawText(*font, 10, 15, "FPS : "+Str(DM_FPS()))
       DM_DrawText(*font, 10, 30, "F1/F2/F3/F4 : index of animate's tiny1")

     DM_EndScene()
     
     
  Until Quit=1

  DM_ClearGraphics()
  End


Procedure FrameFind( *pframe.D3DXFRAME , *frame.D3DXFRAME)
  Protected a$
 
  a$=Space(tab)
  Repeat
    *frame = DM_AnimateGetChild(*tiny(0), *pframe, *frame)
    If *frame
      Debug a$+DM_AnimFrameName(*frame)
      tab+3
      FrameFind(*frame, #Null)
    EndIf
  Until *frame=#Null
  tab-3
 
EndProcedure
; IDE Options = PureBasic v4.00 (Windows - x86)
; CursorPosition = 69
; FirstLine = 53
Pouvez vous m'aider s'il vous plait ?

Publié : lun. 19/janv./2009 12:02
par djes

Publié : lun. 19/janv./2009 18:02
par tmyke
Si je comprends bien ,tu veux simplement que ton perso suive le terrain.

J'essais de te faire un petit code d'ici à ce soir.

Publié : lun. 19/janv./2009 20:05
par tmyke
Bon, voici un petit code qui fait suivre ton personnage en fonction du terrain.
LEs media sont ceux du package DM3D.
C'est dans un premier temps beaucoups plus simple que de mettre en oeuvre des instruction
de gestion de la physique et des collisions.

Code : Tout sélectionner

; ------------------------------------------------------------
;   DreaMotion3D
;
;   Exemple     :   Terrain Sample
;   Historique  :
;     18/09/06  00:00    DreaMotion3D Team
;     21/11/08  21:37    TMyke
;
; ------------------------------------------------------------

; Include Files  
IncludePath "Include\"  :   IncludeFile "dreamotion3d.pbi"


; Globales
Global	anglex.f, angley.f, flagXDown.w
Global	mox.f, omx.f, moy.l, omy.l
Global	mFar.f, hh.f


  Global	*camera.CEntity
  Global *texture.CTexture
  Global	*font.CFont
  Global *tiny.CAnimX
  Global Quit.b
  
  ;   Init PB modules
  If InitSprite() = 0 Or InitKeyboard() = 0 Or InitMouse() = 0 
    End
  EndIf

  ; set graphic window 3D
  DM_Graphics3D(800,600, 32,  0, 1)
  ; load font
  *font = DM_LoadFont( "Tahoma",9 , 0)
  DM_TextColor(*font, 198,198,198,255)
  ; change directory for media
  SetCurrentDirectory("media/")
  
  ; Set ambient color
  DM_AmbientLight(250,  250,  250)
  DM_CreateLight(3)


  ; ---------------------------------------
  ;  a little skybox, well here a skydome
  ;  must be define in first
  ; ---------------------------------------
  *sky.CSkySphere = DM_LoadSkySphere("grassenvmap1024.dds", 50)
  DM_TranslateEntity(*sky, 0,-10,0)



  DM_TextureMipLevel( 0 )
  ; ---------------------------------------
  ;     create terrain with terrain 
  ;     engine
  ; ---------------------------------------
  ; create base terrain with heightmap "map.jpg"
  *terrain = DM_CreateTerrain("height113.bmp", 1.5, #False)
  *brush = DM_CreateBrush("terrain")
  DM_LoadTexture("sol113.jpg", DM_GetTexture(*brush))
  DM_LoadTexture("detail3.bmp", DM_GetTexture(*brush,1))
  DM_PaintTerrain(*terrain, *brush )
  DM_FreeBrush(*brush)    
  mFar=800.0


  *tiny  = DM_LoadAnimMesh("bones_all.x")
  DM_ScaleEntity(*tiny, 13,13,13)
  DM_AnimateSpeed(*tiny, 0.01)
  DM_RotateEntity(*tiny, 0,225,0)




  ; ---------------------------------------
  ;          create camera
  ; ---------------------------------------
  *camera   = DM_CreateCamera(800,600,*tiny)
  DM_MoveEntity(*camera, 0,2,4) 
  DM_TurnEntity(*camera, 10,180,0)
  DM_CameraClsColor(*camera, 125, 125, 125)
  DM_CameraProjRatio(*camera, 800,600, mFar)


  ; ---------------------------------------
  ;           main loop
  ; ---------------------------------------
  ; if fullscreen, must do it for keep mouse cursor
  ;change_curseur( #IDC_ARROW  )
  Repeat
    	ExamineKeyboard()
    	ExamineMouse() 
    	ShowCursor_(1)
     ; if Escape Key, exit
  	If KeyboardReleased(#PB_Key_Escape) Or WindowEvent()=#PB_Event_CloseWindow
  	  Quit=1
  	EndIf


   
      h.f = DM_GetTerrainHeight(*terrain, DM_EntityX(*tiny), DM_EntityZ(*tiny))

    If KeyboardPushed(#PB_Key_Down)
      DM_MoveEntity(*tiny, 0,0,4)
      DM_PositionEntity(*tiny, DM_EntityX(*tiny), h+5, DM_EntityZ(*tiny))
    EndIf
    If KeyboardPushed(#PB_Key_Up)
      DM_MoveEntity(*tiny, 0,0,-4)
      DM_PositionEntity(*tiny, DM_EntityX(*tiny), h+5, DM_EntityZ(*tiny))
    EndIf
     
  If KeyboardPushed(#PB_Key_Right)
    DM_TurnEntity(*tiny, 0,1,0)
  EndIf

  If KeyboardPushed(#PB_Key_Left)
    DM_TurnEntity(*tiny, 0,-1,0)
  EndIf


  	If MouseButton(#PB_MouseButton_Left)
  		If flagXdown=0
  			omx = MouseX()
  			omy = MouseY()
  			flagXDown=11
  		Else
  			moy = MouseY()-omy
  			angley=(moy/5.0)
  			omy= MouseY()
  			mox = MouseX()-omx
  			anglex=(mox/5.0)
  			omx= MouseX()
  			DM_TurnEntity(*camera, angley,anglex,0)
  		EndIf
  	Else
  	 		flagXDown=0
    EndIf

  	; ---------------
  	;      Render
  	; ---------------
  	DM_BeginScene()
    	DM_RenderWorld(*camera)
   	  ; draw some informations
   	  DM_DrawText(*font, 10, 15, "FPS: "+Str(DM_FPS()))	  
  	DM_EndScene()
  Until Quit=1
  ; end
  DM_ClearGraphics()
  End

Publié : lun. 19/janv./2009 21:57
par guerrier001
Oui merci mais est ce que tu pourrait me remettre l'animation du squelette s'il te plait ?

Edit: C'est bon trouver merci