From: <au...@us...> - 2011-05-01 02:02:12
|
Revision: 8489 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=8489&view=rev Author: auria Date: 2011-05-01 02:02:05 +0000 (Sun, 01 May 2011) Log Message: ----------- Added a small tool I made to list the contents of a B3D file; VERY useful to debug the exporter Added Paths: ----------- media/trunk/blender_25/B3DReader/ media/trunk/blender_25/B3DReader/net/ media/trunk/blender_25/B3DReader/net/sourceforge/ media/trunk/blender_25/B3DReader/net/sourceforge/supertuxkart/ media/trunk/blender_25/B3DReader/net/sourceforge/supertuxkart/b3d/ media/trunk/blender_25/B3DReader/net/sourceforge/supertuxkart/b3d/B3DReader.java media/trunk/blender_25/B3DReader.jar Added: media/trunk/blender_25/B3DReader/net/sourceforge/supertuxkart/b3d/B3DReader.java =================================================================== --- media/trunk/blender_25/B3DReader/net/sourceforge/supertuxkart/b3d/B3DReader.java (rev 0) +++ media/trunk/blender_25/B3DReader/net/sourceforge/supertuxkart/b3d/B3DReader.java 2011-05-01 02:02:05 UTC (rev 8489) @@ -0,0 +1,384 @@ +package net.sourceforge.supertuxkart.b3d; + +import java.io.File; +import java.io.FileInputStream; +import java.io.InputStream; +import java.util.ArrayList; + +public class B3DReader +{ + + /* + byte [] data = new byte[] {1,2,3,4}; + + ByteBuffer b = ByteBuffer.wrap(data); + + System.out.println(b.getInt()); + System.out.println(b.getFloat()); + */ + + + static Chunk curr_node = null; + static ArrayList<Chunk> m_all_nodes = new ArrayList<Chunk>(); + static ArrayList<Chunk> m_all_texs = new ArrayList<Chunk>(); + static ArrayList<Chunk> m_all_brus = new ArrayList<Chunk>(); + + + public static int readInt(InputStream i) throws Exception + { + byte[] b_len = new byte[4]; + if (i.read(b_len) != 4) + { + throw new RuntimeException("Can't read int"); + } + + int len = ((b_len[0] & 0xFF) | ((b_len[1] & 0xFF) << 8) | ((b_len[2] & 0xFF) << 16) | ((b_len[3] & 0xFF) << 24)); + return len; + } + + public static String readString(InputStream i) throws Exception + { + String out = ""; + + int b; + + while ((b = i.read()) != 0) + { + out += (char)b; + } + + return out; + } + + public static float readFloat(InputStream i) throws Exception + { + int packed_bytes = readInt(i); + return Float.intBitsToFloat(packed_bytes); + } + + public static void readBB3DChunk(InputStream i, final int length) throws Exception + { + int version = readInt(i); + System.out.println(" Version: " + version); + + while (i.available() > 0) { + readChunk(i, 1); + } + } + + public static void readTEXSChunk(InputStream i, final int length) throws Exception + { + int read = 0; + + while (read < length) + { + String filename = readString(i); + read += filename.length() + 1; + int flags = readInt(i); + int blend = readInt(i); + float x = readFloat(i); + float y = readFloat(i); + float x_scale = readFloat(i); + float y_scale = readFloat(i); + float rot = readFloat(i); + read += 28; + + System.out.println(" Filename: " + filename); + System.out.println(" Flags: " + flags); + System.out.println(" Blend: " + blend); + System.out.println(" Position: (" + x + ", " + y + ")"); + System.out.println(" Scale: (" + x_scale + ", " + y_scale + ")"); + System.out.println(" Rotation: " + rot); + } + } + + public static void readBRUSChunk(InputStream i, final int length) throws Exception + { + int num = readInt(i); + int read = 4; + + while (read < length) + { + String name = readString(i); + read += name.length() + 1; + + float r = readFloat(i); + float g = readFloat(i); + float b = readFloat(i); + float a = readFloat(i); + float shininess = readFloat(i); + int blend = readInt(i); + int fx = readInt(i); + read += 28; + + System.out.println(" Material name: " + name); + System.out.println(" RGBA: (" + r + ", " + g + ", " + b + ", " + a + ")"); + System.out.println(" Shininess: " + shininess); + System.out.println(" Blend: " + blend); + System.out.println(" FX: " + fx); + + + for (int n=0; n<num; n++) + { + int tid = readInt(i); + read += 4; + System.out.println(" TextureID[" + n + "] : " + tid); + } + } + } + + public static void readVRTSChunk(InputStream i, final int length) throws Exception + { + int flags = readInt(i); + int tex_coord_sets = readInt(i); + int tex_coord_set_size = readInt(i); + + System.out.println(" Flags: " + flags + " (Normals=" + ((flags & 0x1) != 0) + ", VertexColors=" + ((flags & 0x2) != 0) + ")"); + System.out.println(" Texture coords per vertex: " + tex_coord_sets); + System.out.println(" Tex_coord_set_size: " + tex_coord_set_size); + + int read = 12; + + while (read < length) + { + float x = readFloat(i); + float y = readFloat(i); + float z = readFloat(i); + read += 12; + + System.out.println(" Vertex: (" + x + ", " + y + ", " + z + ")"); + + if ((flags & 0x1) != 0) + { + float nx = readFloat(i); + float ny = readFloat(i); + float nz = readFloat(i); + read += 12; + + System.out.println(" Normal: (" + nx + ", " + ny + ", " + nz + ")"); + } + + if ((flags & 0x2) != 0) + { + float r = readFloat(i); + float g = readFloat(i); + float b = readFloat(i); + float a = readFloat(i); + read += 16; + + System.out.println(" RGBA: (" + r + ", " + g + ", " + b + ", " + a + ")"); + } + + for (int n=0; n<tex_coord_sets; n++) + { + String coords = ""; + for (int m=0; m<tex_coord_set_size; m++) + { + float coord = readFloat(i); + coords += coord + " "; + read += 4; + } + System.out.println(" TexCoord: ( " + coords + ")"); + } + } + } + + public static void readTRISChunk(InputStream i, final int length) throws Exception + { + int brush_id = readInt(i); + System.out.println(" BrushID: " + brush_id); + + int read = 4; + + while (read < length) + { + int vertex_1 = readInt(i); + int vertex_2 = readInt(i); + int vertex_3 = readInt(i); + read += 12; + System.out.println(" Triangle: (" + vertex_1 + ", " + vertex_2 + ", " + vertex_3 + ")"); + } + } + + public static void readMESHChunk(InputStream i, final int length) throws Exception + { + int brush_id = readInt(i); + System.out.println(" BrushID: " + brush_id); + + // VRTS chunk + readChunk(i, 2); + + // TRIS chunks + readChunk(i, 2); + } + + public static void readBONEChunk(InputStream i, final int length) throws Exception + { + int read = 0; + + while (read < length) + { + int vertex_id = readInt(i); + float weigth = readFloat(i); + read += 8; + System.out.println(" Vertex: " + vertex_id + " (weight=" + weigth + ")"); + } + } + + public static void readKEYSChunk(InputStream i, final int length) throws Exception + { + int flags = readInt(i); + System.out.println(" Flags: (Pos=" + ((flags & 0x1) != 0) + ", scale=" + ((flags & 0x2) != 0) + ", rot=" + ((flags & 0x4) != 0) + ")"); + + int read = 4; + + while (read < length) + { + int frame = readInt(i); + read += 4; + System.out.println(" Frame: " + frame); + + if ((flags & 0x1) != 0) + { + float x = readFloat(i); + float y = readFloat(i); + float z = readFloat(i); + read += 12; + System.out.println(" Position: (" + x + ", " + y + ", " + z + ")"); + } + if ((flags & 0x2) != 0) + { + float x = readFloat(i); + float y = readFloat(i); + float z = readFloat(i); + read += 12; + System.out.println(" Scale: (" + x + ", " + y + ", " + z + ")"); + } + if ((flags & 0x4) != 0) + { + float w = readFloat(i); + float x = readFloat(i); + float y = readFloat(i); + float z = readFloat(i); + read += 16; + System.out.println(" Rot: (" + w + ", " + x + ", " + y + ", " + z + ")"); + } + } + } + + public static void readANIMChunk(InputStream i, final int length) throws Exception + { + int flags = readInt(i); + int frames = readInt(i); + float fps = readFloat(i); + System.out.println(" Flags: " + flags + "(unused)"); + System.out.println(" Frames: " + frames); + System.out.println(" FPS: " + fps); + } + + static class Chunk + { + ArrayList<String> m_strings = new ArrayList<String>(); + ArrayList<Chunk> m_children = new ArrayList<Chunk>(); + String name; + String m_type; + + public Chunk(String type) + { + m_type = type; + } + public void add(String s) { m_strings.add(s); } + } + + public static void readNODEChunk(InputStream i, final int length) throws Exception + { + Chunk node = new Chunk("NODE"); + curr_node = node; + m_all_nodes.add(node); + + node.name = readString(i); + float x = readFloat(i); + float y = readFloat(i); + float z = readFloat(i); + float x_scale = readFloat(i); + float y_scale = readFloat(i); + float z_scale = readFloat(i); + float w_rot = readFloat(i); + float x_rot = readFloat(i); + float y_rot = readFloat(i); + float z_rot = readFloat(i); + + System.out.println(" Name: " + node.name); + System.out.println(" Position: (" + x + ", " + y + ", " + z + ")"); + System.out.println(" Scale: (" + x_scale + ", " + y_scale + ", " + z_scale + ")"); + System.out.println(" Rotation: (" + w_rot + ", " + x_rot + ", " + y_rot + ", " + z_rot + ")"); + } + + public static void readChunk(InputStream i, int level) throws Exception + { + byte[] tag = new byte[4]; + if (i.read(tag) != 4) + { + throw new RuntimeException("Can't read chunk tag"); + } + String tag_str = "" + (char)tag[0] + "" + (char)tag[1] + "" + (char)tag[2] + "" + (char)tag[3]; + + int len = readInt(i); + + for (int n=0; n<level; n++) System.out.print(" "); + System.out.println(tag_str + " (" + len + " bytes)"); + + if (tag_str.equals("BB3D")) + { + readBB3DChunk(i, len); + } + else if (tag_str.equals("TEXS")) + { + readTEXSChunk(i, len); + } + else if (tag_str.equals("BRUS")) + { + readBRUSChunk(i, len); + } + else if (tag_str.equals("VRTS")) + { + readVRTSChunk(i, len); + } + else if (tag_str.equals("TRIS")) + { + readTRISChunk(i, len); + } + else if (tag_str.equals("MESH")) + { + readMESHChunk(i, len); + } + else if (tag_str.equals("BONE")) + { + readBONEChunk(i, len); + } + else if (tag_str.equals("KEYS")) + { + readKEYSChunk(i, len); + } + else if (tag_str.equals("ANIM")) + { + readANIMChunk(i, len); + } + else if (tag_str.equals("NODE")) + { + readNODEChunk(i, len); + } + else + { + System.out.println(" ?? (unknown chunk)"); + for (int n=0; n<len; n++) i.read(); + } + } + + public static void main(String[] args) throws Exception + { + FileInputStream i = new FileInputStream( new File(args[0]) ); + + readChunk(i, 0); + } +} Property changes on: media/trunk/blender_25/B3DReader/net/sourceforge/supertuxkart/b3d/B3DReader.java ___________________________________________________________________ Added: svn:executable + * Added: media/trunk/blender_25/B3DReader.jar =================================================================== (Binary files differ) Property changes on: media/trunk/blender_25/B3DReader.jar ___________________________________________________________________ Added: svn:executable + * Added: svn:mime-type + application/octet-stream This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <au...@us...> - 2011-05-28 17:51:49
|
Revision: 8729 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=8729&view=rev Author: auria Date: 2011-05-28 17:51:43 +0000 (Sat, 28 May 2011) Log Message: ----------- Some improvements to B3D reader Modified Paths: -------------- media/trunk/blender_25/B3DReader/net/sourceforge/supertuxkart/b3d/B3DReader.java media/trunk/blender_25/B3DReader.jar Modified: media/trunk/blender_25/B3DReader/net/sourceforge/supertuxkart/b3d/B3DReader.java =================================================================== --- media/trunk/blender_25/B3DReader/net/sourceforge/supertuxkart/b3d/B3DReader.java 2011-05-28 17:38:52 UTC (rev 8728) +++ media/trunk/blender_25/B3DReader/net/sourceforge/supertuxkart/b3d/B3DReader.java 2011-05-28 17:51:43 UTC (rev 8729) @@ -23,17 +23,19 @@ static ArrayList<Chunk> m_all_texs = new ArrayList<Chunk>(); static ArrayList<Chunk> m_all_brus = new ArrayList<Chunk>(); + static boolean showVrts = true; public static int readInt(InputStream i) throws Exception { - byte[] b_len = new byte[4]; - if (i.read(b_len) != 4) + byte[] bytes = new byte[4]; + if (i.read(bytes) != 4) { throw new RuntimeException("Can't read int"); } - int len = ((b_len[0] & 0xFF) | ((b_len[1] & 0xFF) << 8) | ((b_len[2] & 0xFF) << 16) | ((b_len[3] & 0xFF) << 24)); - return len; + int as_int = ((bytes[0] & 0xFF) | ((bytes[1] & 0xFF) << 8) | ((bytes[2] & 0xFF) << 16) | ((bytes[3] & 0xFF) << 24)); + if (as_int == -0) as_int = 0; + return as_int; } public static String readString(InputStream i) throws Exception @@ -52,8 +54,17 @@ public static float readFloat(InputStream i) throws Exception { - int packed_bytes = readInt(i); - return Float.intBitsToFloat(packed_bytes); + byte[] bytes = new byte[4]; + if (i.read(bytes) != 4) + { + throw new RuntimeException("Can't read int"); + } + + int packed_bytes = ((bytes[0] & 0xFF) | ((bytes[1] & 0xFF) << 8) | ((bytes[2] & 0xFF) << 16) | ((bytes[3] & 0xFF) << 24)); + + float f = Float.intBitsToFloat(packed_bytes); + if (f == -0) f = 0; + return f; } public static void readBB3DChunk(InputStream i, final int length) throws Exception @@ -66,6 +77,16 @@ } } + public static String format3(float f) + { + return String.format("%.3f", f); + } + + public static String format2(float f) + { + return String.format("%.2f", f); + } + public static void readTEXSChunk(InputStream i, final int length) throws Exception { int read = 0; @@ -86,8 +107,8 @@ System.out.println(" Filename: " + filename); System.out.println(" Flags: " + flags); System.out.println(" Blend: " + blend); - System.out.println(" Position: (" + x + ", " + y + ")"); - System.out.println(" Scale: (" + x_scale + ", " + y_scale + ")"); + System.out.println(" Position: (" + format2(x) + ", " + format2(y) + ")"); + System.out.println(" Scale: (" + format2(x_scale) + ", " + format2(y_scale) + ")"); System.out.println(" Rotation: " + rot); } } @@ -146,7 +167,8 @@ float z = readFloat(i); read += 12; - System.out.println(" Vertex: (" + x + ", " + y + ", " + z + ")"); + if (showVrts) + System.out.println(" Vertex: (" + format2(x) + ", " + format2(y) + ", " + format2(z) + ")"); if ((flags & 0x1) != 0) { @@ -155,7 +177,8 @@ float nz = readFloat(i); read += 12; - System.out.println(" Normal: (" + nx + ", " + ny + ", " + nz + ")"); + if (showVrts) + System.out.println(" Normal: (" + format2(nx) + ", " + format2(ny) + ", " + format2(nz) + ")"); } if ((flags & 0x2) != 0) @@ -166,7 +189,8 @@ float a = readFloat(i); read += 16; - System.out.println(" RGBA: (" + r + ", " + g + ", " + b + ", " + a + ")"); + if (showVrts) + System.out.println(" RGBA: (" + r + ", " + g + ", " + b + ", " + a + ")"); } for (int n=0; n<tex_coord_sets; n++) @@ -178,7 +202,9 @@ coords += coord + " "; read += 4; } - System.out.println(" TexCoord: ( " + coords + ")"); + + if (showVrts) + System.out.println(" TexCoord: ( " + coords + ")"); } } } @@ -196,7 +222,8 @@ int vertex_2 = readInt(i); int vertex_3 = readInt(i); read += 12; - System.out.println(" Triangle: (" + vertex_1 + ", " + vertex_2 + ", " + vertex_3 + ")"); + if (showVrts) + System.out.println(" Triangle: (" + vertex_1 + ", " + vertex_2 + ", " + vertex_3 + ")"); } } @@ -244,7 +271,7 @@ float y = readFloat(i); float z = readFloat(i); read += 12; - System.out.println(" Position: (" + x + ", " + y + ", " + z + ")"); + System.out.println(" Position: (" + format2(x) + ", " + format2(y) + ", " + format2(z) + ")"); } if ((flags & 0x2) != 0) { @@ -252,7 +279,7 @@ float y = readFloat(i); float z = readFloat(i); read += 12; - System.out.println(" Scale: (" + x + ", " + y + ", " + z + ")"); + System.out.println(" Scale: (" + format2(x) + ", " + format2(y) + ", " + format2(z) + ")"); } if ((flags & 0x4) != 0) { @@ -261,7 +288,7 @@ float y = readFloat(i); float z = readFloat(i); read += 16; - System.out.println(" Rot: (" + w + ", " + x + ", " + y + ", " + z + ")"); + System.out.println(" Rot: (" + format3(w) + ", " + format3(x) + ", " + format3(y) + ", " + format3(z) + ")"); } } } @@ -309,9 +336,9 @@ float z_rot = readFloat(i); System.out.println(" Name: " + node.name); - System.out.println(" Position: (" + x + ", " + y + ", " + z + ")"); - System.out.println(" Scale: (" + x_scale + ", " + y_scale + ", " + z_scale + ")"); - System.out.println(" Rotation: (" + w_rot + ", " + x_rot + ", " + y_rot + ", " + z_rot + ")"); + System.out.println(" Position: (" + format2(x) + ", " + format2(y) + ", " + format2(z) + ")"); + System.out.println(" Scale: (" + format2(x_scale) + ", " + format2(y_scale) + ", " + format2(z_scale) + ")"); + System.out.println(" Rotation: (" + format3(w_rot) + ", " + format3(x_rot) + ", " + format3(y_rot) + ", " + format3(z_rot) + ")"); } public static void readChunk(InputStream i, int level) throws Exception @@ -377,6 +404,7 @@ public static void main(String[] args) throws Exception { + if (args.length > 1 && args[1].equals("--no-vrts")) showVrts = false; FileInputStream i = new FileInputStream( new File(args[0]) ); readChunk(i, 0); Modified: media/trunk/blender_25/B3DReader.jar =================================================================== (Binary files differ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <au...@us...> - 2011-05-29 19:02:10
|
Revision: 8746 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=8746&view=rev Author: auria Date: 2011-05-29 19:02:02 +0000 (Sun, 29 May 2011) Log Message: ----------- Update blender scripts so you can dump them in /scripts/addons, run blender and have them ready to use Modified Paths: -------------- media/trunk/blender_25/README.txt media/trunk/blender_25/stk_kart.py media/trunk/blender_25/stk_panel.py Added Paths: ----------- media/trunk/blender_25/B3DExport.py media/trunk/blender_25/stk_track.py Removed Paths: ------------- media/trunk/blender_25/B3DExport_2.5.py media/trunk/blender_25/stk_track_2.5.py Added: media/trunk/blender_25/B3DExport.py =================================================================== --- media/trunk/blender_25/B3DExport.py (rev 0) +++ media/trunk/blender_25/B3DExport.py 2011-05-29 19:02:02 UTC (rev 8746) @@ -0,0 +1,1519 @@ +#!BPY + +""" +Name: 'B3D Exporter (.b3d)...' +Blender: 248a +Group: 'Export' +Tooltip: 'Export to Blitz3D file format (.b3d)' +""" +__author__ = ["Diego 'GaNDaLDF' Parisi"] +__url__ = ["www.gandaldf.com"] +__version__ = "3.0" +__bpydoc__ = """\ +""" + +# BLITZ3D EXPORTER 3.0 +# Copyright (C) 2009 by Diego "GaNDaLDF" Parisi - www.gandaldf.com +# +# Lightmap issue fixed by Capricorn 76 Pty. Ltd. - www.capricorn76.com +# +# With changes by Marianne Gagnon and Joerg Henrichs, supertuxkart.sf.net +# +# LICENSE: +# 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 + +bl_info = { + "name": "B3D (BLITZ3D) Model Exporter", + "description": "Exports a blender scene or object to the B3D (BLITZ3D) format", + "author": "Diego 'GaNDaLDF' Parisi, Joerg Henrichs, Marianne Gagnon", + "version": (3,0), + "blender": (2, 5, 7), + "api": 31236, + "location": "File > Export", + "warning": '', # used for warning icon and text in addons panel + "wiki_url": "http://supertuxkart.sourceforge.net/Get_involved", + "tracker_url": "https://sourceforge.net/apps/trac/supertuxkart/>", + "category": "Import-Export"} + + +#If you get an error here, it might be +#because you don't have Python installed. +import bpy +import sys,os,os.path,struct,math,string +import mathutils +import math + +if not hasattr(sys,"argv"): sys.argv = ["???"] + + +#Global Stacks +b3d_parameters = {} +sets_stack = [] +texs_stack = [] +brus_stack = [] +mesh_stack = [] +bone_stack = [] +keys_stack = [] + +per_face_vertices = {} + +the_scene = None + +#Transformation Matrix +TRANS_MATRIX = mathutils.Matrix([[1,0,0,0],[0,0,1,0],[0,1,0,0],[0,0,0,1]]) +BONE_TRANS_MATRIX = mathutils.Matrix([[-1,0,0,0],[0,0,-1,0],[0,-1,0,0],[0,0,0,1]]) + +DEBUG = False +PROGRESS = True +PROGRESS_VERBOSE = False + +#Support Functions +def write_int(value): + return struct.pack("<i",value) + +def write_float(value): + return struct.pack("<f",round(value,4)) + +def write_string(value): + binary_format = "<%ds"%(len(value)+1) + return struct.pack(binary_format, str.encode(value)) + +def write_chunk(name,value): + dummy = bytearray() + return dummy + name + write_int(len(value)) + value + +# ==== Write B3D File ==== +# (main exporter function) +def write_b3d_file(filename, objects=[]): + global sets_stack, texs_stack + global brus_stack, mesh_stack, bone_stack, keys_stack + + #Global Stacks + sets_stack = [] + texs_stack = [] + brus_stack = [] + mesh_stack = [] + bone_stack = [] + keys_stack = [] + file_buf = bytearray() + temp_buf = bytearray() + + temp_buf += write_int(1) #Version + temp_buf += write_texs(objects) #TEXS + temp_buf += write_brus(objects) #BRUS + temp_buf += write_node(objects) #NODE + + if len(temp_buf) > 0: + file_buf += write_chunk(b"BB3D",temp_buf) + temp_buf = "" + + file = open(filename,'wb') + file.write(file_buf) + file.close() + +# ==== Write TEXS Chunk ==== +def write_texs(objects=[]): + global b3d_parameters + texs_buf = bytearray() + temp_buf = bytearray() + layer_max = 0 + obj_count = 0 + set_wrote = 0 + + if objects: + exp_obj = objects + else: + if b3d_parameters.get("export-selected"): + exp_obj = [ob for ob in bpy.data.objects if ob.select] + else: + exp_obj = bpy.data.objects + + if PROGRESS: print(len(exp_obj),"TEXS") + + if PROGRESS_VERBOSE: progress = 0 + + for obj in exp_obj: + + if PROGRESS_VERBOSE: + progress = progress + 1 + if (progress % 10 == 0): print("TEXS",progress,"/",len(exp_obj)) + + if obj.type == "MESH": + set_count = 0 + set_wrote = 0 + #data = obj.getData(mesh = True) + data = obj.data + + # FIXME? + #orig_uvlayer = data.activeUVLayer + + layer_set = [[],[],[],[],[],[],[],[]] + sets_stack.append([[],[],[],[],[],[],[],[]]) + + #if len(data.getUVLayerNames()) <= 8: + if len(data.uv_textures) <= 8: + if len(data.uv_textures) > layer_max: + layer_max = len(data.uv_textures) + else: + layer_max = 8 + + for face in data.faces: + for iuvlayer,uvlayer in enumerate(data.uv_textures): + if iuvlayer < 8: + + # FIXME? + #data.activeUVLayer = uvlayer + + #layer_set[iuvlayer].append(face.uv) + layer_set[iuvlayer].append( uvlayer.data[face.index].uv ) + + for i in range(len(data.uv_textures)): + if set_wrote: + set_count += 1 + set_wrote = 0 + + for iuvlayer in range(i,len(data.uv_textures)): + if layer_set[i] == layer_set[iuvlayer]: + if sets_stack[obj_count][iuvlayer] == []: + if set_count == 0: + tex_flag = 1 + elif set_count == 1: + tex_flag = 65536 + elif set_count > 1: + tex_flag = 1 + if b3d_parameters.get("mipmap"): + enable_mipmaps=8 + else: + enable_mipmaps=0 + sets_stack[obj_count][iuvlayer] = tex_flag|enable_mipmaps + set_wrote = 1 + + for face in data.faces: + for iuvlayer,uvlayer in enumerate(data.uv_textures): + if iuvlayer < 8: + + # FIXME? + #data.activeUVLayer = uvlayer + + #if DEBUG: print("<uv face=", face.index, ">") + if data.uv_textures[0].data[face.index].image: + + img_name = os.path.basename(data.uv_textures[0].data[face.index].image.filepath) + #img_name = data.uv_textures[0].data[face.index].image.name + + if not [img_name, sets_stack[obj_count][iuvlayer]] in texs_stack: + if DEBUG: print("<image id=",len(texs_stack),"name=","'"+img_name+"'","/>") + texs_stack.append([img_name, sets_stack[obj_count][iuvlayer]]) + temp_buf += write_string(img_name) #Texture File Name + temp_buf += write_int(sets_stack[obj_count][iuvlayer]) #Flags + temp_buf += write_int(2) #Blend + temp_buf += write_float(0) #X_Pos + temp_buf += write_float(0) #Y_Pos + temp_buf += write_float(1) #X_Scale + temp_buf += write_float(1) #Y_Scale + temp_buf += write_float(0) #Rotation + #else: + # if DEBUG: print(" <image id=(previous)","name=","'"+img_name+"'","/>") + + #if DEBUG: print("</uv>") + + obj_count += 1 + + #FIXME? + #if orig_uvlayer: + # data.activeUVLayer = orig_uvlayer + + texs_stack.append(layer_max) + + if len(temp_buf) > 0: + texs_buf += write_chunk(b"TEXS",temp_buf) + temp_buf = "" + + return texs_buf + +# ==== Write BRUS Chunk ==== +def write_brus(objects=[]): + global b3d_parameters + brus_buf = bytearray() + temp_buf = bytearray() + mat_count = 0 + obj_count = 0 + + if DEBUG: print("<!-- BRUS chunk -->") + + if objects: + exp_obj = objects + else: + if b3d_parameters.get("export-selected"): + exp_obj = [ob for ob in bpy.data.objects if ob.select] + else: + exp_obj = bpy.data.objects + + if PROGRESS: print(len(exp_obj),"BRUS") + if PROGRESS_VERBOSE: progress = 0 + + for obj in exp_obj: + + if PROGRESS_VERBOSE: + progress += 1 + if (progress % 10 == 0): print("BRUS",progress,"/",len(exp_obj)) + + if obj.type == "MESH": + #data = obj.getData(mesh = True) + data = obj.data + + # FIXME? + #orig_uvlayer = data.activeUVLayer + + if DEBUG: print("<obj name=",obj.name,">") + + for face in data.faces: + img_found = 0 + face_stack = [] + + if DEBUG: print(" <!-- Building FACE 'stack' -->") + + #for iuvlayer,uvlayer in enumerate(data.getUVLayerNames()): + for iuvlayer,uvlayer in enumerate(data.uv_textures): + if iuvlayer < 8: + + #FIXME? + #data.activeUVLayer = uvlayer + + img_id = -1 + + #if data.faceUV and face.image: + if data.uv_textures[0].data[face.index].image: + img_found = 1 + + #print("len(texs_stack) =", len(texs_stack)) + for i in range(len(texs_stack)-1): + + img_name = os.path.basename(data.uv_textures[0].data[face.index].image.filepath) + #img_name = data.uv_textures[0].data[face.index].image.name + + if texs_stack[i][0] == img_name: + if texs_stack[i][1] == sets_stack[obj_count][iuvlayer]: + img_id = i + + face_stack.insert(iuvlayer,img_id) + if DEBUG: print(" <uv face=",face.index,"layer=", iuvlayer, " imgid=", img_id, "/>") + + for i in range(len(face_stack),texs_stack[-1]): + face_stack.append(-1) + + + if DEBUG: print(" <!-- Writing chunk -->") + + if not img_found: + if data.materials: + if data.materials[face.material_index]: + mat_data = data.materials[face.material_index] + mat_colr = mat_data.diffuse_color[0] + mat_colg = mat_data.diffuse_color[1] + mat_colb = mat_data.diffuse_color[2] + mat_alpha = mat_data.alpha + mat_name = mat_data.name + + if not mat_name in brus_stack: + brus_stack.append(mat_name) + temp_buf += write_string(mat_name) #Brush Name + temp_buf += write_float(mat_colr) #Red + temp_buf += write_float(mat_colg) #Green + temp_buf += write_float(mat_colb) #Blue + temp_buf += write_float(mat_alpha) #Alpha + temp_buf += write_float(0) #Shininess + temp_buf += write_int(1) #Blend + if b3d_parameters.get("vertex-colors") and len(data.vertex_colors): + temp_buf += write_int(2) #Fx + else: + temp_buf += write_int(0) #Fx + + for i in face_stack: + temp_buf += write_int(i) #Texture ID + else: + if b3d_parameters.get("vertex-colors") and len(data.vertex_colors) > 0: + if not face_stack in brus_stack: + brus_stack.append(face_stack) + mat_count += 1 + temp_buf += write_string("Brush.%.3i"%mat_count) #Brush Name + temp_buf += write_float(1) #Red + temp_buf += write_float(1) #Green + temp_buf += write_float(1) #Blue + temp_buf += write_float(1) #Alpha + temp_buf += write_float(0) #Shininess + temp_buf += write_int(1) #Blend + temp_buf += write_int(2) #Fx + + for i in face_stack: + temp_buf += write_int(i) #Texture ID + else: # img_found + if not face_stack in brus_stack: + brus_stack.append(face_stack) + mat_count += 1 + temp_buf += write_string("Brush.%.3i"%mat_count) #Brush Name + temp_buf += write_float(1) #Red + temp_buf += write_float(1) #Green + temp_buf += write_float(1) #Blue + temp_buf += write_float(1) #Alpha + temp_buf += write_float(0) #Shininess + temp_buf += write_int(1) #Blend + + if DEBUG: print(" <brush id=",len(brus_stack),">") + + if b3d_parameters.get("vertex-colors") and len(data.vertex_colors) > 0: + temp_buf += write_int(2) #Fx + else: + temp_buf += write_int(0) #Fx + + for i in face_stack: + temp_buf += write_int(i) #Texture ID + if DEBUG: print(" <texture id=",i,">") + + if DEBUG: print(" </brush>") + + if DEBUG: print("") + + if DEBUG: print("</obj>") + obj_count += 1 + + #FIXME? + #if orig_uvlayer: + # data.activeUVLayer = orig_uvlayer + + if len(temp_buf) > 0: + brus_buf += write_chunk(b"BRUS",write_int(texs_stack[-1]) + temp_buf) #N Texs + temp_buf = "" + + return brus_buf + +# ==== Write NODE Chunk ==== +def write_node(objects=[]): + global bone_stack + global keys_stack + global b3d_parameters + global the_scene + + root_buf = bytearray() + node_buf = bytearray() + main_buf = bytearray() + temp_buf = bytearray() + obj_count = 0 + amb_light = 0 + + num_mesh = 0 + num_ligs = 0 + num_cams = 0 + num_lorc = 0 + #exp_scn = Blender.Scene.GetCurrent() + #exp_scn = the_scene + #exp_con = exp_scn.getRenderingContext() + + #first_frame = Blender.Draw.Create(exp_con.startFrame()) + #last_frame = Blender.Draw.Create(exp_con.endFrame()) + #num_frames = last_frame.val - first_frame.val + first_frame = the_scene.frame_start + last_frame = the_scene.frame_end + num_frames = last_frame - first_frame + + + if DEBUG: print("<node first_frame=", first_frame, " last_frame=", last_frame, ">") + + if objects: + exp_obj = objects + else: + if b3d_parameters.get("export-selected"): + exp_obj = [ob for ob in bpy.data.objects if ob.select] + else: + exp_obj = bpy.data.objects + + for obj in exp_obj: + if obj.type == "MESH": + num_mesh += 1 + if obj.type == "CAMERA": + num_cams += 1 + if obj.type == "LAMP": + num_ligs += 1 + + if b3d_parameters.get("cameras"): + num_lorc += num_cams + + if b3d_parameters.get("lights"): + num_lorc += 1 + num_lorc += num_ligs + + if num_mesh + num_lorc > 1: + exp_root = 1 + else: + exp_root = 0 + + if exp_root: + root_buf += write_string("ROOT") #Node Name + + root_buf += write_float(0) #Position X + root_buf += write_float(0) #Position Y + root_buf += write_float(0) #Position Z + + root_buf += write_float(1) #Scale X + root_buf += write_float(1) #Scale Y + root_buf += write_float(1) #Scale Z + + root_buf += write_float(1) #Rotation W + root_buf += write_float(0) #Rotation X + root_buf += write_float(0) #Rotation Y + root_buf += write_float(0) #Rotation Z + + if PROGRESS: progress = 0 + + for obj in exp_obj: + + if PROGRESS: + progress += 1 + print("NODE:",progress,"/",len(exp_obj)) + + if obj.type == "MESH": + + if DEBUG: print(" <mesh name=",obj.name,">") + + bone_stack = [] + keys_stack = [] + #data = obj.getData(mesh = True) + + anim_data = None + if obj.parent: + if obj.parent.type == "ARMATURE": + arm = obj.parent + if arm.animation_data: + anim_data = arm.animation_data + + + if anim_data: + matrix = mathutils.Matrix() + + temp_buf += write_string(obj.name) #Node Name + + position = matrix.to_translation() + temp_buf += write_float(-position[0]) #Position X + temp_buf += write_float(position[1]) #Position Y + temp_buf += write_float(position[2]) #Position Z + + scale = matrix.to_scale() + temp_buf += write_float(scale[0]) #Scale X + temp_buf += write_float(scale[2]) #Scale Y + temp_buf += write_float(scale[1]) #Scale Z + + if DEBUG: print(" <arm name=", obj.name, " loc=", -position[0], position[1], position[2], " scale=", scale[0], scale[1], scale[2], "/>") + + quat = matrix.to_quaternion() + quat.normalize() + + temp_buf += write_float(quat.w) #Rotation W + temp_buf += write_float(quat.x) #Rotation X + temp_buf += write_float(quat.z) #Rotation Y + temp_buf += write_float(quat.y) #Rotation Z + else: + if b3d_parameters.get("local-space"): + matrix = TRANS_MATRIX + + scale = [1.0,1.0,1.0] + + else: + + e = obj.matrix_world.to_euler() + t = obj.matrix_world.to_translation() + + #e.rotate_axis('X', -math.pi/2) + #e.rotate_axis('Z',- math.pi/2) + + tmp = e[2] + e[2] = e[1] + e[1] = tmp + + #print(obj.name, e[0], e[1], e[2]) + + matrix = e.to_matrix().to_4x4() + matrix = mathutils.Matrix.Translation(t)*matrix + + scale = obj.matrix_world.to_scale() + + #matrix = mathutils.Matrix.Rotation(math.pi/2,4,'X') + #matrix *= obj.matrix_world + #matrix *= TRANS_MATRIX + + #matrix = obj.matrix_world + #matrix *= TRANS_MATRIX + + temp_buf += write_string(obj.name) #Node Name + + #print("Matrix : ", matrix) + position = matrix.to_translation() + + temp_buf += write_float(position[0]) #Position X + temp_buf += write_float(position[2]) #Position Y + temp_buf += write_float(position[1]) #Position Z + + temp_buf += write_float(scale[0]) #Scale X + temp_buf += write_float(scale[2]) #Scale Y + temp_buf += write_float(scale[1]) #Scale Z + + #matrix *= mathutils.Matrix.Rotation(math.pi, 4, 'Y') + #matrix *= mathutils.Matrix.Rotation(math.pi/2, 4, 'X') + quat = matrix.to_quaternion() + quat.normalize() + + temp_buf += write_float(quat.w) #Rotation W + temp_buf += write_float(quat.x) #Rotation X + temp_buf += write_float(quat.y) #Rotation Y + temp_buf += write_float(-quat.z) #Rotation Z + + if DEBUG: print(" <position>",position[0],position[2],position[1],"</position>") + if DEBUG: print(" <scale>",scale[0],scale[1],scale[2],"</scale>") + if DEBUG: print(" <rotation>", quat.w, quat.x, quat.y, quat.z, "</rotation>") + + + if anim_data: + #Blender.Set("curframe",0) + #Blender.Window.Redraw() + #bpy.ops.anim.change_frame(frame=0) + + the_scene.frame_set(0,subframe=0.0) + + #data = arm.getData() + arm_matrix = arm.matrix_world + #arm_matrix *= TRANS_MATRIX.inverted() + + def read_armature(arm_matrix,bone,parent = None): + if (parent and not bone.parent.name == parent.name): + return + + matrix = mathutils.Matrix(bone.matrix) + + if parent: + + print("==== "+bone.name+" ====") + a = (bone.matrix_local) + + print("A : [%.2f %.2f %.2f %.2f]" % (a[0][0], a[0][1], a[0][2], a[0][3])) + print(" [%.2f %.2f %.2f %.2f]" % (a[1][0], a[1][1], a[1][2], a[1][3])) + print(" [%.2f %.2f %.2f %.2f]" % (a[2][0], a[2][1], a[2][2], a[2][3])) + print(" [%.2f %.2f %.2f %.2f]" % (a[3][0], a[3][1], a[3][2], a[3][3])) + + b = (parent.matrix_local.inverted().to_4x4()) + + print("B : [%.2f %.2f %.2f %.2f]" % (b[0][0], b[0][1], b[0][2], b[0][3])) + print(" [%.2f %.2f %.2f %.2f]" % (b[1][0], b[1][1], b[1][2], b[1][3])) + print(" [%.2f %.2f %.2f %.2f]" % (b[2][0], b[2][1], b[2][2], b[2][3])) + print(" [%.2f %.2f %.2f %.2f]" % (b[3][0], b[3][1], b[3][2], b[3][3])) + + par_matrix = b * a + + c = par_matrix + print("C : [%.2f %.2f %.2f %.2f]" % (c[0][0], c[0][1], c[0][2], c[0][3])) + print(" [%.2f %.2f %.2f %.2f]" % (c[1][0], c[1][1], c[1][2], c[1][3])) + print(" [%.2f %.2f %.2f %.2f]" % (c[2][0], c[2][1], c[2][2], c[2][3])) + print(" [%.2f %.2f %.2f %.2f]" % (c[3][0], c[3][1], c[3][2], c[3][3])) + + else: + arm_matrix_2 = arm_matrix*TRANS_MATRIX + arm_matrix_2[0][0] = -arm_matrix_2[0][0] + arm_matrix_2[3][0] = -arm_matrix_2[3][0] + + tmp = arm_matrix_2[3][1] + arm_matrix_2[3][1] = arm_matrix_2[3][2] + arm_matrix_2[3][2] = tmp + + matrix_with_t = mathutils.Matrix.Translation(bone.head) * matrix.to_4x4() + + par_matrix = arm_matrix_2 * matrix_with_t + + + bone_stack.append([par_matrix,parent,bone]) + + if bone.children: + for child in bone.children: read_armature(arm_matrix,child,bone) + + for bone in arm.data.bones.values(): + if not bone.parent: + read_armature(arm_matrix,bone) + + # FIXME? + #arm_action.setActive(arm) + + frame_count = first_frame + + if PROGRESS_VERBOSE: + print(" FRAME:",frame_count,"in",frame_count,"..",last_frame) + anim_progress = 0 + + while frame_count <= last_frame: + + if PROGRESS_VERBOSE: + anim_progress += 1 + if (anim_progress % 50 == 0): print(" FRAME:",frame_count,"in",frame_count,"..",last_frame) + + #FIXME? + #Blender.Set("curframe",int(frame_count)) + #the_scene.frame_current = int(frame_count) + #bpy.ops.anim.change_frame(frame=int(frame_count)) + the_scene.frame_set(int(frame_count), subframe=0.0) + + if DEBUG: print(" <frame id=", int(frame_count), ">") + #Blender.Window.Redraw() + arm_pose = arm.pose + #arm_matrix = arm.getMatrix("worldspace") + arm_matrix = arm.matrix_world + arm_matrix *= BONE_TRANS_MATRIX + + # FIXME: ugly manual changes to matrix to make it more similar to Blender 2.4 exporter matrix + arm_matrix[1][2] = -arm_matrix[1][2] + arm_matrix[2][1] = -arm_matrix[2][1] + arm_matrix[3][0] = -arm_matrix[3][0] + tmp = arm_matrix[3][1] + arm_matrix[3][1] = arm_matrix[3][2] + arm_matrix[3][2] = tmp + + #print("arm_matrix =", arm_matrix) + + for bone_name in arm.data.bones.keys(): + #bone_matrix = mathutils.Matrix(arm_pose.bones[bone_name].poseMatrix) + bone_matrix = mathutils.Matrix(arm_pose.bones[bone_name].matrix) + + #print("(outer loop) bone_matrix for",bone_name,"=", bone_matrix) + + #print(bone_name,":",bone_matrix) + + #bone_matrix = bpy.data.scenes[0].objects[0].pose.bones['Bone'].matrix + + for ibone in range(len(bone_stack)): + + if bone_stack[ibone][2].name == bone_name: + + if DEBUG: print(" <bone id=",ibone,"name=",bone_name,">") + + if bone_stack[ibone][1]: + par_matrix = mathutils.Matrix(arm_pose.bones[bone_stack[ibone][1].name].matrix) + bone_matrix = par_matrix.inverted()*bone_matrix + pass + else: + if b3d_parameters.get("local-space"): + #bone_matrix *= TRANS_MATRIX + pass + else: + bone_matrix = arm_matrix*bone_matrix + + # FIXME: silly tweaks to resemble the Blender 2.4 exporter matrix + #bone_matrix[1][2] = -bone_matrix[1][2] + #bone_matrix[2][1] = -bone_matrix[2][1] + #bone_matrix[3][0] = -bone_matrix[3][0] + + #print("bone_matrix =", bone_matrix) + + bone_loc = bone_matrix.to_translation() + bone_rot = bone_matrix.to_quaternion() + bone_rot.normalize() + bone_sca = bone_matrix.to_scale() + keys_stack.append([frame_count - first_frame+1, bone_name, bone_loc, bone_sca, bone_rot]) + if DEBUG: print(" <loc>", bone_loc, "</loc>") + if DEBUG: print(" <rot>", bone_rot, "</rot>") + if DEBUG: print(" <scale>", bone_sca, "</scale>") + if DEBUG: print(" </bone>") + + frame_count += 1 + + if DEBUG: print(" </frame>") + + #Blender.Set("curframe",0) + #Blender.Window.Redraw() + + temp_buf += write_node_mesh(obj,obj_count,anim_data,exp_root) #NODE MESH + + if anim_data: + temp_buf += write_node_anim(num_frames) #NODE ANIM + + for ibone in range(len(bone_stack)): + if not bone_stack[ibone][1]: + temp_buf += write_node_node(ibone) #NODE NODE + + obj_count += 1 + + if len(temp_buf) > 0: + node_buf += write_chunk(b"NODE",temp_buf) + temp_buf = bytearray() + + if DEBUG: print(" </mesh>") + + if b3d_parameters.get("cameras"): + if obj.type == "CAMERA": + data = obj.data + matrix = obj.getMatrix("worldspace") + matrix *= TRANS_MATRIX + + if data.type == "ORTHO": + cam_type = 2 + cam_zoom = round(data.scale,4) + else: + cam_type = 1 + cam_zoom = round(data.lens,4) + + cam_near = round(data.clipStart,4) + cam_far = round(data.clipEnd,4) + + node_name = ("CAMS"+"\n%s"%obj.name+"\n%s"%cam_type+\ + "\n%s"%cam_zoom+"\n%s"%cam_near+"\n%s"%cam_far) + temp_buf += write_string(node_name) #Node Name + + position = matrix.translation_part() + temp_buf += write_float(-position[0]) #Position X + temp_buf += write_float(position[1]) #Position Y + temp_buf += write_float(position[2]) #Position Z + + scale = matrix.scale_part() + temp_buf += write_float(scale[0]) #Scale X + temp_buf += write_float(scale[1]) #Scale Y + temp_buf += write_float(scale[2]) #Scale Z + + matrix *= mathutils.Matrix.Rotation(180,4,'Y') + quat = matrix.to_quat() + quat.normalize() + + temp_buf += write_float(quat.w) #Rotation W + temp_buf += write_float(quat.x) #Rotation X + temp_buf += write_float(quat.y) #Rotation Y + temp_buf += write_float(-quat.z) #Rotation Z + + if len(temp_buf) > 0: + node_buf += write_chunk(b"NODE",temp_buf) + temp_buf = "" + + if b3d_parameters.get("lights"): + if amb_light == 0: + data = Blender.World.GetCurrent() + + amb_light = 1 + amb_color = (int(data.amb[2]*255) |(int(data.amb[1]*255) << 8) | (int(data.amb[0]*255) << 16)) + + node_name = (b"AMBI"+"\n%s"%amb_color) + temp_buf += write_string(node_name) #Node Name + + temp_buf += write_float(0) #Position X + temp_buf += write_float(0) #Position Y + temp_buf += write_float(0) #Position Z + + temp_buf += write_float(1) #Scale X + temp_buf += write_float(1) #Scale Y + temp_buf += write_float(1) #Scale Z + + temp_buf += write_float(1) #Rotation W + temp_buf += write_float(0) #Rotation X + temp_buf += write_float(0) #Rotation Y + temp_buf += write_float(0) #Rotation Z + + if len(temp_buf) > 0: + node_buf += write_chunk(b"NODE",temp_buf) + temp_buf = "" + + if obj.type == "LAMP": + data = obj.getData() + matrix = obj.getMatrix("worldspace") + matrix *= TRANS_MATRIX + + if data.type == 0: + lig_type = 2 + elif data.type == 2: + lig_type = 3 + else: + lig_type = 1 + + lig_angle = round(data.spotSize,4) + lig_color = (int(data.b*255) |(int(data.g*255) << 8) | (int(data.r*255) << 16)) + lig_range = round(data.dist,4) + + node_name = ("LIGS"+"\n%s"%obj.name+"\n%s"%lig_type+\ + "\n%s"%lig_angle+"\n%s"%lig_color+"\n%s"%lig_range) + temp_buf += write_string(node_name) #Node Name + + position = matrix.translation_part() + temp_buf += write_float(-position[0]) #Position X + temp_buf += write_float(position[1]) #Position Y + temp_buf += write_float(position[2]) #Position Z + if DEBUG: print(" <position>",-position[0],position[1],position[2],"</position>") + + scale = matrix.scale_part() + temp_buf += write_float(scale[0]) #Scale X + temp_buf += write_float(scale[1]) #Scale Y + temp_buf += write_float(scale[2]) #Scale Z + + if DEBUG: print(" <scale>",scale[0],scale[1],scale[2],"</scale>") + + matrix *= mathutils.Matrix.Rotation(180,4,'Y') + quat = matrix.toQuat() + quat.normalize() + + temp_buf += write_float(quat.w) #Rotation W + temp_buf += write_float(quat.x) #Rotation X + temp_buf += write_float(quat.y) #Rotation Y + temp_buf += write_float(-quat.z) #Rotation Z + + if DEBUG: print(" <rotation>", quat.w, quat.x, quat.y, quat.z, "</rotation>") + + if len(temp_buf) > 0: + node_buf += write_chunk(b"NODE",temp_buf) + temp_buf = "" + + if len(node_buf) > 0: + if exp_root: + main_buf += write_chunk(b"NODE",root_buf + node_buf) + else: + main_buf += node_buf + + node_buf = "" + root_buf = "" + + if DEBUG: print("</node>") + + return main_buf + +# ==== Write NODE MESH Chunk ==== +def write_node_mesh(obj,obj_count,arm_action,exp_root): + global mesh_stack + mesh_stack = [] + mesh_buf = bytearray() + temp_buf = bytearray() + + temp_buf += write_int(-1) #Brush ID + temp_buf += write_node_mesh_vrts(obj,obj_count,arm_action,exp_root) #NODE MESH VRTS + temp_buf += write_node_mesh_tris(obj,obj_count,arm_action,exp_root) #NODE MESH TRIS + + if len(temp_buf) > 0: + mesh_buf += write_chunk(b"MESH",temp_buf) + temp_buf = "" + + return mesh_buf + +#ids_count = 0 + +# ==== Write NODE MESH VRTS Chunk ==== +def write_node_mesh_vrts(obj,obj_count,arm_action,exp_root): + #global ids_count + vrts_buf = bytearray() + temp_buf = bytearray() + obj_flags = 0 + ids_count = 0 + + #data = obj.getData(mesh = True) + data = obj.data + + # FIXME: port to 2.5 API? + #orig_uvlayer = data.activeUVLayer + + if b3d_parameters.get("vertex-normals"): + obj_flags += 1 + + #if b3d_parameters.get("vertex-colors") and data.getColorLayerNames(): + if b3d_parameters.get("vertex-colors") and len(data.vertex_colors) > 0: + obj_flags += 2 + + temp_buf += write_int(obj_flags) #Flags + #temp_buf += write_int(len(data.getUVLayerNames())) #UV Set + temp_buf += write_int(len(data.uv_textures)) #UV Set + temp_buf += write_int(2) #UV Set Size + + # ---- Prepare the mesh "stack" + + #for i in data.vertices: + # mesh_stack.append([-1,-1,-1,[],[[],[],[],[],[],[],[],[]],[]]) + + # FIXME: major bottleneck + if PROGRESS: print("Preparing mesh_stack") + amount = 0 + for f in data.faces: + for v in f.vertices: + mesh_stack.append([-1,-1,-1,[],[[],[],[],[],[],[],[],[]],[]]) + + # ---- Fill the mesh "stack" + if DEBUG: print("") + if DEBUG: print(" <!-- Building mesh_stack -->\n") + + ivert = -1 + + + if PROGRESS_VERBOSE: + progress = 0 + print(" mesh_stack, face:",0,"/",len(data.faces)) + + for face in data.faces: + + if DEBUG: print(" <!-- Face",face.index,"-->") + + if PROGRESS_VERBOSE: + progress += 1 + if (progress % 50 == 0): print(" mesh_stack, face:",progress,"/",len(data.faces)) + + + per_face_vertices[face.index] = [] + + for vertex_id,vert in enumerate(face.vertices): + + ivert += 1 + + #ivert = data.vertices[vert].index + + if DEBUG: print(" <!-- B3D Vertex",ivert,"is blender vertex",data.vertices[vert].index,"for face",face.index,"-->") + + per_face_vertices[face.index].append(ivert) + + if mesh_stack[ivert][0] != -1: + if DEBUG: print(" <!-- Vertex",ivert,"already handled -->") + + if mesh_stack[ivert][0] == -1: + link_matrix = obj.matrix_world + mesh_matrix = mathutils.Matrix([link_matrix[0],link_matrix[1],link_matrix[2],link_matrix[3]]) + vert_matrix = mathutils.Matrix.Translation(data.vertices[vert].co) + + #if arm_action: + if b3d_parameters.get("local-space"): + vert_matrix *= TRANS_MATRIX + t = [0,0,0] + + else: + vert_matrix *= TRANS_MATRIX + + #e = obj.matrix_world.to_euler() + t = obj.matrix_world.to_translation() + #s = obj.matrix_world.to_scale() + + #tmp = e[2] + #e[2] = e[1] + #e[1] = tmp + + #rotation_matrix = e.to_matrix().to_4x4() + + #scale_matrix = mathutils.Matrix() + #scale_matrix[0][0] = s[0] + #scale_matrix[1][1] = s[1] + #scale_matrix[2][2] = s[2] + + #vert_matrix = scale_matrix*vert_matrix + + #vert_matrix *= TRANS_MATRIX + #vert_matrix = vert_matrix*rotation_matrix + + vert_matrix = vert_matrix.to_translation() + + + mesh_stack[ivert][0] = ivert + mesh_stack[ivert][1] = mathutils.Vector([vert_matrix[0]+t[0], vert_matrix[1]+t[1], vert_matrix[2]+t[2]]) + + #if DEBUG: print " <vertex id=",vert.index,"/>" + + if b3d_parameters.get("vertex-normals"): + link_matrix = obj.matrix_world + mesh_matrix = mathutils.Matrix([link_matrix[0],link_matrix[1],link_matrix[2],link_matrix[3]]) + norm_matrix = mathutils.Matrix.Translation(data.vertices[vert].normal) + + if arm_action: + norm_matrix *= mesh_matrix + + norm_matrix *= TRANS_MATRIX + norm_matrix = norm_matrix.to_translation() + + mesh_stack[ivert][2] = norm_matrix + + if b3d_parameters.get("vertex-colors") and len(data.vertex_colors) > 0: + if vertex_id == 0: + mesh_stack[ivert][3] = data.vertex_colors[0].data[face.index].color1 + elif vertex_id == 1: + mesh_stack[ivert][3] = data.vertex_colors[0].data[face.index].color2 + elif vertex_id == 2: + mesh_stack[ivert][3] = data.vertex_colors[0].data[face.index].color3 + elif vertex_id == 3: + mesh_stack[ivert][3] = data.vertex_colors[0].data[face.index].color4 + + if (len(data.uv_textures) > 0): + if vertex_id == 0: + mesh_stack[ivert][4][0].append([face.index,data.uv_textures[0].data[face.index].uv1]) + if DEBUG: print(" <uv face=",face.index,"vertex=",vertex_id,">", + data.uv_textures[0].data[face.index].uv1,"</uv>") + elif vertex_id == 1: + mesh_stack[ivert][4][0].append([face.index,data.uv_textures[0].data[face.index].uv2]) + if DEBUG: print(" <uv face=",face.index,"vertex=",vertex_id,">", + data.uv_textures[0].data[face.index].uv2,"</uv>") + elif vertex_id == 2: + mesh_stack[ivert][4][0].append([face.index,data.uv_textures[0].data[face.index].uv3]) + if DEBUG: print(" <uv face=",face.index,"vertex=",vertex_id,">", + data.uv_textures[0].data[face.index].uv3,"</uv>") + elif vertex_id == 3: + mesh_stack[ivert][4][0].append([face.index,data.uv_textures[0].data[face.index].uv4]) + if DEBUG: print(" <uv face=",face.index,"vertex=",vertex_id,">", + data.uv_textures[0].data[face.index].uv4,"</uv>") + else: + self.report({'ERROR'}, "Only triangles and quads are supported") + else: + mesh_stack[ivert][4][0].append([face.index,[0.0,0.0]]) + + #mesh_stack[vert.index][5].append(vert_influ) + + for vg in obj.vertex_groups: + w = 0.0 + try: + w = vg.weight(vert) + except: + pass + mesh_stack[ivert][5].append((vg.name, w)) + + if DEBUG: print(" <weigth vertex=", ivert,"bone=",vg.name,">",w,"</weight>") + + #print("mesh_stack[ivert][5] =",mesh_stack[ivert][5]) + + #if data.vertexUV and not data.faceUV: + # mesh_stack[vert.index][4][0].append([face.index,vert.uvco[0]]) + #if not data.vertexUV and not data.faceUV: + # mesh_stack[vert.index][4][0].append([face.index,[0.0,0.0]]) + + if DEBUG: print("") + + #if data.faceUV: + # if not 65536 in sets_stack[obj_count]: + # vert_opti = 1 + # else: + # vert_opti = 0 +# +# for iuvlayer,uvlayer in enumerate(data.getUVLayerNames()): +# if iuvlayer < 8: +# data.activeUVLayer = uvlayer +# for face in data.faces: +# for ivert,vert in enumerate(face.verts): +# if vert_opti: +# if not face.uv[ivert] in mesh_stack[vert.index][4][iuvlayer]: +# mesh_stack[vert.index][4][iuvlayer].append([face.index,face.uv[ivert]]) +# else: +# mesh_stack[vert.index][4][iuvlayer].append([face.index,face.uv[ivert]]) + + # FIXME: port to 2.5 API? + #if orig_uvlayer: + # data.activeUVLayer = orig_uvlayer + + if PROGRESS_VERBOSE: progress = 0 + + for ivert in range(len(mesh_stack)): + + if PROGRESS_VERBOSE: + progress += 1 + if (progress % 50 == 0): print(" VRTS:",progress,"/",len(mesh_stack)) + + + mesh_stack[ivert][0] = ids_count + + if DEBUG: print(" <ivert id=",ivert,">") + + for iuv in range(len(mesh_stack[ivert][4][0])): + ids_count += 1 + + temp_buf += write_float(mesh_stack[ivert][1].x) #X + temp_buf += write_float(mesh_stack[ivert][1].z) #Y + temp_buf += write_float(mesh_stack[ivert][1].y) #Z + + if DEBUG: print(" <vertex id=",ids_count," loc=",-mesh_stack[ivert][1].x, + mesh_stack[ivert][1].y, + mesh_stack[ivert][1].z,">") + + if b3d_parameters.get("vertex-normals"): + temp_buf += write_float(mesh_stack[ivert][2].x) #NX + temp_buf += write_float(mesh_stack[ivert][2].z) #NY + temp_buf += write_float(mesh_stack[ivert][2].y) #NZ + if DEBUG: print(" <normal>",-mesh_stack[ivert][2].x, + mesh_stack[ivert][2].y, + mesh_stack[ivert][2].z,"</normal>") + + if b3d_parameters.get("vertex-colors") and len(data.vertex_colors) > 0: + temp_buf += write_float(mesh_stack[ivert][3].r) #R + temp_buf += write_float(mesh_stack[ivert][3].g) #G + temp_buf += write_float(mesh_stack[ivert][3].b) #B + temp_buf += write_float(1.0) #A (FIXME?) + #temp_buf += write_float(mesh_stack[ivert][3].a/255.0) #A + if DEBUG: print(" <color>",mesh_stack[ivert][3].r, + mesh_stack[ivert][3].g, + mesh_stack[ivert][3].b,"</color>") + + #for iuvlayer in xrange(len(data.getUVLayerNames())): + for iuvlayer in range(len(data.uv_textures)): + temp_buf += write_float(mesh_stack[ivert][4][iuvlayer][iuv][1][0]) #U + temp_buf += write_float(1-mesh_stack[ivert][4][iuvlayer][iuv][1][1]) #V + if DEBUG: print(" <uv layer=",iuvlayer,">",mesh_stack[ivert][4][iuvlayer][iuv][1][0], + 1-mesh_stack[ivert][4][iuvlayer][iuv][1][1],"</uv>") + + if DEBUG: print(" </vertex>") + + if DEBUG: print(" </ivert>") + + if len(temp_buf) > 0: + vrts_buf += write_chunk(b"VRTS",temp_buf) + temp_buf = "" + + return vrts_buf + +# ==== Write NODE MESH TRIS Chunk ==== +def write_node_mesh_tris(obj,obj_count,arm_action,exp_root): + #data = obj.getData(mesh = True) + data = obj.data + + #FIXME? + #orig_uvlayer = data.activeUVLayer + + # An dictoriary that maps all brush-ids to a list of faces + # using this brush. This helps to sort the triangles by + # brush, creating less mesh buffer in irrlicht. + dBrushId2Face = {} + + if DEBUG: print("") + + for face in data.faces: + img_found = 0 + face_stack = [] + + #for iuvlayer,uvlayer in enumerate(data.getUVLayerNames()): + for iuvlayer,uvlayer in enumerate(data.uv_textures): + if iuvlayer < 8: + + #FIXME? + #data.activeUVLayer = uvlayer + + # Blender 2.5 : + # data.uv_textures[0].data[0].image + + img_id = -1 + + #FIXME? + #if data.faceUV and face.image: + if data.uv_textures[0].data[face.index].image: + img_found = 1 + for i in range(len(texs_stack)-1): + if texs_stack[i][0] == os.path.basename(data.uv_textures[0].data[face.index].image.filepath): + if texs_stack[i][1] == sets_stack[obj_count][iuvlayer]: + img_id = i + + face_stack.insert(iuvlayer,img_id) + + for i in range(len(face_stack),texs_stack[-1]): + face_stack.append(-1) + + if img_found == 0: + brus_id = -1 + if data.materials: + if data.materials[face.material_index]: + mat_name = data.materials[face.material_index].name + for i in range(len(brus_stack)): + if brus_stack[i] == mat_name: + brus_id = i + else: + for i in range(len(brus_stack)): + if brus_stack[i] == face_stack: + brus_id = i + else: + brus_id = -1 + for i in range(len(brus_stack)): + if brus_stack[i] == face_stack: + brus_id = i + + if brus_id in dBrushId2Face: + dBrushId2Face[brus_id].append(face) + else: + dBrushId2Face[brus_id] = [face] + + if DEBUG: print(" <!-- Face",face.index,"in brush",brus_id,"-->") + + tris_buf = bytearray() + + if DEBUG: print("") + if DEBUG: print(" <!-- TRIS chunk -->") + + if PROGRESS_VERBOSE: progress = 0 + + for brus_id in dBrushId2Face.keys(): + + if PROGRESS_VERBOSE: + progress += 1 + print("BRUS:",progress,"/",len(dBrushId2Face.keys())) + + temp_buf = write_int(brus_id) #Brush ID + + if DEBUG: print(" <brush id=", brus_id, ">") + + if PROGRESS_VERBOSE: progress2 = 0 + + for face in dBrushId2Face[brus_id]: + + if PROGRESS_VERBOSE: + progress2 += 1 + if (progress2 % 50 == 0): print(" TRIS:",progress2,"/",len(dBrushId2Face[brus_id])) + + #face_id = [0,0,0,0] + #if data.faceUV: + #if len(data.uv_textures) > 0: + # for i in range(len(face.vertices)): + # vi = data.vertices[face.vertices[i]].index + # for iuv in range(len(mesh_stack[vi][4][0])): + # if mesh_stack[vi][4][0][iuv][0] == face.index: + # face_id[i] = mesh_stack[vi][0] + iuv + #else: + # for i in range(len(face.verts)): + # face_id[i] = mesh_stack[face.v[i].index][0] + + vertices = per_face_vertices[face.index] + + temp_buf += write_int(vertices[2]) #A + temp_buf += write_int(vertices[1]) #B + temp_buf += write_int(vertices[0]) #C + + if DEBUG: print(" <face id=", vertices[2], vertices[1], vertices[0],"/> <!-- face",face.index,"-->") + + if len(face.vertices) == 4: + temp_buf += write_int(vertices[3]) #A + temp_buf += write_int(vertices[2]) #B + temp_buf += write_int(vertices[0]) #C + if DEBUG: print(" <face id=", vertices[3], vertices[2], vertices[0],"/> <!-- face",face.index,"-->") + + if DEBUG: print(" </brush>") + tris_buf += write_chunk(b"TRIS",temp_buf) + + #FIXME? + #if orig_uvlayer: + # data.activeUVLayer = orig_uvlayer + + return tris_buf + +# ==== Write NODE ANIM Chunk ==== +def write_node_anim(num_frames): + anim_buf = bytearray() + temp_buf = bytearray() + + temp_buf += write_int(0) #Flags + temp_buf += write_int(num_frames) #Frames + temp_buf += write_float(60) #FPS + + if len(temp_buf) > 0: + anim_buf += write_chunk(b"ANIM",temp_buf) + temp_buf = "" + + return anim_buf + +# ==== Write NODE NODE Chunk ==== +def write_node_node(ibone): + node_buf = bytearray() + temp_buf = bytearray() + + matrix = bone_stack[ibone][0] + temp_buf += write_string(bone_stack[ibone][2].name) #Node Name + + position = matrix.to_translation() + temp_buf += write_float(-position[0]) #Position X + temp_buf += write_float(position[1]) #Position Y + temp_buf += write_float(position[2]) #Position Z + + scale = matrix.to_scale() + temp_buf += write_float(scale[0]) #Scale X + temp_buf += write_float(scale[1]) #Scale Y + temp_buf += write_float(scale[2]) #Scale Z + + quat = matrix.to_quaternion() + quat.normalize() + + temp_buf += write_float(quat.w) #Rotation W + temp_buf += write_float(-quat.x) #Rotation X + temp_buf += write_float(quat.y) #Rotation Y + temp_buf += write_float(quat.z) #Rotation Z + + temp_buf += write_node_bone(ibone) + temp_buf += write_node_keys(ibone) + + for iibone in range(len(bone_stack)): + if bone_stack[iibone][1] == bone_stack[ibone][2]: + temp_buf += write_node_node(iibone) + + if len(temp_buf) > 0: + node_buf += write_chunk(b"NODE",temp_buf) + temp_buf = bytearray() + + return node_buf + +# ==== Write NODE BONE Chunk ==== +def write_node_bone(ibone): + bone_buf = bytearray() + temp_buf = bytearray() + + for ivert in range(len(mesh_stack)): + for iuv in range(len(mesh_stack[ivert][4][0])): + for vert_influ in mesh_stack[ivert][5]: + #print("bone_stack[ibone] =", bone_stack[ibone]) + #print("vert_influ =",vert_influ) + if bone_stack[ibone][2].name == vert_influ[0]: + if DEBUG: print(" <bone name=",bone_stack[ibone][2].name,"face_vertex_id=", mesh_stack[ivert][0] + iuv, + " weigth=", vert_influ[1] , "/>") + temp_buf += write_int(mesh_stack[ivert][0] + iuv) # Face Vertex ID + temp_buf += write_float(vert_influ[1]) #Weight + + bone_buf += write_chunk(b"BONE",temp_buf) + temp_buf = bytearray() + + return bone_buf + +# ==== Write NODE KEYS Chunk ==== +def write_node_keys(ibone): + keys_buf = bytearray() + temp_buf = bytearray() + + temp_buf += write_int(7) #Flags + + for ikeys in range(len(keys_stack)): + if keys_stack[ikeys][1] == bone_stack[ibone][2].name: + temp_buf += write_int(keys_stack[ikeys][0]) #Frame + + position = keys_stack[ikeys][2] + temp_buf += write_float(-position[0]) #Position X + temp_buf += write_float(position[1]) #Position Y + temp_buf += write_float(position[2]) #Position Z + + scale = keys_stack[ikeys][3] + temp_buf += write_float(scale[0]) #Scale X + temp_buf += write_float(scale[1]) #Scale Y + temp_buf += write_float(scale[2]) #Scale Z + + quat = keys_stack[ikeys][4] + quat.normalize() + + temp_buf += write_float(quat.w) #Rotation W + temp_buf += write_float(-quat.x) #Rotation X + temp_buf += write_float(quat.y) #Rotation Y + temp_buf += write_float(quat.z) #Rotation Z + + keys_buf += write_chunk(b"KEYS",temp_buf) + temp_buf = bytearray() + + return keys_buf + + +# ==== CONFIRM OPERATOR ==== +class B3D_Confirm_Operator(bpy.types.Operator): + bl_idname = ("screen.b3d_confirm") + bl_label = ("File Exists, Overwrite?") + + def invoke(self, context, event): + wm = context.window_manager + return wm.invoke_props_dialog(self) + + def execute(self, context): + write_b3d_file(B3D_Confirm_Operator.filepath) + return {'FINISHED'} + + +#class ObjectListItem(bpy.types.PropertyGroup): +# id = bpy.props.IntProperty(name="ID") +# +#bpy.utils.register_class(ObjectListItem) + +# ==== EXPORT OPERATOR ==== + +class B3D_Export_Operator(bpy.types.Operator): + bl_idname = ("screen.b3d_export") + bl_label = ("B3D Export") + filepath = bpy.props.StringProperty(subtype="FILE_PATH") + + selected = bpy.props.BoolProperty(name="Export Selected Only", default=False) + vnormals = bpy.props.BoolProperty(name="Export Vertex Normals", default=True) + vcolors = bpy.props.BoolProperty(name="Export Vertex Colors", default=True) + cameras = bpy.props.BoolProperty(name="Export Cameras", default=False) + lights = bpy.props.BoolProperty(name="Export Lights", default=False) + mipmap = bpy.props.BoolProperty(name="Mipmap", default=False) + localsp = bpy.props.BoolProperty(name="Use Local Space Coords", default=False) + + overwrite_without_asking = bpy.props.BoolProperty(name="Overwrite without asking", default=False) + + #skip_dialog = False + + #objects = bpy.props.CollectionProperty(type=ObjectListItem, options={'HIDDEN'}) + + def invoke(self, context, event): + blend_filepath = context.blend_data.filepath + if not blend_filepath: + blend_filepath = "Untitled.b3d" + else: + import os + blend_filepath = os.path.splitext(blend_filepath)[0] + ".b3d" + self.filepath = blend_filepath + + context.window_manager.fileselect_add(self) + return {'RUNNING_MODAL'} + + def execute(self, context): + + global b3d_parameters + b3d_parameters["export-selected"] = self.selected + b3d_parameters["vertex-normals" ] = self.vnormals + b3d_parameters["vertex-colors" ] = self.vcolors + b3d_parameters["cameras" ] = self.cameras + b3d_parameters["lights" ] = self.lights + b3d_parameters["mipmap" ] = self.mipmap + b3d_parameters["local-space" ] = self.localsp + + if self.filepath == "": + return {'FINISHED'} + + if not self.filepath.endswith(".b3d"): + self.filepath += ".b3d" + + obj_list = [] + try: + # FIXME: silly and ugly hack, the list of objects to export is passed through + # a custom scene property + obj_list = context.scene.obj_list + except: + pass + + if len(obj_list) > 0: + + #objlist = [] + #for a in self.objects: + # objlist.append(bpy.data.objects[a.id]) + # + #write_b3d_file(self.filepath, obj_list) + + ... [truncated message content] |
From: <au...@us...> - 2011-05-29 19:05:31
|
Revision: 8747 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=8747&view=rev Author: auria Date: 2011-05-29 19:05:25 +0000 (Sun, 29 May 2011) Log Message: ----------- Fixed typos in URLs Modified Paths: -------------- media/trunk/blender_25/B3DExport.py media/trunk/blender_25/stk_kart.py media/trunk/blender_25/stk_panel.py media/trunk/blender_25/stk_track.py Modified: media/trunk/blender_25/B3DExport.py =================================================================== --- media/trunk/blender_25/B3DExport.py 2011-05-29 19:02:02 UTC (rev 8746) +++ media/trunk/blender_25/B3DExport.py 2011-05-29 19:05:25 UTC (rev 8747) @@ -44,7 +44,7 @@ "location": "File > Export", "warning": '', # used for warning icon and text in addons panel "wiki_url": "http://supertuxkart.sourceforge.net/Get_involved", - "tracker_url": "https://sourceforge.net/apps/trac/supertuxkart/>", + "tracker_url": "https://sourceforge.net/apps/trac/supertuxkart/", "category": "Import-Export"} Modified: media/trunk/blender_25/stk_kart.py =================================================================== --- media/trunk/blender_25/stk_kart.py 2011-05-29 19:02:02 UTC (rev 8746) +++ media/trunk/blender_25/stk_kart.py 2011-05-29 19:05:25 UTC (rev 8747) @@ -27,7 +27,7 @@ "location": "File > Export", "warning": '', # used for warning icon and text in addons panel "wiki_url": "http://supertuxkart.sourceforge.net/Get_involved", - "tracker_url": "https://sourceforge.net/apps/trac/supertuxkart/>", + "tracker_url": "https://sourceforge.net/apps/trac/supertuxkart/", "category": "Import-Export"} #If you get an error here, it might be Modified: media/trunk/blender_25/stk_panel.py =================================================================== --- media/trunk/blender_25/stk_panel.py 2011-05-29 19:02:02 UTC (rev 8746) +++ media/trunk/blender_25/stk_panel.py 2011-05-29 19:05:25 UTC (rev 8747) @@ -9,7 +9,7 @@ "location": "Properties Panel", "warning": '', # used for warning icon and text in addons panel "wiki_url": "http://supertuxkart.sourceforge.net/Get_involved", - "tracker_url": "https://sourceforge.net/apps/trac/supertuxkart/>", + "tracker_url": "https://sourceforge.net/apps/trac/supertuxkart/", "category": "Object"} import bpy Modified: media/trunk/blender_25/stk_track.py =================================================================== --- media/trunk/blender_25/stk_track.py 2011-05-29 19:02:02 UTC (rev 8746) +++ media/trunk/blender_25/stk_track.py 2011-05-29 19:05:25 UTC (rev 8747) @@ -40,7 +40,7 @@ "location": "File > Export", "warning": '', # used for warning icon and text in addons panel "wiki_url": "http://supertuxkart.sourceforge.net/Get_involved", - "tracker_url": "https://sourceforge.net/apps/trac/supertuxkart/>", + "tracker_url": "https://sourceforge.net/apps/trac/supertuxkart/", "category": "Import-Export"} from mathutils import * This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <au...@us...> - 2011-11-29 02:49:04
|
Revision: 10274 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=10274&view=rev Author: auria Date: 2011-11-29 02:48:58 +0000 (Tue, 29 Nov 2011) Log Message: ----------- SUpport for additive lightmaps in exporter and panel Modified Paths: -------------- media/trunk/blender_25/stk_material_export.py media/trunk/blender_25/stk_panel.py Modified: media/trunk/blender_25/stk_material_export.py =================================================================== --- media/trunk/blender_25/stk_material_export.py 2011-11-29 02:48:37 UTC (rev 10273) +++ media/trunk/blender_25/stk_material_export.py 2011-11-29 02:48:58 UTC (rev 10274) @@ -81,6 +81,7 @@ lTextureDefaults = { 'light' : ("Y", None), + 'additive_lightmap' : ("N", None), 'fog' : ("Y", None), 'backface_culling' : ("Y", None), 'below_surface' : ("N", None), @@ -104,7 +105,7 @@ } lBooleanAttributes = ["clampu","clampv","light","sphere","surface","below_surface", - "falling_effect", "crash_reset", "fog", + "falling_effect", "crash_reset", "fog", "additive_lightmap", "anisotropic","backface_culling","ignore","disable_z_write","reset", "sfx_positional"] Modified: media/trunk/blender_25/stk_panel.py =================================================================== --- media/trunk/blender_25/stk_panel.py 2011-11-29 02:48:37 UTC (rev 10273) +++ media/trunk/blender_25/stk_panel.py 2011-11-29 02:48:58 UTC (rev 10274) @@ -880,6 +880,8 @@ doc="If checked, karts will have good grip on this surface and not slip, even at angles"), StkBoolProperty( id='ignore', name="Ignore (ghost material)", default="false", contextLevel=CONTEXT_MATERIAL, doc="Drive through this texture like it didn't exist (good for smoke, etc.)"), + StkBoolProperty( id='additive_lightmap',name="Lightmap is additive", default="false", contextLevel=CONTEXT_MATERIAL, + doc="Make lightmap additive (only makes sense if this material has a lightmap)"), StkProperty( id='mask', name="Mask image", default="", doc="Greyscale image containing the alpha channel (transparency) for this image"), StkProperty( id='normal_map', name="Normal Map", default="", This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <au...@us...> - 2011-12-22 00:34:13
|
Revision: 10470 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=10470&view=rev Author: auria Date: 2011-12-22 00:34:07 +0000 (Thu, 22 Dec 2011) Log Message: ----------- Update script to allow conditionally showing objects (useful for fallback when splatting is not available) Modified Paths: -------------- media/trunk/blender_25/stk_panel.py media/trunk/blender_25/stk_track.py Modified: media/trunk/blender_25/stk_panel.py =================================================================== --- media/trunk/blender_25/stk_panel.py 2011-12-21 21:43:01 UTC (rev 10469) +++ media/trunk/blender_25/stk_panel.py 2011-12-22 00:34:07 UTC (rev 10470) @@ -572,7 +572,9 @@ 'box' : StkEnumChoice("Box", []), 'sphere' : StkEnumChoice("Sphere", []), 'exact' : StkEnumChoice("Exact", []) - }, default='box', doc="Shape to use in the physics engine to represent this object") + }, default='box', doc="Shape to use in the physics engine to represent this object"), + StkProperty('if', "Visible if...", "", doc="Make this object conditionally visible"), + StkProperty('ifnot', "Visible if not...", "", doc="Make this object conditionally visible") ], doc="This object will stay in place, if the user drives on this object they will 'hit a wall'"), 'move' : StkEnumChoice("Movable by player", Modified: media/trunk/blender_25/stk_track.py =================================================================== --- media/trunk/blender_25/stk_track.py 2011-12-21 21:43:01 UTC (rev 10469) +++ media/trunk/blender_25/stk_track.py 2011-12-22 00:34:07 UTC (rev 10470) @@ -1159,6 +1159,18 @@ else: model_string = " model=\"%s\""%b3d_name + condition_if = getProperty(obj, "if", "") + if len(condition_if) > 0: + condition_if_str = " if=\"%s\""%condition_if + else: + condition_if_str = "" + + condition_ifnot = getProperty(obj, "ifnot", "") + if len(condition_ifnot) > 0: + condition_ifnot_str = " ifnot=\"%s\""%condition_ifnot + else: + condition_ifnot_str = "" + interaction = getProperty(obj, "interaction", '??') if interaction == 'reset': reset_string = " reset=\"y\"" @@ -1166,13 +1178,15 @@ reset_string = "" if lAnim: - f.write(" <static-object%s%s %s%s>\n"% \ - (lodstring, model_string, getXYZHPRString(obj), reset_string) ) + f.write(" <static-object%s%s %s%s%s%s>\n"% \ + (lodstring, model_string, getXYZHPRString(obj), reset_string, + condition_if_str, condition_ifnot_str) ) self.writeAnimatedTextures(f, lAnim) f.write(" </static-object>\n") else: - f.write(" <static-object%s%s %s%s/>\n"% \ - (lodstring, model_string, getXYZHPRString(obj), reset_string) ) + f.write(" <static-object%s%s %s%s%s%s/>\n"% \ + (lodstring, model_string, getXYZHPRString(obj), reset_string, + condition_if_str, condition_ifnot_str) ) self.writeAnimatedTextures(f, lAnimTextures) # -------------------------------------------------------------------------- This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <au...@us...> - 2012-08-05 00:22:06
|
Revision: 11462 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=11462&view=rev Author: auria Date: 2012-08-05 00:21:58 +0000 (Sun, 05 Aug 2012) Log Message: ----------- Add support to export scripts for exporting subtitles (and also normal maps with a shadow map, which I'd forgotten to commit along the C++ code) Modified Paths: -------------- media/trunk/blender_25/stk_material_export.py media/trunk/blender_25/stk_track.py media/trunk/blender_25/stkdata/stk_material_parameters.xml Modified: media/trunk/blender_25/stk_material_export.py =================================================================== --- media/trunk/blender_25/stk_material_export.py 2012-08-05 00:21:46 UTC (rev 11461) +++ media/trunk/blender_25/stk_material_export.py 2012-08-05 00:21:58 UTC (rev 11462) @@ -98,6 +98,7 @@ 'ignore' : ("N", None), 'mask' : ("", None), 'normal_map' : ("", 'use_normal_map'), + 'normal_light_map' : ("", 'use_normal_map'), 'use_normal_map' : ("N", None), 'reset' : ("N", None), 'sphere' : ("N", None), @@ -223,4 +224,4 @@ def register(): bpy.utils.register_module(__name__) - \ No newline at end of file + Modified: media/trunk/blender_25/stk_track.py =================================================================== --- media/trunk/blender_25/stk_track.py 2012-08-05 00:21:46 UTC (rev 11461) +++ media/trunk/blender_25/stk_track.py 2012-08-05 00:21:58 UTC (rev 11462) @@ -1867,6 +1867,24 @@ for obj in lBillboards: self.writeBillboard(f, obj) + # Subtitles + subtitles = [] + end_time = bpy.data.scenes[0].frame_end + for marker in reversed(bpy.data.scenes[0].timeline_markers): + if marker.name.startswith("subtitle"): + subtitle_text = bpy.data.scenes[0][marker.name] + subtitles.insert(0, [marker.frame, end_time - 1, subtitle_text]) + end_time = marker.frame + + if len(subtitles) > 0: + f.write(" <subtitles>\n") + + for subtitle in subtitles: + f.write(" <subtitle from=\"%i\" to=\"%i\" text=\"%s\"/>\n" % (subtitle[0], subtitle[1], subtitle[2])) + + f.write(" </subtitles>\n") + + # Assemble all sky/fog related parameters # --------------------------------------- if len(lSun) > 1: Modified: media/trunk/blender_25/stkdata/stk_material_parameters.xml =================================================================== --- media/trunk/blender_25/stkdata/stk_material_parameters.xml 2012-08-05 00:21:46 UTC (rev 11461) +++ media/trunk/blender_25/stkdata/stk_material_parameters.xml 2012-08-05 00:21:58 UTC (rev 11462) @@ -84,7 +84,8 @@ <!-- Normal map --> <BoolProp id="use_normal_map" name="Normal Map" default="false" doc="Use normal maps for this material (the model must be exported as tangent for this to work)"> - <StringProp id="normal_map" name="Normal Map Image" default="" doc="Image containing the normal map for this texture (optional)"/> + <StringProp id="normal_map" name="Normal Map Image" default="" doc="Image containing the normal map for this texture"/> + <StringProp id="normal_light_map" name="Light Map Image" default="" doc="Image containing the lightmap for this texture (optional)"/> </BoolProp> <!-- Particles --> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <au...@us...> - 2013-09-21 00:56:20
|
Revision: 14120 http://sourceforge.net/p/supertuxkart/code/14120 Author: auria Date: 2013-09-21 00:56:18 +0000 (Sat, 21 Sep 2013) Log Message: ----------- Add hat_offset property to exporter, which is used for christmas hat but also soccer mode and has been missing from the exporter for quite some time Modified Paths: -------------- media/trunk/blender_25/stk_kart.py media/trunk/blender_25/stkdata/stk_panel_parameters.xml Modified: media/trunk/blender_25/stk_kart.py =================================================================== --- media/trunk/blender_25/stk_kart.py 2013-09-21 00:42:01 UTC (rev 14119) +++ media/trunk/blender_25/stk_kart.py 2013-09-21 00:56:18 UTC (rev 14120) @@ -318,6 +318,13 @@ saveAnimations(f) saveWheels(f, lWheels, path) saveNitroEmitter(f, lNitroEmitter, path) + + hat_offset = "0.0 1.0 0.0" + if 'hat_offset' in the_scene and len(the_scene['hat_offset']) > 0: + hat_offset = the_scene['hat_offset'] + + f.write(' <hat offset="' + hat_offset + '"/>\n') + f.write('</kart>\n') f.close() Modified: media/trunk/blender_25/stkdata/stk_panel_parameters.xml =================================================================== --- media/trunk/blender_25/stkdata/stk_panel_parameters.xml 2013-09-21 00:42:01 UTC (rev 14119) +++ media/trunk/blender_25/stkdata/stk_panel_parameters.xml 2013-09-21 00:56:18 UTC (rev 14120) @@ -81,7 +81,7 @@ <EnumChoice id="small" label="Small"/> </EnumProp> - + <StringProp id="hat_offset" name="Hat offset" default="0.0 1.0 0.0" doc="Where to place hat relative to bone named Head"/> <BoolProp id="random_wheel_rot" name="Randomize wheel rotation" default="true" doc="Randomize the initial rotation of wheels to reduce the feeling that all wheels are identical"/> </BoolProp> </Properties> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <au...@us...> - 2013-10-29 00:40:49
|
Revision: 14336 http://sourceforge.net/p/supertuxkart/code/14336 Author: auria Date: 2013-10-29 00:40:45 +0000 (Tue, 29 Oct 2013) Log Message: ----------- Blender : improve kart color validation to accurately report errors instead of crashing; fix color picker Modified Paths: -------------- media/trunk/blender_25/stk_kart.py media/trunk/blender_25/stk_panel.py Modified: media/trunk/blender_25/stk_kart.py =================================================================== --- media/trunk/blender_25/stk_kart.py 2013-10-28 23:52:49 UTC (rev 14335) +++ media/trunk/blender_25/stk_kart.py 2013-10-29 00:40:45 UTC (rev 14336) @@ -265,9 +265,13 @@ log_error("Incorrect kart color") return - split_color[0] = "%.2f" % (int(split_color[0]) / 255.0) - split_color[1] = "%.2f" % (int(split_color[1]) / 255.0) - split_color[2] = "%.2f" % (int(split_color[2]) / 255.0) + try: + split_color[0] = "%.2f" % (int(split_color[0]) / 255.0) + split_color[1] = "%.2f" % (int(split_color[1]) / 255.0) + split_color[2] = "%.2f" % (int(split_color[2]) / 255.0) + except: + log_error("Incorrect kart color") + return #b3d_export.b3d_parameters["vertex-normals" ] = 1 # Vertex normals. #b3d_export.b3d_parameters["vertex-colors" ] = 1 # Vertex colors Modified: media/trunk/blender_25/stk_panel.py =================================================================== --- media/trunk/blender_25/stk_panel.py 2013-10-28 23:52:49 UTC (rev 14335) +++ media/trunk/blender_25/stk_panel.py 2013-10-29 00:40:45 UTC (rev 14336) @@ -560,7 +560,7 @@ box = layout.box() row = box.row() try: - row.template_color_wheel(self, "temp_color", value_slider=True, cubic=False) + row.template_color_picker(self, "temp_color", value_slider=True, cubic=False) except Exception as ex: import sys print("Except :(", type(ex), ex, "{",ex.args,"}") This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <de...@us...> - 2014-09-02 17:10:37
|
Revision: 15545 http://sourceforge.net/p/supertuxkart/code/15545 Author: deveee Date: 2014-09-02 17:10:34 +0000 (Tue, 02 Sep 2014) Log Message: ----------- Add weather properties to the exporter Modified Paths: -------------- media/trunk/blender_25/stk_track.py media/trunk/blender_25/stkdata/stk_panel_parameters.xml Modified: media/trunk/blender_25/stk_track.py =================================================================== --- media/trunk/blender_25/stk_track.py 2014-09-01 18:20:12 UTC (rev 15544) +++ media/trunk/blender_25/stk_track.py 2014-09-02 17:10:34 UTC (rev 15545) @@ -2602,12 +2602,24 @@ if sky_color: f.write(" <sky-color rgb=\"%s\"/>\n"%sky_color) - weather = getSceneProperty(scene, "weather", None) - if weather and weather != "none": - if weather[:4]!=".xml": - weather=weather+".xml" - f.write(" <weather particles=\"%s\" />\n"%weather) + weather = "" + weather_type = getSceneProperty(scene, "weather_type", "none") + if weather_type != "none": + if weather_type[:4] != ".xml": + weather_type = weather_type + ".xml" + weather = " particles=" + weather_type + + lightning = getSceneProperty(scene, "weather_lightning", "false") + if lightning == "true": + weather = weather + " lightning=\"true\"" + weather_sound = getSceneProperty(scene, "weather_sound", "") + if weather_sound != "": + weather = weather + " sound=\"" + weather_sound + "\"" + + if weather != "": + f.write(" <weather%s/>\n"%weather) + rad2deg = 180.0/3.1415926 Modified: media/trunk/blender_25/stkdata/stk_panel_parameters.xml =================================================================== --- media/trunk/blender_25/stkdata/stk_panel_parameters.xml 2014-09-01 18:20:12 UTC (rev 15544) +++ media/trunk/blender_25/stkdata/stk_panel_parameters.xml 2014-09-02 17:10:34 UTC (rev 15545) @@ -69,16 +69,20 @@ <FloatProp id="start_sidewards_distance" name="Start Sidewards Distance" default="1.1"/> <FloatProp id="start_upwards_distance" name="Start upwards distance" default="1.1"/> <BoolProp id="smooth_normals" name="Smooth Normals" default="false" doc="Whether to interpolate the normals (gives smoother driving but requires that floors and walls be split)"/> - <EnumProp id="weather" name="Weather" default="none" doc="The weather effect to use in this track"> - <EnumChoice id="none" label="None" doc="The weather effect to use in this track"/> - <EnumChoice id="rain" label="Rain" doc="The weather effect to use in this track"/> - <EnumChoice id="snow" label="Snow" doc="The weather effect to use in this track"/> - </EnumProp> + <BoolProp id="shadows" name="Dynamic shadows (STK 0.8.2)" default="true" doc="Whether to enable dynamic shadows"/> + <PropGroup id="weather" name="Weather"> + <EnumProp id="weather_type" name="Weather type" default="none" doc="The weather effect to use in this track"> + <EnumChoice id="none" label="None" doc="The weather effect to use in this track"/> + <EnumChoice id="rain" label="Rain" doc="The weather effect to use in this track"/> + <EnumChoice id="snow" label="Snow" doc="The weather effect to use in this track"/> + </EnumProp> + <BoolProp id="weather_lightning" name="Lightning" default="false" doc="The weather effect to use in this track"/> + <StringProp id="weather_sound" name="Weather sound" default=""/> + </PropGroup> <!-- <BoolProp id="clouds" name="Cloud shadows (STK 0.8.2)" default="false" doc="Whether to add simulated cloud shadows on the ground"> </BoolProp> --> - <BoolProp id="shadows" name="Dynamic shadows (STK 0.8.2)" default="true" doc="Whether to enable dynamic shadows"/> <PropGroup id="propgroup_postpro" name="Post processing (advanced)"> <BoolProp id="bloom" name="Bloom (STK 0.8.2)" default="true" doc="Whether this track uses bloom"> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <au...@us...> - 2015-08-21 23:44:43
|
Revision: 16387 http://sourceforge.net/p/supertuxkart/code/16387 Author: auria Date: 2015-08-21 23:44:40 +0000 (Fri, 21 Aug 2015) Log Message: ----------- Remove bloom option from exporter, does not work Modified Paths: -------------- media/trunk/blender_25/stk_track.py media/trunk/blender_25/stkdata/stk_panel_parameters.xml Modified: media/trunk/blender_25/stk_track.py =================================================================== --- media/trunk/blender_25/stk_track.py 2015-08-20 00:14:37 UTC (rev 16386) +++ media/trunk/blender_25/stk_track.py 2015-08-21 23:44:40 UTC (rev 16387) @@ -1971,7 +1971,7 @@ music = getSceneProperty(scene, "music", "") screenshot = getSceneProperty(scene, "screenshot", "") smooth_normals = getSceneProperty(scene, "smooth_normals", "false") - has_bloom = (getSceneProperty(scene, "bloom", "false") == "true") + #has_bloom = (getSceneProperty(scene, "bloom", "false") == "true") bloom_threshold = getSceneProperty(scene, "bloom_threshold", "0.75") has_cloud_shadows = (getSceneProperty(scene, "clouds", "false") == "true") #has_lens_flare = (getSceneProperty(scene, "sunlensflare", "false") == "true") @@ -2044,11 +2044,11 @@ else: f.write(" reverse = \"N\"\n") - if has_bloom: - f.write(" bloom = \"Y\"\n") - f.write(" bloom-threshold = \"%s\"\n" % bloom_threshold) - else: - f.write(" bloom = \"N\"\n") + #if has_bloom: + # f.write(" bloom = \"Y\"\n") + # f.write(" bloom-threshold = \"%s\"\n" % bloom_threshold) + #else: + # f.write(" bloom = \"N\"\n") #if has_colorlevel: # f.write(" color-level-in = \"" + str(colorlevel_inblack) + " " + str(colorlevel_ingamma) + " " + str(colorlevel_inwhite) + "\"\n") Modified: media/trunk/blender_25/stkdata/stk_panel_parameters.xml =================================================================== --- media/trunk/blender_25/stkdata/stk_panel_parameters.xml 2015-08-20 00:14:37 UTC (rev 16386) +++ media/trunk/blender_25/stkdata/stk_panel_parameters.xml 2015-08-21 23:44:40 UTC (rev 16387) @@ -86,11 +86,11 @@ <StringProp id="ambientmap_texture1" name="Ambient map, North" default=""/> <StringProp id="ambientmap_texture6" name="Ambient map, South" default=""/> </BoolProp> + <!-- <BoolProp id="bloom" name="Bloom (STK 0.8.2)" default="true" doc="Whether this track uses bloom"> - <!-- <FloatProp id="bloom_threshold" name="Bloom threshold" doc="Brightness at which bloom starts being applied" default="0.75" min="0.0" max="1.0"/> - --> </BoolProp> + --> <!-- <BoolProp id="sunlensflare" name="Sun lens flare (STK 0.8.2)" default="false" doc="Show lens flare when looking at the sun. Lens flare underscore and maximise the emotional and psychological impact of a scene"/> --> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <au...@us...> - 2016-07-01 23:20:30
|
Revision: 16678 http://sourceforge.net/p/supertuxkart/code/16678 Author: auria Date: 2016-07-01 23:20:27 +0000 (Fri, 01 Jul 2016) Log Message: ----------- Support colorizing kart parts, for Benau's branch Modified Paths: -------------- media/trunk/blender_25/stk_material_export.py media/trunk/blender_25/stkdata/stk_material_parameters.xml Modified: media/trunk/blender_25/stk_material_export.py =================================================================== --- media/trunk/blender_25/stk_material_export.py 2016-07-01 01:54:01 UTC (rev 16677) +++ media/trunk/blender_25/stk_material_export.py 2016-07-01 23:20:27 UTC (rev 16678) @@ -115,7 +115,9 @@ 'splatting_lightmap' : {'default': "", 'parent': ('shader','splatting'), 'type': 'string'}, #'water_shader_speed_1' : {'default': 6.6667, 'parent': ('graphical_effect','water_shader'), 'type': 'number'}, #'water_shader_speed_2' : {'default': 4.0, 'parent': ('graphical_effect','water_shader'), 'type': 'number'}, - 'water_splash' : {'default': "N", 'parent': None, 'type': 'bool'} + 'water_splash' : {'default': "N", 'parent': None, 'type': 'bool'}, + 'colorizable' : {'default': "N", 'parent': ('shader','solid'), 'type': 'bool'}, + 'colorization_factor' : {'default': "", 'parent': 'colorizable', 'type': 'number'} } #start_time = bsys.time() Modified: media/trunk/blender_25/stkdata/stk_material_parameters.xml =================================================================== --- media/trunk/blender_25/stkdata/stk_material_parameters.xml 2016-07-01 01:54:01 UTC (rev 16677) +++ media/trunk/blender_25/stkdata/stk_material_parameters.xml 2016-07-01 23:20:27 UTC (rev 16678) @@ -11,6 +11,13 @@ <StringProp id="normal_map" name="Normal map" default="" doc="Use normal maps for this material (the model must be exported as tangent for this to work)"/> <StringProp id="mask" name="Mask image (optional)" default="" doc="Greyscale image containing the alpha channel (transparency) for this image"/> <!--<StringProp id="light_map" name="Light map" default=""/>--> + + <!-- Slowdown --> + <BoolProp id="colorizable" name="Colorizable (for karts)" default="false" + doc="Used on karts in soccer mode to give a kart the team's colors"> + <FloatProp id="colorization_factor" name="Colorization factor" default="1.0" min="0.0" max="1.0" + doc="How much to change color"/> + </BoolProp> </EnumChoice> <!-- Alpha testing --> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <au...@us...> - 2016-07-27 22:45:28
|
Revision: 16729 http://sourceforge.net/p/supertuxkart/code/16729 Author: auria Date: 2016-07-27 22:45:26 +0000 (Wed, 27 Jul 2016) Log Message: ----------- Exporter : support for lean option Modified Paths: -------------- media/trunk/blender_25/stk_kart.py media/trunk/blender_25/stkdata/stk_panel_parameters.xml Modified: media/trunk/blender_25/stk_kart.py =================================================================== --- media/trunk/blender_25/stk_kart.py 2016-07-27 04:07:41 UTC (rev 16728) +++ media/trunk/blender_25/stk_kart.py 2016-07-27 22:45:26 UTC (rev 16729) @@ -382,6 +382,9 @@ f.write(' <hat offset="' + hat_offset + '"/>\n') + if 'kartLean' in the_scene and len(the_scene['kartLean']) > 0: + f.write(' <lean max="' + the_scene['kartLean'] + '"/>\n') + f.write('</kart>\n') f.close() Modified: media/trunk/blender_25/stkdata/stk_panel_parameters.xml =================================================================== --- media/trunk/blender_25/stkdata/stk_panel_parameters.xml 2016-07-27 04:07:41 UTC (rev 16728) +++ media/trunk/blender_25/stkdata/stk_panel_parameters.xml 2016-07-27 22:45:26 UTC (rev 16729) @@ -141,6 +141,9 @@ <EnumChoice id="medium" label="Medium" /> <EnumChoice id="heavy" label="Heavy" /> </EnumProp> + + <StringProp id="kartLean" name="Lean max (advanced)" default="" doc="Customize lean, for instance *0-10"/> + </BoolProp> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <au...@us...> - 2011-06-10 01:10:38
|
Revision: 8870 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=8870&view=rev Author: auria Date: 2011-06-10 01:10:32 +0000 (Fri, 10 Jun 2011) Log Message: ----------- misc improvements to the python scripts Modified Paths: -------------- media/trunk/blender_25/stk_kart.py media/trunk/blender_25/stk_panel.py media/trunk/blender_25/stk_track.py Modified: media/trunk/blender_25/stk_kart.py =================================================================== --- media/trunk/blender_25/stk_kart.py 2011-06-10 00:54:18 UTC (rev 8869) +++ media/trunk/blender_25/stk_kart.py 2011-06-10 01:10:32 UTC (rev 8870) @@ -337,6 +337,11 @@ filepath = bpy.props.StringProperty(subtype="FILE_PATH") def invoke(self, context, event): + + if 'is_stk_kart' not in context.scene or context.scene['is_stk_kart'] != 'true': + log_error("Not a STK kart!") + return {'FINISHED'} + blend_filepath = context.blend_data.filepath if not blend_filepath: blend_filepath = "Untitled" @@ -349,9 +354,9 @@ return {'RUNNING_MODAL'} def execute(self, context): - if self.filepath == "": + if self.filepath == "" or 'is_stk_kart' not in context.scene or context.scene['is_stk_kart'] != 'true': return {'FINISHED'} - + global operator operator = self Modified: media/trunk/blender_25/stk_panel.py =================================================================== --- media/trunk/blender_25/stk_panel.py 2011-06-10 00:54:18 UTC (rev 8869) +++ media/trunk/blender_25/stk_panel.py 2011-06-10 01:10:32 UTC (rev 8870) @@ -702,6 +702,15 @@ the_list.append( (curr.name, filename, filename) ) print("Refreshed list :",the_list) + global selected_image + global preview_texture + if 'selected_image' not in context.scene['selected_image'] and len(bpy.data.images) > 0: + preview_texture.image = bpy.data.images[0] + context.scene['selected_image'] = preview_texture.image.name + createProperties(preview_texture.image, STK_MATERIAL_PROPERTIES) + + context.region.tag_redraw() + class STK_SelectImage(bpy.types.Operator): bl_idname = ("screen.stk_select_image") bl_label = ("STK Object :: select image") @@ -726,6 +735,8 @@ if self.value in bpy.data.images: createProperties(bpy.data.images[self.value], STK_MATERIAL_PROPERTIES) + context.region.tag_redraw() + return {'FINISHED'} bpy.utils.register_class(STK_SelectImage) Modified: media/trunk/blender_25/stk_track.py =================================================================== --- media/trunk/blender_25/stk_track.py 2011-06-10 00:54:18 UTC (rev 8869) +++ media/trunk/blender_25/stk_track.py 2011-06-10 01:10:32 UTC (rev 8870) @@ -1958,6 +1958,11 @@ filepath = bpy.props.StringProperty(subtype="FILE_PATH") def invoke(self, context, event): + + if 'is_stk_track' not in context.scene or context.scene['is_stk_track'] != 'true': + log_error("Not a STK track!") + return {'FINISHED'} + blend_filepath = context.blend_data.filepath if not blend_filepath: blend_filepath = "Untitled" @@ -1970,7 +1975,7 @@ return {'RUNNING_MODAL'} def execute(self, context): - if self.filepath == "": + if self.filepath == "" or 'is_stk_track' not in context.scene or context.scene['is_stk_track'] != 'true': return {'FINISHED'} global operator This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <au...@us...> - 2011-06-19 21:07:40
|
Revision: 8978 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=8978&view=rev Author: auria Date: 2011-06-19 21:07:34 +0000 (Sun, 19 Jun 2011) Log Message: ----------- Added support for mask material proeprty Modified Paths: -------------- media/trunk/blender_25/stk_panel.py media/trunk/blender_25/stk_track.py Modified: media/trunk/blender_25/stk_panel.py =================================================================== --- media/trunk/blender_25/stk_panel.py 2011-06-19 20:55:55 UTC (rev 8977) +++ media/trunk/blender_25/stk_panel.py 2011-06-19 21:07:34 UTC (rev 8978) @@ -587,6 +587,7 @@ ('falling_effect', StkBoolProperty( id='falling_effect', name="Falling Effect", default="false", contextLevel=CONTEXT_MATERIAL)), ('graphical_effect', StkEnumProperty( id='graphical_effect', name="Graphical Effect", default='none', contextLevel=CONTEXT_MATERIAL, values=GFX_VALUES)), ('ignore', StkBoolProperty( id='ignore', name="Ignore (ghost material)", default="false", contextLevel=CONTEXT_MATERIAL)), + ('mask', StkProperty( id='mask', name="Mask image", default="")), ('particle', StkBoolProperty( id='particle', name="Particle effect", default="false", contextLevel=CONTEXT_MATERIAL, subproperties=PARTICLE_PROPERTIES)), ('use_sfx', StkBoolProperty( id='use_sfx', name="Play sound effect", default="false", contextLevel=CONTEXT_MATERIAL, subproperties=SFX_PROPERTIES)), ('reset', StkBoolProperty( id='reset', name="Reset kart", default="false", contextLevel=CONTEXT_MATERIAL)), Modified: media/trunk/blender_25/stk_track.py =================================================================== --- media/trunk/blender_25/stk_track.py 2011-06-19 20:55:55 UTC (rev 8977) +++ media/trunk/blender_25/stk_track.py 2011-06-19 21:07:34 UTC (rev 8978) @@ -1683,6 +1683,7 @@ 'falling_effect' : ("N", None), 'graphical_effect' : ('none', None), 'ignore' : ("N", None), + 'mask' : ("", None), 'reset' : ("N", None), 'sphere' : ("N", None), 'surface' : ("N", None), This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <au...@us...> - 2011-06-19 22:29:35
|
Revision: 8985 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=8985&view=rev Author: auria Date: 2011-06-19 22:29:29 +0000 (Sun, 19 Jun 2011) Log Message: ----------- Rename conversion script Added Paths: ----------- media/trunk/blender_25/convert_24_to_25.py Removed Paths: ------------- media/trunk/blender_25/convert_from_game_logic.py Copied: media/trunk/blender_25/convert_24_to_25.py (from rev 8942, media/trunk/blender_25/convert_from_game_logic.py) =================================================================== --- media/trunk/blender_25/convert_24_to_25.py (rev 0) +++ media/trunk/blender_25/convert_24_to_25.py 2011-06-19 22:29:29 UTC (rev 8985) @@ -0,0 +1,57 @@ +import bpy + +for obj in bpy.data.objects: + print("Processing", obj.name) + if obj.game and obj.game.properties: + for k in obj.game.properties.keys(): + # TODO: remove old values? + val = obj.game.properties[k].value + + if val == "nitro-small": val = "nitro_small" + elif val == "nitro-big" : val = "nitro_big" + elif val == "yes" : val = "true" + elif val == "no" : val = "false" + elif val == "particle-emitter" : val = "particle_emitter" + elif val == "main-driveline" : val = "maindriveline" + + obj[k.replace("-","_").lower()] = val + + if 'anim_texture' in obj and len(obj['anim_texture']) > 0: + obj['enable_anim_texture'] = 'true' + else: + obj['enable_anim_texture'] = 'false' + +s = bpy.data.scenes[0] +for prop in s.keys(): + # TODO: remove old values? + val = s[prop] + if val == "yes" : val = "true" + s[prop.replace("-","_").lower()] = val + +for m in bpy.data.images: + for prop in m.keys(): + # TODO: remove old values? + val = m[prop] + if val == "yes" : val = "true" + m[prop.replace("-","_").replace(":","_").lower()] = val + + if 'max_speed' in m and m['max_speed'] < 1.0: + m['use_slowdown'] = 'true' + else: + m['use_slowdown'] = 'false' + + if 'sfx_filename' in m and len(m['sfx_filename']) > 0: + m['use_sfx'] = 'true' + else: + m['use_sfx'] = 'false' + + if 'particle_base' in m and len(m['particle_base']) > 0: + m['particle'] = 'true' + else: + m['particle'] = 'false' + + +# TODO: while we're at it, convert all old transparency/alpha properties over to the new compositing one? +# TODO: Convert kart color from floating point format to integer format + +bpy.data.scenes[0]['is_stk_track'] = 'true' \ No newline at end of file Deleted: media/trunk/blender_25/convert_from_game_logic.py =================================================================== --- media/trunk/blender_25/convert_from_game_logic.py 2011-06-19 22:24:33 UTC (rev 8984) +++ media/trunk/blender_25/convert_from_game_logic.py 2011-06-19 22:29:29 UTC (rev 8985) @@ -1,56 +0,0 @@ -import bpy - -for obj in bpy.data.objects: - print("Processing", obj.name) - if obj.game and obj.game.properties: - for k in obj.game.properties.keys(): - # TODO: remove old values? - val = obj.game.properties[k].value - - if val == "nitro-small": val = "nitro_small" - elif val == "nitro-big" : val = "nitro_big" - elif val == "yes" : val = "true" - elif val == "no" : val = "false" - elif val == "particle-emitter" : val = "particle_emitter" - - obj[k.replace("-","_").lower()] = val - - if 'anim_texture' in obj and len(obj['anim_texture']) > 0: - obj['enable_anim_texture'] = 'true' - else: - obj['enable_anim_texture'] = 'false' - -s = bpy.data.scenes[0] -for prop in s.keys(): - # TODO: remove old values? - val = s[prop] - if val == "yes" : val = "true" - s[prop.replace("-","_").lower()] = val - -for m in bpy.data.images: - for prop in m.keys(): - # TODO: remove old values? - val = m[prop] - if val == "yes" : val = "true" - m[prop.replace("-","_").replace(":","_").lower()] = val - - if 'max_speed' in m and m['max_speed'] < 1.0: - m['use_slowdown'] = 'true' - else: - m['use_slowdown'] = 'false' - - if 'sfx_filename' in m and len(m['sfx_filename']) > 0: - m['use_sfx'] = 'true' - else: - m['use_sfx'] = 'false' - - if 'particle_base' in m and len(m['particle_base']) > 0: - m['particle'] = 'true' - else: - m['particle'] = 'false' - - -# TODO: while we're at it, convert all old transparency/alpha properties over to the new compositing one? -# TODO: Convert kart color from floating point format to integer format - -bpy.data.scenes[0]['is_stk_track'] = 'true' \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <au...@us...> - 2011-06-27 00:00:31
|
Revision: 9101 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=9101&view=rev Author: auria Date: 2011-06-27 00:00:24 +0000 (Mon, 27 Jun 2011) Log Message: ----------- Added battl mode starts position support to STK panel Modified Paths: -------------- media/trunk/blender_25/stk_panel.py media/trunk/blender_25/stk_track.py Modified: media/trunk/blender_25/stk_panel.py =================================================================== --- media/trunk/blender_25/stk_panel.py 2011-06-26 23:24:18 UTC (rev 9100) +++ media/trunk/blender_25/stk_panel.py 2011-06-27 00:00:24 UTC (rev 9101) @@ -460,6 +460,7 @@ 'particle_emitter' : StkEnumChoice('Particle Emitter', {'kind' : StkProperty(id='kind', name="Particle File", default="smoke.xml") }), + 'start' : StkEnumChoice('Start position', {'start_index' : StkIntProperty('start_index', "Start Index", 1)}), 'sun' : StkEnumChoice('Sun', {'ambient' : StkColorProperty('ambient', "Ambient Color", contextLevel=CONTEXT_OBJECT), 'diffuse' : StkColorProperty('diffuse', "Diffuse Color", contextLevel=CONTEXT_OBJECT), Modified: media/trunk/blender_25/stk_track.py =================================================================== --- media/trunk/blender_25/stk_track.py 2011-06-26 23:24:18 UTC (rev 9100) +++ media/trunk/blender_25/stk_track.py 2011-06-27 00:00:24 UTC (rev 9101) @@ -1400,17 +1400,10 @@ count = 1 for obj in lStart: stktype = getProperty(obj, "type", obj.name).upper() - try: - id = int(getProperty(obj, "position", "")) - except: - id=None - if not id: - try: - id = int(stktype[5:]) - except ValueError: - log_warning ("No valid id in '%s' - using %d\n"%(stktype, count)) - id = count - count = count + 1 + id = int(getProperty(obj, "start_index", "-1")) + if id == "-1": + log_warning("Invalid start position " + id) + dId2Obj[id] = obj l = dId2Obj.keys() #l.sort() # sorting not needed AFAICT, the dictionary keeps the keys sorted @@ -1843,6 +1836,7 @@ elif stktype[:5]=="START": # Start empties are called start1, start2, ... lStart.append(obj) + continue elif stktype=="PARTICLE_EMITTER": lParticleEmitters.append(obj) continue This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <au...@us...> - 2011-07-01 00:43:25
|
Revision: 9117 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=9117&view=rev Author: auria Date: 2011-07-01 00:43:18 +0000 (Fri, 01 Jul 2011) Log Message: ----------- Add new high-adhesion in STK panel and exporter, + another minor fix Modified Paths: -------------- media/trunk/blender_25/stk_panel.py media/trunk/blender_25/stk_track.py Modified: media/trunk/blender_25/stk_panel.py =================================================================== --- media/trunk/blender_25/stk_panel.py 2011-07-01 00:23:57 UTC (rev 9116) +++ media/trunk/blender_25/stk_panel.py 2011-07-01 00:43:18 UTC (rev 9117) @@ -449,7 +449,7 @@ 'ignore' : StkEnumChoice('Ignore', {}), 'item' : StkEnumChoice('Item (Gift Box)', {}), 'lap' : StkEnumChoice('Lap line', - {'activate' : StkProperty(id='activate', name="Activate", default="") + {'activate' : StkObjectReferenceProperty(id='activate', name="Activate", default="", contextLevel=CONTEXT_OBJECT, filter=lambda self, o : 'type' in o and o['type'] == 'check') #'toggle' : Stkproperty("Toggle"), #'inner_radius' : StkFloatProperty("Color radius"), #'color' : @@ -599,6 +599,7 @@ ('use_slowdown', StkBoolProperty( id='use_slowdown', name="Enable Slowdown", default="false", contextLevel=CONTEXT_MATERIAL, subproperties=SLOWDOWN_PROPERTIES)), ('falling_effect', StkBoolProperty( id='falling_effect', name="Falling Effect", default="false", contextLevel=CONTEXT_MATERIAL)), ('graphical_effect', StkEnumProperty( id='graphical_effect', name="Graphical Effect", default='none', contextLevel=CONTEXT_MATERIAL, values=GFX_VALUES)), + ('high_adhesion', StkBoolProperty( id='high_adhesion', name="High tires adhesion", default="false", contextLevel=CONTEXT_MATERIAL)), ('ignore', StkBoolProperty( id='ignore', name="Ignore (ghost material)", default="false", contextLevel=CONTEXT_MATERIAL)), ('mask', StkProperty( id='mask', name="Mask image", default="")), ('particle', StkBoolProperty( id='particle', name="Particle effect", default="false", contextLevel=CONTEXT_MATERIAL, subproperties=PARTICLE_PROPERTIES)), @@ -606,7 +607,6 @@ ('reset', StkBoolProperty( id='reset', name="Reset kart", default="false", contextLevel=CONTEXT_MATERIAL)), ('sphere', StkBoolProperty( id='sphere', name="Sphere mapping", default="false", contextLevel=CONTEXT_MATERIAL)), ('surface', StkBoolProperty( id='surface', name="Surface", default="false", contextLevel=CONTEXT_MATERIAL)), - ('friction', StkFloatProperty( id='friction', name="Tires adhesion", default=50000.0)), ('zipper', StkBoolProperty( id='zipper', name="Zipper (speed boost)", default="false", contextLevel=CONTEXT_MATERIAL, subproperties=ZIPPER_PROPERTIES)) ]) Modified: media/trunk/blender_25/stk_track.py =================================================================== --- media/trunk/blender_25/stk_track.py 2011-07-01 00:23:57 UTC (rev 9116) +++ media/trunk/blender_25/stk_track.py 2011-07-01 00:43:18 UTC (rev 9117) @@ -1690,7 +1690,7 @@ 'reset' : ("N", None), 'sphere' : ("N", None), 'surface' : ("N", None), - 'friction' : (50000.0, None), + 'high_adhesion' : ('false', None), 'slowdown_time' : (1.0, 'use_slowdown'), 'max_speed' : (1.0, 'use_slowdown') } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <au...@us...> - 2011-08-06 20:59:58
|
Revision: 9432 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=9432&view=rev Author: auria Date: 2011-08-06 20:59:52 +0000 (Sat, 06 Aug 2011) Log Message: ----------- Add sound emitter support to the scripts Modified Paths: -------------- media/trunk/blender_25/stk_panel.py media/trunk/blender_25/stk_track.py Modified: media/trunk/blender_25/stk_panel.py =================================================================== --- media/trunk/blender_25/stk_panel.py 2011-08-06 20:37:54 UTC (rev 9431) +++ media/trunk/blender_25/stk_panel.py 2011-08-06 20:59:52 UTC (rev 9432) @@ -470,6 +470,11 @@ {'kind' : StkProperty(id='kind', name="Particle File", default="smoke.xml") }, docs="To be applied to an empty; particles will be emitted from this point"), 'start' : StkEnumChoice('Start position', {'start_index' : StkIntProperty('start_index', "Start Index", 1)}, docs="A start position for karts in battle mode (only useful if this track is an arena)"), + 'sfx_emitter' : StkEnumChoice('Sound Emitter', OrderedDict([ + ('sfx_filename' , StkProperty( id='sfx_filename', name="Sound File", default="some_file.ogg")), + ('sfx_volume' , StkFloatProperty( id='sfx_volume', name="Sound volume", default=1.0)), + ('sfx_rolloff' , StkFloatProperty( id='sfx_rolloff', name="Rolloff rate", default=0.1))]), + docs="A sound will be heard when close to this point"), 'sun' : StkEnumChoice('Sun', {'ambient' : StkColorProperty('ambient', "Ambient Color", contextLevel=CONTEXT_OBJECT, docs="Click here to pick an ambient color"), 'diffuse' : StkColorProperty('diffuse', "Diffuse Color", contextLevel=CONTEXT_OBJECT, docs="Click here to pick a diffuse color"), Modified: media/trunk/blender_25/stk_track.py =================================================================== --- media/trunk/blender_25/stk_track.py 2011-08-06 20:37:54 UTC (rev 9431) +++ media/trunk/blender_25/stk_track.py 2011-08-06 20:59:52 UTC (rev 9432) @@ -1146,8 +1146,23 @@ except: log_error("Invalid particle emitter <" + getProperty(obj, "name", obj.name) + "> ", sys.exc_info()[0]) - + # -------------------------------------------------------------------------- + # Sound emitter + def writeSoundEmitters(self,f, lSoundEmitters): + for obj in lSoundEmitters: + try: + # origin + originXYZ = getXYZHPRString(obj) + f.write(' <object type="sfx-emitter" sound="%s" rolloff="%s" volume="%s" %s/>\n' %\ + (getProperty(obj, "sfx_filename", "some_sound.ogg"), + getProperty(obj, "sfx_rolloff", 0.05), + getProperty(obj, "sfx_volume", 0), originXYZ)) + except: + log_error("Invalid particle emitter <" + getProperty(obj, "name", obj.name) + "> ", + sys.exc_info()[0]) + + # -------------------------------------------------------------------------- # Writes out all checklines. # \param lChecks All check meshes # \param mainDriveline The main driveline, from which the lap @@ -1450,8 +1465,8 @@ # -------------------------------------------------------------------------- # Writes the scene files, which includes all models, animations, and items - def writeSceneFile(self, sPath, sTrackName, lWater, lTrack, lItems, - lObjects, lBillboards, lParticleEmitters, lChecks, lSun, mainDriveline, lStart, + def writeSceneFile(self, sPath, sTrackName, lWater, lTrack, lItems, lObjects, lBillboards, + lParticleEmitters, lSoundEmitters, lChecks, lSun, mainDriveline, lStart, lEndCameras, lCameraCurves): #start_time = bsys.time() @@ -1492,6 +1507,9 @@ if lParticleEmitters: self.writeParticleEmitters(f, lParticleEmitters) + if lSoundEmitters: + self.writeSoundEmitters(f, lSoundEmitters) + for obj in lOtherObjects: self.writeObject(f, sPath, obj) for obj in lBillboards: @@ -1813,6 +1831,7 @@ lObjects = [] # All special objects lBillboards = [] # All billboards lParticleEmitters = [] # All particle emitters + lSoundEmitters = [] lChecks = [] # All check structures lSun = [] lStart = [] # All start positions @@ -1850,6 +1869,9 @@ elif stktype=="PARTICLE_EMITTER": lParticleEmitters.append(obj) continue + elif stktype=="SFX_EMITTER": + lSoundEmitters.append(obj) + continue else: print("Empty '%s' has type '%s' which is not valid - ignored."%\ (obj.name, stktype)) @@ -1937,8 +1959,8 @@ if len(lDrivelines)==0: lDrivelines=[None] self.writeSceneFile(sPath, sTrackName, lWater, lTrack, lItems, - lObjects, lBillboards, lParticleEmitters, lChecks, lSun, lDrivelines[0], - lStart, lEndCameras, lCameraCurves) + lObjects, lBillboards, lParticleEmitters, lSoundEmitters, lChecks, lSun, + lDrivelines[0], lStart, lEndCameras, lCameraCurves) # materials file # ---------- self.writeMaterialsFile(sPath) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <au...@us...> - 2011-08-28 01:51:22
|
Revision: 9636 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=9636&view=rev Author: auria Date: 2011-08-28 01:51:15 +0000 (Sun, 28 Aug 2011) Log Message: ----------- Add crash-reset support to the exporter and panel Modified Paths: -------------- media/trunk/blender_25/stk_panel.py media/trunk/blender_25/stk_track.py Modified: media/trunk/blender_25/stk_panel.py =================================================================== --- media/trunk/blender_25/stk_panel.py 2011-08-28 01:36:54 UTC (rev 9635) +++ media/trunk/blender_25/stk_panel.py 2011-08-28 01:51:15 UTC (rev 9636) @@ -620,7 +620,8 @@ ('mask', StkProperty( id='mask', name="Mask image", default="")), ('particle', StkBoolProperty( id='particle', name="Particle effect", default="false", contextLevel=CONTEXT_MATERIAL, subproperties=PARTICLE_PROPERTIES, docs="Whether to emit particles (e.g. smoke) when driving on this surface")), ('use_sfx', StkBoolProperty( id='use_sfx', name="Play sound effect", default="false", contextLevel=CONTEXT_MATERIAL, subproperties=SFX_PROPERTIES, docs="Whether to play a sound when driving on this surface")), - ('reset', StkBoolProperty( id='reset', name="Reset kart", default="false", contextLevel=CONTEXT_MATERIAL, docs="whether to rescue kart if it ends up on this surface")), + ('reset', StkBoolProperty( id='reset', name="Reset kart (on drive)", default="false", contextLevel=CONTEXT_MATERIAL, docs="whether to rescue kart if it ends up [driving] on this surface")), + ('crash_reset', StkBoolProperty( id='crash_reset', name="Reset kart (on touch)", default="false", contextLevel=CONTEXT_MATERIAL, docs="whether to rescue kart if it touches/hits this material in any way")), ('sphere', StkBoolProperty( id='sphere', name="Sphere mapping", default="false", contextLevel=CONTEXT_MATERIAL, docs="use sphere mapping on this object (mainly used to simulate a reflection effect)")), ('surface', StkBoolProperty( id='surface', name="Surface", default="false", contextLevel=CONTEXT_MATERIAL, docs="whether this material is the surface of a water area")), ('zipper', StkBoolProperty( id='zipper', name="Zipper (speed boost)", default="false", contextLevel=CONTEXT_MATERIAL, subproperties=ZIPPER_PROPERTIES, docs="Whether to get a speed boost when driving on this surface")) Modified: media/trunk/blender_25/stk_track.py =================================================================== --- media/trunk/blender_25/stk_track.py 2011-08-28 01:36:54 UTC (rev 9635) +++ media/trunk/blender_25/stk_track.py 2011-08-28 01:51:15 UTC (rev 9636) @@ -1703,6 +1703,7 @@ 'backface_culling' : ("Y", None), 'below_surface' : ("N", None), 'compositing' : ('none', None), + 'crash_reset' : ("N", None), 'clampu' : ("N", None), 'clampv' : ("N", None), 'disable_z_write' : ("N", None), @@ -1719,7 +1720,7 @@ } lBooleanAttributes = ["clampu","clampv","light","sphere","surface","below_surface", - "falling_effect", + "falling_effect", "crash_reset", "anisotropic","backface_culling","ignore","disable_z_write","reset", "sfx_positional"] This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <au...@us...> - 2011-08-28 18:28:53
|
Revision: 9642 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=9642&view=rev Author: auria Date: 2011-08-28 18:28:47 +0000 (Sun, 28 Aug 2011) Log Message: ----------- Add crash-reset-particles support to panel and exporter Modified Paths: -------------- media/trunk/blender_25/stk_panel.py media/trunk/blender_25/stk_track.py Modified: media/trunk/blender_25/stk_panel.py =================================================================== --- media/trunk/blender_25/stk_panel.py 2011-08-28 16:15:42 UTC (rev 9641) +++ media/trunk/blender_25/stk_panel.py 2011-08-28 18:28:47 UTC (rev 9642) @@ -604,6 +604,10 @@ ('sfx_rolloff' , StkFloatProperty( id='sfx_rolloff', name="Rolloff rate", default=0.1)) ]) +CRASH_RESET_PROPERTIES = OrderedDict([ + ('crash_reset_particles', StkProperty( id='crash_reset_particles', name="Particles on hit", default="")) + ]) + STK_MATERIAL_PROPERTIES = OrderedDict([ ('light', StkBoolProperty( id='light', name="Affected by lights", default="true", contextLevel=CONTEXT_MATERIAL, docs="Whether this material is affected by lgihts and shadows")), ('backface_culling', StkBoolProperty( id='backface_culling', name="Backface Culling", default="true", contextLevel=CONTEXT_MATERIAL, docs="If checked, this material will only be visible on the side of the normal")), @@ -621,7 +625,7 @@ ('particle', StkBoolProperty( id='particle', name="Particle effect", default="false", contextLevel=CONTEXT_MATERIAL, subproperties=PARTICLE_PROPERTIES, docs="Whether to emit particles (e.g. smoke) when driving on this surface")), ('use_sfx', StkBoolProperty( id='use_sfx', name="Play sound effect", default="false", contextLevel=CONTEXT_MATERIAL, subproperties=SFX_PROPERTIES, docs="Whether to play a sound when driving on this surface")), ('reset', StkBoolProperty( id='reset', name="Reset kart (on drive)", default="false", contextLevel=CONTEXT_MATERIAL, docs="whether to rescue kart if it ends up [driving] on this surface")), - ('crash_reset', StkBoolProperty( id='crash_reset', name="Reset kart (on touch)", default="false", contextLevel=CONTEXT_MATERIAL, docs="whether to rescue kart if it touches/hits this material in any way")), + ('crash_reset', StkBoolProperty( id='crash_reset', name="Reset kart (on touch)", default="false", contextLevel=CONTEXT_MATERIAL, subproperties=CRASH_RESET_PROPERTIES, docs="whether to rescue kart if it touches/hits this material in any way")), ('sphere', StkBoolProperty( id='sphere', name="Sphere mapping", default="false", contextLevel=CONTEXT_MATERIAL, docs="use sphere mapping on this object (mainly used to simulate a reflection effect)")), ('surface', StkBoolProperty( id='surface', name="Surface", default="false", contextLevel=CONTEXT_MATERIAL, docs="whether this material is the surface of a water area")), ('zipper', StkBoolProperty( id='zipper', name="Zipper (speed boost)", default="false", contextLevel=CONTEXT_MATERIAL, subproperties=ZIPPER_PROPERTIES, docs="Whether to get a speed boost when driving on this surface")) Modified: media/trunk/blender_25/stk_track.py =================================================================== --- media/trunk/blender_25/stk_track.py 2011-08-28 16:15:42 UTC (rev 9641) +++ media/trunk/blender_25/stk_track.py 2011-08-28 18:28:47 UTC (rev 9642) @@ -1699,24 +1699,25 @@ lTextureDefaults = { - 'light' : ("Y", None), - 'backface_culling' : ("Y", None), - 'below_surface' : ("N", None), - 'compositing' : ('none', None), - 'crash_reset' : ("N", None), - 'clampu' : ("N", None), - 'clampv' : ("N", None), - 'disable_z_write' : ("N", None), - 'falling_effect' : ("N", None), - 'graphical_effect' : ('none', None), - 'ignore' : ("N", None), - 'mask' : ("", None), - 'reset' : ("N", None), - 'sphere' : ("N", None), - 'surface' : ("N", None), - 'high_adhesion' : ('false', None), - 'slowdown_time' : (1.0, 'use_slowdown'), - 'max_speed' : (1.0, 'use_slowdown') + 'light' : ("Y", None), + 'backface_culling' : ("Y", None), + 'below_surface' : ("N", None), + 'compositing' : ('none', None), + 'crash_reset' : ("N", None), + 'crash_reset_particles' : ("", 'crash_reset'), + 'clampu' : ("N", None), + 'clampv' : ("N", None), + 'disable_z_write' : ("N", None), + 'falling_effect' : ("N", None), + 'graphical_effect' : ('none', None), + 'ignore' : ("N", None), + 'mask' : ("", None), + 'reset' : ("N", None), + 'sphere' : ("N", None), + 'surface' : ("N", None), + 'high_adhesion' : ('false', None), + 'slowdown_time' : (1.0, 'use_slowdown'), + 'max_speed' : (1.0, 'use_slowdown') } lBooleanAttributes = ["clampu","clampv","light","sphere","surface","below_surface", This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <au...@us...> - 2011-08-28 21:57:15
|
Revision: 9644 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=9644&view=rev Author: auria Date: 2011-08-28 21:57:09 +0000 (Sun, 28 Aug 2011) Log Message: ----------- Extract the materials exporter to a new file so that in the future it can be used by the kart exporter too Modified Paths: -------------- media/trunk/blender_25/stk_track.py Added Paths: ----------- media/trunk/blender_25/stk_material_export.py Added: media/trunk/blender_25/stk_material_export.py =================================================================== --- media/trunk/blender_25/stk_material_export.py (rev 0) +++ media/trunk/blender_25/stk_material_export.py 2011-08-28 21:57:09 UTC (rev 9644) @@ -0,0 +1,212 @@ +""" +Name: 'STK Material Exporter...' +Blender: 258 +Group: 'Export' +Tooltip: 'Export a SuperTuxKart track scene' +""" +__author__ = ["Joerg Henrichs (hiker), Marianne Gagnon (Auria)"] +__url__ = ["supertuxkart.sourceforge.net"] +__version__ = "$Revision$" +__bpydoc__ = """\ +""" + +bl_info = { + "name": "SuperTuxKart Material Exporter", + "description": "Exports image properties to the SuperTuxKart track format", + "author": "Joerg Henrichs, Marianne Gagnon", + "version": (1,0), + "blender": (2, 5, 8), + "api": 31236, + "location": "File > Export", + "warning": '', # used for warning icon and text in addons panel + "wiki_url": "http://supertuxkart.sourceforge.net/Get_involved", + "tracker_url": "https://sourceforge.net/apps/trac/supertuxkart/", + "category": "Import-Export"} + + +def getScriptVersion(): + try: + m = re.search('(\d+)', __version__) + return str(m.group(0)) + except: + return "Unknown" + +import bpy +import os + +# ------------------------------------------------------------------------------ +# Gets an id property of an object, returning the default if the id property +# is not set. If set_value_if_undefined is set and the property is not +# defined, this function will also set the property to this default value. +def getIdProperty(obj, name, default="", set_value_if_undefined=1): + import traceback + try: + prop = obj[name] + if isinstance(prop, str): + return obj[name].replace('&', '&') # this is XML + else: + return prop + except: + if default!=None and set_value_if_undefined: + obj[name] = default + return default + +# -------------------------------------------------------------------------- +# Write several ways of writing true/false as Y/N +def convertTextToYN(sText): + sTemp = sText.strip().upper() + if sTemp=="0" or sTemp[0]=="N" or sTemp=="FALSE": + return "N" + else: + return "Y" + + +# Writes the materials files, which includes all texture definitions +# (remember: Blenders "image" objects are STK's "material" objects) +# Please use the STKProperty browser!!! +def writeMaterialsFile(sPath): + # Read & Write the materials to the file + limage = bpy.data.images + + materfound = False + for i in limage: + for sAttrib in i.keys(): + materfound = True + break + if not materfound: + print("No Materials defined.") + return + + + + lTextureDefaults = { + 'light' : ("Y", None), + 'backface_culling' : ("Y", None), + 'below_surface' : ("N", None), + 'compositing' : ('none', None), + 'crash_reset' : ("N", None), + 'crash_reset_particles' : ("", 'crash_reset'), + 'clampu' : ("N", None), + 'clampv' : ("N", None), + 'disable_z_write' : ("N", None), + 'falling_effect' : ("N", None), + 'graphical_effect' : ('none', None), + 'ignore' : ("N", None), + 'mask' : ("", None), + 'reset' : ("N", None), + 'sphere' : ("N", None), + 'surface' : ("N", None), + 'high_adhesion' : ('false', None), + 'slowdown_time' : (1.0, 'use_slowdown'), + 'max_speed' : (1.0, 'use_slowdown') + } + + lBooleanAttributes = ["clampu","clampv","light","sphere","surface","below_surface", + "falling_effect", "crash_reset", + "anisotropic","backface_culling","ignore","disable_z_write","reset", + "sfx_positional"] + + #start_time = bsys.time() + print("Writing material file --> \t") + + f = open(sPath+"/materials.xml", mode="w", encoding="utf-8") + f.write("<?xml version=\"1.0\"?>\n") + f.write("<!-- Generated with script from SVN rev %s -->\n"%getScriptVersion()) + f.write("<materials>\n") + + for i in limage: + #iterate through material definitions and collect data + sImage = "" + sSFX = "" + sParticle = "" + sZipper = "" + hasSoundeffect = (convertTextToYN(getIdProperty(i, "use_sfx", "no")) == "Y") + hasParticle = (convertTextToYN(getIdProperty(i, "particle", "no")) == "Y") + hasZipper = (convertTextToYN(getIdProperty(i, "zipper", "no")) == "Y") + + # Create a copy of the list of defaults so that it can be modified. Then add + # all properties of the current image + l = [] + for sAttrib in i.keys(): + if sAttrib not in l: + l.append( (sAttrib, i[sAttrib]) ) + + for AProperty,ADefault in l: + # Don't add the (default) values to the property list + currentValue = getIdProperty(i, AProperty, ADefault, + set_value_if_undefined=0) + #Correct for all the ways booleans can be represented (true/false;yes/no;zero/not_zero) + if AProperty in lBooleanAttributes: + currentValue = convertTextToYN(currentValue) + + #These items pertain to the soundeffects (starting with sfx:) + if AProperty.strip().startswith("sfx_"): + strippedName = AProperty.strip()[len("sfx_"):] + + if strippedName in ['filename', 'rolloff', 'min_speed', 'max_speed', 'min_pitch', 'max_pitch', 'positional', 'volume']: + if isinstance(currentValue, float): + sSFX = "%s %s=\"%.2f\""%(sSFX,strippedName,currentValue) + else: + sSFX = "%s %s=\"%s\""%(sSFX,strippedName,currentValue) + elif AProperty.strip().upper().startswith("PARTICLE_"): + #These items pertain to the particles (starting with sfx:) + strippedName = AProperty.strip()[len("PARTICLE_"):] + sParticle = "%s %s=\"%s\""%(sParticle,strippedName,currentValue) + elif AProperty.strip().upper().startswith("ZIPPER_"): + #These items pertain to the particles (starting with sfx:) + strippedName = AProperty.strip()[len("ZIPPER_"):] + + sZipper = "%s %s=\"%s\""%(sZipper,strippedName,currentValue) + else: + #These items are standard items + prop = AProperty.strip()#.lower() + + if prop in lTextureDefaults.keys(): + + # if this property isc onditional on another + cond = lTextureDefaults[prop][1] + + if currentValue != lTextureDefaults[prop][0] and (cond is None or (cond in i and i[cond] == "true")): + if isinstance(currentValue, float): + # In blender, proeprties use '_', but STK still expects '-' + sImage = "%s %s=\"%.2f\""%(sImage,AProperty.replace("_","-"),currentValue) + else: + # In blender, proeprties use '_', but STK still expects '-' + sImage = "%s %s=\"%s\""%(sImage,AProperty.replace("_","-"),currentValue) + + # Now write the main content of the materials.xml file + if sImage or hasSoundeffect or hasParticle or hasZipper: + #Get the filename of the image. + s = i.filepath + sImage=" <material name=\"%s\"%s" % (os.path.basename(s),sImage) + if hasSoundeffect: + sImage="%s>\n <sfx%s/" % (sImage,sSFX) + if hasParticle: + sImage="%s>\n <particles%s/" % (sImage,sParticle) + if hasZipper: + sImage="%s>\n <zipper%s/" % (sImage,sZipper) + if not hasSoundeffect and not hasParticle and not hasZipper: + sImage="%s/>\n" % (sImage) + else: + sImage="%s>\n </material>\n" % (sImage) + + f.write(sImage) + + f.write("</materials>\n") + + f.close() + #print bsys.time()-start_time,"seconds" + # ---------------------------------------------------------------------- + +class STK_Material_Export_Operator(bpy.types.Operator): + bl_idname = ("screen.stk_material_exporter") + bl_label = ("Export Materials") + filepath = bpy.props.StringProperty() + + def execute(self, context): + writeMaterialsFile(self.filepath) + return {'FINISHED'} + +def register(): + bpy.utils.register_module(__name__) + \ No newline at end of file Property changes on: media/trunk/blender_25/stk_material_export.py ___________________________________________________________________ Added: svn:executable + * Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Modified: media/trunk/blender_25/stk_track.py =================================================================== --- media/trunk/blender_25/stk_track.py 2011-08-28 21:06:27 UTC (rev 9643) +++ media/trunk/blender_25/stk_track.py 2011-08-28 21:57:09 UTC (rev 9644) @@ -1716,144 +1716,6 @@ f.close() #print bsys.time()-start_time,"seconds" - # -------------------------------------------------------------------------- - # Writes the materials files, which includes all texture definitions - # (remember: Blenders "image" objects are STK's "material" objects) - # Please use the STKProperty browser!!! - def writeMaterialsFile(self, sPath): - # Read & Write the materials to the file - limage = bpy.data.images - - materfound = False - for i in limage: - for sAttrib in i.keys(): - materfound = True - break - if not materfound: - print("No Materials defined.") - return - - - - lTextureDefaults = { - 'light' : ("Y", None), - 'backface_culling' : ("Y", None), - 'below_surface' : ("N", None), - 'compositing' : ('none', None), - 'crash_reset' : ("N", None), - 'crash_reset_particles' : ("", 'crash_reset'), - 'clampu' : ("N", None), - 'clampv' : ("N", None), - 'disable_z_write' : ("N", None), - 'falling_effect' : ("N", None), - 'graphical_effect' : ('none', None), - 'ignore' : ("N", None), - 'mask' : ("", None), - 'reset' : ("N", None), - 'sphere' : ("N", None), - 'surface' : ("N", None), - 'high_adhesion' : ('false', None), - 'slowdown_time' : (1.0, 'use_slowdown'), - 'max_speed' : (1.0, 'use_slowdown') - } - - lBooleanAttributes = ["clampu","clampv","light","sphere","surface","below_surface", - "falling_effect", "crash_reset", - "anisotropic","backface_culling","ignore","disable_z_write","reset", - "sfx_positional"] - - #start_time = bsys.time() - print("Writing material file --> \t") - - f = open(sPath+"/materials.xml", mode="w", encoding="utf-8") - f.write("<?xml version=\"1.0\"?>\n") - f.write("<!-- Generated with script from SVN rev %s -->\n"%getScriptVersion()) - f.write("<materials>\n") - - for i in limage: - #iterate through material definitions and collect data - sImage = "" - sSFX = "" - sParticle = "" - sZipper = "" - hasSoundeffect = (convertTextToYN(getIdProperty(i, "use_sfx", "no")) == "Y") - hasParticle = (convertTextToYN(getIdProperty(i, "particle", "no")) == "Y") - hasZipper = (convertTextToYN(getIdProperty(i, "zipper", "no")) == "Y") - - # Create a copy of the list of defaults so that it can be modified. Then add - # all properties of the current image - l = [] - for sAttrib in i.keys(): - if sAttrib not in l: - l.append( (sAttrib, i[sAttrib]) ) - - for AProperty,ADefault in l: - # Don't add the (default) values to the property list - currentValue = getIdProperty(i, AProperty, ADefault, - set_value_if_undefined=0) - #Correct for all the ways booleans can be represented (true/false;yes/no;zero/not_zero) - if AProperty in lBooleanAttributes: - currentValue = convertTextToYN(currentValue) - - #These items pertain to the soundeffects (starting with sfx:) - if AProperty.strip().startswith("sfx_"): - strippedName = AProperty.strip()[len("sfx_"):] - - if strippedName in ['filename', 'rolloff', 'min_speed', 'max_speed', 'min_pitch', 'max_pitch', 'positional', 'volume']: - if isinstance(currentValue, float): - sSFX = "%s %s=\"%.2f\""%(sSFX,strippedName,currentValue) - else: - sSFX = "%s %s=\"%s\""%(sSFX,strippedName,currentValue) - elif AProperty.strip().upper().startswith("PARTICLE_"): - #These items pertain to the particles (starting with sfx:) - strippedName = AProperty.strip()[len("PARTICLE_"):] - sParticle = "%s %s=\"%s\""%(sParticle,strippedName,currentValue) - elif AProperty.strip().upper().startswith("ZIPPER_"): - #These items pertain to the particles (starting with sfx:) - strippedName = AProperty.strip()[len("ZIPPER_"):] - - sZipper = "%s %s=\"%s\""%(sZipper,strippedName,currentValue) - else: - #These items are standard items - prop = AProperty.strip()#.lower() - - if prop in lTextureDefaults.keys(): - - # if this property isc onditional on another - cond = lTextureDefaults[prop][1] - - if currentValue != lTextureDefaults[prop][0] and (cond is None or (cond in i and i[cond] == "true")): - if isinstance(currentValue, float): - # In blender, proeprties use '_', but STK still expects '-' - sImage = "%s %s=\"%.2f\""%(sImage,AProperty.replace("_","-"),currentValue) - else: - # In blender, proeprties use '_', but STK still expects '-' - sImage = "%s %s=\"%s\""%(sImage,AProperty.replace("_","-"),currentValue) - - # Now write the main content of the materials.xml file - if sImage or hasSoundeffect or hasParticle or hasZipper: - #Get the filename of the image. - s = i.filepath - sImage=" <material name=\"%s\"%s" % (os.path.basename(s),sImage) - if hasSoundeffect: - sImage="%s>\n <sfx%s/" % (sImage,sSFX) - if hasParticle: - sImage="%s>\n <particles%s/" % (sImage,sParticle) - if hasZipper: - sImage="%s>\n <zipper%s/" % (sImage,sZipper) - if not hasSoundeffect and not hasParticle and not hasZipper: - sImage="%s/>\n" % (sImage) - else: - sImage="%s>\n </material>\n" % (sImage) - - f.write(sImage) - - f.write("</materials>\n") - - f.close() - #print bsys.time()-start_time,"seconds" - # ---------------------------------------------------------------------- - def __init__(self, sFilename): self.dExportedObjects = {} @@ -2004,7 +1866,11 @@ lDrivelines[0], lStart, lEndCameras, lCameraCurves) # materials file # ---------- - self.writeMaterialsFile(sPath) + if 'stk_material_exporter' not in dir(bpy.ops.screen): + log_error("Cannot find the material exporter, make sure you installed it properly") + return + + bpy.ops.screen.stk_material_exporter(filepath=sPath) import datetime now = datetime.datetime.now() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <au...@us...> - 2011-08-30 19:10:27
|
Revision: 9664 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=9664&view=rev Author: auria Date: 2011-08-30 19:10:20 +0000 (Tue, 30 Aug 2011) Log Message: ----------- Update blender scripts for new LOD Modified Paths: -------------- media/trunk/blender_25/B3DReader/net/sourceforge/supertuxkart/b3d/B3DReader.java media/trunk/blender_25/B3DReader.jar media/trunk/blender_25/stk_panel.py media/trunk/blender_25/stk_track.py Modified: media/trunk/blender_25/B3DReader/net/sourceforge/supertuxkart/b3d/B3DReader.java =================================================================== --- media/trunk/blender_25/B3DReader/net/sourceforge/supertuxkart/b3d/B3DReader.java 2011-08-30 19:10:17 UTC (rev 9663) +++ media/trunk/blender_25/B3DReader/net/sourceforge/supertuxkart/b3d/B3DReader.java 2011-08-30 19:10:20 UTC (rev 9664) @@ -24,6 +24,7 @@ static ArrayList<Chunk> m_all_brus = new ArrayList<Chunk>(); static boolean showVrts = true; + static boolean showKeyframes = true; public static int readInt(InputStream i) throws Exception { @@ -67,6 +68,21 @@ return f; } + public static String readFloat(InputStream i, boolean printBytes) throws Exception + { + byte[] bytes = new byte[4]; + if (i.read(bytes) != 4) + { + throw new RuntimeException("Can't read int"); + } + + int packed_bytes = ((bytes[0] & 0xFF) | ((bytes[1] & 0xFF) << 8) | ((bytes[2] & 0xFF) << 16) | ((bytes[3] & 0xFF) << 24)); + + float f = Float.intBitsToFloat(packed_bytes); + if (f == -0) f = 0; + return f + ""; // + " [" + Integer.toHexString(packed_bytes) + "]"; + } + public static void readBB3DChunk(InputStream i, final int length) throws Exception { int version = readInt(i); @@ -79,7 +95,11 @@ public static String format3(float f) { - return String.format("%.3f", f); + String lOut = String.format("%.3f", f); + + if (lOut.equals("-0.000")) return "0.000"; + + return lOut; } public static String format2(float f) @@ -91,6 +111,8 @@ { int read = 0; + int n = 0; + while (read < length) { String filename = readString(i); @@ -104,12 +126,15 @@ float rot = readFloat(i); read += 28; + System.out.println(" TEXS entry " + n + ": "); System.out.println(" Filename: " + filename); System.out.println(" Flags: " + flags); System.out.println(" Blend: " + blend); System.out.println(" Position: (" + format2(x) + ", " + format2(y) + ")"); System.out.println(" Scale: (" + format2(x_scale) + ", " + format2(y_scale) + ")"); System.out.println(" Rotation: " + rot); + + n++; } } @@ -118,6 +143,8 @@ int num = readInt(i); int read = 4; + int brush_id = 0; + while (read < length) { String name = readString(i); @@ -132,6 +159,7 @@ int fx = readInt(i); read += 28; + System.out.println(" BRUSH " + brush_id + " :"); System.out.println(" Material name: " + name); System.out.println(" RGBA: (" + r + ", " + g + ", " + b + ", " + a + ")"); System.out.println(" Shininess: " + shininess); @@ -145,6 +173,8 @@ read += 4; System.out.println(" TextureID[" + n + "] : " + tid); } + + brush_id++; } } @@ -248,7 +278,9 @@ int vertex_id = readInt(i); float weigth = readFloat(i); read += 8; - System.out.println(" Vertex: " + vertex_id + " (weight=" + weigth + ")"); + + if (showVrts) + System.out.println(" Vertex: " + vertex_id + " (weight=" + weigth + ")"); } } @@ -263,15 +295,19 @@ { int frame = readInt(i); read += 4; - System.out.println(" Frame: " + frame); + if (showKeyframes) + System.out.println(" Frame: " + frame); + if ((flags & 0x1) != 0) { float x = readFloat(i); float y = readFloat(i); float z = readFloat(i); read += 12; - System.out.println(" Position: (" + format2(x) + ", " + format2(y) + ", " + format2(z) + ")"); + + if (showKeyframes) + System.out.println(" Position: (" + format2(x) + ", " + format2(y) + ", " + format2(z) + ")"); } if ((flags & 0x2) != 0) { @@ -279,7 +315,9 @@ float y = readFloat(i); float z = readFloat(i); read += 12; - System.out.println(" Scale: (" + format2(x) + ", " + format2(y) + ", " + format2(z) + ")"); + + if (showKeyframes) + System.out.println(" Scale: (" + format2(x) + ", " + format2(y) + ", " + format2(z) + ")"); } if ((flags & 0x4) != 0) { @@ -288,7 +326,9 @@ float y = readFloat(i); float z = readFloat(i); read += 16; - System.out.println(" Rot: (" + format3(w) + ", " + format3(x) + ", " + format3(y) + ", " + format3(z) + ")"); + + if (showKeyframes) + System.out.println(" Rot: (" + format3(w) + ", " + format3(x) + ", " + format3(y) + ", " + format3(z) + ")"); } } } @@ -353,7 +393,8 @@ int len = readInt(i); for (int n=0; n<level; n++) System.out.print(" "); - System.out.println(tag_str + " (" + len + " bytes)"); + // System.out.println(tag_str + " (" + len + " bytes)"); + System.out.println(tag_str); if (tag_str.equals("BB3D")) { @@ -404,8 +445,13 @@ public static void main(String[] args) throws Exception { - if (args.length > 1 && args[1].equals("--no-vrts")) showVrts = false; - FileInputStream i = new FileInputStream( new File(args[0]) ); + for (int n=0; n<args.length-1; n++) + { + if (args[n].equals("--no-vrts")) showVrts = false; + if (args[n].equals("--no-keys")) showKeyframes = false; + } + + FileInputStream i = new FileInputStream( new File(args[args.length - 1]) ); readChunk(i, 0); } Modified: media/trunk/blender_25/B3DReader.jar =================================================================== (Binary files differ) Modified: media/trunk/blender_25/stk_panel.py =================================================================== --- media/trunk/blender_25/stk_panel.py 2011-08-30 19:10:17 UTC (rev 9663) +++ media/trunk/blender_25/stk_panel.py 2011-08-30 19:10:20 UTC (rev 9664) @@ -463,6 +463,14 @@ #'inner_radius' : StkFloatProperty("Color radius"), #'color' : }, docs="An extension to the factory lap line"), + 'lod_instance' : StkEnumChoice('LOD Instance', + {'lod_name' : StkProperty( id='lod_name', name="LOD Group Name", default="SomeModel") + }, docs="A LOD (level-of-detail) instance, will display either of the LOD Models in this LOD group at this location"), + 'lod_model' : StkEnumChoice('LOD Model', + {'lod_distance' : StkFloatProperty( id='lod_distance', name="Distance", default=60.0), + 'lod_name' : StkProperty( id='lod_name', name="LOD Group Name", default="SomeModel"), + 'name' : StkProperty( id='name', name="Model Filename", default="") + }, docs="A LOD (level-of-detail) model (this model will not be visible in game, only LOD instances will)"), 'nitro_big' : StkEnumChoice('Nitro (big)', {}, docs="A big nitro collectible (apply to an Empty)"), 'nitro_small' : StkEnumChoice('Nitro (small)', {}, docs="A small nitro collectible (apply to an Empty)"), 'object' : StkEnumChoice('Object', object_properties, docs="An (animatable) object that is exported to a separate model file"), Modified: media/trunk/blender_25/stk_track.py =================================================================== --- media/trunk/blender_25/stk_track.py 2011-08-30 19:10:17 UTC (rev 9663) +++ media/trunk/blender_25/stk_track.py 2011-08-30 19:10:20 UTC (rev 9664) @@ -1073,9 +1073,16 @@ if shape: shape="shape=\"%s\""%shape if not ipo: ipo=[] - # Note: Y and Z are swapped! - f.write(" <object type=\"animation\" model=\"%s\" %s %s%s>\n"% \ - (name, getXYZHPRString(obj), shape, looped)) + + lodstring = self.getLODString(obj) + + # TODO: don't export any model name for LOD instances + if parent and parent.type=="ARMATURE": + f.write(" <object type=\"animation\" model=\"%s\" %s %s%s%s>\n"% \ + (name, getXYZHPRString(parent), shape, looped, lodstring)) + else: + f.write(" <object type=\"animation\" model=\"%s\" %s %s%s%s>\n"% \ + (name, getXYZHPRString(obj), shape, looped, lodstring)) self.writeIPO(f, ipo) f.write(" </object>\n") @@ -1101,6 +1108,9 @@ # physical). def writeStaticObjects(self, f, sPath, lStaticObjects, lAnimTextures): for obj in lStaticObjects: + + lodstring = self.getLODString(obj) + # An object can set the 'name' property, then this name will # be used to name the exported object (instead of the python name # which might be a default name with a number). Additionally, names @@ -1110,19 +1120,46 @@ name = getProperty(obj, "name", obj.name) if len(name) == 0: name = obj.name - b3d_name = self.exportLocalB3D(obj, sPath, name) - kind = getProperty(obj, "kind", "") + if getProperty(obj, "type", "X") != "lod_instance": + b3d_name = self.exportLocalB3D(obj, sPath, name) + kind = getProperty(obj, "kind", "") + + if getProperty(obj, "type", "X") == "lod_instance": + model_string = "" + else: + model_string = " model=\"%s\""%b3d_name + if lAnim: - f.write(" <static-object model=\"%s\" %s>\n"% \ - (b3d_name, getXYZHPRString(obj)) ) + f.write(" <static-object%s%s %s>\n"% \ + (lodstring, model_string, getXYZHPRString(obj)) ) self.writeAnimatedTextures(f, lAnim) f.write(" </static-object>\n") else: - f.write(" <static-object model=\"%s\" %s/>\n"% \ - (b3d_name, getXYZHPRString(obj)) ) + f.write(" <static-object%s%s %s/>\n"% \ + (lodstring, model_string, getXYZHPRString(obj)) ) self.writeAnimatedTextures(f, lAnimTextures) # -------------------------------------------------------------------------- + # Get LOD string for a given object (returns an empty string if object is not LOD) + def getLODString(self, obj): + lodstring = "" + type = getProperty(obj, "type", "object") + if type == "lod_model": + dist = type = getProperty(obj, "lod_distance", None) + if dist is None: + log_warning("LOD model " + obj.name + " has no distance property") + group = type = getProperty(obj, "lod_name", "") + if len(group) == 0: + log_warning("LOD model " + obj.name + " has no group property") + lodstring = ' lod_distance="' + str(dist) + '" lod_group="' + group + '"' + elif type == "lod_instance": + group = type = getProperty(obj, "lod_name", "") + if len(group) == 0: + log_warning("LOD instance " + obj.name + " has no group property") + lodstring = ' lod_instance="true" lod_group="' + group + '"' + return lodstring + + # -------------------------------------------------------------------------- # billboard section (check if the billboard is correct and write in the file) def writeBillboard(self,f, obj): data = obj.data @@ -1384,7 +1421,7 @@ dy = getProperty(obj, "anim_dy", 0) lAnimTextures.append( (anim_texture, dx, dy) ) return lAnimTextures - + # -------------------------------------------------------------------------- # Writes a non-static track object. The objects can be animated or # non-animated meshes, and physical or non-physical. @@ -1392,8 +1429,10 @@ def writeObject(self, f, sPath, obj): name = getProperty(obj, "name", obj.name) if len(name) == 0: name = obj.name - b3d_name = self.exportLocalB3D(obj, sPath, name) + if getProperty(obj, "type", "X") != "lod_instance": + b3d_name = self.exportLocalB3D(obj, sPath, name) + # First kind of object: ipo. There is one or # more IPOs define controlling this object. # Second kind of object: no ipo, and no physics. @@ -1414,9 +1453,12 @@ % obj.name) shape="box" mass = getProperty(obj, "mass", 10) + lodstring = self.getLODString(obj) + + # TODO: don't export any model name for LOD instances f.write(" <object type=\"movable\" %s\n"%(getXYZHPRString(obj))) - f.write(" model=\"%s\" shape=\"%s\" mass=\"%s\"/>\n"\ - % (b3d_name, shape, mass)) + f.write(" model=\"%s\" shape=\"%s\" mass=\"%s\"%s/>\n"\ + % (b3d_name, shape, mass, lodstring)) # Now the object either has an IPO, or is a 'ghost' object. # Either can have an IPO. Even if the objects don't move @@ -1519,6 +1561,7 @@ lStaticObjects = [] lOtherObjects = [] for obj in lObjects: + interact = getProperty(obj, "interaction", "static") if interact=="static": @@ -1802,7 +1845,7 @@ found_main_driveline = True elif stktype=="DRIVELINE": lDrivelines.append(Driveline(obj, 0)) - elif stktype=="OBJECT" or stktype=="SPECIAL_OBJECT": + elif stktype=="OBJECT" or stktype=="SPECIAL_OBJECT" or stktype=="LOD_MODEL" or stktype=="LOD_INSTANCE": lObjects.append(obj) # for billboard elif stktype=="BILLBOARD": This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <au...@us...> - 2011-08-30 19:13:12
|
Revision: 9665 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=9665&view=rev Author: auria Date: 2011-08-30 19:13:06 +0000 (Tue, 30 Aug 2011) Log Message: ----------- Minor tweaks to B3D reader Modified Paths: -------------- media/trunk/blender_25/B3DReader/net/sourceforge/supertuxkart/b3d/B3DReader.java media/trunk/blender_25/B3DReader.jar Modified: media/trunk/blender_25/B3DReader/net/sourceforge/supertuxkart/b3d/B3DReader.java =================================================================== --- media/trunk/blender_25/B3DReader/net/sourceforge/supertuxkart/b3d/B3DReader.java 2011-08-30 19:10:20 UTC (rev 9664) +++ media/trunk/blender_25/B3DReader/net/sourceforge/supertuxkart/b3d/B3DReader.java 2011-08-30 19:13:06 UTC (rev 9665) @@ -126,13 +126,13 @@ float rot = readFloat(i); read += 28; - System.out.println(" TEXS entry " + n + ": "); - System.out.println(" Filename: " + filename); - System.out.println(" Flags: " + flags); - System.out.println(" Blend: " + blend); - System.out.println(" Position: (" + format2(x) + ", " + format2(y) + ")"); - System.out.println(" Scale: (" + format2(x_scale) + ", " + format2(y_scale) + ")"); - System.out.println(" Rotation: " + rot); + System.out.println(" TEXS entry " + n + ": "); + System.out.println(" Filename: " + filename); + System.out.println(" Flags: " + flags); + System.out.println(" Blend: " + blend); + System.out.println(" Position: (" + format2(x) + ", " + format2(y) + ")"); + System.out.println(" Scale: (" + format2(x_scale) + ", " + format2(y_scale) + ")"); + System.out.println(" Rotation: " + rot); n++; } @@ -159,19 +159,19 @@ int fx = readInt(i); read += 28; - System.out.println(" BRUSH " + brush_id + " :"); - System.out.println(" Material name: " + name); - System.out.println(" RGBA: (" + r + ", " + g + ", " + b + ", " + a + ")"); - System.out.println(" Shininess: " + shininess); - System.out.println(" Blend: " + blend); - System.out.println(" FX: " + fx); + System.out.println(" BRUSH " + brush_id + " :"); + System.out.println(" Material name: " + name); + System.out.println(" RGBA: (" + r + ", " + g + ", " + b + ", " + a + ")"); + System.out.println(" Shininess: " + shininess); + System.out.println(" Blend: " + blend); + System.out.println(" FX: " + fx); for (int n=0; n<num; n++) { int tid = readInt(i); read += 4; - System.out.println(" TextureID[" + n + "] : " + tid); + System.out.println(" TextureID[" + n + "] : " + tid); } brush_id++; @@ -242,7 +242,7 @@ public static void readTRISChunk(InputStream i, final int length) throws Exception { int brush_id = readInt(i); - System.out.println(" BrushID: " + brush_id); + System.out.println(" Tris.BrushID: " + brush_id); int read = 4; @@ -253,7 +253,7 @@ int vertex_3 = readInt(i); read += 12; if (showVrts) - System.out.println(" Triangle: (" + vertex_1 + ", " + vertex_2 + ", " + vertex_3 + ")"); + System.out.println(" Triangle: (" + vertex_1 + ", " + vertex_2 + ", " + vertex_3 + ")"); } } Modified: media/trunk/blender_25/B3DReader.jar =================================================================== (Binary files differ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <au...@us...> - 2011-09-03 18:46:54
|
Revision: 9728 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=9728&view=rev Author: auria Date: 2011-09-03 18:46:48 +0000 (Sat, 03 Sep 2011) Log Message: ----------- Add support for clip_distance property in exporter Modified Paths: -------------- media/trunk/blender_25/stk_panel.py media/trunk/blender_25/stk_track.py Modified: media/trunk/blender_25/stk_panel.py =================================================================== --- media/trunk/blender_25/stk_panel.py 2011-09-03 18:35:44 UTC (rev 9727) +++ media/trunk/blender_25/stk_panel.py 2011-09-03 18:46:48 UTC (rev 9728) @@ -154,8 +154,6 @@ self.doc = doc self.unique_id_suffix = unique_id_suffix - print("CTOR ",id + unique_id_suffix," static_objects = ", static_objects) - class SelectObjectOperator(bpy.types.Operator): bl_idname = "scene.stk_select_object_" + id + unique_id_suffix bl_label = "Select Object Operator" @@ -639,7 +637,9 @@ 'nitro_small' : StkEnumChoice('Nitro (small)', {}, doc="A small nitro collectible (apply to an Empty)"), 'object' : StkEnumChoice('Object', object_properties, doc="An (animatable) object that is exported to a separate model file"), 'particle_emitter' : StkEnumChoice('Particle Emitter', - {'kind' : StkProperty(id='kind', name="Particle File", default="smoke.xml") + {'kind' : StkProperty(id='kind', name="Particle File", default="smoke.xml"), + 'clip_distance' : StkIntProperty(id='clip_distance', name="Clip Distance", default=0, + doc="If non-zero, the camera distance at which particles are hidden (for performance reasons)") }, doc="To be applied to an empty; particles will be emitted from this point"), 'start' : StkEnumChoice('Start position', subproperties={'start_index' : StkIntProperty('start_index', "Start Index", 1, doc="Start position index for battle mode")}, Modified: media/trunk/blender_25/stk_track.py =================================================================== --- media/trunk/blender_25/stk_track.py 2011-09-03 18:35:44 UTC (rev 9727) +++ media/trunk/blender_25/stk_track.py 2011-09-03 18:46:48 UTC (rev 9728) @@ -1215,8 +1215,13 @@ try: # origin originXYZ = getXYZHString(obj) - f.write(' <particle-emitter kind="%s" %s/>\n' %\ - (getProperty(obj, "kind", 0) ,originXYZ)) + + if getProperty(obj, "clip_distance", 0) > 0 : + f.write(' <particle-emitter kind="%s" %s clip_distance="%i"/>\n' %\ + (getProperty(obj, "kind", 0), originXYZ, getProperty(obj, "clip_distance", 0))) + else: + f.write(' <particle-emitter kind="%s" %s/>\n' %\ + (getProperty(obj, "kind", 0), originXYZ)) except: log_error("Invalid particle emitter <" + getProperty(obj, "name", obj.name) + "> ", sys.exc_info()[0]) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |