Página 1 de 1

CREACION DE TMB EXPORT.PY para Blender

Publicado: Sab Oct 13, 2012 11:02 am
por Proidzen
Hola a todos soy nuevo en el foro, bueno les contare el motivo por el cual estoy aqui, yo edito y monto servidores de Tantra (es un juego en linea) y bueno quisiera editar los modelos 3d del juego estan en una extensión \".tmb\" esta extension no es muy comun y los modelos 3d del juego en tmb no son como decirlo de buena calidad el asunto esque alguna persona creo un importador de estos modelos para blender
el llamado tmb_import.py el problema esque nunca se llego a crear el exportador para q se pudiera crear un modelo 3d desde cero e importarlo al juego en eso quisiera la ayuda de ustedes si pudieran darme una guia de como crear el exportador o crearlo por mi... les dejo el script para q lo analizen y el codigo de este..

CODIGO TMB IMPORT.PY :

#!BPY

# Copyright (c) 2008 Peter S. Stevens
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the \"Software\"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.


\"\"\"
Name: \'Tantra Online (*.tmb)...\'
Blender: 246
Group: \'Import\'
Tooltip: \'Import Tantra Online *.tmb game files\'
\"\"\"

__author__ = \'Peter S. Stevens\'
__email__ = \'pstevens:cryptomail*org\'
__url__ = (\'blender\', \'elysiun\', \'Project homepage, http://www.ragezone.com/\')
__version__ = \'09.05.0a\'
__bpydoc__ = \"\"\" \\
This script imports Tantra Online *.tmb game files
\"\"\"


import Blender
import struct


def tmb_read_mesh(file_object, revision):
data_chunk = file_object.read(256) # Read mesh name

name = data_chunk[0:data_chunk.find(\'\\0\', 0)]

print \"mesh %s start 0x%x\" % (name, file_object.tell() - 256)

data_chunk = file_object.read(4) # Read vertex count

vertex_count = struct.unpack(\' 1:
data_chunk = file_object.read(4 * (matrix_count - 1))

for x in xrange(matrix_count):
data_chunk = file_object.read(64) # Read matrix

data_chunk = file_object.read(12)

x_count, face_count = struct.unpack_from(\' 1:
data_chunk = file_object.read(4 * (matrix_count - 1))

print \"\\tface count %d, %d\" % (x_count, face_count)

for x in xrange(face_count):
data_chunk = file_object.read(12)

face_vertices = [mesh.verts[y] for y in struct.unpack(\'<3I\', data_chunk)]

mesh.faces.extend(face_vertices)

face = mesh.faces[-1]

face.uv = [vertex.uvco for vertex in face_vertices]

for x in xrange(matrix_count):
data_chunk = file_object.read(256) # Read texture file name

texture_file_name = data_chunk[0:data_chunk.find(\'\\0\', 0)]

print \"\\ttexture %d: %s\" % (x, texture_file_name)

data_chunk = file_object.read(40)

if revision == 2:
data_chunk = file_object.read(8)

joint_count, unknown_0 = struct.unpack(\'<2I\', data_chunk) # Read joint count

for x in xrange(joint_count):
data_chunk = file_object.read(256)

joint_name = data_chunk[0:data_chunk.find(\'\\0\', 0)]

print \"\\tjoint %s\" % joint_name

unknown_1 = []

for x in xrange(unknown_0):
data_chunk = file_object.read(4)

unknown_1.append(struct.unpack(\'<I\', data_chunk)[0])

for unknown in unknown_1:
for x in xrange(unknown):
data_chunk = file_object.read(8)

data_chunk = file_object.read(4) # unknown_0

unknown_2 = struct.unpack(\'<I\', data_chunk)[0]

unknown_3 = []

for x in xrange(unknown_2):
data_chunk = file_object.read(4)

unknown_3.append(struct.unpack(\'<I\', data_chunk)[0])

for unknown in unknown_3:
for x in xrange(unknown):
data_chunk = file_object.read(4)

for x in xrange(vertex_count):
data_chunk = file_object.read(12)

print \"mesh %s end 0x%x\" % (name, file_object.tell())

return mesh_object


def tmb_read(file_path):
file_object = None

try:
file_object = open(file_path, \'rb\')

data_chunk = file_object.read(12) # Read header chunk

unknown_0, revision, mesh_count = struct.unpack(\'<3I\', data_chunk)

print \"mesh count %d\" % mesh_count

mesh_objects = []

for x in xrange(mesh_count):
mesh_objects.append(tmb_read_mesh(file_object, revision))

scene = Blender.Scene.GetCurrent()

for mesh_object in mesh_objects:
scene.objects.link(mesh_object)
except IOError, (errno, strerror):
Blender.Draw.PupMenu(\"Error%%t|I/O error(%d): %s.\" % (errno, strerror))
except Exception, err:
Blender.Draw.PupMenu(\"Error%%t|.%s\" % err)
finally:
if file_object is not None:
file_object.close()


def main():
def tmb_file_selector(file_path):
if file_path and not Blender.sys.exists(file_path):
Blender.Draw.PupMenu(\"Error%%t|The file %s does not exist.\" % file_path)
else:
tmb_read(file_path)

Blender.Window.FileSelector(tmb_file_selector, \'Ok\', Blender.sys.makename(ext=\'.tmb\'))


if __name__ == \"__main__\":
main()


UN MODELO TMB:

http://www.mediafire.com/?86ivhv0quwk3l83