Incoporating the object with a DBC animation data file
Hi there
This is regarding how to put a DB animation together with an object's data so as to be able to play the animation as an .x or .3ds object.
1) Make your animation in DB - use this program I made if you want to (just change the name of the object to whatever you choose):
REM USE THIS SECTION TO PLAY THE ANIMATION
load object "walk.x",1
clear all object keyframes 1
append object animation "walk.x","myanim.dat",1,1
loop object 1,1,total object frames(1)
set object speed 1,5
REM USE THE ABOVE SECTION TO PLAY THE ANIMATION
rem Loading the object and clear all keyframes
load object "walk.x",1
clear all object keyframes 1
rem Get the count of limbs and reset all angles
for i =1 to 100
if limb exist(1,i)=1 then inc tlimbcount else exit
next i
rem Reset Variables
limbno=1
sync on : sync rate 0 : do
if cameramode<>1 then gosub LimbFunctions
if cameramode<>1 then gosub SaveAnimation
gosub CameraMovement
gosub ScreenOutput
gosub Controls
gosub PlayAnimation
gosub DeleteAnimation
sync : loop
CameraMovement:
if inkey$()="c" and cameramode=0 then cameramode=1 : wait 100
if inkey$()="c" and cameramode=1 then cameramode=0 : wait 100
if cameramode=1
if mouseclick()=1 then move camera 2
if mouseclick()=2 then move camera -2
rotate camera wrapvalue(camera angle x()+mousemovey()),wrapvalue(camera angle y()+mousemovex()),0.0
endif
RETURN
LimbFunctions:
rem If requested to change limb then change limb to selected limb number
if inkey$()="l" and limbselect=0 then limbselect=1
if limbselect=1
input "Enter Limb Number:",limbno
if limbno>0 then limbselect=0
endif
`Color the current limb and uncolour all else
color limb 1,limbno,rgb(225,75,75)
for i=1 to tlimbcount
if i<>limbno then color limb 1,i,rgb(200,200,200)
next i
rem Update limb angle
if mouseclick()=0 then rotate limb 1,limbno,wrapvalue(limb angle x(1,limbno)+(mousemovey()/2)),wrapvalue(limb angle y(1,limbno)+(mousemovex()/2)),limb angle z(1,limbno)
if mouseclick()=1 then rotate limb 1,limbno,limb angle x(1,limbno),limb angle y(1,limbno),wrapvalue(limb angle z(1,limbno)+(mousemovex()/2))
rem If returnkey=1 then the limb to reset position
if controlkey()=1 then rotate limb 1,limbno,0.0,0.0,0.0
RETURN
SaveAnimation:
if spacekey()=1 then set object keyframe 1,keyframecount : wait 100 : inc keyframecount,5
if inkey$()="s" then save object animation "myanim.dat",1 : wait 100
RETURN
PlayAnimation:
if inkey$()="p" then wait 100 : loop object 1
if inkey$()="P" then wait 100 : stop object 1 : set object frame 1,1.0
RETURN
DeleteAnimation:
if inkey$()="d" then dec keyframecount,5 : wait 100
if inkey$()="D" then for i = 0 to keyframecount : clear object keyframe 1,i : next i : keyframecount=0 : wait 100
RETURN
ScreenOutput:
set cursor 0,0 : print "Limb Angle X", limb angle x(1,limbno)
set cursor 0,15 : print "Limb Angle Y", limb angle y(1,limbno)
set cursor 0,30 : print "Limb Angle Z", limb angle z(1,limbno)
set cursor 0,45 : print "Current Limb",limbno
set cursor 0,60 : print "Total Limb Numer",tlimbcount
set cursor 0,85 : print "Current Keyframe",keyframecount
RETURN
Controls:
set cursor 400,480-15:print "d = delete current keyframe"
set cursor 400,480-30:print "D = delete all keyframes"
set cursor 400,480-45:print "p = loop object"
set cursor 400,480-60:print "P = stop object"
set cursor 400,480-85:print "spacekey = save current keyframe"
set cursor 400,480-100:print "s = save all frames to file"
set cursor 400,480-115:print "returnkey = reset all angles"
set cursor 400,480-130:print "l = change limb number"
set cursor 400,480-145:print "----------"
set cursor 400,480-160:print " CONTROLS "
RETURN
remend
2) Copy all the data in your object file ONLY UNTIL WHERE THE ANIMATION DATA STARTS which is usually something like "AnimationSet xdb_animset_0" into your animation file (which is saved as myanim.dat as default).
To do this, you must rename your model file and myanim.dat as a Text files and then open them in WordPad or Notepad.
Remember to keep the copied data on TOP of the animation data from myanim.dat
Now you can play the animation and load the object in DB editor as a normal .x object - though maybe not in other applications because the syntax is not standard.
Hope this helps anyone
HelloWorld Tommorrow