Misfit3D OpenGL editor (WIN and Linux) native file reader.

Post your FreeBASIC source, examples, tips and tricks here. Please don’t post code without including an explanation.
Post Reply
D.J.Peters
Posts: 8631
Joined: May 28, 2005 3:28
Contact:

Misfit3D OpenGL editor (WIN and Linux) native file reader.

Post by D.J.Peters »

Misfit 3D is an old but easy to use open source OpenGL 3D editor with skeletal bone/joint and frame based animation.
It supports many texture and 3D file formats.
Missing things can be added via Plugin Windows *.dll or Linux *.so libs.
Image
I self use version 1.3.8 for editing my car models one feature are I can add individual metha data like mass gear ratios and so on.
Or i can add user defined points with rotation and translation good for the physical part of the models.
I read the C++ classes and wrote an native *.mm3d filereader.
The internal material properties are exactly the Open GL counter part in this file format.
Wat you see while editing is what you will get in your own Open GL game or what ever

bla lba bla :-)

Joshy

Short overview of this nice tiny tool on youtube:
https://www.youtube.com/watch?v=1KQFh8uRBjk
https://www.youtube.com/watch?v=h9hwM2o3BvQ

Code: Select all

' Misfit 3D 1.3.8 native file format *.mm3d

 ' Flags
 ' 1 = MF_HIDDEN
 ' 2 = MF_SELECTED
 ' 4 = MF_FREE (vertex does not have to be conntected to a face)

 ' Material Flags and &HF
 '  0 = MATTYPE_TEXTURE
 ' 13 = MATTYPE_COLOR
 ' 14 = MATTYPE_GRADIENT
 ' 15 = MATTYPE_BLANK

 ' 16 = MF_MAT_CLAMP_S clamp s coord instead of repeat
 ' 32 = MF_MAT_CLAMP_T clamp t coord instead of repeat

#define VERBOSE

#ifdef VERBOSE
#define DPRINT(_txt_) open err for output as #99 : print #99,_txt_ : close #99
#else
#define DPRINT(_txt_) :
#endif


const as ulongint MAGIC = &H443354494653494D ' "MISFIT3D"

const FILENAME = "test01.mm3d"

type MM3D_HEADER field=1
  as ulongint Magic
  as ubyte    Major
  as ubyte    Minor
  as ubyte    Flags
  as ubyte    nOffsets
end type

type MM3D_OFFSET field=2
  as ushort   OffsetType
  as ulong    Offset
end type

type MM3D_METAINFORMATION
  as zstring ptr pKey
  as zstring ptr pValue
end type
type PMM3D_METAINFORMATION as MM3D_METAINFORMATION ptr
dim as PMM3D_METAINFORMATION ptr pMetaInformations
dim as long                      nMetaInformations

type MM3D_VERTEX field=2
  as ushort Flags 
  as single Coords(2)
end type
dim as MM3D_VERTEX ptr pVertices
dim as long            nVertices

type MM3D_TRIANGLE field=2
  as ushort Flags
  as ulong  Vertices(2)
end type

dim as MM3D_TRIANGLE ptr pTriangles
dim as long              nTriangles
 
type MM3D_NORMALS field=2
  as ushort   Flags
  as ulong    TriangleIndex
  as single   Normal(2,2)
end type
dim as MM3D_NORMALS ptr pNormals
dim as long             nNormals

type MM3D_GROUP field=1
  as ushort       Flags
  as zstring ptr  pName
  as ulong        nTriangles
  as ulong   ptr pTriangleIndices
  as ubyte        Smoothness
  as ulong        MaterialIndex
end type
type PMM3D_GROUP as MM3D_GROUP ptr
dim as PMM3D_GROUP ptr pGroups
dim as long            nGroups



type MM3D_MATERIAL field=2
  as ushort      Flags
  as ulong       TextureIndex
  as zstring ptr pName
  as single      Ambient(3)
  as single      Diffuse(3)
  as single      Specular(3)
  as single      Emissive(3)
  as single      Shininess
end type
type PMM3D_MATERIAL as MM3D_MATERIAL ptr
dim as PMM3D_MATERIAL ptr pMaterials
dim as long               nMaterials

type MM3D_EXTERNAL_TEXTURE field=2
  as ushort      Flags
  as zstring ptr pPath
end type
type PMM3D_EXTERNAL_TEXTURE as MM3D_EXTERNAL_TEXTURE ptr
dim as PMM3D_EXTERNAL_TEXTURE ptr pExternalTextures
dim as long                      nExternalTextures

type MM3D_TEXTURE_COORD field=2
  as ushort Flags
  as ulong  TriangleIndex
  as single sCoords(2)
  as single tCoords(2)
end type
dim as MM3D_TEXTURE_COORD ptr pTextureCoords
dim as long                  nTextureCoords 

type MM3D_SMOOTH_ANGLE field=1
  as ulong    GroupIndex
  as ubyte    Angle
end type
type PMM3D_SMOOTH_ANGLE as MM3D_SMOOTH_ANGLE ptr
dim as PMM3D_SMOOTH_ANGLE ptr pSmoothAngles
dim as long                  nSmoothAngles

type MM3D_TEXTURE_PROJECTION field=2
  as ushort      Flags
  as zstring ptr pName
  as long        ProjectionsType
  as single      PosVector(2)
  as single      UpVector(2)
  as single      SeamVector(2)
  as single      ProjectionRange(1,1)
end type
type PMM3D_TEXTURE_PROJECTION as MM3D_TEXTURE_PROJECTION ptr
dim as PMM3D_TEXTURE_PROJECTION ptr pTextureProjections
dim as long                        nTextureProjections

type MM3D_TEXTURE_PROJECTIONS_TRIANGLE
  as ulong ProjIndex
  as ulong nTriangles
  as ulong ptr pIndicies
end type
type PMM3D_TEXTURE_PROJECTIONS_TRIANGLE as MM3D_TEXTURE_PROJECTIONS_TRIANGLE ptr
dim as PMM3D_TEXTURE_PROJECTIONS_TRIANGLE ptr pTextureProjectionTriangles
dim as long                                 nTextureProjectionTriangles

type MM3D_POINT
  as ushort      Flags
  as zstring ptr pName
  as long        PointType
  as long        BoneIndex
  as single      Rotation(2)
  as single      Translation(2)
end type
type PMM3D_POINT as MM3D_POINT ptr
dim as PMM3D_POINT ptr pPoints
dim as long            nPoints


type MM3D_JOINT
  as ushort      Flags
  as zstring ptr pName
  as long        ParentIndex
  as single      Rotation(2)
  as single      Translation(2)
end type
type PMM3D_JOINT as MM3D_JOINT ptr
dim as PMM3D_JOINT ptr pJoints
dim as long            nJoints


type MM3D_SKELETAL_ANIMATION_KEYFRAME field=1
  as ulong JointIndex
  as ubyte    KeyframeType
  as single   param(2)
end type
type PMM3D_SKELETAL_ANIMATION_KEYFRAME as MM3D_SKELETAL_ANIMATION_KEYFRAME ptr

type MM3D_SKELETAL_ANIMATION_FRAME
  as ulong    nKeyframes
  as PMM3D_SKELETAL_ANIMATION_KEYFRAME ptr pKeyframes
end type
type PMM3D_SKELETAL_ANIMATION_FRAME as MM3D_SKELETAL_ANIMATION_FRAME ptr

type MM3D_SKELETAL_ANIMATION
  as ushort          Flags
  as zstring ptr     pName
  as single          FPS
  as ulong           nFrames
  as PMM3D_SKELETAL_ANIMATION_FRAME ptr pFrames
end type
type PMM3D_SKELETAL_ANIMATION as MM3D_SKELETAL_ANIMATION ptr
dim as PMM3D_SKELETAL_ANIMATION ptr pSkeletalAnimations
dim as long                        nSkeletalAnimations

type MM3D_FRAME_ANIMATION_VERTEX
  as single Coords(2)
end type
type PMM3D_FRAME_ANIMATION_VERTEX as MM3D_FRAME_ANIMATION_VERTEX ptr

type MM3D_FRAME_ANIMATION_FRAME
  as long                        nFrameVertices
  as PMM3D_FRAME_ANIMATION_VERTEX ptr pFrameVertices
end type
type PMM3D_FRAME_ANIMATION_FRAME as MM3D_FRAME_ANIMATION_FRAME ptr

type MM3D_FRAME_ANIMATION
  as ushort                        Flags
  as zstring ptr                   pName
  as single                        FPS
  as ulong                      nFrames
  as PMM3D_FRAME_ANIMATION_FRAME ptr pFrames
end type
type PMM3D_FRAME_ANIMATION as MM3D_FRAME_ANIMATION ptr
dim as PMM3D_FRAME_ANIMATION ptr pFrameAnimations
dim as long                     nFrameAnimations

'
' main
'
ChDir ExePath

dim as long hFile=FreeFile()

if open(FILENAME,for binary,access read,as #hFile) then
  print "error: can't open " & FILENAME 
  beep:sleep:end 1
end if

dim as long nBytes=lof(hFile)
if nBytes<sizeof(MM3D_HEADER) then
  close #hFile
  print "error: wrong file size " & nBytes 
  beep:sleep:end 2
end if
' read file in memory
dim as ubyte ptr pFile=new ubyte[nBytes]
get #hFile,,*pFile,nBytes
close #hFile

dim as any ptr pBuffer=pFile

dim as MM3D_HEADER Header=*cptr(MM3D_HEADER ptr,pBuffer):pBuffer+=sizeof(MM3D_HEADER)
if Header.magic<>MAGIC then
  delete pFile
  print "error: " & FILENAME & " isn't a MISFIT3D file !"
  beep:sleep:end 3
end if

if Header.major<1 then
  delete pFile
  print "error: wrong version " & Header.major & "." & Header.minor & " must be 1.0 or greather !"
  beep:sleep:end 4
end if

' assign from memory
#define PU8  cptr(ubyte    ptr,pBuffer) : pBuffer+=1
#define PU16 cptr(ushort   ptr,pBuffer) : pBuffer+=2
#define PU32 cptr(ulong    ptr,pBuffer) : pBuffer+=4
#define PI32 cptr(long     ptr,pBuffer) : pBuffer+=4
#define PF32 cptr(single   ptr,pBuffer) : pBuffer+=4
#define PF64 cptr(double   ptr,pBuffer) : pBuffer+=8


' read from memory
#define U8  *cptr(ubyte    ptr,pBuffer) : pBuffer+=1
#define U16 *cptr(ushort   ptr,pBuffer) : pBuffer+=2
#define U32 *cptr(ulong    ptr,pBuffer) : pBuffer+=4
#define I32 *cptr(long     ptr,pBuffer) : pBuffer+=4
#define F32 *cptr(single   ptr,pBuffer) : pBuffer+=4
#define F64 *cptr(double   ptr,pBuffer) : pBuffer+=8
#define ZS   cptr(zstring  ptr,pBuffer) : while *cptr(ubyte ptr,pBuffer)<>0:pBuffer+=1:wend:pBuffer+=1

dim as MM3D_OFFSET ptr pOffsets=pBuffer' : pBuffer+=Header.noffsets*sizeof(MM3D_OFFSET)
for n as long=0 to Header.noffsets-1
  if pOffsets[n].offsettype=&H3fff then continue for ' File end offset
  'DPRINT( "0x" & hex(pOffsets[n].offsettype,4) & " , " & pOffsets[n].offset)
  dim as long Variable=iif(pOffsets[n].offsettype and &H8000,0,-1)
  pBuffer=@pFile[pOffsets[n].offset]
  dim as ushort   flags =U16
  dim as ulong count =U32
  if count<1 then continue for
  dim as ulong size
  if Variable=0 then 
    size = U32
    'DPRINT( "type = 0x" & hex(pOffsets[n].offsettype,4) & " flags = " & flags & " count = " & count & " size = " & size)
  else
    'DPRINT( "type = 0x" & hex(pOffsets[n].offsettype,4) & " flags = " & flags & " count = " & count)
  end if
  
  select case pOffsets[n].offsettype

  ' OffsetTypeA (MSB is 0 = variable size)
  case &H1001

      DPRINT("Meta information : " & count)
      nMetaInformations=count : pMetaInformations=new PMM3D_METAINFORMATION[nMetaInformations]
      for i as long=0 to nMetaInformations-1
        size=U32
        pMetaInformations[i]=new MM3D_METAINFORMATION
        pMetaInformations[i]->pKey  =ZS
        pMetaInformations[i]->pValue=ZS
        DPRINT( "Key = " & chr(34) & *pMetaInformations[i]->pKey & chr(34) & " Value = " & chr(34) & *pMetaInformations[i]->pValue & chr(34))
      next


  case &H1002 

      DPRINT("Unknown type information : " & count)

  case &H0101

      DPRINT("Groups : " & count)
      nGroups=count : pGroups=new PMM3D_GROUP[nGroups]
      for i as long=0 to nGroups-1
        size=U32
        pGroups[i]=new MM3D_GROUP
        pGroups[i]->Flags           =U16
        pGroups[i]->pName           =ZS
        pGroups[i]->nTriangles      =U32
        DPRINT("Flags = " & pGroups[i]->Flags & " Name = " & chr(34) & *pGroups[i]->pName & chr(34) & " nTriangles = " & pGroups[i]->nTriangles)
        pGroups[i]->pTriangleIndices=pBuffer:pBuffer+=sizeof(ulong)*pGroups[i]->nTriangles
        pGroups[i]->Smoothness      =U8
        pGroups[i]->MaterialIndex   =U32
        DPRINT("Smoothness = " & pGroups[i]->Smoothness & " MaterialIndex = " & pGroups[i]->MaterialIndex)
        DPRINT("Triangle indices :")
        #ifdef VERBOSE
        const as long NPERROW = 12
        dim as long k=0
        dim as long nLines=pGroups[i]->nTriangles  \  NPERROW
        dim as long nRest =pGroups[i]->nTriangles mod NPERROW
        if nLines>0 then
          for nl as long=0 to nLines-1
            dim as string l = "" & pGroups[i]->pTriangleIndices[k]:k+=1
            for j as long=1 to NPERROW-1
              l &= ", " & pGroups[i]->pTriangleIndices[k]:k+=1
            next
            DPRINT(l)
          next
        end if
        if nRest>0 then
          dim as string l = "" & pGroups[i]->pTriangleIndices[k]:k+=1
          for j as long=1 to nRest-1
            l &= ", " & pGroups[i]->pTriangleIndices[k]:k+=1
          next
          DPRINT(l)
        end if
        #endif
      next


  case &H0141 

      DPRINT("Embedded textures : " & count)


  case &H0142 

      DPRINT("External textures : " & count)
      nExternalTextures=count : pExternalTextures=new PMM3D_EXTERNAL_TEXTURE[nExternalTextures]
      for i as long = 0 to nExternalTextures-1
        size=U32
        pExternalTextures[i]=new MM3D_EXTERNAL_TEXTURE
        pExternalTextures[i]->Flags = U16
        if size>512 then
          pExternalTextures[i]->pPath=0
          while *cptr(ubyte ptr,pBuffer)<>0:pBuffer+=1:wend:pBuffer+=1
          DPRINT("Flags = " & pExternalTextures[i]->Flags & " Path size to large = "  & size)
        else
          pExternalTextures[i]->pPath = ZS
          DPRINT("Flags = " & pExternalTextures[i]->Flags & " Path = " & *pExternalTextures[i]->pPath)
        end if
      next


  case &H0161 

      DPRINT("Materials : " & count)
      nMaterials=count : pMaterials=new PMM3D_MATERIAL[nMaterials]
      for i as long=0 to nMaterials-1
        size=U32
        pMaterials[i]=new MM3D_MATERIAL
        pMaterials[i]->Flags        =U16
        pMaterials[i]->TextureIndex =U32
        pMaterials[i]->pName        =ZS
        DPRINT( "Name = " & chr(34) & *pMaterials[i]->pName & chr(34) & " Flags = " & pMaterials[i]->Flags & " TextureIndex = " & pMaterials[i]->TextureIndex)
        for j as long=0 to 3
          pMaterials[i]->Ambient(j) =F32 
          if pMaterials[i]->Ambient(j)<0 then pMaterials[i]->Ambient(j)=0
        next
        for j as long=0 to 3 
          pMaterials[i]->Diffuse(j) =F32
          if pMaterials[i]->Diffuse(j)<0 then pMaterials[i]->Diffuse(j)=0
        next
        for j as long=0 to 3 
          pMaterials[i]->Specular(j)=F32
          if pMaterials[i]->Specular(j)<0 then pMaterials[i]->Specular(j)=0
        next
        for j as long=0 to 3 
          pMaterials[i]->Emissive(j)=F32
          if pMaterials[i]->Emissive(j)<0 then pMaterials[i]->Emissive(j)=0
        next
        pMaterials[i]->Shininess=F32
        if pMaterials[i]->Shininess<0 then pMaterials[i]->Shininess=0
        #ifdef VERBOSE
        DPRINT("Ambient  = " & pMaterials[i]->Ambient(0)  & " , " & pMaterials[i]->Ambient(1)  & " , " & pMaterials[i]->Ambient(2))
        DPRINT("Diffuse  = " & pMaterials[i]->Diffuse(0)  & " , " & pMaterials[i]->Diffuse(1)  & " , " & pMaterials[i]->Diffuse(2))
        DPRINT("Specular = " & pMaterials[i]->Specular(0) & " , " & pMaterials[i]->Specular(1) & " , " & pMaterials[i]->Specular(2))
        DPRINT("Emissive = " & pMaterials[i]->Emissive(0) & " , " & pMaterials[i]->Emissive(1) & " , " & pMaterials[i]->Emissive(2))
        DPRINT("Shininess= " & pMaterials[i]->Shininess) 
        #endif
      next


  case &H016c

      DPRINT("Texture Projection Triangles : " & count)
      nTextureProjectionTriangles=count 
      pTextureProjectionTriangles=new PMM3D_TEXTURE_PROJECTIONS_TRIANGLE[nTextureProjectionTriangles]
      for i as long=0 to nTextureProjectionTriangles-1
        size=U32
        pTextureProjectionTriangles[i]=new MM3D_TEXTURE_PROJECTIONS_TRIANGLE
        pTextureProjectionTriangles[i]->ProjIndex=U32
        pTextureProjectionTriangles[i]->nTriangles=U32
        DPRINT( "ProjIndex = " & pTextureProjectionTriangles[i]->ProjIndex & " nTriangles = " & pTextureProjectionTriangles[i]->nTriangles)
        pTextureProjectionTriangles[i]->pIndicies=pBuffer:pBuffer+=4*pTextureProjectionTriangles[i]->nTriangles
      next


  case &H0191

      DPRINT("Canvas background images : " & count)


  case &H0301

      DPRINT("Skeletal Animations : " & count)
      nSkeletalAnimations=count
      pSkeletalAnimations=new PMM3D_SKELETAL_ANIMATION[nSkeletalAnimations]
      for i as long= 0 to nSkeletalAnimations-1
        size = U32
        pSkeletalAnimations[i] = new MM3D_SKELETAL_ANIMATION
        pSkeletalAnimations[i]->Flags   = U16
        pSkeletalAnimations[i]->pName   = ZS
        pSkeletalAnimations[i]->FPS     = F32
        pSkeletalAnimations[i]->nFrames = U32
        DPRINT("Flags = " & pSkeletalAnimations[i]->Flags & " Name = " & *pSkeletalAnimations[i]->pName & " FPS = " & pSkeletalAnimations[i]->FPS & " nFrames = " & pSkeletalAnimations[i]->nFrames)
        if pSkeletalAnimations[i]->nFrames>0 then
          pSkeletalAnimations[i]->pFrames = new PMM3D_SKELETAL_ANIMATION_FRAME[pSkeletalAnimations[i]->nFrames]
          for j as long=0 to pSkeletalAnimations[i]->nFrames-1
            pSkeletalAnimations[i]->pFrames[j] = new MM3D_SKELETAL_ANIMATION_FRAME
            pSkeletalAnimations[i]->pFrames[j]->nKeyframes = U32
            if pSkeletalAnimations[i]->pFrames[j]->nKeyframes>0 then
              DPRINT("Skeletal Animation[" & i & "] Frame[" & j & "] nKeyframes = " & pSkeletalAnimations[i]->pFrames[j]->nKeyframes )
              pSkeletalAnimations[i]->pFrames[j]->pKeyframes = new PMM3D_SKELETAL_ANIMATION_KEYFRAME[pSkeletalAnimations[i]->pFrames[j]->nKeyframes]
              for k as long=0 to pSkeletalAnimations[i]->pFrames[j]->nKeyframes-1
                pSkeletalAnimations[i]->pFrames[j]->pKeyframes[k] = new MM3D_SKELETAL_ANIMATION_KEYFRAME
                dim as ulong JointIndex=U32
                pSkeletalAnimations[i]->pFrames[j]->pKeyframes[k]->JointIndex   = JointIndex
                dim as ubyte KeyframeType=U8
                pSkeletalAnimations[i]->pFrames[j]->pKeyframes[k]->KeyframeType = KeyframeType
                dim as single p1=F32
                dim as single p2=F32
                dim as single p3=F32
                pSkeletalAnimations[i]->pFrames[j]->pKeyframes[k]->Param(0)     = p1
                pSkeletalAnimations[i]->pFrames[j]->pKeyframes[k]->Param(1)     = p2
                pSkeletalAnimations[i]->pFrames[j]->pKeyframes[k]->Param(2)     = p3
                DPRINT("Skeletal Animation[" & i & "] Frame[" & j & "] KeyFrame[" & k & "]")
                DPRINT("Joint[" & JointIndex & "]  KeyframeType = " & KeyframeType & " coords = " & p1 & "," & p2 & "," & p3)
              next
            end if
          next
        end if
      next
     
  case &H0321

      DPRINT("Frame Animations : " & count)
      nFrameAnimations=count
      pFrameAnimations=new PMM3D_FRAME_ANIMATION[nFrameAnimations]
      for i as long = 0 to nFrameAnimations-1
        size = U32
        pFrameAnimations[i] = new MM3D_FRAME_ANIMATION
        pFrameAnimations[i]->Flags   = U16
        pFrameAnimations[i]->pName   = ZS
        pFrameAnimations[i]->FPS     = F32
        pFrameAnimations[i]->nFrames = U32
        DPRINT("Flags = " & pFrameAnimations[i]->Flags & " Name = " & *pFrameAnimations[i]->pName & " FPS = " & pFrameAnimations[i]->FPS & " nFrames = " & pFrameAnimations[i]->nFrames)
        if pFrameAnimations[i]->nFrames>0 then
          pFrameAnimations[i]->pFrames = new PMM3D_FRAME_ANIMATION_FRAME[pFrameAnimations[i]->nFrames]
          for j as long=0 to pFrameAnimations[i]->nFrames-1
            pFrameAnimations[i]->pFrames[j] = new MM3D_FRAME_ANIMATION_FRAME
            pFrameAnimations[i]->pFrames[j]->nFrameVertices=nVertices
            if pFrameAnimations[i]->pFrames[j]->nFrameVertices>0 then
              pFrameAnimations[i]->pFrames[j]->pFrameVertices = new PMM3D_FRAME_ANIMATION_VERTEX[pFrameAnimations[i]->pFrames[j]->nFrameVertices]
              for k as long = 0 to pFrameAnimations[i]->pFrames[j]->nFrameVertices-1
                pFrameAnimations[i]->pFrames[j]->pFrameVertices[k]=new MM3D_FRAME_ANIMATION_VERTEX
                pFrameAnimations[i]->pFrames[j]->pFrameVertices[k]->Coords(0)=F32
                pFrameAnimations[i]->pFrames[j]->pFrameVertices[k]->Coords(1)=F32
                pFrameAnimations[i]->pFrames[j]->pFrameVertices[k]->Coords(2)=F32
                DPRINT("Frame Animation[" & i & "] Frame[" & j & "] Vertex[" & k & "]")
                DPRINT("x = " & pFrameAnimations[i]->pFrames[j]->pFrameVertices[k]->Coords(0) & " y = " & pFrameAnimations[i]->pFrames[j]->pFrameVertices[k]->Coords(1) & " z = " & pFrameAnimations[i]->pFrames[j]->pFrameVertices[k]->Coords(2))
              next
            end if
          next
        end if
      next

  case &H0326 

      DPRINT("Frame Animation Points : " & count)


  case &H0341

      DPRINT("Frame Relative Animations : " & count)


  case &H3fff

      DPRINT("File end offset : " & count)


  ' OffsetTypeB (MSB is 1 = fixed size)
  case &H8001 

      DPRINT("Vertices : " & count)
      nVertices=Count 
      pVertices=pBuffer

      for i as long=0 to nVertices-1
         DPRINT("Flags = " & pVertices[i].Flags & " Vertex[" & i & "] = " & _
                             pVertices[i].Coords(0) & " , " & _
                             pVertices[i].Coords(1) & " , " & _
                             pVertices[i].Coords(2))
      next


  case &H8021 

      DPRINT("Triangles : " & count)
      nTriangles=Count : pTriangles=pBuffer
      for i as long=0 to nTriangles-1
        DPRINT("Flags = " & pTriangles[i].Flags & " TriangleVertices = " & _
                            pTriangles[i].Vertices(0) & " , " & _
                            pTriangles[i].Vertices(1) & " , " & _
                            pTriangles[i].Vertices(2))
      next

  case &H8026 

      DPRINT("Triangle Normals : " & count)
      nNormals=Count : pNormals=pBuffer
      for i as long=0 to nNormals-1
        DPRINT("Flags = " & pNormals[i].Flags & " TriangleIndex = " & pNormals[i].TriangleIndex)
        DPRINT( pNormals[i].Normal(0,0) & " , " & pNormals[i].Normal(0,1) & " , " & pNormals[i].Normal(0,2)  )
        DPRINT( pNormals[i].Normal(1,0) & " , " & pNormals[i].Normal(1,1) & " , " & pNormals[i].Normal(1,2)  )
        DPRINT( pNormals[i].Normal(2,0) & " , " & pNormals[i].Normal(2,1) & " , " & pNormals[i].Normal(2,2)  )
      next


  case &H8041

      DPRINT("Joints : " & count)
      nJoints = count : pJoints = new PMM3D_JOINT[nJoints]
      for i as long = 0 to nJoints-1
        pJoints[i] = new MM3D_JOINT
        pJoints[i]->Flags          = U16
        pJoints[i]->pName          = pBuffer:pBuffer+=40
        pJoints[i]->ParentIndex    = I32
        pJoints[i]->Rotation(0)    = F32
        pJoints[i]->Rotation(1)    = F32
        pJoints[i]->Rotation(2)    = F32
        pJoints[i]->Translation(0) = F32
        pJoints[i]->Translation(1) = F32
        pJoints[i]->Translation(2) = F32
        DPRINT("Flags = " & pJoints[i]->Flags & " Name = " & *pJoints[i]->pName & " ParentIndex = " & pJoints[i]->ParentIndex)
        DPRINT("Rotation = " & pJoints[i]->Rotation(0) & "," & _
                               pJoints[i]->Rotation(1) & "," & _
                               pJoints[i]->Rotation(2) & _
               " Translation = " & pJoints[i]->Translation(0) & "," & _
                                   pJoints[i]->Translation(1) & "," & _
                                   pJoints[i]->Translation(2))
      next

  case &H8046 

      DPRINT("Joint Vertices : " & count)


  case &H8061 

      DPRINT("Points : " & count)
      nPoints = count : pPoints = new PMM3D_POINT[nPoints]
      for i as long =0 to nPoints-1
        pPoints[i]=new MM3D_POINT
        pPoints[i]->Flags=U16
        pPoints[i]->pName=cptr(zstring ptr,pBuffer):pBuffer+=40
        pPoints[i]->PointType=I32
        pPoints[i]->BoneIndex=I32
        DPRINT("Flags = " & pPoints[i]->Flags & " Name = " & chr(34) & *pPoints[i]->pName & chr(34) & _
                                                " PointType = " & pPoints[i]->PointType & _
                                                " BoneIndex = " & pPoints[i]->BoneIndex)
        for j as long=0 to 2
          pPoints[i]->Rotation(j)=F32
        next
        DPRINT("Rotation    = " &  pPoints[i]->Rotation(0) & " , " & _
                                   pPoints[i]->Rotation(1) & " , " & _
                                   pPoints[i]->Rotation(2))
        for j as long=0 to 2
          pPoints[i]->Translation(j)=F32
        next
        DPRINT("Translation = " &  pPoints[i]->Translation(0) & " , " & _
                                   pPoints[i]->Translation(1) & " , " & _
                                   pPoints[i]->Translation(2))
      next


  case &H8106 

      DPRINT("Smooth Angles : " & count)
      nSmoothAngles=count : pSmoothangles=new PMM3D_SMOOTH_ANGLE[nSmoothAngles]
      for i as long=0 to nSmoothAngles-1
        pSmoothangles[i]=new MM3D_SMOOTH_ANGLE
        pSmoothangles[i]->GroupIndex=U32
        pSmoothangles[i]->Angle=U8
        DPRINT("GroupIndex = " & pSmoothangles[i]->GroupIndex & " Angle = " & pSmoothangles[i]->Angle)
      next


  case &H8121 

      DPRINT("Texture Coordinates : " & count)
      nTextureCoords=count : pTextureCoords=pBuffer
      for i as long=0 to nTextureCoords-1
        DPRINT("Flags = " & pTextureCoords[i].Flags & " TriangleIndex = " & pTextureCoords[i].TriangleIndex)
        for j as long=0 to 2
          DPRINT("s,u = " & pTextureCoords[i].sCoords(j) & " , " & pTextureCoords[i].tCoords(j))
        next
      next


  case &H8146

      DPRINT("Weighted Influences : " & count)


  case &H8168

      DPRINT("Texture Projections : " & count)
      nTextureProjections=count : pTextureProjections=new PMM3D_TEXTURE_PROJECTION[nTextureProjections]
      for i as long=0 to nTextureProjections-1
        pTextureProjections[i]=new MM3D_TEXTURE_PROJECTION
        pTextureProjections[i]->Flags=U16
        pTextureProjections[i]->pName=cptr(zstring ptr,pBuffer):pBuffer+=40
        pTextureProjections[i]->ProjectionsType=U32
        DPRINT("Flags = " & pTextureProjections[i]->Flags & " Name = " & chr(34) & *pTextureProjections[i]->pName & chr(34) & " Type = " & pTextureProjections[i]->ProjectionsType)
        for j as long=0 to 2
          pTextureProjections[i]->PosVector(j)=F32
        next
        DPRINT("PosVector  = " & pTextureProjections[i]->PosVector(0) & " , " & _
                                 pTextureProjections[i]->PosVector(1) & " , " & _
                                 pTextureProjections[i]->PosVector(2))
        for j as long=0 to 2
          pTextureProjections[i]->UpVector(j)=F32
        next
        DPRINT("UpVector   = "  & pTextureProjections[i]->UpVector(0) & " , " & _
                                  pTextureProjections[i]->UpVector(1) & " , " & _
                                  pTextureProjections[i]->UpVector(2))
        for j as long=0 to 2
          pTextureProjections[i]->SeamVector(j)=F32
        next
        DPRINT("SeamVector = " & pTextureProjections[i]->SeamVector(0) & " , " & _
                                 pTextureProjections[i]->SeamVector(1) & " , " & _
                                 pTextureProjections[i]->SeamVector(2))
        for j as long=0 to 1
          for k as long=0 to 1
            pTextureProjections[i]->ProjectionRange(j,k)=F32
            pTextureProjections[i]->ProjectionRange(j,k)=F32
          next
        next
        DPRINT("ProjRange  = " & pTextureProjections[i]->ProjectionRange(0,0) & " , " & _
                                 pTextureProjections[i]->ProjectionRange(0,1) )
        DPRINT("             " & pTextureProjections[i]->ProjectionRange(1,0) & " , " & _
                                 pTextureProjections[i]->ProjectionRange(1,1) )
      next

  end select
next

print "ok ..."
sleep

Post Reply