GMax Importer entwickeln

Übersicht Ressourcen Andere Programme oder Tools

Neue Antwort erstellen

Vertex

Betreff: GMax Importer entwickeln

BeitragMo, Dez 20, 2004 20:39
Antworten mit Zitat
Benutzer-Profile anzeigen
Da ich ich an einem Importer in GMax(/3DMax) für das Blitz3D Format arbeite, möchte ich mal kurz zeigen, was man genrelles so machen kann. Es gibt ja leider keine (naja gut sagen wir nur schlechte) Tutorials für MaxScript.

Code: [AUSKLAPPEN]
utility TextureTest "TextureTest"
(
   button cmdStart "start" pos:[23,16] width:109 height:28

   on cmdStart pressed do
   (
      ---------------------------------------------------------------------------------
      local texture
      local textureBMP
      local textureMap

      local vertexList     = #()
      local uvwList        = #()
      local faceList       = #()
      local materialIDList = #()

      local testMesh

      local faceIndex

      local testSkin
      local bone1
      local bone2
      ---------------------------------------------------------------------------------

      ---------------------------------------------------------------------------------
      textureBMP = OpenBitmap "C:\\Eigene Dateien\\gmax\\blub.bmp"

      textureMap = bitmapTexture bitmap:textureBMP name:"Texturemap1"

      texture                = standardMaterial Name:"Texture1"
      texture.shaderType     = 1 -- blinn
      texture.diffuseMap     = textureMap

      showTextureMap texture textureMap TRUE
      ---------------------------------------------------------------------------------

      ---------------------------------------------------------------------------------
      append vertexList [-50, 0,  50] -- left  | top
      append vertexList [ 50, 0,  50] -- right | top
      append vertexList [-50, 0, -50] -- left  | bottom
      append vertexList [ 50, 0, -50] -- right | bottom

      append uvwList [0, 1, 0]  -- left  | top
      append uvwList [1, 1, 0]  -- right | top
      append uvwList [0, 0, 0]  -- left  | bottom
      append uvwList [1, 0, 0]  -- right | bottom

      append faceList [4, 2, 1]
      append faceList [1, 3, 4]

      append materialIDList 1
      append materialIDList 1

      testMesh = mesh vertices:vertexList \
            tverts:uvwList \
                                faces:faceList \
                      materialIDs:materialIDList \
                                material:texture

      
      setNormal testMesh 1 [0, -1, 0] -- to front
      setNormal testMesh 2 [0, -1, 0] -- to front
      setNormal testMesh 3 [0, -1, 0] -- to front
      setNormal testMesh 4 [0, -1, 0] -- to front

      buildTVFaces testMesh
      for faceIndex = 1 to faceList.count do
      (
         setTVFace testMesh faceIndex faceList[faceIndex]
      )

      update testMesh TRUE
      ---------------------------------------------------------------------------------

      ---------------------------------------------------------------------------------
      bone1 = boneSys.createBone [0, 0, -50] [0, 0,  0] [0, 0, 0]
      bone2 = boneSys.createBone [0, 0,   0] [0, 0, 50] [0, 0, 0]
      bone2.parent = bone1
      
      max modify mode
      select testMesh
      testSkin = skin()
      addModifier testMesh testSkin

      skinOps.addBone testSkin bone1 1
      skinOps.addBone testSkin bone2 1
      
      skinOps.selectBone testSkin 1
      skinOps.setVertexWeights testSkin 1 2 1
      skinOps.setVertexWeights testSkin 2 2 1
      skinOps.setVertexWeights testSkin 3 1 1
      skinOps.setVertexWeights testSkin 4 1 1
      ---------------------------------------------------------------------------------

      ---------------------------------------------------------------------------------
      frameRate = 24
      animationRange = interval 0 99

      animate on
      (
         at time 0
         (
            rotate bone2 (eulerAngles 0 0 -75)
         )

         at time 99
         (
            rotate bone2 (eulerAngles 0 0 150)
         )
      )
      ---------------------------------------------------------------------------------
   )
)


Die Bitmap muss man natürlich anpassen.

Funktionen für Fileacces sind unteranderem:
Code: [AUSKLAPPEN]
   stream   = fopen "datei" "rb"
   position = ftell stream
   error    = fseek stream pos #seek_set
   value    = readByte stream
   value    = readShort stream
   value    = readLong stream
   value    = readFloat stream
   value    = readString stream
   error    = fclose stream

   filename = getOpenFileName caption  : "my caption" \
                              filename : "start dir"
                              types    : "Blitz3D(*.b3d)|*.b3d|Milkshape3D(*.ms3d)|*.ms3d|All(*.*)|*.*"


Das schreiben einer Datei ist leider nicht erlaubt in GMax(irgendwo muss es sich ja lohnen 3DMax zu kaufen).

mfg olli
vertex.dreamfall.at | GitHub

Neue Antwort erstellen


Übersicht Ressourcen Andere Programme oder Tools

Gehe zu:

Powered by phpBB © 2001 - 2006, phpBB Group