Quote: "
1. I find it hard to follow initially, the code is largely uncommented. So it's not clear what is being done and not clear WHY it's being done.
"
Code comments will be added later, detailing WHY it's being done.
Quote: "
2. I don't see Animation data being written. I could be incorrect but normally that happens at the end of the DBO in it's own section. (I am under the complete belief you know this)
"
There is still a lot of code to be added, so yes, I know this.
Quote: "
3. There doesn't seem to be any Frames being written. The DBO is organized into structures called Frames, and there are just a huge list of code blocks. There's also this confusing mess of recursion in a DBO. This code does not seem to do any of that. However there could be an exception here or there.
"
Yes, the TGC recursion code is confusing. There is still a lot to add and I will explain the recursion process. I have, since uploading the initial code, made a lot more updates that progress further into the DBO structure. Each frame can have either a child or sibling frame , the pointer to these frames are stored as pointers. This helps when rebulding the object "skeleton" hierarchy. The code to do this as you can imagine uses recursion.
Tons more to do, and spare time is pretty much none existent at the moment due to home life and work. Please bear with me on providing further updates to the DBO Load and Save process. I may upload my DBOFastReader code , which reads in DBO and saves out to .X / .OBJ formats (.X fully textured / animated). The code shows how to recreate skeleton bone hierarchal structure. I haven't released it as a tutorial as it reads DBO but doesn't write to DBO, so the idea was to use the TGC C code and see if it could be converted to DBPro equivalent code.
To give you a bit of insight on how the DBOFastReader constructs the Frame (Skeleton) / limb hierarchy, here is an extract of the frame post process code:
FRAMESPOSTPROCESS_CODE:
function FramesPostProcess()
fc=array count(frames())
occ=-1
// first rename "$NoName$" bones i.e. append occurrence number to the frame name
for f=0 to fc
if instr(frames(f).name,"$",1)>0
// replace illegal chars $ if present in animation set name
tempframe$=ReplaceOccur$(frames(f).name,"$","_")
frames(f).name=tempframe$
inc occ
if occ=0
else
frames(f).name=frames(f).name+str$(occ)
endif
endif
next f
for f=0 to fc
if instr(frames(f).name," ",1)>0
tempframe$=ReplaceOccur$(frames(f).name," ","_")
frames(f).name=tempframe$
inc occ
if occ=0
else
frames(f).name=frames(f).name+str$(occ)
endif
endif
next f
for fo=0 to fc
// for each frame (ptr), for each child, find associated frame and copy the child ID and String (Name) to the
if frames(fo).childptr > 0
for fi=0 to fc
if frames(fi).frameptr = frames(fo).childptr
frames(fo).cframe = frames(fi).name
frames(fo).cid = frames(fi).id
exit
endif
next fi
endif
// for each frame (ptr), for each sibling, find associated frame and copy the sibling ID and String (Name) to the source/parent frame
if frames(fo).linkedsiblingptr > 0
for fis=0 to fc
if frames(fis).frameptr = frames(fo).linkedsiblingptr ` OR (frames(fis).frameptr = frames(fo).siblingptr and frames(fo).childptr=0)
frames(fo).sframe = frames(fis).name
frames(fo).sid = frames(fis).id
exit
endif
next fis
endif
// fix 1 : look for 3 occurrences of same sibling ptr, if only 2 then assign sibling ID (SID) to the
// sub frame (not the source frame)
// this fixes hierarchy issues where the next orphan sibling is not found and output during hierarchy
// build (using recursion)
for ff=0 to fc
if fo <> ff
if frames(ff).frameptr = frames(fo).siblingptr
isok=0
for ss = 0 to fc
if frames(ss).linkedsiblingptr = frames(ff).frameptr
isok=1
exit
endif
next ss
if isok =0
frames(fo).sid=frames(ff).id
endif
endif
endif
next ff
next fo
endfunction
function GetLimbChild(fileID, limb)
fr = array count(frames())
l=-1
if frames(limb).id = limb
for ch = 0 to fr
if frames(ch).id = frames(limb).cid
l=frames(limb).cid
exit
endif
next ch
endif
endfunction l
function GetLimbSibling(fileID , limb)
fr = array count(frames())
l=-1
if frames(limb).id = limb
for s = 0 to fr
if frames(s).id = frames(limb).sid
l=frames(limb).sid
exit
endif
next s
else
endif
endfunction l
function GenerateFrameHierarchy(fileID,startlimb)
GenerateFrameHierarchyInfo(fileID,startlimb, Indent)
endfunction
function GenerateFrameHierarchyInfo(fileID, Limb, Indent )
if Limb < 0 then exitfunction
if g_isebe=1
if g_removeebesphere=1
excludeframe=0
else
excludeframe=-1
endif
endif
`if frames(Limb).id=excludeframe then exitfunction
if frames(Limb).name <> ""
if instr(frames(Limb).name,".",0) >0
frames(Limb).name=ReplaceOccur$(frames(Limb).name,".","_")
endif
write string fileID, space$(Indent)+"Frame "+frames(Limb).name+" {" //+str$(Limb)
inc g_openbraces // debug only
// frame transform matrix //
WriteOutFrameTransformMatrixData(fileID,Limb,Indent)
// end frame transform matrix
else
if frames(Limb).id > 0
frames(Limb).name="Group"+str$(frames(Limb).id)
else
frames(Limb).name="Group"
endif
write string fileID, space$(Indent)+"Frame "+frames(Limb).name+" {" //+str$(Limb)
inc g_openbraces // debug only
// frame transform matrix //
WriteOutFrameTransformMatrixData(fileID,Limb,Indent)
// end frame transform matrix
endif
// frame associated mesh (if any)
WriteOutMeshData(fileID,Limb,Indent)
// end frame associated mesh (if any)
if frames(Limb).name <> ""
GenerateFrameHierarchyInfo(fileID, getlimbchild(fileID, Limb), Indent + 2)
write string fileID,space$(Indent + 2)+"}"
inc g_closebraces // debug only
GenerateFrameHierarchyInfo(fileID, getlimbsibling(fileID, Limb), Indent)
endif
endfunction
Pro Programmer / Data Scientist, languages: SAS, C++, SQL, PL-SQL, DBPro, Purebasic, JavaScript, others