Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Musgrove <LetterRip@gmail.com>2006-04-26 02:05:03 +0400
committerTom Musgrove <LetterRip@gmail.com>2006-04-26 02:05:03 +0400
commit512cb9799d3209e4ff09abe97c8ab97f8986d934 (patch)
tree1a5b8e4abe2360fc83638a01840bc7dce729ea0f /release/scripts/md2_export.py
parent74acf8224d66e7b950608e4c3e16cb683a5a9aef (diff)
==scripts ==
update to MD2 exporter by Bob Holcomb
Diffstat (limited to 'release/scripts/md2_export.py')
-rw-r--r--release/scripts/md2_export.py203
1 files changed, 195 insertions, 8 deletions
diff --git a/release/scripts/md2_export.py b/release/scripts/md2_export.py
index d02f1101d9a..63781b7a88a 100644
--- a/release/scripts/md2_export.py
+++ b/release/scripts/md2_export.py
@@ -2,13 +2,13 @@
"""
Name: 'MD2 (.md2)'
-Blender: 239
+Blender: 241
Group: 'Export'
Tooltip: 'Export to Quake file format (.md2).'
"""
__author__ = 'Bob Holcomb'
-__version__ = '0.16'
+__version__ = '0.17
__url__ = ["Bob's site, http://bane.servebeer.com",
"Support forum, http://scourage.servebeer.com/phpbb/", "blender", "elysiun"]
__email__ = ["Bob Holcomb, bob_holcomb:hotmail*com", "scripts"]
@@ -114,7 +114,7 @@ def draw_gui():
######### Draw and Exit Buttons
Button("Export",EVENT_SAVE_MD2 , 10, 10, 80, 18)
- Button("Exit",EVENT_EXIT , 170, 10, 80, 18)
+ Button("Exit",EVENT_EXIT , 170, 10, 80, 18)
def event(evt, val):
if (evt == QKEY and not val):
@@ -175,6 +175,170 @@ MD2_FRAME_NAME_LIST=(("stand",1,40),
("death2",185,190),
("death3",191,198))
#198 frames
+
+MD2_NORMALS=((-0.525731, 0.000000, 0.850651),
+ (-0.442863, 0.238856, 0.864188),
+ (-0.295242, 0.000000, 0.955423),
+ (-0.309017, 0.500000, 0.809017),
+ (-0.162460, 0.262866, 0.951056),
+ (0.000000, 0.000000, 1.000000),
+ (0.000000, 0.850651, 0.525731),
+ (-0.147621, 0.716567, 0.681718),
+ (0.147621, 0.716567, 0.681718),
+ (0.000000, 0.525731, 0.850651),
+ (0.309017, 0.500000, 0.809017),
+ (0.525731, 0.000000, 0.850651),
+ (0.295242, 0.000000, 0.955423),
+ (0.442863, 0.238856, 0.864188),
+ (0.162460, 0.262866, 0.951056),
+ (-0.681718, 0.147621, 0.716567),
+ (-0.809017, 0.309017, 0.500000),
+ (-0.587785, 0.425325, 0.688191),
+ (-0.850651, 0.525731, 0.000000),
+ (-0.864188, 0.442863, 0.238856),
+ (-0.716567, 0.681718, 0.147621),
+ (-0.688191, 0.587785, 0.425325),
+ (-0.500000, 0.809017, 0.309017),
+ (-0.238856, 0.864188, 0.442863),
+ (-0.425325, 0.688191, 0.587785),
+ (-0.716567, 0.681718, -0.147621),
+ (-0.500000, 0.809017, -0.309017),
+ (-0.525731, 0.850651, 0.000000),
+ (0.000000, 0.850651, -0.525731),
+ (-0.238856, 0.864188, -0.442863),
+ (0.000000, 0.955423, -0.295242),
+ (-0.262866, 0.951056, -0.162460),
+ (0.000000, 1.000000, 0.000000),
+ (0.000000, 0.955423, 0.295242),
+ (-0.262866, 0.951056, 0.162460),
+ (0.238856, 0.864188, 0.442863),
+ (0.262866, 0.951056, 0.162460),
+ (0.500000, 0.809017, 0.309017),
+ (0.238856, 0.864188, -0.442863),
+ (0.262866, 0.951056, -0.162460),
+ (0.500000, 0.809017, -0.309017),
+ (0.850651, 0.525731, 0.000000),
+ (0.716567, 0.681718, 0.147621),
+ (0.716567, 0.681718, -0.147621),
+ (0.525731, 0.850651, 0.000000),
+ (0.425325, 0.688191, 0.587785),
+ (0.864188, 0.442863, 0.238856),
+ (0.688191, 0.587785, 0.425325),
+ (0.809017, 0.309017, 0.500000),
+ (0.681718, 0.147621, 0.716567),
+ (0.587785, 0.425325, 0.688191),
+ (0.955423, 0.295242, 0.000000),
+ (1.000000, 0.000000, 0.000000),
+ (0.951056, 0.162460, 0.262866),
+ (0.850651, -0.525731, 0.000000),
+ (0.955423, -0.295242, 0.000000),
+ (0.864188, -0.442863, 0.238856),
+ (0.951056, -0.162460, 0.262866),
+ (0.809017, -0.309017, 0.500000),
+ (0.681718, -0.147621, 0.716567),
+ (0.850651, 0.000000, 0.525731),
+ (0.864188, 0.442863, -0.238856),
+ (0.809017, 0.309017, -0.500000),
+ (0.951056, 0.162460, -0.262866),
+ (0.525731, 0.000000, -0.850651),
+ (0.681718, 0.147621, -0.716567),
+ (0.681718, -0.147621, -0.716567),
+ (0.850651, 0.000000, -0.525731),
+ (0.809017, -0.309017, -0.500000),
+ (0.864188, -0.442863, -0.238856),
+ (0.951056, -0.162460, -0.262866),
+ (0.147621, 0.716567, -0.681718),
+ (0.309017, 0.500000, -0.809017),
+ (0.425325, 0.688191, -0.587785),
+ (0.442863, 0.238856, -0.864188),
+ (0.587785, 0.425325, -0.688191),
+ (0.688191, 0.587785, -0.425325),
+ (-0.147621, 0.716567, -0.681718),
+ (-0.309017, 0.500000, -0.809017),
+ (0.000000, 0.525731, -0.850651),
+ (-0.525731, 0.000000, -0.850651),
+ (-0.442863, 0.238856, -0.864188),
+ (-0.295242, 0.000000, -0.955423),
+ (-0.162460, 0.262866, -0.951056),
+ (0.000000, 0.000000, -1.000000),
+ (0.295242, 0.000000, -0.955423),
+ (0.162460, 0.262866, -0.951056),
+ (-0.442863, -0.238856, -0.864188),
+ (-0.309017, -0.500000, -0.809017),
+ (-0.162460, -0.262866, -0.951056),
+ (0.000000, -0.850651, -0.525731),
+ (-0.147621, -0.716567, -0.681718),
+ (0.147621, -0.716567, -0.681718),
+ (0.000000, -0.525731, -0.850651),
+ (0.309017, -0.500000, -0.809017),
+ (0.442863, -0.238856, -0.864188),
+ (0.162460, -0.262866, -0.951056),
+ (0.238856, -0.864188, -0.442863),
+ (0.500000, -0.809017, -0.309017),
+ (0.425325, -0.688191, -0.587785),
+ (0.716567, -0.681718, -0.147621),
+ (0.688191, -0.587785, -0.425325),
+ (0.587785, -0.425325, -0.688191),
+ (0.000000, -0.955423, -0.295242),
+ (0.000000, -1.000000, 0.000000),
+ (0.262866, -0.951056, -0.162460),
+ (0.000000, -0.850651, 0.525731),
+ (0.000000, -0.955423, 0.295242),
+ (0.238856, -0.864188, 0.442863),
+ (0.262866, -0.951056, 0.162460),
+ (0.500000, -0.809017, 0.309017),
+ (0.716567, -0.681718, 0.147621),
+ (0.525731, -0.850651, 0.000000),
+ (-0.238856, -0.864188, -0.442863),
+ (-0.500000, -0.809017, -0.309017),
+ (-0.262866, -0.951056, -0.162460),
+ (-0.850651, -0.525731, 0.000000),
+ (-0.716567, -0.681718, -0.147621),
+ (-0.716567, -0.681718, 0.147621),
+ (-0.525731, -0.850651, 0.000000),
+ (-0.500000, -0.809017, 0.309017),
+ (-0.238856, -0.864188, 0.442863),
+ (-0.262866, -0.951056, 0.162460),
+ (-0.864188, -0.442863, 0.238856),
+ (-0.809017, -0.309017, 0.500000),
+ (-0.688191, -0.587785, 0.425325),
+ (-0.681718, -0.147621, 0.716567),
+ (-0.442863, -0.238856, 0.864188),
+ (-0.587785, -0.425325, 0.688191),
+ (-0.309017, -0.500000, 0.809017),
+ (-0.147621, -0.716567, 0.681718),
+ (-0.425325, -0.688191, 0.587785),
+ (-0.162460, -0.262866, 0.951056),
+ (0.442863, -0.238856, 0.864188),
+ (0.162460, -0.262866, 0.951056),
+ (0.309017, -0.500000, 0.809017),
+ (0.147621, -0.716567, 0.681718),
+ (0.000000, -0.525731, 0.850651),
+ (0.425325, -0.688191, 0.587785),
+ (0.587785, -0.425325, 0.688191),
+ (0.688191, -0.587785, 0.425325),
+ (-0.955423, 0.295242, 0.000000),
+ (-0.951056, 0.162460, 0.262866),
+ (-1.000000, 0.000000, 0.000000),
+ (-0.850651, 0.000000, 0.525731),
+ (-0.955423, -0.295242, 0.000000),
+ (-0.951056, -0.162460, 0.262866),
+ (-0.864188, 0.442863, -0.238856),
+ (-0.951056, 0.162460, -0.262866),
+ (-0.809017, 0.309017, -0.500000),
+ (-0.864188, -0.442863, -0.238856),
+ (-0.951056, -0.162460, -0.262866),
+ (-0.809017, -0.309017, -0.500000),
+ (-0.681718, 0.147621, -0.716567),
+ (-0.681718, -0.147621, -0.716567),
+ (-0.850651, 0.000000, -0.525731),
+ (-0.688191, 0.587785, -0.425325),
+ (-0.587785, 0.425325, -0.688191),
+ (-0.425325, 0.688191, -0.587785),
+ (-0.425325, -0.688191, -0.587785),
+ (-0.587785, -0.425325, -0.688191),
+ (-0.688191, -0.587785, -0.425325))
+
######################################################
# MD2 data structures
@@ -450,9 +614,14 @@ def validation(object):
#select the face for future triangulation
face.sel=1
if result==0: #first time we have this problem, don't pop-up a window every time it finds a quad
- print "Model not made entirely of triangles"
- result=Blender.Draw.PupMenu("Model not made entirely out of Triangles-Convert?%t|YES|NO")
+ print "Model not made entirely of triangles"
+ result=Blender.Draw.PupMenu("Model not made entirely out of Triangles-Convert?%t|YES|NO")
+
+ print "result: ", result
+ #triangulate or quit
if result==1:
+ #selecting face mode
+ Blender.Mesh.Mode(3)
mesh.quadToTriangle(0) #use closest verticies in breaking a quad
elif result==2:
return False #user will fix (I guess)
@@ -500,7 +669,7 @@ def validation(object):
#is this really what the user wants
if (size[0]!=256 or size[1]!=256):
print "Texture map size is non-standard (not 256x256), it is: ",size[0],"x",size[1]
- result=Blender.Draw.PupMenu("Texture map size is non-standard (not 256x256), it is: "+size[0]+"x"+size[1]+": Continue?%t|YES|NO")
+ result=Blender.Draw.PupMenu("Texture map size is non-standard (not 256x256), it is: "+str(size[0])+"x"+str(size[1])+": Continue?%t|YES|NO")
if(result==2):
return False
@@ -668,7 +837,25 @@ def fill_md2(md2, object):
md2.frames[frame_counter].vertices[vert_counter].vertices=(new_x, new_y, new_z)
#need to add the lookup table check here
- md2.frames[frame_counter].vertices[vert_counter].lightnormalindex=0
+ maxdot = -999999.0;
+ maxdotindex = -1;
+
+ for j in range(0,162):
+ #dot = (x[0]*y[0]+x[1]*y[1]+x[2]*y[2])
+ x1=mesh.verts[vert_counter].no[1]
+ y1=mesh.verts[vert_counter].no[0]
+ z1=mesh.verts[vert_counter].no[2]
+ dot = (x1*MD2_NORMALS[j][0]+
+ y1*MD2_NORMALS[j][1]+
+ z1*MD2_NORMALS[j][2]);
+ if (dot > maxdot):
+ maxdot = dot;
+ maxdotindex = j;
+
+ md2.frames[frame_counter].vertices[vert_counter].lightnormalindex=maxdotindex
+
+
+
#output all the frame names-user_frame_list is loaded during the validation
for frame_set in user_frame_list:
@@ -1013,4 +1200,4 @@ def save_md2(filename):
#cleanup
md2=0
- print "Closed the file"
+ print "Closed the file" \ No newline at end of file