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:
Diffstat (limited to 'release/scripts/export_m3g.py')
-rw-r--r--release/scripts/export_m3g.py45
1 files changed, 36 insertions, 9 deletions
diff --git a/release/scripts/export_m3g.py b/release/scripts/export_m3g.py
index afb019fcc1e..c74e7acbcd3 100644
--- a/release/scripts/export_m3g.py
+++ b/release/scripts/export_m3g.py
@@ -1,4 +1,5 @@
#!BPY
+# coding: utf-8
""" Registration info for Blender menus:
Name: 'M3G (.m3g, .java)...'
Blender: 244
@@ -10,7 +11,7 @@ Tooltip: 'Export to M3G'
#
# Source: http://www.nelson-games.de/bl2m3g/source
#
-# $Id: m3g_export.py,v 0.1 2005/04/19 12:25 gerhardv Exp gerhardv $
+# $Id$
#
# Author: Gerhard Völkl
#
@@ -234,6 +235,19 @@ Tooltip: 'Export to M3G'
#
# * Modul shutil is not needed any longer. Exporter has its own copy_file.
# (realized and inspired by ideasman_42 and Martin Neumann)
+#
+# History 0.8
+#
+# * Blender works with SpotAngles 1..180 but M3G works only with 0..90
+# M3G use the 'half angle' (cut off angle) (Thanks to Martin Storsjö)
+#
+# * Error fixed: Texture coordinates was not calculated correct.
+# (Thanks to Milan Piskla, Vlad, Max Gilead, Regis Cosnier ...)
+#
+# * New options in GUI:
+# M3G Version 2.0 : Will export M3G files Vers. 2.0 in future
+# Game Physics: Adds Game Physics infos for NOPE API
+#
# --------------------------------------------------------------------------#
# TODO: Export only selected mesh
# TODO: Optimize Bones <--> Vertex Group mapping
@@ -1213,7 +1227,7 @@ class M3GVertexArray(M3GObject3D):
# Reverse t coordinate because M3G uses a different 2D coordinate system than Blender.
if self.uvmapping:
for i in range(0,len(self.components),2):
- self.components[i]= int(self.components[i]*(-1))
+ self.components[i+1]= int(self.components[i+1]*(-1)) #Error in Version 0.7
for i in range(len(self.components)):
if abs(self.components[i])>maxValue:raise Exception( i+". element too great/small!")
@@ -1284,7 +1298,7 @@ class M3GVertexArray(M3GObject3D):
self.blenderIndexes[key]=index
#print"blenderIndexes",self.blenderIndexes
else:
- # print "VertexArray.append: element=",element
+ print "VertexArray.append: element=",element
self.components.append(element)
class M3GVertexBuffer(M3GObject3D):
@@ -2001,7 +2015,7 @@ class M3GTranslator:
self.scene = Blender.Scene.GetCurrent()
self.world = self.translateWorld(self.scene)
- for obj in self.scene.objects:
+ for obj in self.scene.objects :
if obj.getType()=='Camera': # older Version: isinstance(obj.getData(),Types.CameraType)
self.translateCamera(obj)
elif obj.getType()=='Mesh':
@@ -2176,7 +2190,7 @@ class M3GTranslator:
if mOptions.createAmbientLight & mOptions.lightingEnabled:
lLight = M3GLight()
lLight.mode = lLight.modes['AMBIENT']
- lLight.color = self.translateRGB(AllWorlds[0].getAmb())
+ lLight.color = self.translateRGB(blWorld.getAmb())
self.nodes.append(lLight)
#TODO: Set background picture from world
@@ -2550,7 +2564,7 @@ class M3GTranslator:
mLight.intensity = lamp.energy
#SpotAngle, SpotExponent (SPOT)
if lampType == Lamp.Types.Spot:
- mLight.spotAngle = lamp.spotSize
+ mLight.spotAngle = lamp.spotSize/2
mLight.spotExponent = lamp.spotBlend
self.translateToNode(obj,mLight)
@@ -2945,6 +2959,8 @@ class OptionMgr:
self.perspectiveCorrection = rdict['perspectiveCorrection']
self.smoothShading = rdict['smoothShading']
self.exportAsJava = rdict['exportAsJava']
+ self.exportVersion2 = rdict['exportVersion2']
+ self.exportGamePhysics = rdict['exportGamePhysics']
except: self.save() # if data isn't valid, rewrite it
@@ -2958,6 +2974,8 @@ class OptionMgr:
self.perspectiveCorrection = False
self.smoothShading = True
self.exportAsJava = False
+ self.exportVersion2 = False
+ self.exportGamePhysics = False
def save(self):
d = {}
@@ -2970,7 +2988,9 @@ class OptionMgr:
d['perspectiveCorrection'] = self.perspectiveCorrection
d['smoothShading'] = self.smoothShading
d['exportAsJava'] = self.exportAsJava
-
+ d['exportVersion2'] = self.exportVersion2
+ d['exportGamePhysics'] = self.exportGamePhysics
+
Blender.Registry.SetKey('M3GExport', d, True)
@@ -2993,6 +3013,8 @@ def gui():
perspectiveCorrection = Draw.Create(mOptions.perspectiveCorrection)
smoothShading = Draw.Create(mOptions.smoothShading)
exportAsJava = Draw.Create(mOptions.exportAsJava)
+ exportVersion2 = Draw.Create(mOptions.exportVersion2)
+ exportGamePhysics = Draw.Create(mOptions.exportGamePhysics)
pupBlock = [\
('Texturing'),\
@@ -3008,7 +3030,9 @@ def gui():
('Posing'),\
('All Armature Actions', exportAllActions, 'Exports all actions for armatures'),\
('Export'),\
- ('As Java Source', exportAsJava, 'Exports scene as Java source code')
+ ('As Java Source', exportAsJava, 'Exports scene as Java source code'),\
+ ('M3G Version 2.0', exportVersion2, 'Exports M3G Version 2.0 File'),\
+ ('Game Physics', exportGamePhysics, 'Includes Game Physics infos for NOPE in export')
]
# Only execute if use didn't quit (ESC).
@@ -3022,6 +3046,8 @@ def gui():
mOptions.perspectiveCorrection = perspectiveCorrection.val
mOptions.smoothShading = smoothShading.val
mOptions.exportAsJava = exportAsJava.val
+ mOptions.exportVersion2 = exportVersion2.val
+ mOptions.exportGamePhysics = exportGamePhysics.val
mOptions.save()
if mOptions.exportAsJava:
@@ -3044,4 +3070,5 @@ def file_callback_m3g(filename):
Window.RedrawAll()
if __name__ == '__main__':
- gui() \ No newline at end of file
+ gui()
+