Page 3 of 5

Re: Blender to Sandbox: step by step

Posted: July 24th, 2010, 1:46 pm
by PizzaLover101
what ever the latest version is, I just recently re-downloaded it cuz i couldn't find it on my computer

EDIT: I am using 2.9B

Re: Blender to Sandbox: step by step

Posted: September 29th, 2010, 8:25 pm
by InHumanUnit
I can't find the Blender Scripts.

Re: Blender to Sandbox: step by step

Posted: October 1st, 2010, 8:36 pm
by chocolatepie33
@ Pizza: how can you have 2.9? They barely have the 2.5 betas out.

@IHU: it's the .blender > scripts file path.

Re: Blender to Sandbox: step by step

Posted: October 2nd, 2010, 7:50 am
by InHumanUnit
Do I go in Blender? Or in the files?

Re: Blender to Sandbox: step by step

Posted: October 2nd, 2010, 7:51 am
by PizzaLover101

Re: Blender to Sandbox: step by step

Posted: October 8th, 2010, 9:36 am
by InHumanUnit
Hlp me plz?

Re: Blender to Sandbox: step by step

Posted: November 11th, 2010, 11:02 am
by InHumanUnit
Okay....I figured most of this out but the UVs I don't understand.

Re: Blender to Sandbox: step by step

Posted: November 11th, 2010, 11:42 pm
by chocolatepie33
InHumanUnit wrote:Okay....I figured most of this out but the UVs I don't understand.

same here with anything in Blender.

Re: Blender to Sandbox: step by step

Posted: January 11th, 2011, 7:10 pm
by idunno
I've been trying to export one of my models and followed the advice/answers already given but it's not working. Everything works, but when I get to Part III, the export option doesn't appear.

I copied all the python scripts into the blender scripts folder, but there is no md3 option in file>export. I have also loaded the scrpit into the text editor and it's still not working. It comes up with the error 'python scrpit error: check console' and then the text 'import md3' (towards the beginning of the code) is highlighted.
(BTW I have no idea if this has anything to do with the error or not).

Code: Select all

Name: 'Quake3 (.md3)...'
Blender: 240
Group: 'Export'
Tooltip: 'Export to Quake3 file format. (.md3)'
__author__ = "PhaethonH, Bob Holcomb, Damien McGinnes, Robert (Tr3B) Beckebans"
__url__ = ("")
__version__ = "0.3 2006-01-09"

__bpydoc__ = """\
This script exports a Quake3 file (MD3).



Known issues:<br>


import sys, struct, string, math
from types import *

import os
from os import path

import Blender
from Blender import *

import md3
from md3 import *

import q_math
from q_math import *

import q_shared
from q_shared import *

def applyTransform(vert, matrix):
   return vert * matrix

def updateFrameBounds(v, f):
   for i in range(0, 3):
      f.mins[i] = min(v[i], f.mins[i])
   for i in range(0, 3):
      f.maxs[i] = max(v[i], f.maxs[i])

def updateFrameRadius(f):
   f.radius = RadiusFromBounds(f.mins, f.maxs)

def processSurface(blenderObject, md3, pathName, modelName):
   # because md3 doesnt suppoort faceUVs like blender, we need to duplicate
   # any vertex that has multiple uv coords

   vertDict = {}
   indexDict = {} # maps a vertex index to the revised index after duplicating to account for uv
   vertList = [] # list of vertices ordered by revised index
   numVerts = 0
   uvList = [] # list of tex coords ordered by revised index
   faceList = [] # list of faces (they index into vertList)
   numFaces = 0

   Blender.Set("curframe", 1)

   # get access to the mesh data (as at frame #1)
   mesh = NMesh.GetRawFromObject(
   matrix = blenderObject.getMatrix('worldspace')
   normmatrix = Mathutils.Matrix(matrix).invert().transpose().rotationPart()

   surf = md3Surface()
   surf.numFrames = md3.numFrames = blenderObject.getName()
   surf.ident = MD3_IDENT
   # create shader for surface
   surf.numShaders += 1
   surf.shaders[0].index = 0
   print mesh.materials
   if not mesh.materials:
      surf.shaders[0].name = pathName +
      surf.shaders[0].name = pathName + mesh.materials[0].name

   # process each face in the mesh
   for face in mesh.faces:
      tris_in_this_face = []  #to handle quads and up...
      # this makes a list of indices for each tri in this face. a quad will be [[0,1,1],[0,2,3]]
      for vi in range(1, len(face.v)-1):
         tris_in_this_face.append([0, vi, vi + 1])
      # loop across each tri in the face, then each vertex in the tri
      for this_tri in tris_in_this_face:
         numFaces += 1
         tri = md3Triangle()
         tri_ind = 0
         for i in this_tri:
            # get the vertex index, coords and uv coords
            index = face.v[i].index
            v = face.v[i].co
            if mesh.hasFaceUV():
               uv = face.uv[i]
            elif mesh.hasVertexUV():
               uv = (face.v[i].uvco[0], face.v[i].uvco[1])
               uv = (0.0, 0.0) # handle case with no tex coords   

            if vertDict.has_key((index, uv)):
               # if we've seen this exact vertex before, simply add it
               # to the tris list of vertex indices
               tri.indexes[tri_ind] = vertDict[(index, uv)]
               # havent seen this tri before
               # (or its uv coord is different, so we need to duplicate it)
               vertDict[(index, uv)] = numVerts
               # put the uv coord into the list
               # (uv coord are directly related to each vertex)
               tex = md3TexCoord()
               tex.u = uv[0]
               tex.v = uv[1]

               tri.indexes[tri_ind] = numVerts

               # now because we have created a new index,
               # we need a way to link it to the index that
               # blender returns for NMVert.index
               if indexDict.has_key(index):
                  # already there - each of the entries against
                  # this key represents  the same vertex with a
                  # different uv value
                  ilist = indexDict[index]
                  indexDict[index] = ilist
                  # this is a new one
                  indexDict[index] = [numVerts]

               numVerts += 1
            tri_ind +=1

   # we're done with faces and uv coords
   for t in uvList:

   for f in faceList:

   surf.numTriangles = len(faceList)
   surf.numVerts = numVerts

   # now vertices are stored as frames -
   # all vertices for frame 1, all vertices for frame 2...., all vertices for frame n
   # so we need to iterate across blender's frames, and copy out each vertex
   for   frameNum in range(1, md3.numFrames + 1):
      Blender.Set("curframe", frameNum)

      m = NMesh.GetRawFromObject(

      vlist = [0] * numVerts
      for vertex in m.verts:
            vindices = indexDict[vertex.index]
            print "warning found a vertex in %s that is not part of a face" %

         vTx = applyTransform(, matrix)
         nTx = applyTransform(Mathutils.Vector([0],[1],[2]), normmatrix)
         updateFrameBounds(vTx, md3.frames[frameNum - 1])
         vert = md3Vert() = vTx[0:3]
         vert.normal = vert.encode(nTx[0:3])
         for ind in vindices:  # apply the position to all the duplicated vertices
            vlist[ind] = vert

      updateFrameRadius(md3.frames[frameNum - 1])

      for vl in vlist:

   md3.numSurfaces += 1

def saveModel(fileName):
   if(fileName.find('.md3', -4) <= 0):
      fileName += '.md3'
   print "Exporting MD3 format to ", fileName
   pathName = stripGamePath(stripModel(fileName))
   print "shader path name ", pathName
   modelName = stripExtension(stripPath(fileName))
   print "model name ", modelName
   md3 = md3Object()
   md3.ident = MD3_IDENT
   md3.version = MD3_VERSION

   tagList = []

   md3.numFrames = Blender.Get("curframe")
   Blender.Set("curframe", 1)

   # create a bunch of blank frames, they'll be filled in by 'processSurface'
   for i in range(1, md3.numFrames + 1):
      frame = md3Frame() = "frame_" + str(i)

   # export all selected objects
   objlist = Blender.Object.GetSelected()

   # process each object for the export
   for obj in objlist:
      # check if it's a mesh object
      if obj.getType() == "Mesh":
         print "processing surface",
         if len(md3.surfaces) == MD3_MAX_SURFACES:
            print "hit md3 limit (%i) for number of surfaces, skipping" % MD3_MAX_SURFACES , obj.getName()
            processSurface(obj, md3, pathName, modelName)
      elif obj.getType() == "Empty":   # for tags, we just put em in a list so we can process them all together
         if[0:4] == "tag_":
            print "processing tag",
            md3.numTags += 1
         print "skipping object",

   # work out the transforms for the tags for each frame of the export
   for fr in range(1, md3.numFrames + 1):
      Blender.Set("curframe", fr)
      for tag in tagList:
         t = md3Tag()
         matrix = tag.getMatrix('worldspace')
         t.origin[0] = matrix[3][0]
         t.origin[1] = matrix[3][1]
         t.origin[2] = matrix[3][2]
         t.axis[0] = matrix[0][0]
         t.axis[1] = matrix[0][1]
         t.axis[2] = matrix[0][2]
         t.axis[3] = matrix[1][0]
         t.axis[4] = matrix[1][1]
         t.axis[5] = matrix[1][2]
         t.axis[6] = matrix[2][0]
         t.axis[7] = matrix[2][1]
         t.axis[8] = matrix[2][2] =

   # export!
   file = open(fileName, "wb")

Blender.Window.FileSelector(saveModel, "Export Quake3 MD3")

Blender has also recognised python and I'm using windows 7 32 bit and blender 2.49b.

thanks in advance!

Re: Blender to Sandbox: step by step

Posted: January 12th, 2011, 9:13 am
by InHumanUnit
Ehhh...I suggest everyone stops using Blender that Pc can't export. Mine can't either.
I suggest you get MIlkshape3D. Its easier, and can export to MD3.