[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [10815] trunk/blender/release/scripts/ export_m3g.py: Script from Gerhard for exporting blender to m3g and java source,
Campbell Barton
cbarton at metavr.com
Tue May 29 23:39:43 CEST 2007
Revision: 10815
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=10815
Author: campbellbarton
Date: 2007-05-29 23:39:29 +0200 (Tue, 29 May 2007)
Log Message:
-----------
Script from Gerhard for exporting blender to m3g and java source,
see website for examples
http://www.nelson-games.de/bl2m3g/default.html
Added Paths:
-----------
trunk/blender/release/scripts/export_m3g.py
Added: trunk/blender/release/scripts/export_m3g.py
===================================================================
--- trunk/blender/release/scripts/export_m3g.py (rev 0)
+++ trunk/blender/release/scripts/export_m3g.py 2007-05-29 21:39:29 UTC (rev 10815)
@@ -0,0 +1,3047 @@
+#!BPY
+""" Registration info for Blender menus:
+Name: 'M3G (.m3g, .java)...'
+Blender: 244
+Group: 'Export'
+Tooltip: 'Export to M3G'
+"""
+#------------------------------------------------------------------------
+# M3G exporter for blender 2.37 or above
+#
+# Source: http://www.nelson-games.de/bl2m3g/source
+#
+# $Id: m3g_export.py,v 0.1 2005/04/19 12:25 gerhardv Exp gerhardv $
+#
+# Author: Gerhard V\xF6lkl
+#
+# ***** BEGIN GPL LICENSE BLOCK *****
+#
+# Copyright (C) 2005: gerhard v\xF6lkl gkvoelkl at yahoo.de
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation,
+# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+# ***** END GPL LICENCE BLOCK *****
+#
+# To use script:
+# 1.) load this file in the text window.
+# (press SHIFT+F11, Open New via Datablock button)
+# 2.) make sure your mouse is over the text edit window and
+# run this script. (press ALT+P)
+# Or:
+# copy to the scripts directory and it will appear in the
+# export list. (Needs 2.32 or higher)
+#
+# Based on informations from:
+# wrl2export.py from Rick Kimball and others
+# --------------------------------------------------------------------------#
+# History 0.2
+# * maximal Precision in VertexArray (with algorithms from Kalle Raita)
+# * IPO Animation with mesh: Rotation, Translation and Size
+# History 0.3
+# * to find a 3d object in your java programm you can assign a userID
+# your blender object has name 'cube#01' your 3d object will have ID 01
+# the number after '#' is taken
+# * more than one material per mesh can be used
+# * uv texture support (implemented by Aki Koskinen and Juha Laitinen)
+# The image which is bound to the faces will be exportet within m3g-file
+# Limitations by M3G-API:
+# The width and height of the image must be non-negative powers of two,
+# but they need not to be equal. Maximum value is 256.
+# *.java export: Only PNG images can be used.
+# History 0.4
+# * check limitation of texture images (credit to MASTER_ZION for Brasil)
+# * Better light: The light modeles of Blender and M3G are naturally
+# different. So the export script trys to translate as much as possible
+#
+# M3G Light type Blender Light type
+# --------------------------------------------------------------
+# AMIENT Light Not available as light type in Blender
+# DIRECTIONAL Light SUN
+# OMNIdirectional light LAMP
+# SPOT light SPOT
+# not translated HEMI
+# not translated AREA
+#
+# Attributs of M3G Lights:
+#
+# Attenuation (OMNI,SPOT):
+# Intensity of light changes with distance
+# The attenuation factor is 1 / (c + l d + q d2)
+# where d is the distance between the light and the vertex being lighted
+# and c, l, q are the constant, linear, and quadratic coefficients.
+# In Blender exists much complex posibilies. To simplify exporter uses
+# only button Dist: distance at which the light intensity is half
+# the Energy
+# Color (ALL)
+# Color of light
+# Intensity (ALL)
+# The RGB color of this Light is multiplied component-wise with the
+# intensity. In Blender : energy
+# SpotAngle (SPOT)
+# the spot cone angle for this Light
+# In Blender: spotSize
+# SpotExponent (SPOT)
+# The spot exponent controls the distribution of the intensity of
+# this Light within the spot cone, such that larger values yield
+# a more concentrated cone. In Blender: SpotBl
+#
+# * Some GUI for options
+# First prototype of GUI was created using RipSting's Blender-Python
+# GUI designer. Download at Http://oregonstate.edu/~dennisa/Blender/BPG/
+#
+# * Ambiente light
+# Information is taken by world ambiente attribute
+#
+# * Parenting Part 1
+# In Blender the Empty object is used to group objects. All objects
+# which have the same empty as parent are the member of the same group.
+#
+# empty <-- Parent of -- element 1
+# <-- Parent of -- element 2
+#
+# is translated in M3G
+#
+# group-Node -- Member --> element 1
+# -- Member --> element 2
+#
+# In Blender every object can be the parent of every other object
+# In M3G that is not possible. Only a group object can be parent.
+# (Or the world object which is derived from group).
+# That will come later as Parenting Part 2
+#
+# * Backface Culling
+# you can use backface culling, if option "use backface culloing" is on.
+# Culling will be set in PolygonMode object of every mesh. The correct
+# winding is controlled.
+# History 0.5
+#* Bone Animation - Armature (Part 1)
+#
+# Armature is the skeleton for skinned meshes. It stores the bones in
+# rest position (more information http://www.blender.org/cms/How_Armatures_work.634.0.html)
+# You can work in Blender with bones and meshes in different ways. In
+# this first attempt only the use of vertex groups is assisted.
+#
+# Blender-Objekts translated into M3G-Objects
+#
+# MESH SkinnedMesh
+# | |
+# v v
+# ARMATURE Group
+# | |
+# v v
+# BONE_1 Group
+# Group_second
+# | |
+# V v
+# BONE_2 Group
+# Group_secound
+#
+# Every bone is translated into two groups at the moment, because
+# the second bone is needed to do the animation in an easy way.
+#
+# The animations in Blender for meshes are stored in action objects.
+#
+# Blender Objects translated into M3G-Objects
+#
+# ARMATURE
+# | activ
+# v
+# ACTION ANIMATIONCONTROLLER
+# | 1..n ^
+# v ANIMATIONTRACK --> Group_second
+# IPOs |
+# v
+# KEYSEQUENZE
+#
+# One action is translated into one animationcontroller. One IPO is
+# translated in one KEYSEQUENZE and one ANIMATIONTRACK.
+#
+# At the moment only the active action of the armature object is translated.
+#
+#* Print Info, if type of light is used that is not supported
+#
+# History 0.5
+#
+#* New Option exportAllAction (default value: false)
+# If that option is true, all actions will be exported - not only the active
+# action.
+# At the moment you can only assign one action to one armature.
+# To know which action is used with which armature the action
+# needs a special name :
+# <Action Name>#A<M3G ID of Armature>E<End Frame>#<ID of Action>
+
+# Example: Name of action : walk#A10E250#02
+# Name of armature : man#10
+# End Frame: 250
+#
+# History 0.6
+# Include the same image only one time into the m3g-file
+#
+# All the following changes of this version was made by Claus Hoefele
+#
+#* Until now all vertices of the faces was been written.
+# Now the vertices will be used again if possible:
+# normal and texture coordinates of to vertices have to be the same
+#
+#* Smooth/solid shading can now be defined for every single material:
+# in Editing panel (F9)>Link and Materials
+#
+#* This script uses now correctly the TexFace and Shadless Buttons in
+# Shading panel (F5)>Material buttons>Material box.
+# TexFace switches on/off the Export of texture coordinates.
+# Shadeless does the some with the normal coordinates
+#
+#* The GUI was redesigned in a PupBlock
+#
+#* Options:
+#
+#** Texturing Enabled: Switches on/off export of textures and texture
+# coordinates. Attention: the TextFace button switches only
+# for one mesh
+#** Texturing External: the textures will be included it mg3-file or
+# exported in seperate file
+#** Lighting Enabled: turns on/off export of lights and normal completly
+# Attention: Shadeless only for one mesh
+#** Persp. Correction: turns on/off perspective correction in PolygonMode.
+#** Smooth Shading: turns on/off smooth shading in PolygonMode.
+#
+#* Textures in external references are used again (with ImageFactory)
+#
+#* Blender function: Double Sided button in Editing Context
+# (F9)>Mesh panel)
+# turn on/off PolygonMode.CULL_BACK anzuschalten.
+#
+#* Script ingnores meshes that have no faces
+#
+# History 0.7
+#
+# * Exporter can work with texture coordinates greater 1 and smaller 0
+#
+# * Adler32 did not work always correct. New implementation made.
+#
+# * Modul shutil is not needed any longer. Exporter has its own copy_file.
+# (realized and inspired by ideasman_42 and Martin Neumann)
+# --------------------------------------------------------------------------#
+# TODO: Export only selected mesh
+# TODO: Optimize Bones <--> Vertex Group mapping
+# TODO: Compressed File
+# TODO: MTex - Support
+# TODO: By Rotating use SQUAD instead of Beziere. It's smoother
+import Blender
+from Blender import Types,Lamp,Material,Texture,Window,Registry,Draw
+from Blender.BGL import *
+from Blender.Object import *
+from Blender.Camera import *
+from Blender.Mesh import *
+from array import array
+import sys, struct, zlib
+from inspect import *
+from types import *
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list