[Résolu]Problème pour créer une collision
Publié : lun. 26/janv./2009 21:47
Bonjour mon problème est de créer une collision sur 2 mesh mais je n'y arrive pas.
Si j'enlève :
il fonctionne mais sans collision , mais quand je met le alors il met "invalid memory acces" . Aidé moi s'il vous plait.
Code : Tout sélectionner
; ------------------------------------------------------------
; DreaMotion3D
;
; Exemple : Poursuite
; Historique :
; 18/12/06 00:00 DreaMotion3D Team
; 18/12/06 20:00 TMyke
;
; ------------------------------------------------------------
; fichier ajouter
IncludePath "Include\" : IncludeFile "dreamotion3d.pbi"
EnableExplicit
; les Globales
Global Quit.b
Global anglex.f, angley.f, flagXDown.w
Global mox.f, omx.f, moy.l, omy.l
Global *tiny.CAnimX
Global *camera.CEntity
Global *land.CEntity
Global *tiger.CEntity
Global *cam.CEntity
Global *light.CEntity
Global *font.CFont
Global *texture.CTexture
Global angle.f, angle2.f, deltax.f, deltay.f, deltaz.f
; on demarre tous les programme necessaire
If InitSprite() = 0 Or InitKeyboard() = 0 Or InitMouse() = 0
End
EndIf
; on ouvre un graphique en pleine ecran
DM_Graphics3D(800, 600, 32, 0, 1)
; on charge le font
*font = DM_LoadFont( "Tahoma",9 , 0)
DM_TextColor (*font, 198,198,198,255)
; ou se trouve tous les gaphique
SetCurrentDirectory("media/")
; la puissance de l'ampoule
*light=DM_CreateLight(3)
Repeat
; creation de d'un squelette
*tiny = DM_LoadAnimMesh("bones_all.x")
DM_ScaleEntity(*tiny, 13,13,13)
DM_AnimateSpeed(*tiny, 0)
DM_RotateEntity(*tiny, 0,0,0)
; ---------------------------------------
; charger les mesh
; ---------------------------------------
; apparition du tigre qui la bouffer
*tiger = DM_LoadMesh("tiger.x")
DM_TranslateEntity(*tiger, 0,10,-120)
; ---------------------------------------
; set collide mesh parameters
; ---------------------------------------
DM_InitPhysic()
DM_EntityType(*tiger,1)
DM_SetCollideForm(#HULL_PRIMITIVE)
DM_EntityType(*tiny,1)
; ---------------------------------------
; create camera
; ---------------------------------------
*camera = DM_CreateCamera()
DM_MoveEntity(*camera, 20,15,-350)
DM_RotateEntity(*camera, 0,-10,0)
DM_CameraClsColor(*camera, 25, 25, 25)
; if fullscreen, must do it for keep mouse cursor
;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
If DM_EntityCollide(*tiny, *tiger)
DM_MoveEntity(*tiny, 0,0,0)
Else
DM_MoveEntity(*tiny, 0,0,-4)
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 pass
; ---------------
DM_UpdateWorld()
DM_BeginScene()
DM_RenderWorld(*camera)
; draw text
DM_DrawText(*font, 10, 15, "Black Cube When collide... ")
DM_EndScene()
Until Quit=1
Until Quit=1
DM_ClearGraphics()
End
; IDE Options = PureBasic v4.00 (Windows - x86)
; CursorPosition = 69
; FirstLine = 53
Code : Tout sélectionner
DM_EntityType(*tiger,1)
DM_SetCollideForm(#HULL_PRIMITIVE)
DM_EntityType(*tiny,1)