[B3D] frei bewegliche Bones trotz animation, 3D Steuerung

Übersicht BlitzBasic Codearchiv

Neue Antwort erstellen

Dottakopf

Betreff: [B3D] frei bewegliche Bones trotz animation, 3D Steuerung

BeitragDo, Dez 09, 2010 21:02
Antworten mit Zitat
Benutzer-Profile anzeigen
Hi Blitzer,


dieser Post ist für leute die sich frisch an einen 3D Spiel wagen, und sich gerade den kopf zerbrechen wie sie Ihre Spielerfigur in der 3D Welt bewegen.
Zeigen soll das Beispiel wie man sein Model unterteilen muss, um seiner Figur Animationen zu geben, und gleichzeitig die Bones/joints der Arme für Rüstungen, Waffen oder sonst was "frei" zu haben.

Da ich das ganze als testaufbau für mein aktuelles Projekt gemacht habe, ist das hier natürlich nur ein denkanstoß. Aber man kann sich hier mal schnell einige dinge ansehen wie sie in etwa umgesetzt werden können.

Zu sehen ist eine 3D Figur(Stickman) der ,leicht übertrieben, eine Laufanimation abspielt. Die Restlichen Bones können zufällig umpositioniert werden. Nichts großartiges.. aber wer sowas machen möchte und nicht extra ein dummy Model erstellen will und sich alles zusammen fizeln möchte kann das hier benutzen. Alle Bones/Joints außer den Beinen sind frei beweglich....


-> frei verwendbares 3D Model(zerteilt in beine und oberkörper) [.ms3d file,.b3d file]
-> 3D Kameraführung eines Egoshooters
-> Bones frei benutzen trotz gleichzeitig abgespieleter animation
-> nichts aufregendes

Steuerung:
WASD und Maus
Leertaste bewegt die arm-bones zufällig (Lol.. techno moves)
Pfeiltasten lassen die Kamera umd den Spieler fliegen.


link mit allen sourcen(alles frei verwendbar...) hier: 64kb
https://www.blitzforum.de/upload/file.php?id=9941


Source Code
Code: [AUSKLAPPEN]


Graphics3D 800,600,16,2
SetBuffer BackBuffer()
timer=CreateTimer(60)




;gebraucht für die Maussteuerung (begrenzung für nach "oben und unten gucken" )
Global fTurnSpeed# = .2
Global fTurnVelocityFactor# = .6
Global fTurnVelocityY#
Global iControlMode%=1


;Mesh und co
Global Msh_Stickman1,Msh_stickman2,pos_cube,body_bone
Global GameCam






pos_cube = CreateCube() ;der Positions würfel dient zu Positionierung(Player Pivot) der einzelnen Mesh Teile
      ScaleEntity pos_cube,2,2,2
      MoveEntity pos_cube,6.5,0,0
      EntityColor pos_cube,255,0,0
      



Msh_Stickman1 = LoadAnimMesh("stickman1.b3d")  ;oberteil ohne animationen
         RotateEntity Msh_Stickman1,0,90,0
         MoveEntity Msh_Stickman1,0,0,0
         ScaleEntity Msh_Stickman1,0.5,0.5,0.5
         body_bone=FindChild(Msh_Stickman1,"body")
         EntityParent Msh_Stickman1,pos_cube



Msh_stickman2 = LoadAnimMesh("stickman2.b3d")  ;unterteil mit animationen
         RotateEntity Msh_stickman2,0,90,0
         MoveEntity Msh_stickman2,0,0,0
         ScaleEntity Msh_stickman2,0.5,0.5,0.5
         EntityParent Msh_stickman2,pos_cube
         Animate Msh_stickman2,1,0.5,0,1



GameCam = CreateCamera()
         MoveEntity GameCam,0,30,-200
         EntityParent GameCam,body_bone









;ein paar cubes zur orientierung / unwichtig
For x = 0 To 100
cc=CreateCube()
PositionEntity cc,Rnd(-200,200),Rnd(-100,100),Rnd(-200,200)
EntityColor cc,Rnd(0,255),Rnd(0,255),Rnd(0,255)
Next
plane=CreatePlane()
EntityColor plane,0,100,0
MoveEntity plane,0,-15,0
l=CreateLight(2)
MoveEntity l,-100,100,100
;--------------------------------





AmbientLight 128,128,128
MoveMouse GraphicsWidth()/2,GraphicsHeight()/2



;/////////////////////////////////////// MAIN LOOOP \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
Repeat
Cls
WaitTimer(timer)


         
         update_player();Spieler bewegung
            


         ;Spin Cam
         If KeyDown(203) Then MoveEntity GameCam,10,0,0
         If KeyDown(205) Then MoveEntity GameCam,-10,0,0
         PointEntity GameCam,Msh_Stickman1



         ;Random Postion of Hands
         If KeyDown(57) Then
            techno=1
            bone_left=FindChild(Msh_Stickman1,"schulter_links")
            bone_right=FindChild(Msh_Stickman1,"schulter_rechts")
            TurnEntity bone_left,Rnd(10,20),Rnd(10,20),Rnd(10,20)
            TurnEntity bone_right,Rnd(10,20),Rnd(10,20),Rnd(10,20)
         End If






UpdateWorld()
RenderWorld()

         ;info anzeigen
         Color 255,255,255
         Text 0,0, "3D Model + Bone Moving while Animating Demo by Dottakopf"
         Text 0,30,"USE WASD Keys and Mouse to Move"
         Text 0,50,"Use [->]  and [<-] Keys to Spin Game Cam"
         Text 0,70,"Press Space to Randrom Possition Hand-Bones"
         If techno=1 Then
            Color 10,10,10
            Rect GraphicsWidth()/2,GraphicsHeight()/2+50,200,30,1
            Color Rnd(100,255),Rnd(100,255),Rnd(100,255)
            Text GraphicsWidth()/2,GraphicsHeight()/2+50, "Stickman Techno Moves :-)"
         End If
         techno=0
Flip 0
Until KeyHit(1)



;////////////////////////////////////////////\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\





Function update_player()



            
            ;MOVEMENT
             ;WASD Tasten
             If KeyDown(17) Then MoveEntity pos_cube ,0,0,+2:move=1
             If KeyDown(31) Then MoveEntity pos_cube ,0,0,-2:move=1
             If KeyDown(30) Then MoveEntity pos_cube ,-2,0,0:move=1
             If KeyDown(32) Then MoveEntity pos_cube,+2,0,0 :move=1
      


                     ;Vectoren ermitteln für nach oben drehen
                     fTurnVelocityY = fTurnVelocityY*fTurnVelocityFactor
                     fTurnVelocityY = fTurnVelocityY + fTurnSpeed* MouseYSpeed()


                     
                     TurnEntity pos_cube,0, MouseXSpeed()/3,0;seitliches drehen
                     
                              
                              

                              ;winkel prüfen evt anpassen /oben und unten
                              If EntityRoll(body_bone) + fTurnVelocityY < 60 Then
                                 If EntityRoll(body_bone) + fTurnVelocityY > -60 Then
                                    RotateEntity body_bone, EntityPitch(body_bone), EntityYaw(body_bone), EntityRoll(body_bone)+ fTurnVelocityY
                                 Else
                                    RotateEntity body_bone, EntityPitch(body_bone), EntityYaw(body_bone), -60
                                    fTurnVelocityY = 0
                                 EndIf
                              Else
                                 RotateEntity body_bone, EntityPitch(body_bone), EntityYaw(body_bone), 60
                                 fTurnVelocityY = 0
                                 
                              EndIf

                     MoveMouse GraphicsWidth()/2, GraphicsHeight()/2





End Function









Gruß
Dottakopf
Rechtschreibfehler gelten der allgemeinen Belustigung!

Neue Antwort erstellen


Übersicht BlitzBasic Codearchiv

Gehe zu:

Powered by phpBB © 2001 - 2006, phpBB Group