Blender models??
I just recently downloaded Blender, and have been attempting to create some simple models to start with (I''m new to 3d modelling). Well, now that I have a model to work with, I''d like to be able to load the model into my program so that I can display it. I''ve looked around, but haven''t found any info on the blender file format, so I was wondering if anyone has done this before, and if you have any suggestions.
Thanks,
J.W.
P.S. I''m also looking into GMax, and using the tempest plugin to convert to md3 models, which there is a lot of info on, but I''m not sure which to use just yet.
December 04, 2001 10:09 PM
I have been using Blender for a about 3 years and I can tell you it is a great FREE tool for creating models for games. What I did was write a Python script that exports the model to .OBJ format which is really easy to parse. Another thing you may look into is the game engine that is built into Blender, there are tons of tutorials on the web about it.
There are many export scripts on the blender pages, even one to save the model as OpenGL C code.
www.EberKain.comThere it is, Television, Look Listen Kneel Pray.
December 05, 2001 10:56 PM
Is there a stand-alone program available (not a script) that reads a
BLEND file and spits out a OBJ file (or any other format) ?
BLEND file and spits out a OBJ file (or any other format) ?
December 05, 2001 11:08 PM
Can''t answer your question but, totally out of curiosity, why not a script?
.blend files are really just memory dumps of the interface, there file format changes with every update, so writeing a script to read them would be pointless. You can export it as a .wrl useing blenders interface. or you can use this obj export script. It works with the latest blender versions.
#
# OBJ (3.0) exporter for Blender v2.11+ (by Volker [vmx] Mische)
# Based on w3d2 jano''s script
#
# Things that can be done (i don''t need them, perhaps somebody else?):
# - Smoothing groups
# - Material output
#
# Here comes the introduction of jano''s original script:
#
# w3d2 exporter for Blender v2.11+
# Based on Flure''s w3d script; exports raw data in easy to parse format
# Press alt-p in this window and each mesh will be exported to a file
# Comment out corresponding FILE.write lines for info you don''t want/need
#
import Blender
scene = Blender.getCurrentScene()
for name in scene.objects:
if Blender.isMesh(name):
print("Writing %s...\n" % name)
fileName = "%s.obj" % name
FILE = open(fileName, "w")
FILE.write("# Wavefront OBJ (3.0) exported by vmx''s Blender export script\n\n")
FILE.write("# Meshname: \t%s\n" % name)
object = Blender.getObject(name)
mesh = Blender.getMesh(object.data)
faces = mesh.faces
materials = object.materials
vertices = mesh.vertices
vnormals = mesh.normals
texcoords = mesh.texcoords
vcolors = mesh.colors
# Total vertices and faces; comment if not useful
FILE.write("# Total number of Faces: \t%s\n" % len(faces))
FILE.write("# Total number of Vertices:\t%s\n" % len(vertices))
FILE.write("\n")
# print first image map for uvcoords to use
# to be updated when we get access to other textures
if mesh.texture: FILE.write("# UV Texture: \t%s\n\n" % mesh.texture)
# Print all vertices to file
for vertice in vertices:
FILE.write("v %s %s %s\n" % (vertice[0], vertice[1], vertice[2]))
FILE.write("\n")
# Print all normals of the vertices to file
for vnormal in vnormals:
FILE.write("vn %s %s %s\n" % (vnormal[0], vnormal[1], vnormal[2]))
FILE.write("\n")
# Print all UV-coordinates to file, if there are one
if texcoords:
# Make an array with the right size,
# to put all texcoordinates in
uv = []
for i in range(len(vertices)):
uv.append(["i","i"])
# Put all texcoordinates in "uv" to get the right order
for i in range(len(faces)):
uv[faces[0]][0] = texcoords[0][0]<br> uv[faces[0]][1] = texcoords[0][1]<br><br> uv[faces[1]][0] = texcoords[1][0]<br> uv[faces[1]][1] = texcoords[1][1]<br><br> uv[faces[2]][0] = texcoords[2][0]<br> uv[faces[2]][1] = texcoords[2][1]<br><br> if faces[3]: # If the face is a quad<br> uv[faces[3]][0] = texcoords[3][0]<br> uv[faces[3]][1] = texcoords[3][1]<br><br> # The final output<br> for texcoord in uv:<br> FILE.write("vt %s %s\n" % (texcoord[0], texcoord[1]))<br><br><br> # Group name is the name of the mesh<br> FILE.write("\ng %s\n" % (name)) <br><br><br> # Print the faces to file<br> for face in faces:<br><br> # If the face is a quad<br> if face[3]:<br> FILE.write("f %s/%s/%s %s/%s/%s %s/%s/%s %s/%s/%s\n" % (face[0]+1, face[0]+1, face[0]+1, face[1]+1, face[1]+1, face[1]+1, face[2]+1, face[2]+1, face[2]+1, face[3]+1, face[3]+1, face[3]+1))<br><br> # If the face is a triangle<br> else:<br> FILE.write("f %s/%s/%s %s/%s/%s %s/%s/%s\n" % (face[0]+1, face[0]+1, face[0]+1, face[1]+1, face[1]+1, face[1]+1, face[2]+1, face[2]+1, face[2]+1))<br><br><br> FILE.close()<br><br><br>print "finished" </i>
#
# OBJ (3.0) exporter for Blender v2.11+ (by Volker [vmx] Mische)
# Based on w3d2 jano''s script
#
# Things that can be done (i don''t need them, perhaps somebody else?):
# - Smoothing groups
# - Material output
#
# Here comes the introduction of jano''s original script:
#
# w3d2 exporter for Blender v2.11+
# Based on Flure''s w3d script; exports raw data in easy to parse format
# Press alt-p in this window and each mesh will be exported to a file
# Comment out corresponding FILE.write lines for info you don''t want/need
#
import Blender
scene = Blender.getCurrentScene()
for name in scene.objects:
if Blender.isMesh(name):
print("Writing %s...\n" % name)
fileName = "%s.obj" % name
FILE = open(fileName, "w")
FILE.write("# Wavefront OBJ (3.0) exported by vmx''s Blender export script\n\n")
FILE.write("# Meshname: \t%s\n" % name)
object = Blender.getObject(name)
mesh = Blender.getMesh(object.data)
faces = mesh.faces
materials = object.materials
vertices = mesh.vertices
vnormals = mesh.normals
texcoords = mesh.texcoords
vcolors = mesh.colors
# Total vertices and faces; comment if not useful
FILE.write("# Total number of Faces: \t%s\n" % len(faces))
FILE.write("# Total number of Vertices:\t%s\n" % len(vertices))
FILE.write("\n")
# print first image map for uvcoords to use
# to be updated when we get access to other textures
if mesh.texture: FILE.write("# UV Texture: \t%s\n\n" % mesh.texture)
# Print all vertices to file
for vertice in vertices:
FILE.write("v %s %s %s\n" % (vertice[0], vertice[1], vertice[2]))
FILE.write("\n")
# Print all normals of the vertices to file
for vnormal in vnormals:
FILE.write("vn %s %s %s\n" % (vnormal[0], vnormal[1], vnormal[2]))
FILE.write("\n")
# Print all UV-coordinates to file, if there are one
if texcoords:
# Make an array with the right size,
# to put all texcoordinates in
uv = []
for i in range(len(vertices)):
uv.append(["i","i"])
# Put all texcoordinates in "uv" to get the right order
for i in range(len(faces)):
uv[faces[0]][0] = texcoords[0][0]<br> uv[faces[0]][1] = texcoords[0][1]<br><br> uv[faces[1]][0] = texcoords[1][0]<br> uv[faces[1]][1] = texcoords[1][1]<br><br> uv[faces[2]][0] = texcoords[2][0]<br> uv[faces[2]][1] = texcoords[2][1]<br><br> if faces[3]: # If the face is a quad<br> uv[faces[3]][0] = texcoords[3][0]<br> uv[faces[3]][1] = texcoords[3][1]<br><br> # The final output<br> for texcoord in uv:<br> FILE.write("vt %s %s\n" % (texcoord[0], texcoord[1]))<br><br><br> # Group name is the name of the mesh<br> FILE.write("\ng %s\n" % (name)) <br><br><br> # Print the faces to file<br> for face in faces:<br><br> # If the face is a quad<br> if face[3]:<br> FILE.write("f %s/%s/%s %s/%s/%s %s/%s/%s %s/%s/%s\n" % (face[0]+1, face[0]+1, face[0]+1, face[1]+1, face[1]+1, face[1]+1, face[2]+1, face[2]+1, face[2]+1, face[3]+1, face[3]+1, face[3]+1))<br><br> # If the face is a triangle<br> else:<br> FILE.write("f %s/%s/%s %s/%s/%s %s/%s/%s\n" % (face[0]+1, face[0]+1, face[0]+1, face[1]+1, face[1]+1, face[1]+1, face[2]+1, face[2]+1, face[2]+1))<br><br><br> FILE.close()<br><br><br>print "finished" </i>
www.EberKain.comThere it is, Television, Look Listen Kneel Pray.
Thanks for all the help. Now I have enough to keep my hands full for a while, at least until I can get the models loading and displaying properly
From there I''ll probably try to animate the models, but first I need to be able to create them, and be able to load them.
J.W.

J.W.
December 06, 2001 12:19 PM
quote:
.blend files are really just memory dumps of the interface,
Yeah, I''ve seen a text output of a test file.
This is the strangest thing I have ever seen for a file format.
I''m still scratching my head trying to understand it.
December 06, 2001 12:20 PM
quote:
.blend files are really just memory dumps of the interface,
Yeah, I''ve seen a text output of a test file.
This is the strangest thing I have ever seen for a file format.
I''m still scratching my head trying to understand it.
It''s just for simplicity. There is nothing easier to parse.
Alex Broadwin
A-Tronic Software & Design
-----
"if you fail in life, you were destined to fail. If you suceed in life, call me."
"The answer is out there."
"Please help, I''m using Windows!"
Alex Broadwin
A-Tronic Software & Design
-----
"if you fail in life, you were destined to fail. If you suceed in life, call me."
"The answer is out there."
"Please help, I''m using Windows!"
Alex BroadwinA-Tronic Software & Design-----"if you fail in life, you were destined to fail. If you suceed in life, call me.""The answer is out there.""Please help, I'm using Windows!"
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement