2008-05-11 12:41:12 +00:00
|
|
|
# coding: utf-8
|
2009-11-01 15:21:20 +00:00
|
|
|
# ##### BEGIN GPL LICENSE BLOCK #####
|
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or
|
|
|
|
# modify it under the terms of the GNU General Public License
|
|
|
|
# as published by the Free Software Foundation; either version 2
|
|
|
|
# of the License, or (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program; if not, write to the Free Software Foundation,
|
|
|
|
# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
#
|
|
|
|
# ##### END GPL LICENSE BLOCK #####
|
|
|
|
|
2009-05-05 21:51:54 +00:00
|
|
|
__author__ = ["Campbell Barton", "Bob Holcomb", "Richard Lärkäng", "Damien McGinnes", "Mark Stijnman"]
|
2006-12-25 23:14:48 +00:00
|
|
|
__url__ = ("blenderartists.org", "www.blender.org", "www.gametutorials.com", "lib3ds.sourceforge.net/")
|
2006-05-14 03:11:55 +00:00
|
|
|
__version__ = "0.90a"
|
2005-12-15 01:42:45 +00:00
|
|
|
__bpydoc__ = """\
|
|
|
|
|
|
|
|
3ds Exporter
|
|
|
|
|
Commited 3ds export enhancements from Mark Stijnman (beowulff)
Will need to do some updates, Mesh over NMesh and optimize some areas but it works and is a big improvement.
from
https://projects.blender.org/tracker/index.php?func=detail&aid=4156&group_id=9&atid=127
Detailed description:
Modified the 3ds export script 3ds_export.py:
- It now exports face UV correctly. 3ds only supports one UV coordinate per vertex. The script now duplicates vertices that had multiple UV pairs assigned to them so that each duplicate now only contains one and only one UV. Faces have their vertex indices adjusted accordingly.
- Quads are now split into triangles better. 3ds only supports triangles, so quads need to be split into two triangles. Instead of rather arbitrarily splitting along the diagonal between points 0 and 2, the script now splits along the shortest diagonal. This creates a higher quality triangular mesh, as well as better preservation of symmetry.
- Now creates an object node block, exporting object nodes, needed by some 3D importers. Among others, allows one to export object hierarchy.
- Now exports Empties as 3ds Dummies.
To be able to add all of the above new features, the script has been mostly rewritten and strongly restructured.
Motivation for the rewrite was the desire to be able to use Blender to produce custom 3d cars for Trackmania:Sunrise (TM:S). Previously, the TM:S importer could not correctly handle the 3ds files from the Blender 3ds export script. With this version, one can export cars complete with UV textures, correct wheel placement and light placement. To my knowledge, this script would make Blender the first fully free 3d modeller that allows one to export 3ds models for TM:S (expect a tutorial soon). The ability to have proper UV coordinates exported into the 3ds file should also be very welcome to many.
Add A Comment: Notepad
2006-05-02 11:26:32 +00:00
|
|
|
This script Exports a 3ds file.
|
2005-12-15 01:42:45 +00:00
|
|
|
|
Commited 3ds export enhancements from Mark Stijnman (beowulff)
Will need to do some updates, Mesh over NMesh and optimize some areas but it works and is a big improvement.
from
https://projects.blender.org/tracker/index.php?func=detail&aid=4156&group_id=9&atid=127
Detailed description:
Modified the 3ds export script 3ds_export.py:
- It now exports face UV correctly. 3ds only supports one UV coordinate per vertex. The script now duplicates vertices that had multiple UV pairs assigned to them so that each duplicate now only contains one and only one UV. Faces have their vertex indices adjusted accordingly.
- Quads are now split into triangles better. 3ds only supports triangles, so quads need to be split into two triangles. Instead of rather arbitrarily splitting along the diagonal between points 0 and 2, the script now splits along the shortest diagonal. This creates a higher quality triangular mesh, as well as better preservation of symmetry.
- Now creates an object node block, exporting object nodes, needed by some 3D importers. Among others, allows one to export object hierarchy.
- Now exports Empties as 3ds Dummies.
To be able to add all of the above new features, the script has been mostly rewritten and strongly restructured.
Motivation for the rewrite was the desire to be able to use Blender to produce custom 3d cars for Trackmania:Sunrise (TM:S). Previously, the TM:S importer could not correctly handle the 3ds files from the Blender 3ds export script. With this version, one can export cars complete with UV textures, correct wheel placement and light placement. To my knowledge, this script would make Blender the first fully free 3d modeller that allows one to export 3ds models for TM:S (expect a tutorial soon). The ability to have proper UV coordinates exported into the 3ds file should also be very welcome to many.
Add A Comment: Notepad
2006-05-02 11:26:32 +00:00
|
|
|
Exporting is based on 3ds loader from www.gametutorials.com(Thanks DigiBen) and using information
|
|
|
|
from the lib3ds project (http://lib3ds.sourceforge.net/) sourcecode.
|
2005-12-15 01:42:45 +00:00
|
|
|
"""
|
|
|
|
|
|
|
|
# ***** BEGIN GPL LICENSE BLOCK *****
|
|
|
|
#
|
|
|
|
# Script copyright (C) Bob Holcomb
|
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or
|
|
|
|
# modify it under the terms of the GNU General Public License
|
|
|
|
# as published by the Free Software Foundation; either version 2
|
|
|
|
# of the License, or (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program; if not, write to the Free Software Foundation,
|
|
|
|
# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
#
|
|
|
|
# ***** END GPL LICENCE BLOCK *****
|
|
|
|
# --------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
######################################################
|
|
|
|
# Importing modules
|
|
|
|
######################################################
|
|
|
|
|
2009-09-29 15:27:00 +00:00
|
|
|
import struct
|
|
|
|
import os
|
|
|
|
import time
|
|
|
|
|
2007-03-26 19:44:44 +00:00
|
|
|
import bpy
|
2009-09-29 15:27:00 +00:00
|
|
|
|
|
|
|
# import Blender
|
|
|
|
# from BPyMesh import getMeshFromObject
|
|
|
|
# from BPyObject import getDerivedObjects
|
|
|
|
# try:
|
|
|
|
# import struct
|
|
|
|
# except:
|
|
|
|
# struct = None
|
|
|
|
|
|
|
|
# also used by X3D exporter
|
|
|
|
# return a tuple (free, object list), free is True if memory should be freed later with free_derived_objects()
|
|
|
|
def create_derived_objects(ob):
|
|
|
|
if ob.parent and ob.parent.dupli_type != 'NONE':
|
|
|
|
return False, None
|
|
|
|
|
|
|
|
if ob.dupli_type != 'NONE':
|
|
|
|
ob.create_dupli_list()
|
|
|
|
return True, [(dob.object, dob.matrix) for dob in ob.dupli_list]
|
|
|
|
else:
|
|
|
|
return False, [(ob, ob.matrix)]
|
|
|
|
|
|
|
|
# also used by X3D exporter
|
|
|
|
def free_derived_objects(ob):
|
|
|
|
ob.free_dupli_list()
|
2005-12-15 01:42:45 +00:00
|
|
|
|
2007-05-06 02:19:43 +00:00
|
|
|
# So 3ds max can open files, limit names to 12 in length
|
|
|
|
# this is verry annoying for filenames!
|
|
|
|
name_unique = []
|
|
|
|
name_mapping = {}
|
|
|
|
def sane_name(name):
|
|
|
|
name_fixed = name_mapping.get(name)
|
|
|
|
if name_fixed != None:
|
|
|
|
return name_fixed
|
|
|
|
|
|
|
|
if len(name) > 12:
|
|
|
|
new_name = name[:12]
|
|
|
|
else:
|
|
|
|
new_name = name
|
|
|
|
|
|
|
|
i = 0
|
|
|
|
|
|
|
|
while new_name in name_unique:
|
|
|
|
new_name = new_name[:-4] + '.%.3d' % i
|
|
|
|
i+=1
|
|
|
|
|
2007-05-06 09:54:17 +00:00
|
|
|
name_unique.append(new_name)
|
2007-05-06 02:19:43 +00:00
|
|
|
name_mapping[name] = new_name
|
|
|
|
return new_name
|
2006-05-14 03:11:55 +00:00
|
|
|
|
2005-12-15 01:42:45 +00:00
|
|
|
######################################################
|
|
|
|
# Data Structures
|
|
|
|
######################################################
|
|
|
|
|
|
|
|
#Some of the chunks that we will export
|
|
|
|
#----- Primary Chunk, at the beginning of each file
|
2009-09-29 15:27:00 +00:00
|
|
|
PRIMARY= int("0x4D4D",16)
|
2005-12-15 01:42:45 +00:00
|
|
|
|
|
|
|
#------ Main Chunks
|
2009-09-29 15:27:00 +00:00
|
|
|
OBJECTINFO = int("0x3D3D",16); #This gives the version of the mesh and is found right before the material and object information
|
|
|
|
VERSION = int("0x0002",16); #This gives the version of the .3ds file
|
|
|
|
KFDATA = int("0xB000",16); #This is the header for all of the key frame info
|
2005-12-15 01:42:45 +00:00
|
|
|
|
|
|
|
#------ sub defines of OBJECTINFO
|
|
|
|
MATERIAL=45055 #0xAFFF // This stored the texture info
|
|
|
|
OBJECT=16384 #0x4000 // This stores the faces, vertices, etc...
|
|
|
|
|
|
|
|
#>------ sub defines of MATERIAL
|
2009-09-29 15:27:00 +00:00
|
|
|
MATNAME = int("0xA000",16); # This holds the material name
|
|
|
|
MATAMBIENT = int("0xA010",16); # Ambient color of the object/material
|
|
|
|
MATDIFFUSE = int("0xA020",16); # This holds the color of the object/material
|
|
|
|
MATSPECULAR = int("0xA030",16); # SPecular color of the object/material
|
|
|
|
MATSHINESS = int("0xA040",16); # ??
|
|
|
|
MATMAP = int("0xA200",16); # This is a header for a new material
|
|
|
|
MATMAPFILE = int("0xA300",16); # This holds the file name of the texture
|
2005-12-15 01:42:45 +00:00
|
|
|
|
2009-09-29 15:27:00 +00:00
|
|
|
RGB1= int("0x0011",16)
|
|
|
|
RGB2= int("0x0012",16)
|
2005-12-15 01:42:45 +00:00
|
|
|
|
|
|
|
#>------ sub defines of OBJECT
|
2009-09-29 15:27:00 +00:00
|
|
|
OBJECT_MESH = int("0x4100",16); # This lets us know that we are reading a new object
|
|
|
|
OBJECT_LIGHT = int("0x4600",16); # This lets un know we are reading a light object
|
|
|
|
OBJECT_CAMERA= int("0x4700",16); # This lets un know we are reading a camera object
|
2005-12-15 01:42:45 +00:00
|
|
|
|
|
|
|
#>------ sub defines of CAMERA
|
2009-09-29 15:27:00 +00:00
|
|
|
OBJECT_CAM_RANGES= int("0x4720",16); # The camera range values
|
2005-12-15 01:42:45 +00:00
|
|
|
|
|
|
|
#>------ sub defines of OBJECT_MESH
|
2009-09-29 15:27:00 +00:00
|
|
|
OBJECT_VERTICES = int("0x4110",16); # The objects vertices
|
|
|
|
OBJECT_FACES = int("0x4120",16); # The objects faces
|
|
|
|
OBJECT_MATERIAL = int("0x4130",16); # This is found if the object has a material, either texture map or color
|
|
|
|
OBJECT_UV = int("0x4140",16); # The UV texture coordinates
|
|
|
|
OBJECT_TRANS_MATRIX = int("0x4160",16); # The Object Matrix
|
2005-12-15 01:42:45 +00:00
|
|
|
|
Commited 3ds export enhancements from Mark Stijnman (beowulff)
Will need to do some updates, Mesh over NMesh and optimize some areas but it works and is a big improvement.
from
https://projects.blender.org/tracker/index.php?func=detail&aid=4156&group_id=9&atid=127
Detailed description:
Modified the 3ds export script 3ds_export.py:
- It now exports face UV correctly. 3ds only supports one UV coordinate per vertex. The script now duplicates vertices that had multiple UV pairs assigned to them so that each duplicate now only contains one and only one UV. Faces have their vertex indices adjusted accordingly.
- Quads are now split into triangles better. 3ds only supports triangles, so quads need to be split into two triangles. Instead of rather arbitrarily splitting along the diagonal between points 0 and 2, the script now splits along the shortest diagonal. This creates a higher quality triangular mesh, as well as better preservation of symmetry.
- Now creates an object node block, exporting object nodes, needed by some 3D importers. Among others, allows one to export object hierarchy.
- Now exports Empties as 3ds Dummies.
To be able to add all of the above new features, the script has been mostly rewritten and strongly restructured.
Motivation for the rewrite was the desire to be able to use Blender to produce custom 3d cars for Trackmania:Sunrise (TM:S). Previously, the TM:S importer could not correctly handle the 3ds files from the Blender 3ds export script. With this version, one can export cars complete with UV textures, correct wheel placement and light placement. To my knowledge, this script would make Blender the first fully free 3d modeller that allows one to export 3ds models for TM:S (expect a tutorial soon). The ability to have proper UV coordinates exported into the 3ds file should also be very welcome to many.
Add A Comment: Notepad
2006-05-02 11:26:32 +00:00
|
|
|
#>------ sub defines of KFDATA
|
2009-09-29 15:27:00 +00:00
|
|
|
KFDATA_KFHDR = int("0xB00A",16);
|
|
|
|
KFDATA_KFSEG = int("0xB008",16);
|
|
|
|
KFDATA_KFCURTIME = int("0xB009",16);
|
|
|
|
KFDATA_OBJECT_NODE_TAG = int("0xB002",16);
|
Commited 3ds export enhancements from Mark Stijnman (beowulff)
Will need to do some updates, Mesh over NMesh and optimize some areas but it works and is a big improvement.
from
https://projects.blender.org/tracker/index.php?func=detail&aid=4156&group_id=9&atid=127
Detailed description:
Modified the 3ds export script 3ds_export.py:
- It now exports face UV correctly. 3ds only supports one UV coordinate per vertex. The script now duplicates vertices that had multiple UV pairs assigned to them so that each duplicate now only contains one and only one UV. Faces have their vertex indices adjusted accordingly.
- Quads are now split into triangles better. 3ds only supports triangles, so quads need to be split into two triangles. Instead of rather arbitrarily splitting along the diagonal between points 0 and 2, the script now splits along the shortest diagonal. This creates a higher quality triangular mesh, as well as better preservation of symmetry.
- Now creates an object node block, exporting object nodes, needed by some 3D importers. Among others, allows one to export object hierarchy.
- Now exports Empties as 3ds Dummies.
To be able to add all of the above new features, the script has been mostly rewritten and strongly restructured.
Motivation for the rewrite was the desire to be able to use Blender to produce custom 3d cars for Trackmania:Sunrise (TM:S). Previously, the TM:S importer could not correctly handle the 3ds files from the Blender 3ds export script. With this version, one can export cars complete with UV textures, correct wheel placement and light placement. To my knowledge, this script would make Blender the first fully free 3d modeller that allows one to export 3ds models for TM:S (expect a tutorial soon). The ability to have proper UV coordinates exported into the 3ds file should also be very welcome to many.
Add A Comment: Notepad
2006-05-02 11:26:32 +00:00
|
|
|
|
|
|
|
#>------ sub defines of OBJECT_NODE_TAG
|
2009-09-29 15:27:00 +00:00
|
|
|
OBJECT_NODE_ID = int("0xB030",16);
|
|
|
|
OBJECT_NODE_HDR = int("0xB010",16);
|
|
|
|
OBJECT_PIVOT = int("0xB013",16);
|
|
|
|
OBJECT_INSTANCE_NAME = int("0xB011",16);
|
|
|
|
POS_TRACK_TAG = int("0xB020",16);
|
|
|
|
ROT_TRACK_TAG = int("0xB021",16);
|
|
|
|
SCL_TRACK_TAG = int("0xB022",16);
|
Commited 3ds export enhancements from Mark Stijnman (beowulff)
Will need to do some updates, Mesh over NMesh and optimize some areas but it works and is a big improvement.
from
https://projects.blender.org/tracker/index.php?func=detail&aid=4156&group_id=9&atid=127
Detailed description:
Modified the 3ds export script 3ds_export.py:
- It now exports face UV correctly. 3ds only supports one UV coordinate per vertex. The script now duplicates vertices that had multiple UV pairs assigned to them so that each duplicate now only contains one and only one UV. Faces have their vertex indices adjusted accordingly.
- Quads are now split into triangles better. 3ds only supports triangles, so quads need to be split into two triangles. Instead of rather arbitrarily splitting along the diagonal between points 0 and 2, the script now splits along the shortest diagonal. This creates a higher quality triangular mesh, as well as better preservation of symmetry.
- Now creates an object node block, exporting object nodes, needed by some 3D importers. Among others, allows one to export object hierarchy.
- Now exports Empties as 3ds Dummies.
To be able to add all of the above new features, the script has been mostly rewritten and strongly restructured.
Motivation for the rewrite was the desire to be able to use Blender to produce custom 3d cars for Trackmania:Sunrise (TM:S). Previously, the TM:S importer could not correctly handle the 3ds files from the Blender 3ds export script. With this version, one can export cars complete with UV textures, correct wheel placement and light placement. To my knowledge, this script would make Blender the first fully free 3d modeller that allows one to export 3ds models for TM:S (expect a tutorial soon). The ability to have proper UV coordinates exported into the 3ds file should also be very welcome to many.
Add A Comment: Notepad
2006-05-02 11:26:32 +00:00
|
|
|
|
2006-05-14 03:11:55 +00:00
|
|
|
def uv_key(uv):
|
2009-09-29 15:27:00 +00:00
|
|
|
return round(uv[0], 6), round(uv[1], 6)
|
|
|
|
# return round(uv.x, 6), round(uv.y, 6)
|
2005-12-15 01:42:45 +00:00
|
|
|
|
Commited 3ds export enhancements from Mark Stijnman (beowulff)
Will need to do some updates, Mesh over NMesh and optimize some areas but it works and is a big improvement.
from
https://projects.blender.org/tracker/index.php?func=detail&aid=4156&group_id=9&atid=127
Detailed description:
Modified the 3ds export script 3ds_export.py:
- It now exports face UV correctly. 3ds only supports one UV coordinate per vertex. The script now duplicates vertices that had multiple UV pairs assigned to them so that each duplicate now only contains one and only one UV. Faces have their vertex indices adjusted accordingly.
- Quads are now split into triangles better. 3ds only supports triangles, so quads need to be split into two triangles. Instead of rather arbitrarily splitting along the diagonal between points 0 and 2, the script now splits along the shortest diagonal. This creates a higher quality triangular mesh, as well as better preservation of symmetry.
- Now creates an object node block, exporting object nodes, needed by some 3D importers. Among others, allows one to export object hierarchy.
- Now exports Empties as 3ds Dummies.
To be able to add all of the above new features, the script has been mostly rewritten and strongly restructured.
Motivation for the rewrite was the desire to be able to use Blender to produce custom 3d cars for Trackmania:Sunrise (TM:S). Previously, the TM:S importer could not correctly handle the 3ds files from the Blender 3ds export script. With this version, one can export cars complete with UV textures, correct wheel placement and light placement. To my knowledge, this script would make Blender the first fully free 3d modeller that allows one to export 3ds models for TM:S (expect a tutorial soon). The ability to have proper UV coordinates exported into the 3ds file should also be very welcome to many.
Add A Comment: Notepad
2006-05-02 11:26:32 +00:00
|
|
|
# size defines:
|
|
|
|
SZ_SHORT = 2
|
|
|
|
SZ_INT = 4
|
|
|
|
SZ_FLOAT = 4
|
2005-12-15 01:42:45 +00:00
|
|
|
|
2007-01-04 20:44:33 +00:00
|
|
|
class _3ds_short(object):
|
2006-07-05 07:10:03 +00:00
|
|
|
'''Class representing a short (2-byte integer) for a 3ds file.
|
|
|
|
*** This looks like an unsigned short H is unsigned from the struct docs - Cam***'''
|
2007-01-04 20:44:33 +00:00
|
|
|
__slots__ = 'value'
|
Commited 3ds export enhancements from Mark Stijnman (beowulff)
Will need to do some updates, Mesh over NMesh and optimize some areas but it works and is a big improvement.
from
https://projects.blender.org/tracker/index.php?func=detail&aid=4156&group_id=9&atid=127
Detailed description:
Modified the 3ds export script 3ds_export.py:
- It now exports face UV correctly. 3ds only supports one UV coordinate per vertex. The script now duplicates vertices that had multiple UV pairs assigned to them so that each duplicate now only contains one and only one UV. Faces have their vertex indices adjusted accordingly.
- Quads are now split into triangles better. 3ds only supports triangles, so quads need to be split into two triangles. Instead of rather arbitrarily splitting along the diagonal between points 0 and 2, the script now splits along the shortest diagonal. This creates a higher quality triangular mesh, as well as better preservation of symmetry.
- Now creates an object node block, exporting object nodes, needed by some 3D importers. Among others, allows one to export object hierarchy.
- Now exports Empties as 3ds Dummies.
To be able to add all of the above new features, the script has been mostly rewritten and strongly restructured.
Motivation for the rewrite was the desire to be able to use Blender to produce custom 3d cars for Trackmania:Sunrise (TM:S). Previously, the TM:S importer could not correctly handle the 3ds files from the Blender 3ds export script. With this version, one can export cars complete with UV textures, correct wheel placement and light placement. To my knowledge, this script would make Blender the first fully free 3d modeller that allows one to export 3ds models for TM:S (expect a tutorial soon). The ability to have proper UV coordinates exported into the 3ds file should also be very welcome to many.
Add A Comment: Notepad
2006-05-02 11:26:32 +00:00
|
|
|
def __init__(self, val=0):
|
|
|
|
self.value=val
|
|
|
|
|
2005-12-15 01:42:45 +00:00
|
|
|
def get_size(self):
|
Commited 3ds export enhancements from Mark Stijnman (beowulff)
Will need to do some updates, Mesh over NMesh and optimize some areas but it works and is a big improvement.
from
https://projects.blender.org/tracker/index.php?func=detail&aid=4156&group_id=9&atid=127
Detailed description:
Modified the 3ds export script 3ds_export.py:
- It now exports face UV correctly. 3ds only supports one UV coordinate per vertex. The script now duplicates vertices that had multiple UV pairs assigned to them so that each duplicate now only contains one and only one UV. Faces have their vertex indices adjusted accordingly.
- Quads are now split into triangles better. 3ds only supports triangles, so quads need to be split into two triangles. Instead of rather arbitrarily splitting along the diagonal between points 0 and 2, the script now splits along the shortest diagonal. This creates a higher quality triangular mesh, as well as better preservation of symmetry.
- Now creates an object node block, exporting object nodes, needed by some 3D importers. Among others, allows one to export object hierarchy.
- Now exports Empties as 3ds Dummies.
To be able to add all of the above new features, the script has been mostly rewritten and strongly restructured.
Motivation for the rewrite was the desire to be able to use Blender to produce custom 3d cars for Trackmania:Sunrise (TM:S). Previously, the TM:S importer could not correctly handle the 3ds files from the Blender 3ds export script. With this version, one can export cars complete with UV textures, correct wheel placement and light placement. To my knowledge, this script would make Blender the first fully free 3d modeller that allows one to export 3ds models for TM:S (expect a tutorial soon). The ability to have proper UV coordinates exported into the 3ds file should also be very welcome to many.
Add A Comment: Notepad
2006-05-02 11:26:32 +00:00
|
|
|
return SZ_SHORT
|
2005-12-15 01:42:45 +00:00
|
|
|
|
Commited 3ds export enhancements from Mark Stijnman (beowulff)
Will need to do some updates, Mesh over NMesh and optimize some areas but it works and is a big improvement.
from
https://projects.blender.org/tracker/index.php?func=detail&aid=4156&group_id=9&atid=127
Detailed description:
Modified the 3ds export script 3ds_export.py:
- It now exports face UV correctly. 3ds only supports one UV coordinate per vertex. The script now duplicates vertices that had multiple UV pairs assigned to them so that each duplicate now only contains one and only one UV. Faces have their vertex indices adjusted accordingly.
- Quads are now split into triangles better. 3ds only supports triangles, so quads need to be split into two triangles. Instead of rather arbitrarily splitting along the diagonal between points 0 and 2, the script now splits along the shortest diagonal. This creates a higher quality triangular mesh, as well as better preservation of symmetry.
- Now creates an object node block, exporting object nodes, needed by some 3D importers. Among others, allows one to export object hierarchy.
- Now exports Empties as 3ds Dummies.
To be able to add all of the above new features, the script has been mostly rewritten and strongly restructured.
Motivation for the rewrite was the desire to be able to use Blender to produce custom 3d cars for Trackmania:Sunrise (TM:S). Previously, the TM:S importer could not correctly handle the 3ds files from the Blender 3ds export script. With this version, one can export cars complete with UV textures, correct wheel placement and light placement. To my knowledge, this script would make Blender the first fully free 3d modeller that allows one to export 3ds models for TM:S (expect a tutorial soon). The ability to have proper UV coordinates exported into the 3ds file should also be very welcome to many.
Add A Comment: Notepad
2006-05-02 11:26:32 +00:00
|
|
|
def write(self,file):
|
2007-01-04 20:44:33 +00:00
|
|
|
file.write(struct.pack("<H", self.value))
|
Commited 3ds export enhancements from Mark Stijnman (beowulff)
Will need to do some updates, Mesh over NMesh and optimize some areas but it works and is a big improvement.
from
https://projects.blender.org/tracker/index.php?func=detail&aid=4156&group_id=9&atid=127
Detailed description:
Modified the 3ds export script 3ds_export.py:
- It now exports face UV correctly. 3ds only supports one UV coordinate per vertex. The script now duplicates vertices that had multiple UV pairs assigned to them so that each duplicate now only contains one and only one UV. Faces have their vertex indices adjusted accordingly.
- Quads are now split into triangles better. 3ds only supports triangles, so quads need to be split into two triangles. Instead of rather arbitrarily splitting along the diagonal between points 0 and 2, the script now splits along the shortest diagonal. This creates a higher quality triangular mesh, as well as better preservation of symmetry.
- Now creates an object node block, exporting object nodes, needed by some 3D importers. Among others, allows one to export object hierarchy.
- Now exports Empties as 3ds Dummies.
To be able to add all of the above new features, the script has been mostly rewritten and strongly restructured.
Motivation for the rewrite was the desire to be able to use Blender to produce custom 3d cars for Trackmania:Sunrise (TM:S). Previously, the TM:S importer could not correctly handle the 3ds files from the Blender 3ds export script. With this version, one can export cars complete with UV textures, correct wheel placement and light placement. To my knowledge, this script would make Blender the first fully free 3d modeller that allows one to export 3ds models for TM:S (expect a tutorial soon). The ability to have proper UV coordinates exported into the 3ds file should also be very welcome to many.
Add A Comment: Notepad
2006-05-02 11:26:32 +00:00
|
|
|
|
|
|
|
def __str__(self):
|
|
|
|
return str(self.value)
|
2005-12-15 01:42:45 +00:00
|
|
|
|
2007-01-04 20:44:33 +00:00
|
|
|
class _3ds_int(object):
|
2006-07-05 07:10:03 +00:00
|
|
|
'''Class representing an int (4-byte integer) for a 3ds file.'''
|
2007-01-04 20:44:33 +00:00
|
|
|
__slots__ = 'value'
|
Commited 3ds export enhancements from Mark Stijnman (beowulff)
Will need to do some updates, Mesh over NMesh and optimize some areas but it works and is a big improvement.
from
https://projects.blender.org/tracker/index.php?func=detail&aid=4156&group_id=9&atid=127
Detailed description:
Modified the 3ds export script 3ds_export.py:
- It now exports face UV correctly. 3ds only supports one UV coordinate per vertex. The script now duplicates vertices that had multiple UV pairs assigned to them so that each duplicate now only contains one and only one UV. Faces have their vertex indices adjusted accordingly.
- Quads are now split into triangles better. 3ds only supports triangles, so quads need to be split into two triangles. Instead of rather arbitrarily splitting along the diagonal between points 0 and 2, the script now splits along the shortest diagonal. This creates a higher quality triangular mesh, as well as better preservation of symmetry.
- Now creates an object node block, exporting object nodes, needed by some 3D importers. Among others, allows one to export object hierarchy.
- Now exports Empties as 3ds Dummies.
To be able to add all of the above new features, the script has been mostly rewritten and strongly restructured.
Motivation for the rewrite was the desire to be able to use Blender to produce custom 3d cars for Trackmania:Sunrise (TM:S). Previously, the TM:S importer could not correctly handle the 3ds files from the Blender 3ds export script. With this version, one can export cars complete with UV textures, correct wheel placement and light placement. To my knowledge, this script would make Blender the first fully free 3d modeller that allows one to export 3ds models for TM:S (expect a tutorial soon). The ability to have proper UV coordinates exported into the 3ds file should also be very welcome to many.
Add A Comment: Notepad
2006-05-02 11:26:32 +00:00
|
|
|
def __init__(self, val=0):
|
|
|
|
self.value=val
|
2005-12-15 01:42:45 +00:00
|
|
|
|
|
|
|
def get_size(self):
|
Commited 3ds export enhancements from Mark Stijnman (beowulff)
Will need to do some updates, Mesh over NMesh and optimize some areas but it works and is a big improvement.
from
https://projects.blender.org/tracker/index.php?func=detail&aid=4156&group_id=9&atid=127
Detailed description:
Modified the 3ds export script 3ds_export.py:
- It now exports face UV correctly. 3ds only supports one UV coordinate per vertex. The script now duplicates vertices that had multiple UV pairs assigned to them so that each duplicate now only contains one and only one UV. Faces have their vertex indices adjusted accordingly.
- Quads are now split into triangles better. 3ds only supports triangles, so quads need to be split into two triangles. Instead of rather arbitrarily splitting along the diagonal between points 0 and 2, the script now splits along the shortest diagonal. This creates a higher quality triangular mesh, as well as better preservation of symmetry.
- Now creates an object node block, exporting object nodes, needed by some 3D importers. Among others, allows one to export object hierarchy.
- Now exports Empties as 3ds Dummies.
To be able to add all of the above new features, the script has been mostly rewritten and strongly restructured.
Motivation for the rewrite was the desire to be able to use Blender to produce custom 3d cars for Trackmania:Sunrise (TM:S). Previously, the TM:S importer could not correctly handle the 3ds files from the Blender 3ds export script. With this version, one can export cars complete with UV textures, correct wheel placement and light placement. To my knowledge, this script would make Blender the first fully free 3d modeller that allows one to export 3ds models for TM:S (expect a tutorial soon). The ability to have proper UV coordinates exported into the 3ds file should also be very welcome to many.
Add A Comment: Notepad
2006-05-02 11:26:32 +00:00
|
|
|
return SZ_INT
|
2005-12-15 01:42:45 +00:00
|
|
|
|
Commited 3ds export enhancements from Mark Stijnman (beowulff)
Will need to do some updates, Mesh over NMesh and optimize some areas but it works and is a big improvement.
from
https://projects.blender.org/tracker/index.php?func=detail&aid=4156&group_id=9&atid=127
Detailed description:
Modified the 3ds export script 3ds_export.py:
- It now exports face UV correctly. 3ds only supports one UV coordinate per vertex. The script now duplicates vertices that had multiple UV pairs assigned to them so that each duplicate now only contains one and only one UV. Faces have their vertex indices adjusted accordingly.
- Quads are now split into triangles better. 3ds only supports triangles, so quads need to be split into two triangles. Instead of rather arbitrarily splitting along the diagonal between points 0 and 2, the script now splits along the shortest diagonal. This creates a higher quality triangular mesh, as well as better preservation of symmetry.
- Now creates an object node block, exporting object nodes, needed by some 3D importers. Among others, allows one to export object hierarchy.
- Now exports Empties as 3ds Dummies.
To be able to add all of the above new features, the script has been mostly rewritten and strongly restructured.
Motivation for the rewrite was the desire to be able to use Blender to produce custom 3d cars for Trackmania:Sunrise (TM:S). Previously, the TM:S importer could not correctly handle the 3ds files from the Blender 3ds export script. With this version, one can export cars complete with UV textures, correct wheel placement and light placement. To my knowledge, this script would make Blender the first fully free 3d modeller that allows one to export 3ds models for TM:S (expect a tutorial soon). The ability to have proper UV coordinates exported into the 3ds file should also be very welcome to many.
Add A Comment: Notepad
2006-05-02 11:26:32 +00:00
|
|
|
def write(self,file):
|
2007-01-04 20:44:33 +00:00
|
|
|
file.write(struct.pack("<I", self.value))
|
Commited 3ds export enhancements from Mark Stijnman (beowulff)
Will need to do some updates, Mesh over NMesh and optimize some areas but it works and is a big improvement.
from
https://projects.blender.org/tracker/index.php?func=detail&aid=4156&group_id=9&atid=127
Detailed description:
Modified the 3ds export script 3ds_export.py:
- It now exports face UV correctly. 3ds only supports one UV coordinate per vertex. The script now duplicates vertices that had multiple UV pairs assigned to them so that each duplicate now only contains one and only one UV. Faces have their vertex indices adjusted accordingly.
- Quads are now split into triangles better. 3ds only supports triangles, so quads need to be split into two triangles. Instead of rather arbitrarily splitting along the diagonal between points 0 and 2, the script now splits along the shortest diagonal. This creates a higher quality triangular mesh, as well as better preservation of symmetry.
- Now creates an object node block, exporting object nodes, needed by some 3D importers. Among others, allows one to export object hierarchy.
- Now exports Empties as 3ds Dummies.
To be able to add all of the above new features, the script has been mostly rewritten and strongly restructured.
Motivation for the rewrite was the desire to be able to use Blender to produce custom 3d cars for Trackmania:Sunrise (TM:S). Previously, the TM:S importer could not correctly handle the 3ds files from the Blender 3ds export script. With this version, one can export cars complete with UV textures, correct wheel placement and light placement. To my knowledge, this script would make Blender the first fully free 3d modeller that allows one to export 3ds models for TM:S (expect a tutorial soon). The ability to have proper UV coordinates exported into the 3ds file should also be very welcome to many.
Add A Comment: Notepad
2006-05-02 11:26:32 +00:00
|
|
|
|
|
|
|
def __str__(self):
|
|
|
|
return str(self.value)
|
2005-12-15 01:42:45 +00:00
|
|
|
|
2007-01-04 20:44:33 +00:00
|
|
|
class _3ds_float(object):
|
2006-07-05 07:10:03 +00:00
|
|
|
'''Class representing a 4-byte IEEE floating point number for a 3ds file.'''
|
2007-01-04 20:44:33 +00:00
|
|
|
__slots__ = 'value'
|
Commited 3ds export enhancements from Mark Stijnman (beowulff)
Will need to do some updates, Mesh over NMesh and optimize some areas but it works and is a big improvement.
from
https://projects.blender.org/tracker/index.php?func=detail&aid=4156&group_id=9&atid=127
Detailed description:
Modified the 3ds export script 3ds_export.py:
- It now exports face UV correctly. 3ds only supports one UV coordinate per vertex. The script now duplicates vertices that had multiple UV pairs assigned to them so that each duplicate now only contains one and only one UV. Faces have their vertex indices adjusted accordingly.
- Quads are now split into triangles better. 3ds only supports triangles, so quads need to be split into two triangles. Instead of rather arbitrarily splitting along the diagonal between points 0 and 2, the script now splits along the shortest diagonal. This creates a higher quality triangular mesh, as well as better preservation of symmetry.
- Now creates an object node block, exporting object nodes, needed by some 3D importers. Among others, allows one to export object hierarchy.
- Now exports Empties as 3ds Dummies.
To be able to add all of the above new features, the script has been mostly rewritten and strongly restructured.
Motivation for the rewrite was the desire to be able to use Blender to produce custom 3d cars for Trackmania:Sunrise (TM:S). Previously, the TM:S importer could not correctly handle the 3ds files from the Blender 3ds export script. With this version, one can export cars complete with UV textures, correct wheel placement and light placement. To my knowledge, this script would make Blender the first fully free 3d modeller that allows one to export 3ds models for TM:S (expect a tutorial soon). The ability to have proper UV coordinates exported into the 3ds file should also be very welcome to many.
Add A Comment: Notepad
2006-05-02 11:26:32 +00:00
|
|
|
def __init__(self, val=0.0):
|
|
|
|
self.value=val
|
|
|
|
|
2005-12-15 01:42:45 +00:00
|
|
|
def get_size(self):
|
Commited 3ds export enhancements from Mark Stijnman (beowulff)
Will need to do some updates, Mesh over NMesh and optimize some areas but it works and is a big improvement.
from
https://projects.blender.org/tracker/index.php?func=detail&aid=4156&group_id=9&atid=127
Detailed description:
Modified the 3ds export script 3ds_export.py:
- It now exports face UV correctly. 3ds only supports one UV coordinate per vertex. The script now duplicates vertices that had multiple UV pairs assigned to them so that each duplicate now only contains one and only one UV. Faces have their vertex indices adjusted accordingly.
- Quads are now split into triangles better. 3ds only supports triangles, so quads need to be split into two triangles. Instead of rather arbitrarily splitting along the diagonal between points 0 and 2, the script now splits along the shortest diagonal. This creates a higher quality triangular mesh, as well as better preservation of symmetry.
- Now creates an object node block, exporting object nodes, needed by some 3D importers. Among others, allows one to export object hierarchy.
- Now exports Empties as 3ds Dummies.
To be able to add all of the above new features, the script has been mostly rewritten and strongly restructured.
Motivation for the rewrite was the desire to be able to use Blender to produce custom 3d cars for Trackmania:Sunrise (TM:S). Previously, the TM:S importer could not correctly handle the 3ds files from the Blender 3ds export script. With this version, one can export cars complete with UV textures, correct wheel placement and light placement. To my knowledge, this script would make Blender the first fully free 3d modeller that allows one to export 3ds models for TM:S (expect a tutorial soon). The ability to have proper UV coordinates exported into the 3ds file should also be very welcome to many.
Add A Comment: Notepad
2006-05-02 11:26:32 +00:00
|
|
|
return SZ_FLOAT
|
2005-12-15 01:42:45 +00:00
|
|
|
|
Commited 3ds export enhancements from Mark Stijnman (beowulff)
Will need to do some updates, Mesh over NMesh and optimize some areas but it works and is a big improvement.
from
https://projects.blender.org/tracker/index.php?func=detail&aid=4156&group_id=9&atid=127
Detailed description:
Modified the 3ds export script 3ds_export.py:
- It now exports face UV correctly. 3ds only supports one UV coordinate per vertex. The script now duplicates vertices that had multiple UV pairs assigned to them so that each duplicate now only contains one and only one UV. Faces have their vertex indices adjusted accordingly.
- Quads are now split into triangles better. 3ds only supports triangles, so quads need to be split into two triangles. Instead of rather arbitrarily splitting along the diagonal between points 0 and 2, the script now splits along the shortest diagonal. This creates a higher quality triangular mesh, as well as better preservation of symmetry.
- Now creates an object node block, exporting object nodes, needed by some 3D importers. Among others, allows one to export object hierarchy.
- Now exports Empties as 3ds Dummies.
To be able to add all of the above new features, the script has been mostly rewritten and strongly restructured.
Motivation for the rewrite was the desire to be able to use Blender to produce custom 3d cars for Trackmania:Sunrise (TM:S). Previously, the TM:S importer could not correctly handle the 3ds files from the Blender 3ds export script. With this version, one can export cars complete with UV textures, correct wheel placement and light placement. To my knowledge, this script would make Blender the first fully free 3d modeller that allows one to export 3ds models for TM:S (expect a tutorial soon). The ability to have proper UV coordinates exported into the 3ds file should also be very welcome to many.
Add A Comment: Notepad
2006-05-02 11:26:32 +00:00
|
|
|
def write(self,file):
|
2007-01-04 20:44:33 +00:00
|
|
|
file.write(struct.pack("<f", self.value))
|
Commited 3ds export enhancements from Mark Stijnman (beowulff)
Will need to do some updates, Mesh over NMesh and optimize some areas but it works and is a big improvement.
from
https://projects.blender.org/tracker/index.php?func=detail&aid=4156&group_id=9&atid=127
Detailed description:
Modified the 3ds export script 3ds_export.py:
- It now exports face UV correctly. 3ds only supports one UV coordinate per vertex. The script now duplicates vertices that had multiple UV pairs assigned to them so that each duplicate now only contains one and only one UV. Faces have their vertex indices adjusted accordingly.
- Quads are now split into triangles better. 3ds only supports triangles, so quads need to be split into two triangles. Instead of rather arbitrarily splitting along the diagonal between points 0 and 2, the script now splits along the shortest diagonal. This creates a higher quality triangular mesh, as well as better preservation of symmetry.
- Now creates an object node block, exporting object nodes, needed by some 3D importers. Among others, allows one to export object hierarchy.
- Now exports Empties as 3ds Dummies.
To be able to add all of the above new features, the script has been mostly rewritten and strongly restructured.
Motivation for the rewrite was the desire to be able to use Blender to produce custom 3d cars for Trackmania:Sunrise (TM:S). Previously, the TM:S importer could not correctly handle the 3ds files from the Blender 3ds export script. With this version, one can export cars complete with UV textures, correct wheel placement and light placement. To my knowledge, this script would make Blender the first fully free 3d modeller that allows one to export 3ds models for TM:S (expect a tutorial soon). The ability to have proper UV coordinates exported into the 3ds file should also be very welcome to many.
Add A Comment: Notepad
2006-05-02 11:26:32 +00:00
|
|
|
|
|
|
|
def __str__(self):
|
|
|
|
return str(self.value)
|
2005-12-15 01:42:45 +00:00
|
|
|
|
|
|
|
|
2007-01-04 20:44:33 +00:00
|
|
|
class _3ds_string(object):
|
2006-07-05 07:10:03 +00:00
|
|
|
'''Class representing a zero-terminated string for a 3ds file.'''
|
2007-01-04 20:44:33 +00:00
|
|
|
__slots__ = 'value'
|
Commited 3ds export enhancements from Mark Stijnman (beowulff)
Will need to do some updates, Mesh over NMesh and optimize some areas but it works and is a big improvement.
from
https://projects.blender.org/tracker/index.php?func=detail&aid=4156&group_id=9&atid=127
Detailed description:
Modified the 3ds export script 3ds_export.py:
- It now exports face UV correctly. 3ds only supports one UV coordinate per vertex. The script now duplicates vertices that had multiple UV pairs assigned to them so that each duplicate now only contains one and only one UV. Faces have their vertex indices adjusted accordingly.
- Quads are now split into triangles better. 3ds only supports triangles, so quads need to be split into two triangles. Instead of rather arbitrarily splitting along the diagonal between points 0 and 2, the script now splits along the shortest diagonal. This creates a higher quality triangular mesh, as well as better preservation of symmetry.
- Now creates an object node block, exporting object nodes, needed by some 3D importers. Among others, allows one to export object hierarchy.
- Now exports Empties as 3ds Dummies.
To be able to add all of the above new features, the script has been mostly rewritten and strongly restructured.
Motivation for the rewrite was the desire to be able to use Blender to produce custom 3d cars for Trackmania:Sunrise (TM:S). Previously, the TM:S importer could not correctly handle the 3ds files from the Blender 3ds export script. With this version, one can export cars complete with UV textures, correct wheel placement and light placement. To my knowledge, this script would make Blender the first fully free 3d modeller that allows one to export 3ds models for TM:S (expect a tutorial soon). The ability to have proper UV coordinates exported into the 3ds file should also be very welcome to many.
Add A Comment: Notepad
2006-05-02 11:26:32 +00:00
|
|
|
def __init__(self, val=""):
|
|
|
|
self.value=val
|
|
|
|
|
2005-12-15 01:42:45 +00:00
|
|
|
def get_size(self):
|
Commited 3ds export enhancements from Mark Stijnman (beowulff)
Will need to do some updates, Mesh over NMesh and optimize some areas but it works and is a big improvement.
from
https://projects.blender.org/tracker/index.php?func=detail&aid=4156&group_id=9&atid=127
Detailed description:
Modified the 3ds export script 3ds_export.py:
- It now exports face UV correctly. 3ds only supports one UV coordinate per vertex. The script now duplicates vertices that had multiple UV pairs assigned to them so that each duplicate now only contains one and only one UV. Faces have their vertex indices adjusted accordingly.
- Quads are now split into triangles better. 3ds only supports triangles, so quads need to be split into two triangles. Instead of rather arbitrarily splitting along the diagonal between points 0 and 2, the script now splits along the shortest diagonal. This creates a higher quality triangular mesh, as well as better preservation of symmetry.
- Now creates an object node block, exporting object nodes, needed by some 3D importers. Among others, allows one to export object hierarchy.
- Now exports Empties as 3ds Dummies.
To be able to add all of the above new features, the script has been mostly rewritten and strongly restructured.
Motivation for the rewrite was the desire to be able to use Blender to produce custom 3d cars for Trackmania:Sunrise (TM:S). Previously, the TM:S importer could not correctly handle the 3ds files from the Blender 3ds export script. With this version, one can export cars complete with UV textures, correct wheel placement and light placement. To my knowledge, this script would make Blender the first fully free 3d modeller that allows one to export 3ds models for TM:S (expect a tutorial soon). The ability to have proper UV coordinates exported into the 3ds file should also be very welcome to many.
Add A Comment: Notepad
2006-05-02 11:26:32 +00:00
|
|
|
return (len(self.value)+1)
|
2005-12-15 01:42:45 +00:00
|
|
|
|
Commited 3ds export enhancements from Mark Stijnman (beowulff)
Will need to do some updates, Mesh over NMesh and optimize some areas but it works and is a big improvement.
from
https://projects.blender.org/tracker/index.php?func=detail&aid=4156&group_id=9&atid=127
Detailed description:
Modified the 3ds export script 3ds_export.py:
- It now exports face UV correctly. 3ds only supports one UV coordinate per vertex. The script now duplicates vertices that had multiple UV pairs assigned to them so that each duplicate now only contains one and only one UV. Faces have their vertex indices adjusted accordingly.
- Quads are now split into triangles better. 3ds only supports triangles, so quads need to be split into two triangles. Instead of rather arbitrarily splitting along the diagonal between points 0 and 2, the script now splits along the shortest diagonal. This creates a higher quality triangular mesh, as well as better preservation of symmetry.
- Now creates an object node block, exporting object nodes, needed by some 3D importers. Among others, allows one to export object hierarchy.
- Now exports Empties as 3ds Dummies.
To be able to add all of the above new features, the script has been mostly rewritten and strongly restructured.
Motivation for the rewrite was the desire to be able to use Blender to produce custom 3d cars for Trackmania:Sunrise (TM:S). Previously, the TM:S importer could not correctly handle the 3ds files from the Blender 3ds export script. With this version, one can export cars complete with UV textures, correct wheel placement and light placement. To my knowledge, this script would make Blender the first fully free 3d modeller that allows one to export 3ds models for TM:S (expect a tutorial soon). The ability to have proper UV coordinates exported into the 3ds file should also be very welcome to many.
Add A Comment: Notepad
2006-05-02 11:26:32 +00:00
|
|
|
def write(self,file):
|
|
|
|
binary_format = "<%ds" % (len(self.value)+1)
|
2007-01-04 20:44:33 +00:00
|
|
|
file.write(struct.pack(binary_format, self.value))
|
Commited 3ds export enhancements from Mark Stijnman (beowulff)
Will need to do some updates, Mesh over NMesh and optimize some areas but it works and is a big improvement.
from
https://projects.blender.org/tracker/index.php?func=detail&aid=4156&group_id=9&atid=127
Detailed description:
Modified the 3ds export script 3ds_export.py:
- It now exports face UV correctly. 3ds only supports one UV coordinate per vertex. The script now duplicates vertices that had multiple UV pairs assigned to them so that each duplicate now only contains one and only one UV. Faces have their vertex indices adjusted accordingly.
- Quads are now split into triangles better. 3ds only supports triangles, so quads need to be split into two triangles. Instead of rather arbitrarily splitting along the diagonal between points 0 and 2, the script now splits along the shortest diagonal. This creates a higher quality triangular mesh, as well as better preservation of symmetry.
- Now creates an object node block, exporting object nodes, needed by some 3D importers. Among others, allows one to export object hierarchy.
- Now exports Empties as 3ds Dummies.
To be able to add all of the above new features, the script has been mostly rewritten and strongly restructured.
Motivation for the rewrite was the desire to be able to use Blender to produce custom 3d cars for Trackmania:Sunrise (TM:S). Previously, the TM:S importer could not correctly handle the 3ds files from the Blender 3ds export script. With this version, one can export cars complete with UV textures, correct wheel placement and light placement. To my knowledge, this script would make Blender the first fully free 3d modeller that allows one to export 3ds models for TM:S (expect a tutorial soon). The ability to have proper UV coordinates exported into the 3ds file should also be very welcome to many.
Add A Comment: Notepad
2006-05-02 11:26:32 +00:00
|
|
|
|
|
|
|
def __str__(self):
|
|
|
|
return self.value
|
2005-12-15 01:42:45 +00:00
|
|
|
|
2007-01-04 20:44:33 +00:00
|
|
|
class _3ds_point_3d(object):
|
2006-07-05 07:10:03 +00:00
|
|
|
'''Class representing a three-dimensional point for a 3ds file.'''
|
2007-01-04 20:44:33 +00:00
|
|
|
__slots__ = 'x','y','z'
|
Commited 3ds export enhancements from Mark Stijnman (beowulff)
Will need to do some updates, Mesh over NMesh and optimize some areas but it works and is a big improvement.
from
https://projects.blender.org/tracker/index.php?func=detail&aid=4156&group_id=9&atid=127
Detailed description:
Modified the 3ds export script 3ds_export.py:
- It now exports face UV correctly. 3ds only supports one UV coordinate per vertex. The script now duplicates vertices that had multiple UV pairs assigned to them so that each duplicate now only contains one and only one UV. Faces have their vertex indices adjusted accordingly.
- Quads are now split into triangles better. 3ds only supports triangles, so quads need to be split into two triangles. Instead of rather arbitrarily splitting along the diagonal between points 0 and 2, the script now splits along the shortest diagonal. This creates a higher quality triangular mesh, as well as better preservation of symmetry.
- Now creates an object node block, exporting object nodes, needed by some 3D importers. Among others, allows one to export object hierarchy.
- Now exports Empties as 3ds Dummies.
To be able to add all of the above new features, the script has been mostly rewritten and strongly restructured.
Motivation for the rewrite was the desire to be able to use Blender to produce custom 3d cars for Trackmania:Sunrise (TM:S). Previously, the TM:S importer could not correctly handle the 3ds files from the Blender 3ds export script. With this version, one can export cars complete with UV textures, correct wheel placement and light placement. To my knowledge, this script would make Blender the first fully free 3d modeller that allows one to export 3ds models for TM:S (expect a tutorial soon). The ability to have proper UV coordinates exported into the 3ds file should also be very welcome to many.
Add A Comment: Notepad
2006-05-02 11:26:32 +00:00
|
|
|
def __init__(self, point=(0.0,0.0,0.0)):
|
|
|
|
self.x, self.y, self.z = point
|
|
|
|
|
2005-12-15 01:42:45 +00:00
|
|
|
def get_size(self):
|
Commited 3ds export enhancements from Mark Stijnman (beowulff)
Will need to do some updates, Mesh over NMesh and optimize some areas but it works and is a big improvement.
from
https://projects.blender.org/tracker/index.php?func=detail&aid=4156&group_id=9&atid=127
Detailed description:
Modified the 3ds export script 3ds_export.py:
- It now exports face UV correctly. 3ds only supports one UV coordinate per vertex. The script now duplicates vertices that had multiple UV pairs assigned to them so that each duplicate now only contains one and only one UV. Faces have their vertex indices adjusted accordingly.
- Quads are now split into triangles better. 3ds only supports triangles, so quads need to be split into two triangles. Instead of rather arbitrarily splitting along the diagonal between points 0 and 2, the script now splits along the shortest diagonal. This creates a higher quality triangular mesh, as well as better preservation of symmetry.
- Now creates an object node block, exporting object nodes, needed by some 3D importers. Among others, allows one to export object hierarchy.
- Now exports Empties as 3ds Dummies.
To be able to add all of the above new features, the script has been mostly rewritten and strongly restructured.
Motivation for the rewrite was the desire to be able to use Blender to produce custom 3d cars for Trackmania:Sunrise (TM:S). Previously, the TM:S importer could not correctly handle the 3ds files from the Blender 3ds export script. With this version, one can export cars complete with UV textures, correct wheel placement and light placement. To my knowledge, this script would make Blender the first fully free 3d modeller that allows one to export 3ds models for TM:S (expect a tutorial soon). The ability to have proper UV coordinates exported into the 3ds file should also be very welcome to many.
Add A Comment: Notepad
2006-05-02 11:26:32 +00:00
|
|
|
return 3*SZ_FLOAT
|
2005-12-15 01:42:45 +00:00
|
|
|
|
Commited 3ds export enhancements from Mark Stijnman (beowulff)
Will need to do some updates, Mesh over NMesh and optimize some areas but it works and is a big improvement.
from
https://projects.blender.org/tracker/index.php?func=detail&aid=4156&group_id=9&atid=127
Detailed description:
Modified the 3ds export script 3ds_export.py:
- It now exports face UV correctly. 3ds only supports one UV coordinate per vertex. The script now duplicates vertices that had multiple UV pairs assigned to them so that each duplicate now only contains one and only one UV. Faces have their vertex indices adjusted accordingly.
- Quads are now split into triangles better. 3ds only supports triangles, so quads need to be split into two triangles. Instead of rather arbitrarily splitting along the diagonal between points 0 and 2, the script now splits along the shortest diagonal. This creates a higher quality triangular mesh, as well as better preservation of symmetry.
- Now creates an object node block, exporting object nodes, needed by some 3D importers. Among others, allows one to export object hierarchy.
- Now exports Empties as 3ds Dummies.
To be able to add all of the above new features, the script has been mostly rewritten and strongly restructured.
Motivation for the rewrite was the desire to be able to use Blender to produce custom 3d cars for Trackmania:Sunrise (TM:S). Previously, the TM:S importer could not correctly handle the 3ds files from the Blender 3ds export script. With this version, one can export cars complete with UV textures, correct wheel placement and light placement. To my knowledge, this script would make Blender the first fully free 3d modeller that allows one to export 3ds models for TM:S (expect a tutorial soon). The ability to have proper UV coordinates exported into the 3ds file should also be very welcome to many.
Add A Comment: Notepad
2006-05-02 11:26:32 +00:00
|
|
|
def write(self,file):
|
2007-01-04 20:44:33 +00:00
|
|
|
file.write(struct.pack('<3f', self.x, self.y, self.z))
|
Commited 3ds export enhancements from Mark Stijnman (beowulff)
Will need to do some updates, Mesh over NMesh and optimize some areas but it works and is a big improvement.
from
https://projects.blender.org/tracker/index.php?func=detail&aid=4156&group_id=9&atid=127
Detailed description:
Modified the 3ds export script 3ds_export.py:
- It now exports face UV correctly. 3ds only supports one UV coordinate per vertex. The script now duplicates vertices that had multiple UV pairs assigned to them so that each duplicate now only contains one and only one UV. Faces have their vertex indices adjusted accordingly.
- Quads are now split into triangles better. 3ds only supports triangles, so quads need to be split into two triangles. Instead of rather arbitrarily splitting along the diagonal between points 0 and 2, the script now splits along the shortest diagonal. This creates a higher quality triangular mesh, as well as better preservation of symmetry.
- Now creates an object node block, exporting object nodes, needed by some 3D importers. Among others, allows one to export object hierarchy.
- Now exports Empties as 3ds Dummies.
To be able to add all of the above new features, the script has been mostly rewritten and strongly restructured.
Motivation for the rewrite was the desire to be able to use Blender to produce custom 3d cars for Trackmania:Sunrise (TM:S). Previously, the TM:S importer could not correctly handle the 3ds files from the Blender 3ds export script. With this version, one can export cars complete with UV textures, correct wheel placement and light placement. To my knowledge, this script would make Blender the first fully free 3d modeller that allows one to export 3ds models for TM:S (expect a tutorial soon). The ability to have proper UV coordinates exported into the 3ds file should also be very welcome to many.
Add A Comment: Notepad
2006-05-02 11:26:32 +00:00
|
|
|
|
|
|
|
def __str__(self):
|
|
|
|
return '(%f, %f, %f)' % (self.x, self.y, self.z)
|
2007-05-06 02:19:43 +00:00
|
|
|
|
|
|
|
# Used for writing a track
|
|
|
|
"""
|
2007-01-04 20:44:33 +00:00
|
|
|
class _3ds_point_4d(object):
|
2006-07-05 07:10:03 +00:00
|
|
|
'''Class representing a four-dimensional point for a 3ds file, for instance a quaternion.'''
|
2007-01-04 20:44:33 +00:00
|
|
|
__slots__ = 'x','y','z','w'
|
Commited 3ds export enhancements from Mark Stijnman (beowulff)
Will need to do some updates, Mesh over NMesh and optimize some areas but it works and is a big improvement.
from
https://projects.blender.org/tracker/index.php?func=detail&aid=4156&group_id=9&atid=127
Detailed description:
Modified the 3ds export script 3ds_export.py:
- It now exports face UV correctly. 3ds only supports one UV coordinate per vertex. The script now duplicates vertices that had multiple UV pairs assigned to them so that each duplicate now only contains one and only one UV. Faces have their vertex indices adjusted accordingly.
- Quads are now split into triangles better. 3ds only supports triangles, so quads need to be split into two triangles. Instead of rather arbitrarily splitting along the diagonal between points 0 and 2, the script now splits along the shortest diagonal. This creates a higher quality triangular mesh, as well as better preservation of symmetry.
- Now creates an object node block, exporting object nodes, needed by some 3D importers. Among others, allows one to export object hierarchy.
- Now exports Empties as 3ds Dummies.
To be able to add all of the above new features, the script has been mostly rewritten and strongly restructured.
Motivation for the rewrite was the desire to be able to use Blender to produce custom 3d cars for Trackmania:Sunrise (TM:S). Previously, the TM:S importer could not correctly handle the 3ds files from the Blender 3ds export script. With this version, one can export cars complete with UV textures, correct wheel placement and light placement. To my knowledge, this script would make Blender the first fully free 3d modeller that allows one to export 3ds models for TM:S (expect a tutorial soon). The ability to have proper UV coordinates exported into the 3ds file should also be very welcome to many.
Add A Comment: Notepad
2006-05-02 11:26:32 +00:00
|
|
|
def __init__(self, point=(0.0,0.0,0.0,0.0)):
|
|
|
|
self.x, self.y, self.z, self.w = point
|
|
|
|
|
2005-12-15 01:42:45 +00:00
|
|
|
def get_size(self):
|
Commited 3ds export enhancements from Mark Stijnman (beowulff)
Will need to do some updates, Mesh over NMesh and optimize some areas but it works and is a big improvement.
from
https://projects.blender.org/tracker/index.php?func=detail&aid=4156&group_id=9&atid=127
Detailed description:
Modified the 3ds export script 3ds_export.py:
- It now exports face UV correctly. 3ds only supports one UV coordinate per vertex. The script now duplicates vertices that had multiple UV pairs assigned to them so that each duplicate now only contains one and only one UV. Faces have their vertex indices adjusted accordingly.
- Quads are now split into triangles better. 3ds only supports triangles, so quads need to be split into two triangles. Instead of rather arbitrarily splitting along the diagonal between points 0 and 2, the script now splits along the shortest diagonal. This creates a higher quality triangular mesh, as well as better preservation of symmetry.
- Now creates an object node block, exporting object nodes, needed by some 3D importers. Among others, allows one to export object hierarchy.
- Now exports Empties as 3ds Dummies.
To be able to add all of the above new features, the script has been mostly rewritten and strongly restructured.
Motivation for the rewrite was the desire to be able to use Blender to produce custom 3d cars for Trackmania:Sunrise (TM:S). Previously, the TM:S importer could not correctly handle the 3ds files from the Blender 3ds export script. With this version, one can export cars complete with UV textures, correct wheel placement and light placement. To my knowledge, this script would make Blender the first fully free 3d modeller that allows one to export 3ds models for TM:S (expect a tutorial soon). The ability to have proper UV coordinates exported into the 3ds file should also be very welcome to many.
Add A Comment: Notepad
2006-05-02 11:26:32 +00:00
|
|
|
return 4*SZ_FLOAT
|
2005-12-15 01:42:45 +00:00
|
|
|
|
Commited 3ds export enhancements from Mark Stijnman (beowulff)
Will need to do some updates, Mesh over NMesh and optimize some areas but it works and is a big improvement.
from
https://projects.blender.org/tracker/index.php?func=detail&aid=4156&group_id=9&atid=127
Detailed description:
Modified the 3ds export script 3ds_export.py:
- It now exports face UV correctly. 3ds only supports one UV coordinate per vertex. The script now duplicates vertices that had multiple UV pairs assigned to them so that each duplicate now only contains one and only one UV. Faces have their vertex indices adjusted accordingly.
- Quads are now split into triangles better. 3ds only supports triangles, so quads need to be split into two triangles. Instead of rather arbitrarily splitting along the diagonal between points 0 and 2, the script now splits along the shortest diagonal. This creates a higher quality triangular mesh, as well as better preservation of symmetry.
- Now creates an object node block, exporting object nodes, needed by some 3D importers. Among others, allows one to export object hierarchy.
- Now exports Empties as 3ds Dummies.
To be able to add all of the above new features, the script has been mostly rewritten and strongly restructured.
Motivation for the rewrite was the desire to be able to use Blender to produce custom 3d cars for Trackmania:Sunrise (TM:S). Previously, the TM:S importer could not correctly handle the 3ds files from the Blender 3ds export script. With this version, one can export cars complete with UV textures, correct wheel placement and light placement. To my knowledge, this script would make Blender the first fully free 3d modeller that allows one to export 3ds models for TM:S (expect a tutorial soon). The ability to have proper UV coordinates exported into the 3ds file should also be very welcome to many.
Add A Comment: Notepad
2006-05-02 11:26:32 +00:00
|
|
|
def write(self,file):
|
2006-07-05 07:10:03 +00:00
|
|
|
data=struct.pack('<4f', self.x, self.y, self.z, self.w)
|
2005-12-15 01:42:45 +00:00
|
|
|
file.write(data)
|
|
|
|
|
Commited 3ds export enhancements from Mark Stijnman (beowulff)
Will need to do some updates, Mesh over NMesh and optimize some areas but it works and is a big improvement.
from
https://projects.blender.org/tracker/index.php?func=detail&aid=4156&group_id=9&atid=127
Detailed description:
Modified the 3ds export script 3ds_export.py:
- It now exports face UV correctly. 3ds only supports one UV coordinate per vertex. The script now duplicates vertices that had multiple UV pairs assigned to them so that each duplicate now only contains one and only one UV. Faces have their vertex indices adjusted accordingly.
- Quads are now split into triangles better. 3ds only supports triangles, so quads need to be split into two triangles. Instead of rather arbitrarily splitting along the diagonal between points 0 and 2, the script now splits along the shortest diagonal. This creates a higher quality triangular mesh, as well as better preservation of symmetry.
- Now creates an object node block, exporting object nodes, needed by some 3D importers. Among others, allows one to export object hierarchy.
- Now exports Empties as 3ds Dummies.
To be able to add all of the above new features, the script has been mostly rewritten and strongly restructured.
Motivation for the rewrite was the desire to be able to use Blender to produce custom 3d cars for Trackmania:Sunrise (TM:S). Previously, the TM:S importer could not correctly handle the 3ds files from the Blender 3ds export script. With this version, one can export cars complete with UV textures, correct wheel placement and light placement. To my knowledge, this script would make Blender the first fully free 3d modeller that allows one to export 3ds models for TM:S (expect a tutorial soon). The ability to have proper UV coordinates exported into the 3ds file should also be very welcome to many.
Add A Comment: Notepad
2006-05-02 11:26:32 +00:00
|
|
|
def __str__(self):
|
|
|
|
return '(%f, %f, %f, %f)' % (self.x, self.y, self.z, self.w)
|
2007-05-06 02:19:43 +00:00
|
|
|
"""
|
|
|
|
|
2007-01-04 20:44:33 +00:00
|
|
|
class _3ds_point_uv(object):
|
2006-07-05 07:10:03 +00:00
|
|
|
'''Class representing a UV-coordinate for a 3ds file.'''
|
2007-01-04 20:44:33 +00:00
|
|
|
__slots__ = 'uv'
|
Commited 3ds export enhancements from Mark Stijnman (beowulff)
Will need to do some updates, Mesh over NMesh and optimize some areas but it works and is a big improvement.
from
https://projects.blender.org/tracker/index.php?func=detail&aid=4156&group_id=9&atid=127
Detailed description:
Modified the 3ds export script 3ds_export.py:
- It now exports face UV correctly. 3ds only supports one UV coordinate per vertex. The script now duplicates vertices that had multiple UV pairs assigned to them so that each duplicate now only contains one and only one UV. Faces have their vertex indices adjusted accordingly.
- Quads are now split into triangles better. 3ds only supports triangles, so quads need to be split into two triangles. Instead of rather arbitrarily splitting along the diagonal between points 0 and 2, the script now splits along the shortest diagonal. This creates a higher quality triangular mesh, as well as better preservation of symmetry.
- Now creates an object node block, exporting object nodes, needed by some 3D importers. Among others, allows one to export object hierarchy.
- Now exports Empties as 3ds Dummies.
To be able to add all of the above new features, the script has been mostly rewritten and strongly restructured.
Motivation for the rewrite was the desire to be able to use Blender to produce custom 3d cars for Trackmania:Sunrise (TM:S). Previously, the TM:S importer could not correctly handle the 3ds files from the Blender 3ds export script. With this version, one can export cars complete with UV textures, correct wheel placement and light placement. To my knowledge, this script would make Blender the first fully free 3d modeller that allows one to export 3ds models for TM:S (expect a tutorial soon). The ability to have proper UV coordinates exported into the 3ds file should also be very welcome to many.
Add A Comment: Notepad
2006-05-02 11:26:32 +00:00
|
|
|
def __init__(self, point=(0.0,0.0)):
|
|
|
|
self.uv = point
|
|
|
|
|
|
|
|
def __cmp__(self, other):
|
|
|
|
return cmp(self.uv,other.uv)
|
|
|
|
|
2005-12-15 01:42:45 +00:00
|
|
|
def get_size(self):
|
Commited 3ds export enhancements from Mark Stijnman (beowulff)
Will need to do some updates, Mesh over NMesh and optimize some areas but it works and is a big improvement.
from
https://projects.blender.org/tracker/index.php?func=detail&aid=4156&group_id=9&atid=127
Detailed description:
Modified the 3ds export script 3ds_export.py:
- It now exports face UV correctly. 3ds only supports one UV coordinate per vertex. The script now duplicates vertices that had multiple UV pairs assigned to them so that each duplicate now only contains one and only one UV. Faces have their vertex indices adjusted accordingly.
- Quads are now split into triangles better. 3ds only supports triangles, so quads need to be split into two triangles. Instead of rather arbitrarily splitting along the diagonal between points 0 and 2, the script now splits along the shortest diagonal. This creates a higher quality triangular mesh, as well as better preservation of symmetry.
- Now creates an object node block, exporting object nodes, needed by some 3D importers. Among others, allows one to export object hierarchy.
- Now exports Empties as 3ds Dummies.
To be able to add all of the above new features, the script has been mostly rewritten and strongly restructured.
Motivation for the rewrite was the desire to be able to use Blender to produce custom 3d cars for Trackmania:Sunrise (TM:S). Previously, the TM:S importer could not correctly handle the 3ds files from the Blender 3ds export script. With this version, one can export cars complete with UV textures, correct wheel placement and light placement. To my knowledge, this script would make Blender the first fully free 3d modeller that allows one to export 3ds models for TM:S (expect a tutorial soon). The ability to have proper UV coordinates exported into the 3ds file should also be very welcome to many.
Add A Comment: Notepad
2006-05-02 11:26:32 +00:00
|
|
|
return 2*SZ_FLOAT
|
|
|
|
|
|
|
|
def write(self,file):
|
2006-07-05 07:10:03 +00:00
|
|
|
data=struct.pack('<2f', self.uv[0], self.uv[1])
|
Commited 3ds export enhancements from Mark Stijnman (beowulff)
Will need to do some updates, Mesh over NMesh and optimize some areas but it works and is a big improvement.
from
https://projects.blender.org/tracker/index.php?func=detail&aid=4156&group_id=9&atid=127
Detailed description:
Modified the 3ds export script 3ds_export.py:
- It now exports face UV correctly. 3ds only supports one UV coordinate per vertex. The script now duplicates vertices that had multiple UV pairs assigned to them so that each duplicate now only contains one and only one UV. Faces have their vertex indices adjusted accordingly.
- Quads are now split into triangles better. 3ds only supports triangles, so quads need to be split into two triangles. Instead of rather arbitrarily splitting along the diagonal between points 0 and 2, the script now splits along the shortest diagonal. This creates a higher quality triangular mesh, as well as better preservation of symmetry.
- Now creates an object node block, exporting object nodes, needed by some 3D importers. Among others, allows one to export object hierarchy.
- Now exports Empties as 3ds Dummies.
To be able to add all of the above new features, the script has been mostly rewritten and strongly restructured.
Motivation for the rewrite was the desire to be able to use Blender to produce custom 3d cars for Trackmania:Sunrise (TM:S). Previously, the TM:S importer could not correctly handle the 3ds files from the Blender 3ds export script. With this version, one can export cars complete with UV textures, correct wheel placement and light placement. To my knowledge, this script would make Blender the first fully free 3d modeller that allows one to export 3ds models for TM:S (expect a tutorial soon). The ability to have proper UV coordinates exported into the 3ds file should also be very welcome to many.
Add A Comment: Notepad
2006-05-02 11:26:32 +00:00
|
|
|
file.write(data)
|
|
|
|
|
|
|
|
def __str__(self):
|
|
|
|
return '(%g, %g)' % self.uv
|
2005-12-15 01:42:45 +00:00
|
|
|
|
2007-01-04 20:44:33 +00:00
|
|
|
class _3ds_rgb_color(object):
|
2006-07-05 07:10:03 +00:00
|
|
|
'''Class representing a (24-bit) rgb color for a 3ds file.'''
|
2007-01-04 20:44:33 +00:00
|
|
|
__slots__ = 'r','g','b'
|
Commited 3ds export enhancements from Mark Stijnman (beowulff)
Will need to do some updates, Mesh over NMesh and optimize some areas but it works and is a big improvement.
from
https://projects.blender.org/tracker/index.php?func=detail&aid=4156&group_id=9&atid=127
Detailed description:
Modified the 3ds export script 3ds_export.py:
- It now exports face UV correctly. 3ds only supports one UV coordinate per vertex. The script now duplicates vertices that had multiple UV pairs assigned to them so that each duplicate now only contains one and only one UV. Faces have their vertex indices adjusted accordingly.
- Quads are now split into triangles better. 3ds only supports triangles, so quads need to be split into two triangles. Instead of rather arbitrarily splitting along the diagonal between points 0 and 2, the script now splits along the shortest diagonal. This creates a higher quality triangular mesh, as well as better preservation of symmetry.
- Now creates an object node block, exporting object nodes, needed by some 3D importers. Among others, allows one to export object hierarchy.
- Now exports Empties as 3ds Dummies.
To be able to add all of the above new features, the script has been mostly rewritten and strongly restructured.
Motivation for the rewrite was the desire to be able to use Blender to produce custom 3d cars for Trackmania:Sunrise (TM:S). Previously, the TM:S importer could not correctly handle the 3ds files from the Blender 3ds export script. With this version, one can export cars complete with UV textures, correct wheel placement and light placement. To my knowledge, this script would make Blender the first fully free 3d modeller that allows one to export 3ds models for TM:S (expect a tutorial soon). The ability to have proper UV coordinates exported into the 3ds file should also be very welcome to many.
Add A Comment: Notepad
2006-05-02 11:26:32 +00:00
|
|
|
def __init__(self, col=(0,0,0)):
|
|
|
|
self.r, self.g, self.b = col
|
|
|
|
|
|
|
|
def get_size(self):
|
|
|
|
return 3
|
|
|
|
|
|
|
|
def write(self,file):
|
2009-09-29 15:27:00 +00:00
|
|
|
file.write( struct.pack('<3B', int(255*self.r), int(255*self.g), int(255*self.b) ) )
|
|
|
|
# file.write( struct.pack('<3c', chr(int(255*self.r)), chr(int(255*self.g)), chr(int(255*self.b)) ) )
|
Commited 3ds export enhancements from Mark Stijnman (beowulff)
Will need to do some updates, Mesh over NMesh and optimize some areas but it works and is a big improvement.
from
https://projects.blender.org/tracker/index.php?func=detail&aid=4156&group_id=9&atid=127
Detailed description:
Modified the 3ds export script 3ds_export.py:
- It now exports face UV correctly. 3ds only supports one UV coordinate per vertex. The script now duplicates vertices that had multiple UV pairs assigned to them so that each duplicate now only contains one and only one UV. Faces have their vertex indices adjusted accordingly.
- Quads are now split into triangles better. 3ds only supports triangles, so quads need to be split into two triangles. Instead of rather arbitrarily splitting along the diagonal between points 0 and 2, the script now splits along the shortest diagonal. This creates a higher quality triangular mesh, as well as better preservation of symmetry.
- Now creates an object node block, exporting object nodes, needed by some 3D importers. Among others, allows one to export object hierarchy.
- Now exports Empties as 3ds Dummies.
To be able to add all of the above new features, the script has been mostly rewritten and strongly restructured.
Motivation for the rewrite was the desire to be able to use Blender to produce custom 3d cars for Trackmania:Sunrise (TM:S). Previously, the TM:S importer could not correctly handle the 3ds files from the Blender 3ds export script. With this version, one can export cars complete with UV textures, correct wheel placement and light placement. To my knowledge, this script would make Blender the first fully free 3d modeller that allows one to export 3ds models for TM:S (expect a tutorial soon). The ability to have proper UV coordinates exported into the 3ds file should also be very welcome to many.
Add A Comment: Notepad
2006-05-02 11:26:32 +00:00
|
|
|
|
|
|
|
def __str__(self):
|
|
|
|
return '{%f, %f, %f}' % (self.r, self.g, self.b)
|
2005-12-15 01:42:45 +00:00
|
|
|
|
2007-01-04 20:44:33 +00:00
|
|
|
class _3ds_face(object):
|
2006-07-05 07:10:03 +00:00
|
|
|
'''Class representing a face for a 3ds file.'''
|
2007-01-04 20:44:33 +00:00
|
|
|
__slots__ = 'vindex'
|
Commited 3ds export enhancements from Mark Stijnman (beowulff)
Will need to do some updates, Mesh over NMesh and optimize some areas but it works and is a big improvement.
from
https://projects.blender.org/tracker/index.php?func=detail&aid=4156&group_id=9&atid=127
Detailed description:
Modified the 3ds export script 3ds_export.py:
- It now exports face UV correctly. 3ds only supports one UV coordinate per vertex. The script now duplicates vertices that had multiple UV pairs assigned to them so that each duplicate now only contains one and only one UV. Faces have their vertex indices adjusted accordingly.
- Quads are now split into triangles better. 3ds only supports triangles, so quads need to be split into two triangles. Instead of rather arbitrarily splitting along the diagonal between points 0 and 2, the script now splits along the shortest diagonal. This creates a higher quality triangular mesh, as well as better preservation of symmetry.
- Now creates an object node block, exporting object nodes, needed by some 3D importers. Among others, allows one to export object hierarchy.
- Now exports Empties as 3ds Dummies.
To be able to add all of the above new features, the script has been mostly rewritten and strongly restructured.
Motivation for the rewrite was the desire to be able to use Blender to produce custom 3d cars for Trackmania:Sunrise (TM:S). Previously, the TM:S importer could not correctly handle the 3ds files from the Blender 3ds export script. With this version, one can export cars complete with UV textures, correct wheel placement and light placement. To my knowledge, this script would make Blender the first fully free 3d modeller that allows one to export 3ds models for TM:S (expect a tutorial soon). The ability to have proper UV coordinates exported into the 3ds file should also be very welcome to many.
Add A Comment: Notepad
2006-05-02 11:26:32 +00:00
|
|
|
def __init__(self, vindex):
|
|
|
|
self.vindex = vindex
|
|
|
|
|
2005-12-15 01:42:45 +00:00
|
|
|
def get_size(self):
|
Commited 3ds export enhancements from Mark Stijnman (beowulff)
Will need to do some updates, Mesh over NMesh and optimize some areas but it works and is a big improvement.
from
https://projects.blender.org/tracker/index.php?func=detail&aid=4156&group_id=9&atid=127
Detailed description:
Modified the 3ds export script 3ds_export.py:
- It now exports face UV correctly. 3ds only supports one UV coordinate per vertex. The script now duplicates vertices that had multiple UV pairs assigned to them so that each duplicate now only contains one and only one UV. Faces have their vertex indices adjusted accordingly.
- Quads are now split into triangles better. 3ds only supports triangles, so quads need to be split into two triangles. Instead of rather arbitrarily splitting along the diagonal between points 0 and 2, the script now splits along the shortest diagonal. This creates a higher quality triangular mesh, as well as better preservation of symmetry.
- Now creates an object node block, exporting object nodes, needed by some 3D importers. Among others, allows one to export object hierarchy.
- Now exports Empties as 3ds Dummies.
To be able to add all of the above new features, the script has been mostly rewritten and strongly restructured.
Motivation for the rewrite was the desire to be able to use Blender to produce custom 3d cars for Trackmania:Sunrise (TM:S). Previously, the TM:S importer could not correctly handle the 3ds files from the Blender 3ds export script. With this version, one can export cars complete with UV textures, correct wheel placement and light placement. To my knowledge, this script would make Blender the first fully free 3d modeller that allows one to export 3ds models for TM:S (expect a tutorial soon). The ability to have proper UV coordinates exported into the 3ds file should also be very welcome to many.
Add A Comment: Notepad
2006-05-02 11:26:32 +00:00
|
|
|
return 4*SZ_SHORT
|
|
|
|
|
|
|
|
def write(self,file):
|
|
|
|
# The last zero is only used by 3d studio
|
2007-01-04 20:44:33 +00:00
|
|
|
file.write(struct.pack("<4H", self.vindex[0],self.vindex[1], self.vindex[2], 0))
|
Commited 3ds export enhancements from Mark Stijnman (beowulff)
Will need to do some updates, Mesh over NMesh and optimize some areas but it works and is a big improvement.
from
https://projects.blender.org/tracker/index.php?func=detail&aid=4156&group_id=9&atid=127
Detailed description:
Modified the 3ds export script 3ds_export.py:
- It now exports face UV correctly. 3ds only supports one UV coordinate per vertex. The script now duplicates vertices that had multiple UV pairs assigned to them so that each duplicate now only contains one and only one UV. Faces have their vertex indices adjusted accordingly.
- Quads are now split into triangles better. 3ds only supports triangles, so quads need to be split into two triangles. Instead of rather arbitrarily splitting along the diagonal between points 0 and 2, the script now splits along the shortest diagonal. This creates a higher quality triangular mesh, as well as better preservation of symmetry.
- Now creates an object node block, exporting object nodes, needed by some 3D importers. Among others, allows one to export object hierarchy.
- Now exports Empties as 3ds Dummies.
To be able to add all of the above new features, the script has been mostly rewritten and strongly restructured.
Motivation for the rewrite was the desire to be able to use Blender to produce custom 3d cars for Trackmania:Sunrise (TM:S). Previously, the TM:S importer could not correctly handle the 3ds files from the Blender 3ds export script. With this version, one can export cars complete with UV textures, correct wheel placement and light placement. To my knowledge, this script would make Blender the first fully free 3d modeller that allows one to export 3ds models for TM:S (expect a tutorial soon). The ability to have proper UV coordinates exported into the 3ds file should also be very welcome to many.
Add A Comment: Notepad
2006-05-02 11:26:32 +00:00
|
|
|
|
|
|
|
def __str__(self):
|
|
|
|
return '[%d %d %d]' % (self.vindex[0],self.vindex[1], self.vindex[2])
|
2005-12-15 01:42:45 +00:00
|
|
|
|
2007-01-04 20:44:33 +00:00
|
|
|
class _3ds_array(object):
|
2006-07-05 07:10:03 +00:00
|
|
|
'''Class representing an array of variables for a 3ds file.
|
2005-12-15 01:42:45 +00:00
|
|
|
|
Commited 3ds export enhancements from Mark Stijnman (beowulff)
Will need to do some updates, Mesh over NMesh and optimize some areas but it works and is a big improvement.
from
https://projects.blender.org/tracker/index.php?func=detail&aid=4156&group_id=9&atid=127
Detailed description:
Modified the 3ds export script 3ds_export.py:
- It now exports face UV correctly. 3ds only supports one UV coordinate per vertex. The script now duplicates vertices that had multiple UV pairs assigned to them so that each duplicate now only contains one and only one UV. Faces have their vertex indices adjusted accordingly.
- Quads are now split into triangles better. 3ds only supports triangles, so quads need to be split into two triangles. Instead of rather arbitrarily splitting along the diagonal between points 0 and 2, the script now splits along the shortest diagonal. This creates a higher quality triangular mesh, as well as better preservation of symmetry.
- Now creates an object node block, exporting object nodes, needed by some 3D importers. Among others, allows one to export object hierarchy.
- Now exports Empties as 3ds Dummies.
To be able to add all of the above new features, the script has been mostly rewritten and strongly restructured.
Motivation for the rewrite was the desire to be able to use Blender to produce custom 3d cars for Trackmania:Sunrise (TM:S). Previously, the TM:S importer could not correctly handle the 3ds files from the Blender 3ds export script. With this version, one can export cars complete with UV textures, correct wheel placement and light placement. To my knowledge, this script would make Blender the first fully free 3d modeller that allows one to export 3ds models for TM:S (expect a tutorial soon). The ability to have proper UV coordinates exported into the 3ds file should also be very welcome to many.
Add A Comment: Notepad
2006-05-02 11:26:32 +00:00
|
|
|
Consists of a _3ds_short to indicate the number of items, followed by the items themselves.
|
2006-07-05 07:10:03 +00:00
|
|
|
'''
|
2007-01-04 20:44:33 +00:00
|
|
|
__slots__ = 'values', 'size'
|
2005-12-15 01:42:45 +00:00
|
|
|
def __init__(self):
|
Commited 3ds export enhancements from Mark Stijnman (beowulff)
Will need to do some updates, Mesh over NMesh and optimize some areas but it works and is a big improvement.
from
https://projects.blender.org/tracker/index.php?func=detail&aid=4156&group_id=9&atid=127
Detailed description:
Modified the 3ds export script 3ds_export.py:
- It now exports face UV correctly. 3ds only supports one UV coordinate per vertex. The script now duplicates vertices that had multiple UV pairs assigned to them so that each duplicate now only contains one and only one UV. Faces have their vertex indices adjusted accordingly.
- Quads are now split into triangles better. 3ds only supports triangles, so quads need to be split into two triangles. Instead of rather arbitrarily splitting along the diagonal between points 0 and 2, the script now splits along the shortest diagonal. This creates a higher quality triangular mesh, as well as better preservation of symmetry.
- Now creates an object node block, exporting object nodes, needed by some 3D importers. Among others, allows one to export object hierarchy.
- Now exports Empties as 3ds Dummies.
To be able to add all of the above new features, the script has been mostly rewritten and strongly restructured.
Motivation for the rewrite was the desire to be able to use Blender to produce custom 3d cars for Trackmania:Sunrise (TM:S). Previously, the TM:S importer could not correctly handle the 3ds files from the Blender 3ds export script. With this version, one can export cars complete with UV textures, correct wheel placement and light placement. To my knowledge, this script would make Blender the first fully free 3d modeller that allows one to export 3ds models for TM:S (expect a tutorial soon). The ability to have proper UV coordinates exported into the 3ds file should also be very welcome to many.
Add A Comment: Notepad
2006-05-02 11:26:32 +00:00
|
|
|
self.values=[]
|
|
|
|
self.size=SZ_SHORT
|
|
|
|
|
|
|
|
# add an item:
|
|
|
|
def add(self,item):
|
|
|
|
self.values.append(item)
|
|
|
|
self.size+=item.get_size()
|
|
|
|
|
2005-12-15 01:42:45 +00:00
|
|
|
def get_size(self):
|
|
|
|
return self.size
|
Commited 3ds export enhancements from Mark Stijnman (beowulff)
Will need to do some updates, Mesh over NMesh and optimize some areas but it works and is a big improvement.
from
https://projects.blender.org/tracker/index.php?func=detail&aid=4156&group_id=9&atid=127
Detailed description:
Modified the 3ds export script 3ds_export.py:
- It now exports face UV correctly. 3ds only supports one UV coordinate per vertex. The script now duplicates vertices that had multiple UV pairs assigned to them so that each duplicate now only contains one and only one UV. Faces have their vertex indices adjusted accordingly.
- Quads are now split into triangles better. 3ds only supports triangles, so quads need to be split into two triangles. Instead of rather arbitrarily splitting along the diagonal between points 0 and 2, the script now splits along the shortest diagonal. This creates a higher quality triangular mesh, as well as better preservation of symmetry.
- Now creates an object node block, exporting object nodes, needed by some 3D importers. Among others, allows one to export object hierarchy.
- Now exports Empties as 3ds Dummies.
To be able to add all of the above new features, the script has been mostly rewritten and strongly restructured.
Motivation for the rewrite was the desire to be able to use Blender to produce custom 3d cars for Trackmania:Sunrise (TM:S). Previously, the TM:S importer could not correctly handle the 3ds files from the Blender 3ds export script. With this version, one can export cars complete with UV textures, correct wheel placement and light placement. To my knowledge, this script would make Blender the first fully free 3d modeller that allows one to export 3ds models for TM:S (expect a tutorial soon). The ability to have proper UV coordinates exported into the 3ds file should also be very welcome to many.
Add A Comment: Notepad
2006-05-02 11:26:32 +00:00
|
|
|
|
|
|
|
def write(self,file):
|
|
|
|
_3ds_short(len(self.values)).write(file)
|
|
|
|
#_3ds_int(len(self.values)).write(file)
|
|
|
|
for value in self.values:
|
|
|
|
value.write(file)
|
|
|
|
|
|
|
|
# To not overwhelm the output in a dump, a _3ds_array only
|
|
|
|
# outputs the number of items, not all of the actual items.
|
|
|
|
def __str__(self):
|
|
|
|
return '(%d items)' % len(self.values)
|
2005-12-15 01:42:45 +00:00
|
|
|
|
2007-01-04 20:44:33 +00:00
|
|
|
class _3ds_named_variable(object):
|
2006-07-05 07:10:03 +00:00
|
|
|
'''Convenience class for named variables.'''
|
Commited 3ds export enhancements from Mark Stijnman (beowulff)
Will need to do some updates, Mesh over NMesh and optimize some areas but it works and is a big improvement.
from
https://projects.blender.org/tracker/index.php?func=detail&aid=4156&group_id=9&atid=127
Detailed description:
Modified the 3ds export script 3ds_export.py:
- It now exports face UV correctly. 3ds only supports one UV coordinate per vertex. The script now duplicates vertices that had multiple UV pairs assigned to them so that each duplicate now only contains one and only one UV. Faces have their vertex indices adjusted accordingly.
- Quads are now split into triangles better. 3ds only supports triangles, so quads need to be split into two triangles. Instead of rather arbitrarily splitting along the diagonal between points 0 and 2, the script now splits along the shortest diagonal. This creates a higher quality triangular mesh, as well as better preservation of symmetry.
- Now creates an object node block, exporting object nodes, needed by some 3D importers. Among others, allows one to export object hierarchy.
- Now exports Empties as 3ds Dummies.
To be able to add all of the above new features, the script has been mostly rewritten and strongly restructured.
Motivation for the rewrite was the desire to be able to use Blender to produce custom 3d cars for Trackmania:Sunrise (TM:S). Previously, the TM:S importer could not correctly handle the 3ds files from the Blender 3ds export script. With this version, one can export cars complete with UV textures, correct wheel placement and light placement. To my knowledge, this script would make Blender the first fully free 3d modeller that allows one to export 3ds models for TM:S (expect a tutorial soon). The ability to have proper UV coordinates exported into the 3ds file should also be very welcome to many.
Add A Comment: Notepad
2006-05-02 11:26:32 +00:00
|
|
|
|
2007-01-04 20:44:33 +00:00
|
|
|
__slots__ = 'value', 'name'
|
Commited 3ds export enhancements from Mark Stijnman (beowulff)
Will need to do some updates, Mesh over NMesh and optimize some areas but it works and is a big improvement.
from
https://projects.blender.org/tracker/index.php?func=detail&aid=4156&group_id=9&atid=127
Detailed description:
Modified the 3ds export script 3ds_export.py:
- It now exports face UV correctly. 3ds only supports one UV coordinate per vertex. The script now duplicates vertices that had multiple UV pairs assigned to them so that each duplicate now only contains one and only one UV. Faces have their vertex indices adjusted accordingly.
- Quads are now split into triangles better. 3ds only supports triangles, so quads need to be split into two triangles. Instead of rather arbitrarily splitting along the diagonal between points 0 and 2, the script now splits along the shortest diagonal. This creates a higher quality triangular mesh, as well as better preservation of symmetry.
- Now creates an object node block, exporting object nodes, needed by some 3D importers. Among others, allows one to export object hierarchy.
- Now exports Empties as 3ds Dummies.
To be able to add all of the above new features, the script has been mostly rewritten and strongly restructured.
Motivation for the rewrite was the desire to be able to use Blender to produce custom 3d cars for Trackmania:Sunrise (TM:S). Previously, the TM:S importer could not correctly handle the 3ds files from the Blender 3ds export script. With this version, one can export cars complete with UV textures, correct wheel placement and light placement. To my knowledge, this script would make Blender the first fully free 3d modeller that allows one to export 3ds models for TM:S (expect a tutorial soon). The ability to have proper UV coordinates exported into the 3ds file should also be very welcome to many.
Add A Comment: Notepad
2006-05-02 11:26:32 +00:00
|
|
|
def __init__(self, name, val=None):
|
|
|
|
self.name=name
|
|
|
|
self.value=val
|
|
|
|
|
2005-12-15 01:42:45 +00:00
|
|
|
def get_size(self):
|
Commited 3ds export enhancements from Mark Stijnman (beowulff)
Will need to do some updates, Mesh over NMesh and optimize some areas but it works and is a big improvement.
from
https://projects.blender.org/tracker/index.php?func=detail&aid=4156&group_id=9&atid=127
Detailed description:
Modified the 3ds export script 3ds_export.py:
- It now exports face UV correctly. 3ds only supports one UV coordinate per vertex. The script now duplicates vertices that had multiple UV pairs assigned to them so that each duplicate now only contains one and only one UV. Faces have their vertex indices adjusted accordingly.
- Quads are now split into triangles better. 3ds only supports triangles, so quads need to be split into two triangles. Instead of rather arbitrarily splitting along the diagonal between points 0 and 2, the script now splits along the shortest diagonal. This creates a higher quality triangular mesh, as well as better preservation of symmetry.
- Now creates an object node block, exporting object nodes, needed by some 3D importers. Among others, allows one to export object hierarchy.
- Now exports Empties as 3ds Dummies.
To be able to add all of the above new features, the script has been mostly rewritten and strongly restructured.
Motivation for the rewrite was the desire to be able to use Blender to produce custom 3d cars for Trackmania:Sunrise (TM:S). Previously, the TM:S importer could not correctly handle the 3ds files from the Blender 3ds export script. With this version, one can export cars complete with UV textures, correct wheel placement and light placement. To my knowledge, this script would make Blender the first fully free 3d modeller that allows one to export 3ds models for TM:S (expect a tutorial soon). The ability to have proper UV coordinates exported into the 3ds file should also be very welcome to many.
Add A Comment: Notepad
2006-05-02 11:26:32 +00:00
|
|
|
if (self.value==None):
|
|
|
|
return 0
|
|
|
|
else:
|
|
|
|
return self.value.get_size()
|
|
|
|
|
2005-12-15 01:42:45 +00:00
|
|
|
def write(self, file):
|
Commited 3ds export enhancements from Mark Stijnman (beowulff)
Will need to do some updates, Mesh over NMesh and optimize some areas but it works and is a big improvement.
from
https://projects.blender.org/tracker/index.php?func=detail&aid=4156&group_id=9&atid=127
Detailed description:
Modified the 3ds export script 3ds_export.py:
- It now exports face UV correctly. 3ds only supports one UV coordinate per vertex. The script now duplicates vertices that had multiple UV pairs assigned to them so that each duplicate now only contains one and only one UV. Faces have their vertex indices adjusted accordingly.
- Quads are now split into triangles better. 3ds only supports triangles, so quads need to be split into two triangles. Instead of rather arbitrarily splitting along the diagonal between points 0 and 2, the script now splits along the shortest diagonal. This creates a higher quality triangular mesh, as well as better preservation of symmetry.
- Now creates an object node block, exporting object nodes, needed by some 3D importers. Among others, allows one to export object hierarchy.
- Now exports Empties as 3ds Dummies.
To be able to add all of the above new features, the script has been mostly rewritten and strongly restructured.
Motivation for the rewrite was the desire to be able to use Blender to produce custom 3d cars for Trackmania:Sunrise (TM:S). Previously, the TM:S importer could not correctly handle the 3ds files from the Blender 3ds export script. With this version, one can export cars complete with UV textures, correct wheel placement and light placement. To my knowledge, this script would make Blender the first fully free 3d modeller that allows one to export 3ds models for TM:S (expect a tutorial soon). The ability to have proper UV coordinates exported into the 3ds file should also be very welcome to many.
Add A Comment: Notepad
2006-05-02 11:26:32 +00:00
|
|
|
if (self.value!=None):
|
|
|
|
self.value.write(file)
|
|
|
|
|
|
|
|
def dump(self,indent):
|
|
|
|
if (self.value!=None):
|
|
|
|
spaces=""
|
2009-09-29 15:27:00 +00:00
|
|
|
for i in range(indent):
|
Commited 3ds export enhancements from Mark Stijnman (beowulff)
Will need to do some updates, Mesh over NMesh and optimize some areas but it works and is a big improvement.
from
https://projects.blender.org/tracker/index.php?func=detail&aid=4156&group_id=9&atid=127
Detailed description:
Modified the 3ds export script 3ds_export.py:
- It now exports face UV correctly. 3ds only supports one UV coordinate per vertex. The script now duplicates vertices that had multiple UV pairs assigned to them so that each duplicate now only contains one and only one UV. Faces have their vertex indices adjusted accordingly.
- Quads are now split into triangles better. 3ds only supports triangles, so quads need to be split into two triangles. Instead of rather arbitrarily splitting along the diagonal between points 0 and 2, the script now splits along the shortest diagonal. This creates a higher quality triangular mesh, as well as better preservation of symmetry.
- Now creates an object node block, exporting object nodes, needed by some 3D importers. Among others, allows one to export object hierarchy.
- Now exports Empties as 3ds Dummies.
To be able to add all of the above new features, the script has been mostly rewritten and strongly restructured.
Motivation for the rewrite was the desire to be able to use Blender to produce custom 3d cars for Trackmania:Sunrise (TM:S). Previously, the TM:S importer could not correctly handle the 3ds files from the Blender 3ds export script. With this version, one can export cars complete with UV textures, correct wheel placement and light placement. To my knowledge, this script would make Blender the first fully free 3d modeller that allows one to export 3ds models for TM:S (expect a tutorial soon). The ability to have proper UV coordinates exported into the 3ds file should also be very welcome to many.
Add A Comment: Notepad
2006-05-02 11:26:32 +00:00
|
|
|
spaces+=" ";
|
|
|
|
if (self.name!=""):
|
2009-09-29 15:27:00 +00:00
|
|
|
print(spaces, self.name, " = ", self.value)
|
Commited 3ds export enhancements from Mark Stijnman (beowulff)
Will need to do some updates, Mesh over NMesh and optimize some areas but it works and is a big improvement.
from
https://projects.blender.org/tracker/index.php?func=detail&aid=4156&group_id=9&atid=127
Detailed description:
Modified the 3ds export script 3ds_export.py:
- It now exports face UV correctly. 3ds only supports one UV coordinate per vertex. The script now duplicates vertices that had multiple UV pairs assigned to them so that each duplicate now only contains one and only one UV. Faces have their vertex indices adjusted accordingly.
- Quads are now split into triangles better. 3ds only supports triangles, so quads need to be split into two triangles. Instead of rather arbitrarily splitting along the diagonal between points 0 and 2, the script now splits along the shortest diagonal. This creates a higher quality triangular mesh, as well as better preservation of symmetry.
- Now creates an object node block, exporting object nodes, needed by some 3D importers. Among others, allows one to export object hierarchy.
- Now exports Empties as 3ds Dummies.
To be able to add all of the above new features, the script has been mostly rewritten and strongly restructured.
Motivation for the rewrite was the desire to be able to use Blender to produce custom 3d cars for Trackmania:Sunrise (TM:S). Previously, the TM:S importer could not correctly handle the 3ds files from the Blender 3ds export script. With this version, one can export cars complete with UV textures, correct wheel placement and light placement. To my knowledge, this script would make Blender the first fully free 3d modeller that allows one to export 3ds models for TM:S (expect a tutorial soon). The ability to have proper UV coordinates exported into the 3ds file should also be very welcome to many.
Add A Comment: Notepad
2006-05-02 11:26:32 +00:00
|
|
|
else:
|
2009-09-29 15:27:00 +00:00
|
|
|
print(spaces, "[unnamed]", " = ", self.value)
|
2005-12-15 01:42:45 +00:00
|
|
|
|
|
|
|
|
Commited 3ds export enhancements from Mark Stijnman (beowulff)
Will need to do some updates, Mesh over NMesh and optimize some areas but it works and is a big improvement.
from
https://projects.blender.org/tracker/index.php?func=detail&aid=4156&group_id=9&atid=127
Detailed description:
Modified the 3ds export script 3ds_export.py:
- It now exports face UV correctly. 3ds only supports one UV coordinate per vertex. The script now duplicates vertices that had multiple UV pairs assigned to them so that each duplicate now only contains one and only one UV. Faces have their vertex indices adjusted accordingly.
- Quads are now split into triangles better. 3ds only supports triangles, so quads need to be split into two triangles. Instead of rather arbitrarily splitting along the diagonal between points 0 and 2, the script now splits along the shortest diagonal. This creates a higher quality triangular mesh, as well as better preservation of symmetry.
- Now creates an object node block, exporting object nodes, needed by some 3D importers. Among others, allows one to export object hierarchy.
- Now exports Empties as 3ds Dummies.
To be able to add all of the above new features, the script has been mostly rewritten and strongly restructured.
Motivation for the rewrite was the desire to be able to use Blender to produce custom 3d cars for Trackmania:Sunrise (TM:S). Previously, the TM:S importer could not correctly handle the 3ds files from the Blender 3ds export script. With this version, one can export cars complete with UV textures, correct wheel placement and light placement. To my knowledge, this script would make Blender the first fully free 3d modeller that allows one to export 3ds models for TM:S (expect a tutorial soon). The ability to have proper UV coordinates exported into the 3ds file should also be very welcome to many.
Add A Comment: Notepad
2006-05-02 11:26:32 +00:00
|
|
|
#the chunk class
|
2007-01-04 20:44:33 +00:00
|
|
|
class _3ds_chunk(object):
|
2006-07-05 07:10:03 +00:00
|
|
|
'''Class representing a chunk in a 3ds file.
|
Commited 3ds export enhancements from Mark Stijnman (beowulff)
Will need to do some updates, Mesh over NMesh and optimize some areas but it works and is a big improvement.
from
https://projects.blender.org/tracker/index.php?func=detail&aid=4156&group_id=9&atid=127
Detailed description:
Modified the 3ds export script 3ds_export.py:
- It now exports face UV correctly. 3ds only supports one UV coordinate per vertex. The script now duplicates vertices that had multiple UV pairs assigned to them so that each duplicate now only contains one and only one UV. Faces have their vertex indices adjusted accordingly.
- Quads are now split into triangles better. 3ds only supports triangles, so quads need to be split into two triangles. Instead of rather arbitrarily splitting along the diagonal between points 0 and 2, the script now splits along the shortest diagonal. This creates a higher quality triangular mesh, as well as better preservation of symmetry.
- Now creates an object node block, exporting object nodes, needed by some 3D importers. Among others, allows one to export object hierarchy.
- Now exports Empties as 3ds Dummies.
To be able to add all of the above new features, the script has been mostly rewritten and strongly restructured.
Motivation for the rewrite was the desire to be able to use Blender to produce custom 3d cars for Trackmania:Sunrise (TM:S). Previously, the TM:S importer could not correctly handle the 3ds files from the Blender 3ds export script. With this version, one can export cars complete with UV textures, correct wheel placement and light placement. To my knowledge, this script would make Blender the first fully free 3d modeller that allows one to export 3ds models for TM:S (expect a tutorial soon). The ability to have proper UV coordinates exported into the 3ds file should also be very welcome to many.
Add A Comment: Notepad
2006-05-02 11:26:32 +00:00
|
|
|
|
|
|
|
Chunks contain zero or more variables, followed by zero or more subchunks.
|
2006-07-05 07:10:03 +00:00
|
|
|
'''
|
2007-01-04 20:44:33 +00:00
|
|
|
__slots__ = 'ID', 'size', 'variables', 'subchunks'
|
Commited 3ds export enhancements from Mark Stijnman (beowulff)
Will need to do some updates, Mesh over NMesh and optimize some areas but it works and is a big improvement.
from
https://projects.blender.org/tracker/index.php?func=detail&aid=4156&group_id=9&atid=127
Detailed description:
Modified the 3ds export script 3ds_export.py:
- It now exports face UV correctly. 3ds only supports one UV coordinate per vertex. The script now duplicates vertices that had multiple UV pairs assigned to them so that each duplicate now only contains one and only one UV. Faces have their vertex indices adjusted accordingly.
- Quads are now split into triangles better. 3ds only supports triangles, so quads need to be split into two triangles. Instead of rather arbitrarily splitting along the diagonal between points 0 and 2, the script now splits along the shortest diagonal. This creates a higher quality triangular mesh, as well as better preservation of symmetry.
- Now creates an object node block, exporting object nodes, needed by some 3D importers. Among others, allows one to export object hierarchy.
- Now exports Empties as 3ds Dummies.
To be able to add all of the above new features, the script has been mostly rewritten and strongly restructured.
Motivation for the rewrite was the desire to be able to use Blender to produce custom 3d cars for Trackmania:Sunrise (TM:S). Previously, the TM:S importer could not correctly handle the 3ds files from the Blender 3ds export script. With this version, one can export cars complete with UV textures, correct wheel placement and light placement. To my knowledge, this script would make Blender the first fully free 3d modeller that allows one to export 3ds models for TM:S (expect a tutorial soon). The ability to have proper UV coordinates exported into the 3ds file should also be very welcome to many.
Add A Comment: Notepad
2006-05-02 11:26:32 +00:00
|
|
|
def __init__(self, id=0):
|
|
|
|
self.ID=_3ds_short(id)
|
|
|
|
self.size=_3ds_int(0)
|
|
|
|
self.variables=[]
|
|
|
|
self.subchunks=[]
|
|
|
|
|
|
|
|
def set_ID(id):
|
|
|
|
self.ID=_3ds_short(id)
|
|
|
|
|
|
|
|
def add_variable(self, name, var):
|
2006-07-05 07:10:03 +00:00
|
|
|
'''Add a named variable.
|
Commited 3ds export enhancements from Mark Stijnman (beowulff)
Will need to do some updates, Mesh over NMesh and optimize some areas but it works and is a big improvement.
from
https://projects.blender.org/tracker/index.php?func=detail&aid=4156&group_id=9&atid=127
Detailed description:
Modified the 3ds export script 3ds_export.py:
- It now exports face UV correctly. 3ds only supports one UV coordinate per vertex. The script now duplicates vertices that had multiple UV pairs assigned to them so that each duplicate now only contains one and only one UV. Faces have their vertex indices adjusted accordingly.
- Quads are now split into triangles better. 3ds only supports triangles, so quads need to be split into two triangles. Instead of rather arbitrarily splitting along the diagonal between points 0 and 2, the script now splits along the shortest diagonal. This creates a higher quality triangular mesh, as well as better preservation of symmetry.
- Now creates an object node block, exporting object nodes, needed by some 3D importers. Among others, allows one to export object hierarchy.
- Now exports Empties as 3ds Dummies.
To be able to add all of the above new features, the script has been mostly rewritten and strongly restructured.
Motivation for the rewrite was the desire to be able to use Blender to produce custom 3d cars for Trackmania:Sunrise (TM:S). Previously, the TM:S importer could not correctly handle the 3ds files from the Blender 3ds export script. With this version, one can export cars complete with UV textures, correct wheel placement and light placement. To my knowledge, this script would make Blender the first fully free 3d modeller that allows one to export 3ds models for TM:S (expect a tutorial soon). The ability to have proper UV coordinates exported into the 3ds file should also be very welcome to many.
Add A Comment: Notepad
2006-05-02 11:26:32 +00:00
|
|
|
|
2006-07-05 07:10:03 +00:00
|
|
|
The name is mostly for debugging purposes.'''
|
Commited 3ds export enhancements from Mark Stijnman (beowulff)
Will need to do some updates, Mesh over NMesh and optimize some areas but it works and is a big improvement.
from
https://projects.blender.org/tracker/index.php?func=detail&aid=4156&group_id=9&atid=127
Detailed description:
Modified the 3ds export script 3ds_export.py:
- It now exports face UV correctly. 3ds only supports one UV coordinate per vertex. The script now duplicates vertices that had multiple UV pairs assigned to them so that each duplicate now only contains one and only one UV. Faces have their vertex indices adjusted accordingly.
- Quads are now split into triangles better. 3ds only supports triangles, so quads need to be split into two triangles. Instead of rather arbitrarily splitting along the diagonal between points 0 and 2, the script now splits along the shortest diagonal. This creates a higher quality triangular mesh, as well as better preservation of symmetry.
- Now creates an object node block, exporting object nodes, needed by some 3D importers. Among others, allows one to export object hierarchy.
- Now exports Empties as 3ds Dummies.
To be able to add all of the above new features, the script has been mostly rewritten and strongly restructured.
Motivation for the rewrite was the desire to be able to use Blender to produce custom 3d cars for Trackmania:Sunrise (TM:S). Previously, the TM:S importer could not correctly handle the 3ds files from the Blender 3ds export script. With this version, one can export cars complete with UV textures, correct wheel placement and light placement. To my knowledge, this script would make Blender the first fully free 3d modeller that allows one to export 3ds models for TM:S (expect a tutorial soon). The ability to have proper UV coordinates exported into the 3ds file should also be very welcome to many.
Add A Comment: Notepad
2006-05-02 11:26:32 +00:00
|
|
|
self.variables.append(_3ds_named_variable(name,var))
|
|
|
|
|
|
|
|
def add_subchunk(self, chunk):
|
2006-07-05 07:10:03 +00:00
|
|
|
'''Add a subchunk.'''
|
Commited 3ds export enhancements from Mark Stijnman (beowulff)
Will need to do some updates, Mesh over NMesh and optimize some areas but it works and is a big improvement.
from
https://projects.blender.org/tracker/index.php?func=detail&aid=4156&group_id=9&atid=127
Detailed description:
Modified the 3ds export script 3ds_export.py:
- It now exports face UV correctly. 3ds only supports one UV coordinate per vertex. The script now duplicates vertices that had multiple UV pairs assigned to them so that each duplicate now only contains one and only one UV. Faces have their vertex indices adjusted accordingly.
- Quads are now split into triangles better. 3ds only supports triangles, so quads need to be split into two triangles. Instead of rather arbitrarily splitting along the diagonal between points 0 and 2, the script now splits along the shortest diagonal. This creates a higher quality triangular mesh, as well as better preservation of symmetry.
- Now creates an object node block, exporting object nodes, needed by some 3D importers. Among others, allows one to export object hierarchy.
- Now exports Empties as 3ds Dummies.
To be able to add all of the above new features, the script has been mostly rewritten and strongly restructured.
Motivation for the rewrite was the desire to be able to use Blender to produce custom 3d cars for Trackmania:Sunrise (TM:S). Previously, the TM:S importer could not correctly handle the 3ds files from the Blender 3ds export script. With this version, one can export cars complete with UV textures, correct wheel placement and light placement. To my knowledge, this script would make Blender the first fully free 3d modeller that allows one to export 3ds models for TM:S (expect a tutorial soon). The ability to have proper UV coordinates exported into the 3ds file should also be very welcome to many.
Add A Comment: Notepad
2006-05-02 11:26:32 +00:00
|
|
|
self.subchunks.append(chunk)
|
2005-12-15 01:42:45 +00:00
|
|
|
|
|
|
|
def get_size(self):
|
2006-07-05 07:10:03 +00:00
|
|
|
'''Calculate the size of the chunk and return it.
|
Commited 3ds export enhancements from Mark Stijnman (beowulff)
Will need to do some updates, Mesh over NMesh and optimize some areas but it works and is a big improvement.
from
https://projects.blender.org/tracker/index.php?func=detail&aid=4156&group_id=9&atid=127
Detailed description:
Modified the 3ds export script 3ds_export.py:
- It now exports face UV correctly. 3ds only supports one UV coordinate per vertex. The script now duplicates vertices that had multiple UV pairs assigned to them so that each duplicate now only contains one and only one UV. Faces have their vertex indices adjusted accordingly.
- Quads are now split into triangles better. 3ds only supports triangles, so quads need to be split into two triangles. Instead of rather arbitrarily splitting along the diagonal between points 0 and 2, the script now splits along the shortest diagonal. This creates a higher quality triangular mesh, as well as better preservation of symmetry.
- Now creates an object node block, exporting object nodes, needed by some 3D importers. Among others, allows one to export object hierarchy.
- Now exports Empties as 3ds Dummies.
To be able to add all of the above new features, the script has been mostly rewritten and strongly restructured.
Motivation for the rewrite was the desire to be able to use Blender to produce custom 3d cars for Trackmania:Sunrise (TM:S). Previously, the TM:S importer could not correctly handle the 3ds files from the Blender 3ds export script. With this version, one can export cars complete with UV textures, correct wheel placement and light placement. To my knowledge, this script would make Blender the first fully free 3d modeller that allows one to export 3ds models for TM:S (expect a tutorial soon). The ability to have proper UV coordinates exported into the 3ds file should also be very welcome to many.
Add A Comment: Notepad
2006-05-02 11:26:32 +00:00
|
|
|
|
2006-07-05 07:10:03 +00:00
|
|
|
The sizes of the variables and subchunks are used to determine this chunk\'s size.'''
|
Commited 3ds export enhancements from Mark Stijnman (beowulff)
Will need to do some updates, Mesh over NMesh and optimize some areas but it works and is a big improvement.
from
https://projects.blender.org/tracker/index.php?func=detail&aid=4156&group_id=9&atid=127
Detailed description:
Modified the 3ds export script 3ds_export.py:
- It now exports face UV correctly. 3ds only supports one UV coordinate per vertex. The script now duplicates vertices that had multiple UV pairs assigned to them so that each duplicate now only contains one and only one UV. Faces have their vertex indices adjusted accordingly.
- Quads are now split into triangles better. 3ds only supports triangles, so quads need to be split into two triangles. Instead of rather arbitrarily splitting along the diagonal between points 0 and 2, the script now splits along the shortest diagonal. This creates a higher quality triangular mesh, as well as better preservation of symmetry.
- Now creates an object node block, exporting object nodes, needed by some 3D importers. Among others, allows one to export object hierarchy.
- Now exports Empties as 3ds Dummies.
To be able to add all of the above new features, the script has been mostly rewritten and strongly restructured.
Motivation for the rewrite was the desire to be able to use Blender to produce custom 3d cars for Trackmania:Sunrise (TM:S). Previously, the TM:S importer could not correctly handle the 3ds files from the Blender 3ds export script. With this version, one can export cars complete with UV textures, correct wheel placement and light placement. To my knowledge, this script would make Blender the first fully free 3d modeller that allows one to export 3ds models for TM:S (expect a tutorial soon). The ability to have proper UV coordinates exported into the 3ds file should also be very welcome to many.
Add A Comment: Notepad
2006-05-02 11:26:32 +00:00
|
|
|
tmpsize=self.ID.get_size()+self.size.get_size()
|
|
|
|
for variable in self.variables:
|
|
|
|
tmpsize+=variable.get_size()
|
|
|
|
for subchunk in self.subchunks:
|
|
|
|
tmpsize+=subchunk.get_size()
|
|
|
|
self.size.value=tmpsize
|
|
|
|
return self.size.value
|
2005-12-15 01:42:45 +00:00
|
|
|
|
|
|
|
def write(self, file):
|
2006-07-05 07:10:03 +00:00
|
|
|
'''Write the chunk to a file.
|
Commited 3ds export enhancements from Mark Stijnman (beowulff)
Will need to do some updates, Mesh over NMesh and optimize some areas but it works and is a big improvement.
from
https://projects.blender.org/tracker/index.php?func=detail&aid=4156&group_id=9&atid=127
Detailed description:
Modified the 3ds export script 3ds_export.py:
- It now exports face UV correctly. 3ds only supports one UV coordinate per vertex. The script now duplicates vertices that had multiple UV pairs assigned to them so that each duplicate now only contains one and only one UV. Faces have their vertex indices adjusted accordingly.
- Quads are now split into triangles better. 3ds only supports triangles, so quads need to be split into two triangles. Instead of rather arbitrarily splitting along the diagonal between points 0 and 2, the script now splits along the shortest diagonal. This creates a higher quality triangular mesh, as well as better preservation of symmetry.
- Now creates an object node block, exporting object nodes, needed by some 3D importers. Among others, allows one to export object hierarchy.
- Now exports Empties as 3ds Dummies.
To be able to add all of the above new features, the script has been mostly rewritten and strongly restructured.
Motivation for the rewrite was the desire to be able to use Blender to produce custom 3d cars for Trackmania:Sunrise (TM:S). Previously, the TM:S importer could not correctly handle the 3ds files from the Blender 3ds export script. With this version, one can export cars complete with UV textures, correct wheel placement and light placement. To my knowledge, this script would make Blender the first fully free 3d modeller that allows one to export 3ds models for TM:S (expect a tutorial soon). The ability to have proper UV coordinates exported into the 3ds file should also be very welcome to many.
Add A Comment: Notepad
2006-05-02 11:26:32 +00:00
|
|
|
|
2006-07-05 07:10:03 +00:00
|
|
|
Uses the write function of the variables and the subchunks to do the actual work.'''
|
Commited 3ds export enhancements from Mark Stijnman (beowulff)
Will need to do some updates, Mesh over NMesh and optimize some areas but it works and is a big improvement.
from
https://projects.blender.org/tracker/index.php?func=detail&aid=4156&group_id=9&atid=127
Detailed description:
Modified the 3ds export script 3ds_export.py:
- It now exports face UV correctly. 3ds only supports one UV coordinate per vertex. The script now duplicates vertices that had multiple UV pairs assigned to them so that each duplicate now only contains one and only one UV. Faces have their vertex indices adjusted accordingly.
- Quads are now split into triangles better. 3ds only supports triangles, so quads need to be split into two triangles. Instead of rather arbitrarily splitting along the diagonal between points 0 and 2, the script now splits along the shortest diagonal. This creates a higher quality triangular mesh, as well as better preservation of symmetry.
- Now creates an object node block, exporting object nodes, needed by some 3D importers. Among others, allows one to export object hierarchy.
- Now exports Empties as 3ds Dummies.
To be able to add all of the above new features, the script has been mostly rewritten and strongly restructured.
Motivation for the rewrite was the desire to be able to use Blender to produce custom 3d cars for Trackmania:Sunrise (TM:S). Previously, the TM:S importer could not correctly handle the 3ds files from the Blender 3ds export script. With this version, one can export cars complete with UV textures, correct wheel placement and light placement. To my knowledge, this script would make Blender the first fully free 3d modeller that allows one to export 3ds models for TM:S (expect a tutorial soon). The ability to have proper UV coordinates exported into the 3ds file should also be very welcome to many.
Add A Comment: Notepad
2006-05-02 11:26:32 +00:00
|
|
|
#write header
|
|
|
|
self.ID.write(file)
|
|
|
|
self.size.write(file)
|
|
|
|
for variable in self.variables:
|
|
|
|
variable.write(file)
|
|
|
|
for subchunk in self.subchunks:
|
|
|
|
subchunk.write(file)
|
|
|
|
|
|
|
|
|
|
|
|
def dump(self, indent=0):
|
2006-07-05 07:10:03 +00:00
|
|
|
'''Write the chunk to a file.
|
Commited 3ds export enhancements from Mark Stijnman (beowulff)
Will need to do some updates, Mesh over NMesh and optimize some areas but it works and is a big improvement.
from
https://projects.blender.org/tracker/index.php?func=detail&aid=4156&group_id=9&atid=127
Detailed description:
Modified the 3ds export script 3ds_export.py:
- It now exports face UV correctly. 3ds only supports one UV coordinate per vertex. The script now duplicates vertices that had multiple UV pairs assigned to them so that each duplicate now only contains one and only one UV. Faces have their vertex indices adjusted accordingly.
- Quads are now split into triangles better. 3ds only supports triangles, so quads need to be split into two triangles. Instead of rather arbitrarily splitting along the diagonal between points 0 and 2, the script now splits along the shortest diagonal. This creates a higher quality triangular mesh, as well as better preservation of symmetry.
- Now creates an object node block, exporting object nodes, needed by some 3D importers. Among others, allows one to export object hierarchy.
- Now exports Empties as 3ds Dummies.
To be able to add all of the above new features, the script has been mostly rewritten and strongly restructured.
Motivation for the rewrite was the desire to be able to use Blender to produce custom 3d cars for Trackmania:Sunrise (TM:S). Previously, the TM:S importer could not correctly handle the 3ds files from the Blender 3ds export script. With this version, one can export cars complete with UV textures, correct wheel placement and light placement. To my knowledge, this script would make Blender the first fully free 3d modeller that allows one to export 3ds models for TM:S (expect a tutorial soon). The ability to have proper UV coordinates exported into the 3ds file should also be very welcome to many.
Add A Comment: Notepad
2006-05-02 11:26:32 +00:00
|
|
|
|
|
|
|
Dump is used for debugging purposes, to dump the contents of a chunk to the standard output.
|
2006-07-05 07:10:03 +00:00
|
|
|
Uses the dump function of the named variables and the subchunks to do the actual work.'''
|
Commited 3ds export enhancements from Mark Stijnman (beowulff)
Will need to do some updates, Mesh over NMesh and optimize some areas but it works and is a big improvement.
from
https://projects.blender.org/tracker/index.php?func=detail&aid=4156&group_id=9&atid=127
Detailed description:
Modified the 3ds export script 3ds_export.py:
- It now exports face UV correctly. 3ds only supports one UV coordinate per vertex. The script now duplicates vertices that had multiple UV pairs assigned to them so that each duplicate now only contains one and only one UV. Faces have their vertex indices adjusted accordingly.
- Quads are now split into triangles better. 3ds only supports triangles, so quads need to be split into two triangles. Instead of rather arbitrarily splitting along the diagonal between points 0 and 2, the script now splits along the shortest diagonal. This creates a higher quality triangular mesh, as well as better preservation of symmetry.
- Now creates an object node block, exporting object nodes, needed by some 3D importers. Among others, allows one to export object hierarchy.
- Now exports Empties as 3ds Dummies.
To be able to add all of the above new features, the script has been mostly rewritten and strongly restructured.
Motivation for the rewrite was the desire to be able to use Blender to produce custom 3d cars for Trackmania:Sunrise (TM:S). Previously, the TM:S importer could not correctly handle the 3ds files from the Blender 3ds export script. With this version, one can export cars complete with UV textures, correct wheel placement and light placement. To my knowledge, this script would make Blender the first fully free 3d modeller that allows one to export 3ds models for TM:S (expect a tutorial soon). The ability to have proper UV coordinates exported into the 3ds file should also be very welcome to many.
Add A Comment: Notepad
2006-05-02 11:26:32 +00:00
|
|
|
spaces=""
|
2009-09-29 15:27:00 +00:00
|
|
|
for i in range(indent):
|
Commited 3ds export enhancements from Mark Stijnman (beowulff)
Will need to do some updates, Mesh over NMesh and optimize some areas but it works and is a big improvement.
from
https://projects.blender.org/tracker/index.php?func=detail&aid=4156&group_id=9&atid=127
Detailed description:
Modified the 3ds export script 3ds_export.py:
- It now exports face UV correctly. 3ds only supports one UV coordinate per vertex. The script now duplicates vertices that had multiple UV pairs assigned to them so that each duplicate now only contains one and only one UV. Faces have their vertex indices adjusted accordingly.
- Quads are now split into triangles better. 3ds only supports triangles, so quads need to be split into two triangles. Instead of rather arbitrarily splitting along the diagonal between points 0 and 2, the script now splits along the shortest diagonal. This creates a higher quality triangular mesh, as well as better preservation of symmetry.
- Now creates an object node block, exporting object nodes, needed by some 3D importers. Among others, allows one to export object hierarchy.
- Now exports Empties as 3ds Dummies.
To be able to add all of the above new features, the script has been mostly rewritten and strongly restructured.
Motivation for the rewrite was the desire to be able to use Blender to produce custom 3d cars for Trackmania:Sunrise (TM:S). Previously, the TM:S importer could not correctly handle the 3ds files from the Blender 3ds export script. With this version, one can export cars complete with UV textures, correct wheel placement and light placement. To my knowledge, this script would make Blender the first fully free 3d modeller that allows one to export 3ds models for TM:S (expect a tutorial soon). The ability to have proper UV coordinates exported into the 3ds file should also be very welcome to many.
Add A Comment: Notepad
2006-05-02 11:26:32 +00:00
|
|
|
spaces+=" ";
|
2009-09-29 15:27:00 +00:00
|
|
|
print(spaces, "ID=", hex(self.ID.value), "size=", self.get_size())
|
Commited 3ds export enhancements from Mark Stijnman (beowulff)
Will need to do some updates, Mesh over NMesh and optimize some areas but it works and is a big improvement.
from
https://projects.blender.org/tracker/index.php?func=detail&aid=4156&group_id=9&atid=127
Detailed description:
Modified the 3ds export script 3ds_export.py:
- It now exports face UV correctly. 3ds only supports one UV coordinate per vertex. The script now duplicates vertices that had multiple UV pairs assigned to them so that each duplicate now only contains one and only one UV. Faces have their vertex indices adjusted accordingly.
- Quads are now split into triangles better. 3ds only supports triangles, so quads need to be split into two triangles. Instead of rather arbitrarily splitting along the diagonal between points 0 and 2, the script now splits along the shortest diagonal. This creates a higher quality triangular mesh, as well as better preservation of symmetry.
- Now creates an object node block, exporting object nodes, needed by some 3D importers. Among others, allows one to export object hierarchy.
- Now exports Empties as 3ds Dummies.
To be able to add all of the above new features, the script has been mostly rewritten and strongly restructured.
Motivation for the rewrite was the desire to be able to use Blender to produce custom 3d cars for Trackmania:Sunrise (TM:S). Previously, the TM:S importer could not correctly handle the 3ds files from the Blender 3ds export script. With this version, one can export cars complete with UV textures, correct wheel placement and light placement. To my knowledge, this script would make Blender the first fully free 3d modeller that allows one to export 3ds models for TM:S (expect a tutorial soon). The ability to have proper UV coordinates exported into the 3ds file should also be very welcome to many.
Add A Comment: Notepad
2006-05-02 11:26:32 +00:00
|
|
|
for variable in self.variables:
|
|
|
|
variable.dump(indent+1)
|
|
|
|
for subchunk in self.subchunks:
|
|
|
|
subchunk.dump(indent+1)
|
2005-12-15 01:42:45 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
Commited 3ds export enhancements from Mark Stijnman (beowulff)
Will need to do some updates, Mesh over NMesh and optimize some areas but it works and is a big improvement.
from
https://projects.blender.org/tracker/index.php?func=detail&aid=4156&group_id=9&atid=127
Detailed description:
Modified the 3ds export script 3ds_export.py:
- It now exports face UV correctly. 3ds only supports one UV coordinate per vertex. The script now duplicates vertices that had multiple UV pairs assigned to them so that each duplicate now only contains one and only one UV. Faces have their vertex indices adjusted accordingly.
- Quads are now split into triangles better. 3ds only supports triangles, so quads need to be split into two triangles. Instead of rather arbitrarily splitting along the diagonal between points 0 and 2, the script now splits along the shortest diagonal. This creates a higher quality triangular mesh, as well as better preservation of symmetry.
- Now creates an object node block, exporting object nodes, needed by some 3D importers. Among others, allows one to export object hierarchy.
- Now exports Empties as 3ds Dummies.
To be able to add all of the above new features, the script has been mostly rewritten and strongly restructured.
Motivation for the rewrite was the desire to be able to use Blender to produce custom 3d cars for Trackmania:Sunrise (TM:S). Previously, the TM:S importer could not correctly handle the 3ds files from the Blender 3ds export script. With this version, one can export cars complete with UV textures, correct wheel placement and light placement. To my knowledge, this script would make Blender the first fully free 3d modeller that allows one to export 3ds models for TM:S (expect a tutorial soon). The ability to have proper UV coordinates exported into the 3ds file should also be very welcome to many.
Add A Comment: Notepad
2006-05-02 11:26:32 +00:00
|
|
|
######################################################
|
|
|
|
# EXPORT
|
|
|
|
######################################################
|
2007-01-31 01:18:51 +00:00
|
|
|
|
2007-01-04 15:20:28 +00:00
|
|
|
def get_material_images(material):
|
|
|
|
# blender utility func.
|
|
|
|
if material:
|
2009-09-29 15:27:00 +00:00
|
|
|
return [s.texture.image for s in material.textures if s and s.texture.type == 'IMAGE' and s.texture.image]
|
|
|
|
|
|
|
|
return []
|
|
|
|
# images = []
|
|
|
|
# if material:
|
|
|
|
# for mtex in material.getTextures():
|
|
|
|
# if mtex and mtex.tex.type == Blender.Texture.Types.IMAGE:
|
|
|
|
# image = mtex.tex.image
|
|
|
|
# if image:
|
|
|
|
# images.append(image) # maye want to include info like diffuse, spec here.
|
|
|
|
# return images
|
|
|
|
|
2007-01-31 01:18:51 +00:00
|
|
|
|
Commited 3ds export enhancements from Mark Stijnman (beowulff)
Will need to do some updates, Mesh over NMesh and optimize some areas but it works and is a big improvement.
from
https://projects.blender.org/tracker/index.php?func=detail&aid=4156&group_id=9&atid=127
Detailed description:
Modified the 3ds export script 3ds_export.py:
- It now exports face UV correctly. 3ds only supports one UV coordinate per vertex. The script now duplicates vertices that had multiple UV pairs assigned to them so that each duplicate now only contains one and only one UV. Faces have their vertex indices adjusted accordingly.
- Quads are now split into triangles better. 3ds only supports triangles, so quads need to be split into two triangles. Instead of rather arbitrarily splitting along the diagonal between points 0 and 2, the script now splits along the shortest diagonal. This creates a higher quality triangular mesh, as well as better preservation of symmetry.
- Now creates an object node block, exporting object nodes, needed by some 3D importers. Among others, allows one to export object hierarchy.
- Now exports Empties as 3ds Dummies.
To be able to add all of the above new features, the script has been mostly rewritten and strongly restructured.
Motivation for the rewrite was the desire to be able to use Blender to produce custom 3d cars for Trackmania:Sunrise (TM:S). Previously, the TM:S importer could not correctly handle the 3ds files from the Blender 3ds export script. With this version, one can export cars complete with UV textures, correct wheel placement and light placement. To my knowledge, this script would make Blender the first fully free 3d modeller that allows one to export 3ds models for TM:S (expect a tutorial soon). The ability to have proper UV coordinates exported into the 3ds file should also be very welcome to many.
Add A Comment: Notepad
2006-05-02 11:26:32 +00:00
|
|
|
def make_material_subchunk(id, color):
|
2006-07-05 07:10:03 +00:00
|
|
|
'''Make a material subchunk.
|
Commited 3ds export enhancements from Mark Stijnman (beowulff)
Will need to do some updates, Mesh over NMesh and optimize some areas but it works and is a big improvement.
from
https://projects.blender.org/tracker/index.php?func=detail&aid=4156&group_id=9&atid=127
Detailed description:
Modified the 3ds export script 3ds_export.py:
- It now exports face UV correctly. 3ds only supports one UV coordinate per vertex. The script now duplicates vertices that had multiple UV pairs assigned to them so that each duplicate now only contains one and only one UV. Faces have their vertex indices adjusted accordingly.
- Quads are now split into triangles better. 3ds only supports triangles, so quads need to be split into two triangles. Instead of rather arbitrarily splitting along the diagonal between points 0 and 2, the script now splits along the shortest diagonal. This creates a higher quality triangular mesh, as well as better preservation of symmetry.
- Now creates an object node block, exporting object nodes, needed by some 3D importers. Among others, allows one to export object hierarchy.
- Now exports Empties as 3ds Dummies.
To be able to add all of the above new features, the script has been mostly rewritten and strongly restructured.
Motivation for the rewrite was the desire to be able to use Blender to produce custom 3d cars for Trackmania:Sunrise (TM:S). Previously, the TM:S importer could not correctly handle the 3ds files from the Blender 3ds export script. With this version, one can export cars complete with UV textures, correct wheel placement and light placement. To my knowledge, this script would make Blender the first fully free 3d modeller that allows one to export 3ds models for TM:S (expect a tutorial soon). The ability to have proper UV coordinates exported into the 3ds file should also be very welcome to many.
Add A Comment: Notepad
2006-05-02 11:26:32 +00:00
|
|
|
|
2006-07-05 07:10:03 +00:00
|
|
|
Used for color subchunks, such as diffuse color or ambient color subchunks.'''
|
Commited 3ds export enhancements from Mark Stijnman (beowulff)
Will need to do some updates, Mesh over NMesh and optimize some areas but it works and is a big improvement.
from
https://projects.blender.org/tracker/index.php?func=detail&aid=4156&group_id=9&atid=127
Detailed description:
Modified the 3ds export script 3ds_export.py:
- It now exports face UV correctly. 3ds only supports one UV coordinate per vertex. The script now duplicates vertices that had multiple UV pairs assigned to them so that each duplicate now only contains one and only one UV. Faces have their vertex indices adjusted accordingly.
- Quads are now split into triangles better. 3ds only supports triangles, so quads need to be split into two triangles. Instead of rather arbitrarily splitting along the diagonal between points 0 and 2, the script now splits along the shortest diagonal. This creates a higher quality triangular mesh, as well as better preservation of symmetry.
- Now creates an object node block, exporting object nodes, needed by some 3D importers. Among others, allows one to export object hierarchy.
- Now exports Empties as 3ds Dummies.
To be able to add all of the above new features, the script has been mostly rewritten and strongly restructured.
Motivation for the rewrite was the desire to be able to use Blender to produce custom 3d cars for Trackmania:Sunrise (TM:S). Previously, the TM:S importer could not correctly handle the 3ds files from the Blender 3ds export script. With this version, one can export cars complete with UV textures, correct wheel placement and light placement. To my knowledge, this script would make Blender the first fully free 3d modeller that allows one to export 3ds models for TM:S (expect a tutorial soon). The ability to have proper UV coordinates exported into the 3ds file should also be very welcome to many.
Add A Comment: Notepad
2006-05-02 11:26:32 +00:00
|
|
|
mat_sub = _3ds_chunk(id)
|
|
|
|
col1 = _3ds_chunk(RGB1)
|
|
|
|
col1.add_variable("color1", _3ds_rgb_color(color));
|
|
|
|
mat_sub.add_subchunk(col1)
|
|
|
|
# optional:
|
|
|
|
# col2 = _3ds_chunk(RGB1)
|
|
|
|
# col2.add_variable("color2", _3ds_rgb_color(color));
|
|
|
|
# mat_sub.add_subchunk(col2)
|
|
|
|
return mat_sub
|
|
|
|
|
2007-01-31 01:18:51 +00:00
|
|
|
|
2007-01-04 15:20:28 +00:00
|
|
|
def make_material_texture_chunk(id, images):
|
2007-01-22 17:31:34 +00:00
|
|
|
"""Make Material Map texture chunk
|
|
|
|
"""
|
2007-01-04 05:59:23 +00:00
|
|
|
mat_sub = _3ds_chunk(id)
|
2007-01-04 15:20:28 +00:00
|
|
|
|
|
|
|
def add_image(img):
|
2009-09-29 15:27:00 +00:00
|
|
|
filename = os.path.basename(image.filename)
|
|
|
|
# filename = image.filename.split('\\')[-1].split('/')[-1]
|
2007-01-04 15:20:28 +00:00
|
|
|
mat_sub_file = _3ds_chunk(MATMAPFILE)
|
2007-05-06 02:19:43 +00:00
|
|
|
mat_sub_file.add_variable("mapfile", _3ds_string(sane_name(filename)))
|
2007-01-04 15:20:28 +00:00
|
|
|
mat_sub.add_subchunk(mat_sub_file)
|
|
|
|
|
|
|
|
for image in images:
|
|
|
|
add_image(image)
|
|
|
|
|
2007-01-04 05:59:23 +00:00
|
|
|
return mat_sub
|
2007-01-31 01:18:51 +00:00
|
|
|
|
2007-05-06 02:19:43 +00:00
|
|
|
def make_material_chunk(material, image):
|
2006-07-05 07:10:03 +00:00
|
|
|
'''Make a material chunk out of a blender material.'''
|
Commited 3ds export enhancements from Mark Stijnman (beowulff)
Will need to do some updates, Mesh over NMesh and optimize some areas but it works and is a big improvement.
from
https://projects.blender.org/tracker/index.php?func=detail&aid=4156&group_id=9&atid=127
Detailed description:
Modified the 3ds export script 3ds_export.py:
- It now exports face UV correctly. 3ds only supports one UV coordinate per vertex. The script now duplicates vertices that had multiple UV pairs assigned to them so that each duplicate now only contains one and only one UV. Faces have their vertex indices adjusted accordingly.
- Quads are now split into triangles better. 3ds only supports triangles, so quads need to be split into two triangles. Instead of rather arbitrarily splitting along the diagonal between points 0 and 2, the script now splits along the shortest diagonal. This creates a higher quality triangular mesh, as well as better preservation of symmetry.
- Now creates an object node block, exporting object nodes, needed by some 3D importers. Among others, allows one to export object hierarchy.
- Now exports Empties as 3ds Dummies.
To be able to add all of the above new features, the script has been mostly rewritten and strongly restructured.
Motivation for the rewrite was the desire to be able to use Blender to produce custom 3d cars for Trackmania:Sunrise (TM:S). Previously, the TM:S importer could not correctly handle the 3ds files from the Blender 3ds export script. With this version, one can export cars complete with UV textures, correct wheel placement and light placement. To my knowledge, this script would make Blender the first fully free 3d modeller that allows one to export 3ds models for TM:S (expect a tutorial soon). The ability to have proper UV coordinates exported into the 3ds file should also be very welcome to many.
Add A Comment: Notepad
2006-05-02 11:26:32 +00:00
|
|
|
material_chunk = _3ds_chunk(MATERIAL)
|
|
|
|
name = _3ds_chunk(MATNAME)
|
2007-01-04 15:20:28 +00:00
|
|
|
|
|
|
|
if material: name_str = material.name
|
|
|
|
else: name_str = 'None'
|
|
|
|
if image: name_str += image.name
|
|
|
|
|
2007-05-06 02:19:43 +00:00
|
|
|
name.add_variable("name", _3ds_string(sane_name(name_str)))
|
Commited 3ds export enhancements from Mark Stijnman (beowulff)
Will need to do some updates, Mesh over NMesh and optimize some areas but it works and is a big improvement.
from
https://projects.blender.org/tracker/index.php?func=detail&aid=4156&group_id=9&atid=127
Detailed description:
Modified the 3ds export script 3ds_export.py:
- It now exports face UV correctly. 3ds only supports one UV coordinate per vertex. The script now duplicates vertices that had multiple UV pairs assigned to them so that each duplicate now only contains one and only one UV. Faces have their vertex indices adjusted accordingly.
- Quads are now split into triangles better. 3ds only supports triangles, so quads need to be split into two triangles. Instead of rather arbitrarily splitting along the diagonal between points 0 and 2, the script now splits along the shortest diagonal. This creates a higher quality triangular mesh, as well as better preservation of symmetry.
- Now creates an object node block, exporting object nodes, needed by some 3D importers. Among others, allows one to export object hierarchy.
- Now exports Empties as 3ds Dummies.
To be able to add all of the above new features, the script has been mostly rewritten and strongly restructured.
Motivation for the rewrite was the desire to be able to use Blender to produce custom 3d cars for Trackmania:Sunrise (TM:S). Previously, the TM:S importer could not correctly handle the 3ds files from the Blender 3ds export script. With this version, one can export cars complete with UV textures, correct wheel placement and light placement. To my knowledge, this script would make Blender the first fully free 3d modeller that allows one to export 3ds models for TM:S (expect a tutorial soon). The ability to have proper UV coordinates exported into the 3ds file should also be very welcome to many.
Add A Comment: Notepad
2006-05-02 11:26:32 +00:00
|
|
|
material_chunk.add_subchunk(name)
|
2007-01-04 15:20:28 +00:00
|
|
|
|
2007-05-06 02:19:43 +00:00
|
|
|
if not material:
|
2007-01-04 15:20:28 +00:00
|
|
|
material_chunk.add_subchunk(make_material_subchunk(MATAMBIENT, (0,0,0) ))
|
|
|
|
material_chunk.add_subchunk(make_material_subchunk(MATDIFFUSE, (.8, .8, .8) ))
|
|
|
|
material_chunk.add_subchunk(make_material_subchunk(MATSPECULAR, (1,1,1) ))
|
|
|
|
|
2007-05-06 02:19:43 +00:00
|
|
|
else:
|
2009-09-29 15:27:00 +00:00
|
|
|
material_chunk.add_subchunk(make_material_subchunk(MATAMBIENT, [a*material.ambient for a in material.diffuse_color] ))
|
|
|
|
# material_chunk.add_subchunk(make_material_subchunk(MATAMBIENT, [a*material.amb for a in material.rgbCol] ))
|
|
|
|
material_chunk.add_subchunk(make_material_subchunk(MATDIFFUSE, material.diffuse_color))
|
|
|
|
# material_chunk.add_subchunk(make_material_subchunk(MATDIFFUSE, material.rgbCol))
|
|
|
|
material_chunk.add_subchunk(make_material_subchunk(MATSPECULAR, material.specular_color))
|
|
|
|
# material_chunk.add_subchunk(make_material_subchunk(MATSPECULAR, material.specCol))
|
2007-05-06 02:19:43 +00:00
|
|
|
|
2007-01-31 01:18:51 +00:00
|
|
|
images = get_material_images(material) # can be None
|
|
|
|
if image: images.append(image)
|
|
|
|
|
|
|
|
if images:
|
|
|
|
material_chunk.add_subchunk(make_material_texture_chunk(MATMAP, images))
|
2007-01-04 15:20:28 +00:00
|
|
|
|
Commited 3ds export enhancements from Mark Stijnman (beowulff)
Will need to do some updates, Mesh over NMesh and optimize some areas but it works and is a big improvement.
from
https://projects.blender.org/tracker/index.php?func=detail&aid=4156&group_id=9&atid=127
Detailed description:
Modified the 3ds export script 3ds_export.py:
- It now exports face UV correctly. 3ds only supports one UV coordinate per vertex. The script now duplicates vertices that had multiple UV pairs assigned to them so that each duplicate now only contains one and only one UV. Faces have their vertex indices adjusted accordingly.
- Quads are now split into triangles better. 3ds only supports triangles, so quads need to be split into two triangles. Instead of rather arbitrarily splitting along the diagonal between points 0 and 2, the script now splits along the shortest diagonal. This creates a higher quality triangular mesh, as well as better preservation of symmetry.
- Now creates an object node block, exporting object nodes, needed by some 3D importers. Among others, allows one to export object hierarchy.
- Now exports Empties as 3ds Dummies.
To be able to add all of the above new features, the script has been mostly rewritten and strongly restructured.
Motivation for the rewrite was the desire to be able to use Blender to produce custom 3d cars for Trackmania:Sunrise (TM:S). Previously, the TM:S importer could not correctly handle the 3ds files from the Blender 3ds export script. With this version, one can export cars complete with UV textures, correct wheel placement and light placement. To my knowledge, this script would make Blender the first fully free 3d modeller that allows one to export 3ds models for TM:S (expect a tutorial soon). The ability to have proper UV coordinates exported into the 3ds file should also be very welcome to many.
Add A Comment: Notepad
2006-05-02 11:26:32 +00:00
|
|
|
return material_chunk
|
|
|
|
|
2007-01-04 20:44:33 +00:00
|
|
|
class tri_wrapper(object):
|
2006-07-05 07:10:03 +00:00
|
|
|
'''Class representing a triangle.
|
Commited 3ds export enhancements from Mark Stijnman (beowulff)
Will need to do some updates, Mesh over NMesh and optimize some areas but it works and is a big improvement.
from
https://projects.blender.org/tracker/index.php?func=detail&aid=4156&group_id=9&atid=127
Detailed description:
Modified the 3ds export script 3ds_export.py:
- It now exports face UV correctly. 3ds only supports one UV coordinate per vertex. The script now duplicates vertices that had multiple UV pairs assigned to them so that each duplicate now only contains one and only one UV. Faces have their vertex indices adjusted accordingly.
- Quads are now split into triangles better. 3ds only supports triangles, so quads need to be split into two triangles. Instead of rather arbitrarily splitting along the diagonal between points 0 and 2, the script now splits along the shortest diagonal. This creates a higher quality triangular mesh, as well as better preservation of symmetry.
- Now creates an object node block, exporting object nodes, needed by some 3D importers. Among others, allows one to export object hierarchy.
- Now exports Empties as 3ds Dummies.
To be able to add all of the above new features, the script has been mostly rewritten and strongly restructured.
Motivation for the rewrite was the desire to be able to use Blender to produce custom 3d cars for Trackmania:Sunrise (TM:S). Previously, the TM:S importer could not correctly handle the 3ds files from the Blender 3ds export script. With this version, one can export cars complete with UV textures, correct wheel placement and light placement. To my knowledge, this script would make Blender the first fully free 3d modeller that allows one to export 3ds models for TM:S (expect a tutorial soon). The ability to have proper UV coordinates exported into the 3ds file should also be very welcome to many.
Add A Comment: Notepad
2006-05-02 11:26:32 +00:00
|
|
|
|
2006-07-05 07:10:03 +00:00
|
|
|
Used when converting faces to triangles'''
|
Commited 3ds export enhancements from Mark Stijnman (beowulff)
Will need to do some updates, Mesh over NMesh and optimize some areas but it works and is a big improvement.
from
https://projects.blender.org/tracker/index.php?func=detail&aid=4156&group_id=9&atid=127
Detailed description:
Modified the 3ds export script 3ds_export.py:
- It now exports face UV correctly. 3ds only supports one UV coordinate per vertex. The script now duplicates vertices that had multiple UV pairs assigned to them so that each duplicate now only contains one and only one UV. Faces have their vertex indices adjusted accordingly.
- Quads are now split into triangles better. 3ds only supports triangles, so quads need to be split into two triangles. Instead of rather arbitrarily splitting along the diagonal between points 0 and 2, the script now splits along the shortest diagonal. This creates a higher quality triangular mesh, as well as better preservation of symmetry.
- Now creates an object node block, exporting object nodes, needed by some 3D importers. Among others, allows one to export object hierarchy.
- Now exports Empties as 3ds Dummies.
To be able to add all of the above new features, the script has been mostly rewritten and strongly restructured.
Motivation for the rewrite was the desire to be able to use Blender to produce custom 3d cars for Trackmania:Sunrise (TM:S). Previously, the TM:S importer could not correctly handle the 3ds files from the Blender 3ds export script. With this version, one can export cars complete with UV textures, correct wheel placement and light placement. To my knowledge, this script would make Blender the first fully free 3d modeller that allows one to export 3ds models for TM:S (expect a tutorial soon). The ability to have proper UV coordinates exported into the 3ds file should also be very welcome to many.
Add A Comment: Notepad
2006-05-02 11:26:32 +00:00
|
|
|
|
2007-01-04 20:44:33 +00:00
|
|
|
__slots__ = 'vertex_index', 'mat', 'image', 'faceuvs', 'offset'
|
2007-01-04 15:20:28 +00:00
|
|
|
def __init__(self, vindex=(0,0,0), mat=None, image=None, faceuvs=None):
|
2006-05-14 03:11:55 +00:00
|
|
|
self.vertex_index= vindex
|
|
|
|
self.mat= mat
|
2007-01-04 15:20:28 +00:00
|
|
|
self.image= image
|
2006-05-14 03:11:55 +00:00
|
|
|
self.faceuvs= faceuvs
|
|
|
|
self.offset= [0, 0, 0] # offset indicies
|
Commited 3ds export enhancements from Mark Stijnman (beowulff)
Will need to do some updates, Mesh over NMesh and optimize some areas but it works and is a big improvement.
from
https://projects.blender.org/tracker/index.php?func=detail&aid=4156&group_id=9&atid=127
Detailed description:
Modified the 3ds export script 3ds_export.py:
- It now exports face UV correctly. 3ds only supports one UV coordinate per vertex. The script now duplicates vertices that had multiple UV pairs assigned to them so that each duplicate now only contains one and only one UV. Faces have their vertex indices adjusted accordingly.
- Quads are now split into triangles better. 3ds only supports triangles, so quads need to be split into two triangles. Instead of rather arbitrarily splitting along the diagonal between points 0 and 2, the script now splits along the shortest diagonal. This creates a higher quality triangular mesh, as well as better preservation of symmetry.
- Now creates an object node block, exporting object nodes, needed by some 3D importers. Among others, allows one to export object hierarchy.
- Now exports Empties as 3ds Dummies.
To be able to add all of the above new features, the script has been mostly rewritten and strongly restructured.
Motivation for the rewrite was the desire to be able to use Blender to produce custom 3d cars for Trackmania:Sunrise (TM:S). Previously, the TM:S importer could not correctly handle the 3ds files from the Blender 3ds export script. With this version, one can export cars complete with UV textures, correct wheel placement and light placement. To my knowledge, this script would make Blender the first fully free 3d modeller that allows one to export 3ds models for TM:S (expect a tutorial soon). The ability to have proper UV coordinates exported into the 3ds file should also be very welcome to many.
Add A Comment: Notepad
2006-05-02 11:26:32 +00:00
|
|
|
|
2007-01-04 15:20:28 +00:00
|
|
|
|
Commited 3ds export enhancements from Mark Stijnman (beowulff)
Will need to do some updates, Mesh over NMesh and optimize some areas but it works and is a big improvement.
from
https://projects.blender.org/tracker/index.php?func=detail&aid=4156&group_id=9&atid=127
Detailed description:
Modified the 3ds export script 3ds_export.py:
- It now exports face UV correctly. 3ds only supports one UV coordinate per vertex. The script now duplicates vertices that had multiple UV pairs assigned to them so that each duplicate now only contains one and only one UV. Faces have their vertex indices adjusted accordingly.
- Quads are now split into triangles better. 3ds only supports triangles, so quads need to be split into two triangles. Instead of rather arbitrarily splitting along the diagonal between points 0 and 2, the script now splits along the shortest diagonal. This creates a higher quality triangular mesh, as well as better preservation of symmetry.
- Now creates an object node block, exporting object nodes, needed by some 3D importers. Among others, allows one to export object hierarchy.
- Now exports Empties as 3ds Dummies.
To be able to add all of the above new features, the script has been mostly rewritten and strongly restructured.
Motivation for the rewrite was the desire to be able to use Blender to produce custom 3d cars for Trackmania:Sunrise (TM:S). Previously, the TM:S importer could not correctly handle the 3ds files from the Blender 3ds export script. With this version, one can export cars complete with UV textures, correct wheel placement and light placement. To my knowledge, this script would make Blender the first fully free 3d modeller that allows one to export 3ds models for TM:S (expect a tutorial soon). The ability to have proper UV coordinates exported into the 3ds file should also be very welcome to many.
Add A Comment: Notepad
2006-05-02 11:26:32 +00:00
|
|
|
def extract_triangles(mesh):
|
2006-07-05 07:10:03 +00:00
|
|
|
'''Extract triangles from a mesh.
|
Commited 3ds export enhancements from Mark Stijnman (beowulff)
Will need to do some updates, Mesh over NMesh and optimize some areas but it works and is a big improvement.
from
https://projects.blender.org/tracker/index.php?func=detail&aid=4156&group_id=9&atid=127
Detailed description:
Modified the 3ds export script 3ds_export.py:
- It now exports face UV correctly. 3ds only supports one UV coordinate per vertex. The script now duplicates vertices that had multiple UV pairs assigned to them so that each duplicate now only contains one and only one UV. Faces have their vertex indices adjusted accordingly.
- Quads are now split into triangles better. 3ds only supports triangles, so quads need to be split into two triangles. Instead of rather arbitrarily splitting along the diagonal between points 0 and 2, the script now splits along the shortest diagonal. This creates a higher quality triangular mesh, as well as better preservation of symmetry.
- Now creates an object node block, exporting object nodes, needed by some 3D importers. Among others, allows one to export object hierarchy.
- Now exports Empties as 3ds Dummies.
To be able to add all of the above new features, the script has been mostly rewritten and strongly restructured.
Motivation for the rewrite was the desire to be able to use Blender to produce custom 3d cars for Trackmania:Sunrise (TM:S). Previously, the TM:S importer could not correctly handle the 3ds files from the Blender 3ds export script. With this version, one can export cars complete with UV textures, correct wheel placement and light placement. To my knowledge, this script would make Blender the first fully free 3d modeller that allows one to export 3ds models for TM:S (expect a tutorial soon). The ability to have proper UV coordinates exported into the 3ds file should also be very welcome to many.
Add A Comment: Notepad
2006-05-02 11:26:32 +00:00
|
|
|
|
2006-07-05 07:10:03 +00:00
|
|
|
If the mesh contains quads, they will be split into triangles.'''
|
Commited 3ds export enhancements from Mark Stijnman (beowulff)
Will need to do some updates, Mesh over NMesh and optimize some areas but it works and is a big improvement.
from
https://projects.blender.org/tracker/index.php?func=detail&aid=4156&group_id=9&atid=127
Detailed description:
Modified the 3ds export script 3ds_export.py:
- It now exports face UV correctly. 3ds only supports one UV coordinate per vertex. The script now duplicates vertices that had multiple UV pairs assigned to them so that each duplicate now only contains one and only one UV. Faces have their vertex indices adjusted accordingly.
- Quads are now split into triangles better. 3ds only supports triangles, so quads need to be split into two triangles. Instead of rather arbitrarily splitting along the diagonal between points 0 and 2, the script now splits along the shortest diagonal. This creates a higher quality triangular mesh, as well as better preservation of symmetry.
- Now creates an object node block, exporting object nodes, needed by some 3D importers. Among others, allows one to export object hierarchy.
- Now exports Empties as 3ds Dummies.
To be able to add all of the above new features, the script has been mostly rewritten and strongly restructured.
Motivation for the rewrite was the desire to be able to use Blender to produce custom 3d cars for Trackmania:Sunrise (TM:S). Previously, the TM:S importer could not correctly handle the 3ds files from the Blender 3ds export script. With this version, one can export cars complete with UV textures, correct wheel placement and light placement. To my knowledge, this script would make Blender the first fully free 3d modeller that allows one to export 3ds models for TM:S (expect a tutorial soon). The ability to have proper UV coordinates exported into the 3ds file should also be very welcome to many.
Add A Comment: Notepad
2006-05-02 11:26:32 +00:00
|
|
|
tri_list = []
|
2009-09-29 15:27:00 +00:00
|
|
|
do_uv = len(mesh.uv_textures)
|
|
|
|
# do_uv = mesh.faceUV
|
2007-05-06 02:19:43 +00:00
|
|
|
|
2009-09-29 15:27:00 +00:00
|
|
|
# if not do_uv:
|
|
|
|
# face_uv = None
|
2007-05-06 02:19:43 +00:00
|
|
|
|
2007-01-04 15:20:28 +00:00
|
|
|
img = None
|
2009-09-29 15:27:00 +00:00
|
|
|
for i, face in enumerate(mesh.faces):
|
|
|
|
f_v = face.verts
|
|
|
|
# f_v = face.v
|
|
|
|
|
|
|
|
uf = mesh.active_uv_texture.data[i] if do_uv else None
|
2007-05-06 02:19:43 +00:00
|
|
|
|
|
|
|
if do_uv:
|
2009-09-29 15:27:00 +00:00
|
|
|
f_uv = uf.uv
|
|
|
|
# f_uv = (uf.uv1, uf.uv2, uf.uv3, uf.uv4) if face.verts[3] else (uf.uv1, uf.uv2, uf.uv3)
|
|
|
|
# f_uv = face.uv
|
|
|
|
img = uf.image if uf else None
|
|
|
|
# img = face.image
|
2007-05-06 02:19:43 +00:00
|
|
|
if img: img = img.name
|
|
|
|
|
2009-09-29 15:27:00 +00:00
|
|
|
# if f_v[3] == 0:
|
2007-05-06 02:19:43 +00:00
|
|
|
if len(f_v)==3:
|
2009-09-29 15:27:00 +00:00
|
|
|
new_tri = tri_wrapper((f_v[0], f_v[1], f_v[2]), face.material_index, img)
|
|
|
|
# new_tri = tri_wrapper((f_v[0].index, f_v[1].index, f_v[2].index), face.mat, img)
|
2007-05-06 02:19:43 +00:00
|
|
|
if (do_uv): new_tri.faceuvs= uv_key(f_uv[0]), uv_key(f_uv[1]), uv_key(f_uv[2])
|
|
|
|
tri_list.append(new_tri)
|
|
|
|
|
|
|
|
else: #it's a quad
|
2009-09-29 15:27:00 +00:00
|
|
|
new_tri = tri_wrapper((f_v[0], f_v[1], f_v[2]), face.material_index, img)
|
|
|
|
# new_tri = tri_wrapper((f_v[0].index, f_v[1].index, f_v[2].index), face.mat, img)
|
|
|
|
new_tri_2 = tri_wrapper((f_v[0], f_v[2], f_v[3]), face.material_index, img)
|
|
|
|
# new_tri_2 = tri_wrapper((f_v[0].index, f_v[2].index, f_v[3].index), face.mat, img)
|
2007-05-06 02:19:43 +00:00
|
|
|
|
|
|
|
if (do_uv):
|
|
|
|
new_tri.faceuvs= uv_key(f_uv[0]), uv_key(f_uv[1]), uv_key(f_uv[2])
|
|
|
|
new_tri_2.faceuvs= uv_key(f_uv[0]), uv_key(f_uv[2]), uv_key(f_uv[3])
|
|
|
|
|
|
|
|
tri_list.append( new_tri )
|
|
|
|
tri_list.append( new_tri_2 )
|
Commited 3ds export enhancements from Mark Stijnman (beowulff)
Will need to do some updates, Mesh over NMesh and optimize some areas but it works and is a big improvement.
from
https://projects.blender.org/tracker/index.php?func=detail&aid=4156&group_id=9&atid=127
Detailed description:
Modified the 3ds export script 3ds_export.py:
- It now exports face UV correctly. 3ds only supports one UV coordinate per vertex. The script now duplicates vertices that had multiple UV pairs assigned to them so that each duplicate now only contains one and only one UV. Faces have their vertex indices adjusted accordingly.
- Quads are now split into triangles better. 3ds only supports triangles, so quads need to be split into two triangles. Instead of rather arbitrarily splitting along the diagonal between points 0 and 2, the script now splits along the shortest diagonal. This creates a higher quality triangular mesh, as well as better preservation of symmetry.
- Now creates an object node block, exporting object nodes, needed by some 3D importers. Among others, allows one to export object hierarchy.
- Now exports Empties as 3ds Dummies.
To be able to add all of the above new features, the script has been mostly rewritten and strongly restructured.
Motivation for the rewrite was the desire to be able to use Blender to produce custom 3d cars for Trackmania:Sunrise (TM:S). Previously, the TM:S importer could not correctly handle the 3ds files from the Blender 3ds export script. With this version, one can export cars complete with UV textures, correct wheel placement and light placement. To my knowledge, this script would make Blender the first fully free 3d modeller that allows one to export 3ds models for TM:S (expect a tutorial soon). The ability to have proper UV coordinates exported into the 3ds file should also be very welcome to many.
Add A Comment: Notepad
2006-05-02 11:26:32 +00:00
|
|
|
|
|
|
|
return tri_list
|
|
|
|
|
|
|
|
|
|
|
|
def remove_face_uv(verts, tri_list):
|
2006-07-05 07:10:03 +00:00
|
|
|
'''Remove face UV coordinates from a list of triangles.
|
Commited 3ds export enhancements from Mark Stijnman (beowulff)
Will need to do some updates, Mesh over NMesh and optimize some areas but it works and is a big improvement.
from
https://projects.blender.org/tracker/index.php?func=detail&aid=4156&group_id=9&atid=127
Detailed description:
Modified the 3ds export script 3ds_export.py:
- It now exports face UV correctly. 3ds only supports one UV coordinate per vertex. The script now duplicates vertices that had multiple UV pairs assigned to them so that each duplicate now only contains one and only one UV. Faces have their vertex indices adjusted accordingly.
- Quads are now split into triangles better. 3ds only supports triangles, so quads need to be split into two triangles. Instead of rather arbitrarily splitting along the diagonal between points 0 and 2, the script now splits along the shortest diagonal. This creates a higher quality triangular mesh, as well as better preservation of symmetry.
- Now creates an object node block, exporting object nodes, needed by some 3D importers. Among others, allows one to export object hierarchy.
- Now exports Empties as 3ds Dummies.
To be able to add all of the above new features, the script has been mostly rewritten and strongly restructured.
Motivation for the rewrite was the desire to be able to use Blender to produce custom 3d cars for Trackmania:Sunrise (TM:S). Previously, the TM:S importer could not correctly handle the 3ds files from the Blender 3ds export script. With this version, one can export cars complete with UV textures, correct wheel placement and light placement. To my knowledge, this script would make Blender the first fully free 3d modeller that allows one to export 3ds models for TM:S (expect a tutorial soon). The ability to have proper UV coordinates exported into the 3ds file should also be very welcome to many.
Add A Comment: Notepad
2006-05-02 11:26:32 +00:00
|
|
|
|
|
|
|
Since 3ds files only support one pair of uv coordinates for each vertex, face uv coordinates
|
|
|
|
need to be converted to vertex uv coordinates. That means that vertices need to be duplicated when
|
2006-07-05 07:10:03 +00:00
|
|
|
there are multiple uv coordinates per vertex.'''
|
Commited 3ds export enhancements from Mark Stijnman (beowulff)
Will need to do some updates, Mesh over NMesh and optimize some areas but it works and is a big improvement.
from
https://projects.blender.org/tracker/index.php?func=detail&aid=4156&group_id=9&atid=127
Detailed description:
Modified the 3ds export script 3ds_export.py:
- It now exports face UV correctly. 3ds only supports one UV coordinate per vertex. The script now duplicates vertices that had multiple UV pairs assigned to them so that each duplicate now only contains one and only one UV. Faces have their vertex indices adjusted accordingly.
- Quads are now split into triangles better. 3ds only supports triangles, so quads need to be split into two triangles. Instead of rather arbitrarily splitting along the diagonal between points 0 and 2, the script now splits along the shortest diagonal. This creates a higher quality triangular mesh, as well as better preservation of symmetry.
- Now creates an object node block, exporting object nodes, needed by some 3D importers. Among others, allows one to export object hierarchy.
- Now exports Empties as 3ds Dummies.
To be able to add all of the above new features, the script has been mostly rewritten and strongly restructured.
Motivation for the rewrite was the desire to be able to use Blender to produce custom 3d cars for Trackmania:Sunrise (TM:S). Previously, the TM:S importer could not correctly handle the 3ds files from the Blender 3ds export script. With this version, one can export cars complete with UV textures, correct wheel placement and light placement. To my knowledge, this script would make Blender the first fully free 3d modeller that allows one to export 3ds models for TM:S (expect a tutorial soon). The ability to have proper UV coordinates exported into the 3ds file should also be very welcome to many.
Add A Comment: Notepad
2006-05-02 11:26:32 +00:00
|
|
|
|
|
|
|
# initialize a list of UniqueLists, one per vertex:
|
2006-05-14 03:11:55 +00:00
|
|
|
#uv_list = [UniqueList() for i in xrange(len(verts))]
|
2009-09-29 15:27:00 +00:00
|
|
|
unique_uvs= [{} for i in range(len(verts))]
|
Commited 3ds export enhancements from Mark Stijnman (beowulff)
Will need to do some updates, Mesh over NMesh and optimize some areas but it works and is a big improvement.
from
https://projects.blender.org/tracker/index.php?func=detail&aid=4156&group_id=9&atid=127
Detailed description:
Modified the 3ds export script 3ds_export.py:
- It now exports face UV correctly. 3ds only supports one UV coordinate per vertex. The script now duplicates vertices that had multiple UV pairs assigned to them so that each duplicate now only contains one and only one UV. Faces have their vertex indices adjusted accordingly.
- Quads are now split into triangles better. 3ds only supports triangles, so quads need to be split into two triangles. Instead of rather arbitrarily splitting along the diagonal between points 0 and 2, the script now splits along the shortest diagonal. This creates a higher quality triangular mesh, as well as better preservation of symmetry.
- Now creates an object node block, exporting object nodes, needed by some 3D importers. Among others, allows one to export object hierarchy.
- Now exports Empties as 3ds Dummies.
To be able to add all of the above new features, the script has been mostly rewritten and strongly restructured.
Motivation for the rewrite was the desire to be able to use Blender to produce custom 3d cars for Trackmania:Sunrise (TM:S). Previously, the TM:S importer could not correctly handle the 3ds files from the Blender 3ds export script. With this version, one can export cars complete with UV textures, correct wheel placement and light placement. To my knowledge, this script would make Blender the first fully free 3d modeller that allows one to export 3ds models for TM:S (expect a tutorial soon). The ability to have proper UV coordinates exported into the 3ds file should also be very welcome to many.
Add A Comment: Notepad
2006-05-02 11:26:32 +00:00
|
|
|
|
|
|
|
# for each face uv coordinate, add it to the UniqueList of the vertex
|
|
|
|
for tri in tri_list:
|
2009-09-29 15:27:00 +00:00
|
|
|
for i in range(3):
|
Commited 3ds export enhancements from Mark Stijnman (beowulff)
Will need to do some updates, Mesh over NMesh and optimize some areas but it works and is a big improvement.
from
https://projects.blender.org/tracker/index.php?func=detail&aid=4156&group_id=9&atid=127
Detailed description:
Modified the 3ds export script 3ds_export.py:
- It now exports face UV correctly. 3ds only supports one UV coordinate per vertex. The script now duplicates vertices that had multiple UV pairs assigned to them so that each duplicate now only contains one and only one UV. Faces have their vertex indices adjusted accordingly.
- Quads are now split into triangles better. 3ds only supports triangles, so quads need to be split into two triangles. Instead of rather arbitrarily splitting along the diagonal between points 0 and 2, the script now splits along the shortest diagonal. This creates a higher quality triangular mesh, as well as better preservation of symmetry.
- Now creates an object node block, exporting object nodes, needed by some 3D importers. Among others, allows one to export object hierarchy.
- Now exports Empties as 3ds Dummies.
To be able to add all of the above new features, the script has been mostly rewritten and strongly restructured.
Motivation for the rewrite was the desire to be able to use Blender to produce custom 3d cars for Trackmania:Sunrise (TM:S). Previously, the TM:S importer could not correctly handle the 3ds files from the Blender 3ds export script. With this version, one can export cars complete with UV textures, correct wheel placement and light placement. To my knowledge, this script would make Blender the first fully free 3d modeller that allows one to export 3ds models for TM:S (expect a tutorial soon). The ability to have proper UV coordinates exported into the 3ds file should also be very welcome to many.
Add A Comment: Notepad
2006-05-02 11:26:32 +00:00
|
|
|
# store the index into the UniqueList for future reference:
|
2006-05-14 03:11:55 +00:00
|
|
|
# offset.append(uv_list[tri.vertex_index[i]].add(_3ds_point_uv(tri.faceuvs[i])))
|
2007-05-06 02:19:43 +00:00
|
|
|
|
2006-05-14 03:11:55 +00:00
|
|
|
context_uv_vert= unique_uvs[tri.vertex_index[i]]
|
|
|
|
uvkey= tri.faceuvs[i]
|
2007-01-04 05:59:23 +00:00
|
|
|
|
2007-05-06 02:19:43 +00:00
|
|
|
offset_index__uv_3ds = context_uv_vert.get(uvkey)
|
2007-01-04 05:59:23 +00:00
|
|
|
|
2007-05-06 02:19:43 +00:00
|
|
|
if not offset_index__uv_3ds:
|
|
|
|
offset_index__uv_3ds = context_uv_vert[uvkey] = len(context_uv_vert), _3ds_point_uv(uvkey)
|
|
|
|
|
|
|
|
tri.offset[i] = offset_index__uv_3ds[0]
|
2007-01-04 05:59:23 +00:00
|
|
|
|
|
|
|
|
2006-05-14 03:11:55 +00:00
|
|
|
|
Commited 3ds export enhancements from Mark Stijnman (beowulff)
Will need to do some updates, Mesh over NMesh and optimize some areas but it works and is a big improvement.
from
https://projects.blender.org/tracker/index.php?func=detail&aid=4156&group_id=9&atid=127
Detailed description:
Modified the 3ds export script 3ds_export.py:
- It now exports face UV correctly. 3ds only supports one UV coordinate per vertex. The script now duplicates vertices that had multiple UV pairs assigned to them so that each duplicate now only contains one and only one UV. Faces have their vertex indices adjusted accordingly.
- Quads are now split into triangles better. 3ds only supports triangles, so quads need to be split into two triangles. Instead of rather arbitrarily splitting along the diagonal between points 0 and 2, the script now splits along the shortest diagonal. This creates a higher quality triangular mesh, as well as better preservation of symmetry.
- Now creates an object node block, exporting object nodes, needed by some 3D importers. Among others, allows one to export object hierarchy.
- Now exports Empties as 3ds Dummies.
To be able to add all of the above new features, the script has been mostly rewritten and strongly restructured.
Motivation for the rewrite was the desire to be able to use Blender to produce custom 3d cars for Trackmania:Sunrise (TM:S). Previously, the TM:S importer could not correctly handle the 3ds files from the Blender 3ds export script. With this version, one can export cars complete with UV textures, correct wheel placement and light placement. To my knowledge, this script would make Blender the first fully free 3d modeller that allows one to export 3ds models for TM:S (expect a tutorial soon). The ability to have proper UV coordinates exported into the 3ds file should also be very welcome to many.
Add A Comment: Notepad
2006-05-02 11:26:32 +00:00
|
|
|
# At this point, each vertex has a UniqueList containing every uv coordinate that is associated with it
|
|
|
|
# only once.
|
|
|
|
|
|
|
|
# Now we need to duplicate every vertex as many times as it has uv coordinates and make sure the
|
|
|
|
# faces refer to the new face indices:
|
|
|
|
vert_index = 0
|
|
|
|
vert_array = _3ds_array()
|
|
|
|
uv_array = _3ds_array()
|
2007-01-04 05:59:23 +00:00
|
|
|
index_list = []
|
Commited 3ds export enhancements from Mark Stijnman (beowulff)
Will need to do some updates, Mesh over NMesh and optimize some areas but it works and is a big improvement.
from
https://projects.blender.org/tracker/index.php?func=detail&aid=4156&group_id=9&atid=127
Detailed description:
Modified the 3ds export script 3ds_export.py:
- It now exports face UV correctly. 3ds only supports one UV coordinate per vertex. The script now duplicates vertices that had multiple UV pairs assigned to them so that each duplicate now only contains one and only one UV. Faces have their vertex indices adjusted accordingly.
- Quads are now split into triangles better. 3ds only supports triangles, so quads need to be split into two triangles. Instead of rather arbitrarily splitting along the diagonal between points 0 and 2, the script now splits along the shortest diagonal. This creates a higher quality triangular mesh, as well as better preservation of symmetry.
- Now creates an object node block, exporting object nodes, needed by some 3D importers. Among others, allows one to export object hierarchy.
- Now exports Empties as 3ds Dummies.
To be able to add all of the above new features, the script has been mostly rewritten and strongly restructured.
Motivation for the rewrite was the desire to be able to use Blender to produce custom 3d cars for Trackmania:Sunrise (TM:S). Previously, the TM:S importer could not correctly handle the 3ds files from the Blender 3ds export script. With this version, one can export cars complete with UV textures, correct wheel placement and light placement. To my knowledge, this script would make Blender the first fully free 3d modeller that allows one to export 3ds models for TM:S (expect a tutorial soon). The ability to have proper UV coordinates exported into the 3ds file should also be very welcome to many.
Add A Comment: Notepad
2006-05-02 11:26:32 +00:00
|
|
|
for i,vert in enumerate(verts):
|
|
|
|
index_list.append(vert_index)
|
2007-01-04 20:44:33 +00:00
|
|
|
|
|
|
|
pt = _3ds_point_3d(vert.co) # reuse, should be ok
|
2007-01-22 17:31:34 +00:00
|
|
|
uvmap = [None] * len(unique_uvs[i])
|
2009-09-29 15:27:00 +00:00
|
|
|
for ii, uv_3ds in unique_uvs[i].values():
|
Commited 3ds export enhancements from Mark Stijnman (beowulff)
Will need to do some updates, Mesh over NMesh and optimize some areas but it works and is a big improvement.
from
https://projects.blender.org/tracker/index.php?func=detail&aid=4156&group_id=9&atid=127
Detailed description:
Modified the 3ds export script 3ds_export.py:
- It now exports face UV correctly. 3ds only supports one UV coordinate per vertex. The script now duplicates vertices that had multiple UV pairs assigned to them so that each duplicate now only contains one and only one UV. Faces have their vertex indices adjusted accordingly.
- Quads are now split into triangles better. 3ds only supports triangles, so quads need to be split into two triangles. Instead of rather arbitrarily splitting along the diagonal between points 0 and 2, the script now splits along the shortest diagonal. This creates a higher quality triangular mesh, as well as better preservation of symmetry.
- Now creates an object node block, exporting object nodes, needed by some 3D importers. Among others, allows one to export object hierarchy.
- Now exports Empties as 3ds Dummies.
To be able to add all of the above new features, the script has been mostly rewritten and strongly restructured.
Motivation for the rewrite was the desire to be able to use Blender to produce custom 3d cars for Trackmania:Sunrise (TM:S). Previously, the TM:S importer could not correctly handle the 3ds files from the Blender 3ds export script. With this version, one can export cars complete with UV textures, correct wheel placement and light placement. To my knowledge, this script would make Blender the first fully free 3d modeller that allows one to export 3ds models for TM:S (expect a tutorial soon). The ability to have proper UV coordinates exported into the 3ds file should also be very welcome to many.
Add A Comment: Notepad
2006-05-02 11:26:32 +00:00
|
|
|
# add a vertex duplicate to the vertex_array for every uv associated with this vertex:
|
2007-01-04 20:44:33 +00:00
|
|
|
vert_array.add(pt)
|
2007-01-22 17:31:34 +00:00
|
|
|
# add the uv coordinate to the uv array:
|
|
|
|
# This for loop does not give uv's ordered by ii, so we create a new map
|
|
|
|
# and add the uv's later
|
|
|
|
# uv_array.add(uv_3ds)
|
|
|
|
uvmap[ii] = uv_3ds
|
|
|
|
|
|
|
|
# Add the uv's in the correct order
|
|
|
|
for uv_3ds in uvmap:
|
Commited 3ds export enhancements from Mark Stijnman (beowulff)
Will need to do some updates, Mesh over NMesh and optimize some areas but it works and is a big improvement.
from
https://projects.blender.org/tracker/index.php?func=detail&aid=4156&group_id=9&atid=127
Detailed description:
Modified the 3ds export script 3ds_export.py:
- It now exports face UV correctly. 3ds only supports one UV coordinate per vertex. The script now duplicates vertices that had multiple UV pairs assigned to them so that each duplicate now only contains one and only one UV. Faces have their vertex indices adjusted accordingly.
- Quads are now split into triangles better. 3ds only supports triangles, so quads need to be split into two triangles. Instead of rather arbitrarily splitting along the diagonal between points 0 and 2, the script now splits along the shortest diagonal. This creates a higher quality triangular mesh, as well as better preservation of symmetry.
- Now creates an object node block, exporting object nodes, needed by some 3D importers. Among others, allows one to export object hierarchy.
- Now exports Empties as 3ds Dummies.
To be able to add all of the above new features, the script has been mostly rewritten and strongly restructured.
Motivation for the rewrite was the desire to be able to use Blender to produce custom 3d cars for Trackmania:Sunrise (TM:S). Previously, the TM:S importer could not correctly handle the 3ds files from the Blender 3ds export script. With this version, one can export cars complete with UV textures, correct wheel placement and light placement. To my knowledge, this script would make Blender the first fully free 3d modeller that allows one to export 3ds models for TM:S (expect a tutorial soon). The ability to have proper UV coordinates exported into the 3ds file should also be very welcome to many.
Add A Comment: Notepad
2006-05-02 11:26:32 +00:00
|
|
|
# add the uv coordinate to the uv array:
|
2006-05-14 03:11:55 +00:00
|
|
|
uv_array.add(uv_3ds)
|
2007-01-22 17:31:34 +00:00
|
|
|
|
2007-01-04 05:59:23 +00:00
|
|
|
vert_index += len(unique_uvs[i])
|
Commited 3ds export enhancements from Mark Stijnman (beowulff)
Will need to do some updates, Mesh over NMesh and optimize some areas but it works and is a big improvement.
from
https://projects.blender.org/tracker/index.php?func=detail&aid=4156&group_id=9&atid=127
Detailed description:
Modified the 3ds export script 3ds_export.py:
- It now exports face UV correctly. 3ds only supports one UV coordinate per vertex. The script now duplicates vertices that had multiple UV pairs assigned to them so that each duplicate now only contains one and only one UV. Faces have their vertex indices adjusted accordingly.
- Quads are now split into triangles better. 3ds only supports triangles, so quads need to be split into two triangles. Instead of rather arbitrarily splitting along the diagonal between points 0 and 2, the script now splits along the shortest diagonal. This creates a higher quality triangular mesh, as well as better preservation of symmetry.
- Now creates an object node block, exporting object nodes, needed by some 3D importers. Among others, allows one to export object hierarchy.
- Now exports Empties as 3ds Dummies.
To be able to add all of the above new features, the script has been mostly rewritten and strongly restructured.
Motivation for the rewrite was the desire to be able to use Blender to produce custom 3d cars for Trackmania:Sunrise (TM:S). Previously, the TM:S importer could not correctly handle the 3ds files from the Blender 3ds export script. With this version, one can export cars complete with UV textures, correct wheel placement and light placement. To my knowledge, this script would make Blender the first fully free 3d modeller that allows one to export 3ds models for TM:S (expect a tutorial soon). The ability to have proper UV coordinates exported into the 3ds file should also be very welcome to many.
Add A Comment: Notepad
2006-05-02 11:26:32 +00:00
|
|
|
|
|
|
|
# Make sure the triangle vertex indices now refer to the new vertex list:
|
2006-05-14 03:11:55 +00:00
|
|
|
for tri in tri_list:
|
2009-09-29 15:27:00 +00:00
|
|
|
for i in range(3):
|
2006-05-14 03:11:55 +00:00
|
|
|
tri.offset[i]+=index_list[tri.vertex_index[i]]
|
|
|
|
tri.vertex_index= tri.offset
|
Commited 3ds export enhancements from Mark Stijnman (beowulff)
Will need to do some updates, Mesh over NMesh and optimize some areas but it works and is a big improvement.
from
https://projects.blender.org/tracker/index.php?func=detail&aid=4156&group_id=9&atid=127
Detailed description:
Modified the 3ds export script 3ds_export.py:
- It now exports face UV correctly. 3ds only supports one UV coordinate per vertex. The script now duplicates vertices that had multiple UV pairs assigned to them so that each duplicate now only contains one and only one UV. Faces have their vertex indices adjusted accordingly.
- Quads are now split into triangles better. 3ds only supports triangles, so quads need to be split into two triangles. Instead of rather arbitrarily splitting along the diagonal between points 0 and 2, the script now splits along the shortest diagonal. This creates a higher quality triangular mesh, as well as better preservation of symmetry.
- Now creates an object node block, exporting object nodes, needed by some 3D importers. Among others, allows one to export object hierarchy.
- Now exports Empties as 3ds Dummies.
To be able to add all of the above new features, the script has been mostly rewritten and strongly restructured.
Motivation for the rewrite was the desire to be able to use Blender to produce custom 3d cars for Trackmania:Sunrise (TM:S). Previously, the TM:S importer could not correctly handle the 3ds files from the Blender 3ds export script. With this version, one can export cars complete with UV textures, correct wheel placement and light placement. To my knowledge, this script would make Blender the first fully free 3d modeller that allows one to export 3ds models for TM:S (expect a tutorial soon). The ability to have proper UV coordinates exported into the 3ds file should also be very welcome to many.
Add A Comment: Notepad
2006-05-02 11:26:32 +00:00
|
|
|
|
|
|
|
return vert_array, uv_array, tri_list
|
2005-12-15 01:42:45 +00:00
|
|
|
|
2007-01-04 15:20:28 +00:00
|
|
|
def make_faces_chunk(tri_list, mesh, materialDict):
|
2006-07-05 07:10:03 +00:00
|
|
|
'''Make a chunk for the faces.
|
|
|
|
|
|
|
|
Also adds subchunks assigning materials to all faces.'''
|
Commited 3ds export enhancements from Mark Stijnman (beowulff)
Will need to do some updates, Mesh over NMesh and optimize some areas but it works and is a big improvement.
from
https://projects.blender.org/tracker/index.php?func=detail&aid=4156&group_id=9&atid=127
Detailed description:
Modified the 3ds export script 3ds_export.py:
- It now exports face UV correctly. 3ds only supports one UV coordinate per vertex. The script now duplicates vertices that had multiple UV pairs assigned to them so that each duplicate now only contains one and only one UV. Faces have their vertex indices adjusted accordingly.
- Quads are now split into triangles better. 3ds only supports triangles, so quads need to be split into two triangles. Instead of rather arbitrarily splitting along the diagonal between points 0 and 2, the script now splits along the shortest diagonal. This creates a higher quality triangular mesh, as well as better preservation of symmetry.
- Now creates an object node block, exporting object nodes, needed by some 3D importers. Among others, allows one to export object hierarchy.
- Now exports Empties as 3ds Dummies.
To be able to add all of the above new features, the script has been mostly rewritten and strongly restructured.
Motivation for the rewrite was the desire to be able to use Blender to produce custom 3d cars for Trackmania:Sunrise (TM:S). Previously, the TM:S importer could not correctly handle the 3ds files from the Blender 3ds export script. With this version, one can export cars complete with UV textures, correct wheel placement and light placement. To my knowledge, this script would make Blender the first fully free 3d modeller that allows one to export 3ds models for TM:S (expect a tutorial soon). The ability to have proper UV coordinates exported into the 3ds file should also be very welcome to many.
Add A Comment: Notepad
2006-05-02 11:26:32 +00:00
|
|
|
|
2007-01-04 15:20:28 +00:00
|
|
|
materials = mesh.materials
|
2007-01-04 20:44:33 +00:00
|
|
|
if not materials:
|
|
|
|
mat = None
|
2007-01-04 15:20:28 +00:00
|
|
|
|
Commited 3ds export enhancements from Mark Stijnman (beowulff)
Will need to do some updates, Mesh over NMesh and optimize some areas but it works and is a big improvement.
from
https://projects.blender.org/tracker/index.php?func=detail&aid=4156&group_id=9&atid=127
Detailed description:
Modified the 3ds export script 3ds_export.py:
- It now exports face UV correctly. 3ds only supports one UV coordinate per vertex. The script now duplicates vertices that had multiple UV pairs assigned to them so that each duplicate now only contains one and only one UV. Faces have their vertex indices adjusted accordingly.
- Quads are now split into triangles better. 3ds only supports triangles, so quads need to be split into two triangles. Instead of rather arbitrarily splitting along the diagonal between points 0 and 2, the script now splits along the shortest diagonal. This creates a higher quality triangular mesh, as well as better preservation of symmetry.
- Now creates an object node block, exporting object nodes, needed by some 3D importers. Among others, allows one to export object hierarchy.
- Now exports Empties as 3ds Dummies.
To be able to add all of the above new features, the script has been mostly rewritten and strongly restructured.
Motivation for the rewrite was the desire to be able to use Blender to produce custom 3d cars for Trackmania:Sunrise (TM:S). Previously, the TM:S importer could not correctly handle the 3ds files from the Blender 3ds export script. With this version, one can export cars complete with UV textures, correct wheel placement and light placement. To my knowledge, this script would make Blender the first fully free 3d modeller that allows one to export 3ds models for TM:S (expect a tutorial soon). The ability to have proper UV coordinates exported into the 3ds file should also be very welcome to many.
Add A Comment: Notepad
2006-05-02 11:26:32 +00:00
|
|
|
face_chunk = _3ds_chunk(OBJECT_FACES)
|
|
|
|
face_list = _3ds_array()
|
|
|
|
|
|
|
|
|
2009-09-29 15:27:00 +00:00
|
|
|
if len(mesh.uv_textures):
|
|
|
|
# if mesh.faceUV:
|
2007-01-04 15:20:28 +00:00
|
|
|
# Gather materials used in this mesh - mat/image pairs
|
|
|
|
unique_mats = {}
|
|
|
|
for i,tri in enumerate(tri_list):
|
|
|
|
|
|
|
|
face_list.add(_3ds_face(tri.vertex_index))
|
|
|
|
|
2007-01-04 20:44:33 +00:00
|
|
|
if materials:
|
|
|
|
mat = materials[tri.mat]
|
|
|
|
if mat: mat = mat.name
|
2007-01-04 15:20:28 +00:00
|
|
|
|
|
|
|
img = tri.image
|
|
|
|
|
|
|
|
try:
|
|
|
|
context_mat_face_array = unique_mats[mat, img][1]
|
|
|
|
except:
|
|
|
|
|
|
|
|
if mat: name_str = mat
|
|
|
|
else: name_str = 'None'
|
|
|
|
if img: name_str += img
|
|
|
|
|
|
|
|
context_mat_face_array = _3ds_array()
|
2007-05-06 02:19:43 +00:00
|
|
|
unique_mats[mat, img] = _3ds_string(sane_name(name_str)), context_mat_face_array
|
2007-01-04 15:20:28 +00:00
|
|
|
|
|
|
|
|
|
|
|
context_mat_face_array.add(_3ds_short(i))
|
|
|
|
# obj_material_faces[tri.mat].add(_3ds_short(i))
|
|
|
|
|
|
|
|
face_chunk.add_variable("faces", face_list)
|
2009-09-29 15:27:00 +00:00
|
|
|
for mat_name, mat_faces in unique_mats.values():
|
2007-01-04 15:20:28 +00:00
|
|
|
obj_material_chunk=_3ds_chunk(OBJECT_MATERIAL)
|
|
|
|
obj_material_chunk.add_variable("name", mat_name)
|
|
|
|
obj_material_chunk.add_variable("face_list", mat_faces)
|
|
|
|
face_chunk.add_subchunk(obj_material_chunk)
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
obj_material_faces=[]
|
|
|
|
obj_material_names=[]
|
|
|
|
for m in materials:
|
|
|
|
if m:
|
2007-05-06 02:19:43 +00:00
|
|
|
obj_material_names.append(_3ds_string(sane_name(m.name)))
|
2007-01-04 15:20:28 +00:00
|
|
|
obj_material_faces.append(_3ds_array())
|
|
|
|
n_materials = len(obj_material_names)
|
|
|
|
|
|
|
|
for i,tri in enumerate(tri_list):
|
|
|
|
face_list.add(_3ds_face(tri.vertex_index))
|
|
|
|
if (tri.mat < n_materials):
|
|
|
|
obj_material_faces[tri.mat].add(_3ds_short(i))
|
|
|
|
|
|
|
|
face_chunk.add_variable("faces", face_list)
|
2009-09-29 15:27:00 +00:00
|
|
|
for i in range(n_materials):
|
2007-01-04 15:20:28 +00:00
|
|
|
obj_material_chunk=_3ds_chunk(OBJECT_MATERIAL)
|
|
|
|
obj_material_chunk.add_variable("name", obj_material_names[i])
|
|
|
|
obj_material_chunk.add_variable("face_list", obj_material_faces[i])
|
|
|
|
face_chunk.add_subchunk(obj_material_chunk)
|
2006-07-05 07:10:03 +00:00
|
|
|
|
Commited 3ds export enhancements from Mark Stijnman (beowulff)
Will need to do some updates, Mesh over NMesh and optimize some areas but it works and is a big improvement.
from
https://projects.blender.org/tracker/index.php?func=detail&aid=4156&group_id=9&atid=127
Detailed description:
Modified the 3ds export script 3ds_export.py:
- It now exports face UV correctly. 3ds only supports one UV coordinate per vertex. The script now duplicates vertices that had multiple UV pairs assigned to them so that each duplicate now only contains one and only one UV. Faces have their vertex indices adjusted accordingly.
- Quads are now split into triangles better. 3ds only supports triangles, so quads need to be split into two triangles. Instead of rather arbitrarily splitting along the diagonal between points 0 and 2, the script now splits along the shortest diagonal. This creates a higher quality triangular mesh, as well as better preservation of symmetry.
- Now creates an object node block, exporting object nodes, needed by some 3D importers. Among others, allows one to export object hierarchy.
- Now exports Empties as 3ds Dummies.
To be able to add all of the above new features, the script has been mostly rewritten and strongly restructured.
Motivation for the rewrite was the desire to be able to use Blender to produce custom 3d cars for Trackmania:Sunrise (TM:S). Previously, the TM:S importer could not correctly handle the 3ds files from the Blender 3ds export script. With this version, one can export cars complete with UV textures, correct wheel placement and light placement. To my knowledge, this script would make Blender the first fully free 3d modeller that allows one to export 3ds models for TM:S (expect a tutorial soon). The ability to have proper UV coordinates exported into the 3ds file should also be very welcome to many.
Add A Comment: Notepad
2006-05-02 11:26:32 +00:00
|
|
|
return face_chunk
|
|
|
|
|
|
|
|
def make_vert_chunk(vert_array):
|
2006-07-05 07:10:03 +00:00
|
|
|
'''Make a vertex chunk out of an array of vertices.'''
|
Commited 3ds export enhancements from Mark Stijnman (beowulff)
Will need to do some updates, Mesh over NMesh and optimize some areas but it works and is a big improvement.
from
https://projects.blender.org/tracker/index.php?func=detail&aid=4156&group_id=9&atid=127
Detailed description:
Modified the 3ds export script 3ds_export.py:
- It now exports face UV correctly. 3ds only supports one UV coordinate per vertex. The script now duplicates vertices that had multiple UV pairs assigned to them so that each duplicate now only contains one and only one UV. Faces have their vertex indices adjusted accordingly.
- Quads are now split into triangles better. 3ds only supports triangles, so quads need to be split into two triangles. Instead of rather arbitrarily splitting along the diagonal between points 0 and 2, the script now splits along the shortest diagonal. This creates a higher quality triangular mesh, as well as better preservation of symmetry.
- Now creates an object node block, exporting object nodes, needed by some 3D importers. Among others, allows one to export object hierarchy.
- Now exports Empties as 3ds Dummies.
To be able to add all of the above new features, the script has been mostly rewritten and strongly restructured.
Motivation for the rewrite was the desire to be able to use Blender to produce custom 3d cars for Trackmania:Sunrise (TM:S). Previously, the TM:S importer could not correctly handle the 3ds files from the Blender 3ds export script. With this version, one can export cars complete with UV textures, correct wheel placement and light placement. To my knowledge, this script would make Blender the first fully free 3d modeller that allows one to export 3ds models for TM:S (expect a tutorial soon). The ability to have proper UV coordinates exported into the 3ds file should also be very welcome to many.
Add A Comment: Notepad
2006-05-02 11:26:32 +00:00
|
|
|
vert_chunk = _3ds_chunk(OBJECT_VERTICES)
|
|
|
|
vert_chunk.add_variable("vertices",vert_array)
|
|
|
|
return vert_chunk
|
|
|
|
|
|
|
|
def make_uv_chunk(uv_array):
|
2006-07-05 07:10:03 +00:00
|
|
|
'''Make a UV chunk out of an array of UVs.'''
|
Commited 3ds export enhancements from Mark Stijnman (beowulff)
Will need to do some updates, Mesh over NMesh and optimize some areas but it works and is a big improvement.
from
https://projects.blender.org/tracker/index.php?func=detail&aid=4156&group_id=9&atid=127
Detailed description:
Modified the 3ds export script 3ds_export.py:
- It now exports face UV correctly. 3ds only supports one UV coordinate per vertex. The script now duplicates vertices that had multiple UV pairs assigned to them so that each duplicate now only contains one and only one UV. Faces have their vertex indices adjusted accordingly.
- Quads are now split into triangles better. 3ds only supports triangles, so quads need to be split into two triangles. Instead of rather arbitrarily splitting along the diagonal between points 0 and 2, the script now splits along the shortest diagonal. This creates a higher quality triangular mesh, as well as better preservation of symmetry.
- Now creates an object node block, exporting object nodes, needed by some 3D importers. Among others, allows one to export object hierarchy.
- Now exports Empties as 3ds Dummies.
To be able to add all of the above new features, the script has been mostly rewritten and strongly restructured.
Motivation for the rewrite was the desire to be able to use Blender to produce custom 3d cars for Trackmania:Sunrise (TM:S). Previously, the TM:S importer could not correctly handle the 3ds files from the Blender 3ds export script. With this version, one can export cars complete with UV textures, correct wheel placement and light placement. To my knowledge, this script would make Blender the first fully free 3d modeller that allows one to export 3ds models for TM:S (expect a tutorial soon). The ability to have proper UV coordinates exported into the 3ds file should also be very welcome to many.
Add A Comment: Notepad
2006-05-02 11:26:32 +00:00
|
|
|
uv_chunk = _3ds_chunk(OBJECT_UV)
|
|
|
|
uv_chunk.add_variable("uv coords", uv_array)
|
|
|
|
return uv_chunk
|
|
|
|
|
2007-01-04 15:20:28 +00:00
|
|
|
def make_mesh_chunk(mesh, materialDict):
|
2006-07-05 07:10:03 +00:00
|
|
|
'''Make a chunk out of a Blender mesh.'''
|
Commited 3ds export enhancements from Mark Stijnman (beowulff)
Will need to do some updates, Mesh over NMesh and optimize some areas but it works and is a big improvement.
from
https://projects.blender.org/tracker/index.php?func=detail&aid=4156&group_id=9&atid=127
Detailed description:
Modified the 3ds export script 3ds_export.py:
- It now exports face UV correctly. 3ds only supports one UV coordinate per vertex. The script now duplicates vertices that had multiple UV pairs assigned to them so that each duplicate now only contains one and only one UV. Faces have their vertex indices adjusted accordingly.
- Quads are now split into triangles better. 3ds only supports triangles, so quads need to be split into two triangles. Instead of rather arbitrarily splitting along the diagonal between points 0 and 2, the script now splits along the shortest diagonal. This creates a higher quality triangular mesh, as well as better preservation of symmetry.
- Now creates an object node block, exporting object nodes, needed by some 3D importers. Among others, allows one to export object hierarchy.
- Now exports Empties as 3ds Dummies.
To be able to add all of the above new features, the script has been mostly rewritten and strongly restructured.
Motivation for the rewrite was the desire to be able to use Blender to produce custom 3d cars for Trackmania:Sunrise (TM:S). Previously, the TM:S importer could not correctly handle the 3ds files from the Blender 3ds export script. With this version, one can export cars complete with UV textures, correct wheel placement and light placement. To my knowledge, this script would make Blender the first fully free 3d modeller that allows one to export 3ds models for TM:S (expect a tutorial soon). The ability to have proper UV coordinates exported into the 3ds file should also be very welcome to many.
Add A Comment: Notepad
2006-05-02 11:26:32 +00:00
|
|
|
|
|
|
|
# Extract the triangles from the mesh:
|
|
|
|
tri_list = extract_triangles(mesh)
|
|
|
|
|
2009-09-29 15:27:00 +00:00
|
|
|
if len(mesh.uv_textures):
|
|
|
|
# if mesh.faceUV:
|
Commited 3ds export enhancements from Mark Stijnman (beowulff)
Will need to do some updates, Mesh over NMesh and optimize some areas but it works and is a big improvement.
from
https://projects.blender.org/tracker/index.php?func=detail&aid=4156&group_id=9&atid=127
Detailed description:
Modified the 3ds export script 3ds_export.py:
- It now exports face UV correctly. 3ds only supports one UV coordinate per vertex. The script now duplicates vertices that had multiple UV pairs assigned to them so that each duplicate now only contains one and only one UV. Faces have their vertex indices adjusted accordingly.
- Quads are now split into triangles better. 3ds only supports triangles, so quads need to be split into two triangles. Instead of rather arbitrarily splitting along the diagonal between points 0 and 2, the script now splits along the shortest diagonal. This creates a higher quality triangular mesh, as well as better preservation of symmetry.
- Now creates an object node block, exporting object nodes, needed by some 3D importers. Among others, allows one to export object hierarchy.
- Now exports Empties as 3ds Dummies.
To be able to add all of the above new features, the script has been mostly rewritten and strongly restructured.
Motivation for the rewrite was the desire to be able to use Blender to produce custom 3d cars for Trackmania:Sunrise (TM:S). Previously, the TM:S importer could not correctly handle the 3ds files from the Blender 3ds export script. With this version, one can export cars complete with UV textures, correct wheel placement and light placement. To my knowledge, this script would make Blender the first fully free 3d modeller that allows one to export 3ds models for TM:S (expect a tutorial soon). The ability to have proper UV coordinates exported into the 3ds file should also be very welcome to many.
Add A Comment: Notepad
2006-05-02 11:26:32 +00:00
|
|
|
# Remove the face UVs and convert it to vertex UV:
|
|
|
|
vert_array, uv_array, tri_list = remove_face_uv(mesh.verts, tri_list)
|
|
|
|
else:
|
|
|
|
# Add the vertices to the vertex array:
|
|
|
|
vert_array = _3ds_array()
|
|
|
|
for vert in mesh.verts:
|
|
|
|
vert_array.add(_3ds_point_3d(vert.co))
|
|
|
|
# If the mesh has vertex UVs, create an array of UVs:
|
2009-09-29 15:27:00 +00:00
|
|
|
if len(mesh.sticky):
|
|
|
|
# if mesh.vertexUV:
|
Commited 3ds export enhancements from Mark Stijnman (beowulff)
Will need to do some updates, Mesh over NMesh and optimize some areas but it works and is a big improvement.
from
https://projects.blender.org/tracker/index.php?func=detail&aid=4156&group_id=9&atid=127
Detailed description:
Modified the 3ds export script 3ds_export.py:
- It now exports face UV correctly. 3ds only supports one UV coordinate per vertex. The script now duplicates vertices that had multiple UV pairs assigned to them so that each duplicate now only contains one and only one UV. Faces have their vertex indices adjusted accordingly.
- Quads are now split into triangles better. 3ds only supports triangles, so quads need to be split into two triangles. Instead of rather arbitrarily splitting along the diagonal between points 0 and 2, the script now splits along the shortest diagonal. This creates a higher quality triangular mesh, as well as better preservation of symmetry.
- Now creates an object node block, exporting object nodes, needed by some 3D importers. Among others, allows one to export object hierarchy.
- Now exports Empties as 3ds Dummies.
To be able to add all of the above new features, the script has been mostly rewritten and strongly restructured.
Motivation for the rewrite was the desire to be able to use Blender to produce custom 3d cars for Trackmania:Sunrise (TM:S). Previously, the TM:S importer could not correctly handle the 3ds files from the Blender 3ds export script. With this version, one can export cars complete with UV textures, correct wheel placement and light placement. To my knowledge, this script would make Blender the first fully free 3d modeller that allows one to export 3ds models for TM:S (expect a tutorial soon). The ability to have proper UV coordinates exported into the 3ds file should also be very welcome to many.
Add A Comment: Notepad
2006-05-02 11:26:32 +00:00
|
|
|
uv_array = _3ds_array()
|
2009-09-29 15:27:00 +00:00
|
|
|
for uv in mesh.sticky:
|
|
|
|
# for vert in mesh.verts:
|
|
|
|
uv_array.add(_3ds_point_uv(uv.co))
|
|
|
|
# uv_array.add(_3ds_point_uv(vert.uvco))
|
Commited 3ds export enhancements from Mark Stijnman (beowulff)
Will need to do some updates, Mesh over NMesh and optimize some areas but it works and is a big improvement.
from
https://projects.blender.org/tracker/index.php?func=detail&aid=4156&group_id=9&atid=127
Detailed description:
Modified the 3ds export script 3ds_export.py:
- It now exports face UV correctly. 3ds only supports one UV coordinate per vertex. The script now duplicates vertices that had multiple UV pairs assigned to them so that each duplicate now only contains one and only one UV. Faces have their vertex indices adjusted accordingly.
- Quads are now split into triangles better. 3ds only supports triangles, so quads need to be split into two triangles. Instead of rather arbitrarily splitting along the diagonal between points 0 and 2, the script now splits along the shortest diagonal. This creates a higher quality triangular mesh, as well as better preservation of symmetry.
- Now creates an object node block, exporting object nodes, needed by some 3D importers. Among others, allows one to export object hierarchy.
- Now exports Empties as 3ds Dummies.
To be able to add all of the above new features, the script has been mostly rewritten and strongly restructured.
Motivation for the rewrite was the desire to be able to use Blender to produce custom 3d cars for Trackmania:Sunrise (TM:S). Previously, the TM:S importer could not correctly handle the 3ds files from the Blender 3ds export script. With this version, one can export cars complete with UV textures, correct wheel placement and light placement. To my knowledge, this script would make Blender the first fully free 3d modeller that allows one to export 3ds models for TM:S (expect a tutorial soon). The ability to have proper UV coordinates exported into the 3ds file should also be very welcome to many.
Add A Comment: Notepad
2006-05-02 11:26:32 +00:00
|
|
|
else:
|
|
|
|
# no UV at all:
|
|
|
|
uv_array = None
|
|
|
|
|
|
|
|
# create the chunk:
|
|
|
|
mesh_chunk = _3ds_chunk(OBJECT_MESH)
|
|
|
|
|
|
|
|
# add vertex chunk:
|
|
|
|
mesh_chunk.add_subchunk(make_vert_chunk(vert_array))
|
|
|
|
# add faces chunk:
|
2006-07-05 07:10:03 +00:00
|
|
|
|
2007-01-04 15:20:28 +00:00
|
|
|
mesh_chunk.add_subchunk(make_faces_chunk(tri_list, mesh, materialDict))
|
2006-07-05 07:10:03 +00:00
|
|
|
|
Commited 3ds export enhancements from Mark Stijnman (beowulff)
Will need to do some updates, Mesh over NMesh and optimize some areas but it works and is a big improvement.
from
https://projects.blender.org/tracker/index.php?func=detail&aid=4156&group_id=9&atid=127
Detailed description:
Modified the 3ds export script 3ds_export.py:
- It now exports face UV correctly. 3ds only supports one UV coordinate per vertex. The script now duplicates vertices that had multiple UV pairs assigned to them so that each duplicate now only contains one and only one UV. Faces have their vertex indices adjusted accordingly.
- Quads are now split into triangles better. 3ds only supports triangles, so quads need to be split into two triangles. Instead of rather arbitrarily splitting along the diagonal between points 0 and 2, the script now splits along the shortest diagonal. This creates a higher quality triangular mesh, as well as better preservation of symmetry.
- Now creates an object node block, exporting object nodes, needed by some 3D importers. Among others, allows one to export object hierarchy.
- Now exports Empties as 3ds Dummies.
To be able to add all of the above new features, the script has been mostly rewritten and strongly restructured.
Motivation for the rewrite was the desire to be able to use Blender to produce custom 3d cars for Trackmania:Sunrise (TM:S). Previously, the TM:S importer could not correctly handle the 3ds files from the Blender 3ds export script. With this version, one can export cars complete with UV textures, correct wheel placement and light placement. To my knowledge, this script would make Blender the first fully free 3d modeller that allows one to export 3ds models for TM:S (expect a tutorial soon). The ability to have proper UV coordinates exported into the 3ds file should also be very welcome to many.
Add A Comment: Notepad
2006-05-02 11:26:32 +00:00
|
|
|
# if available, add uv chunk:
|
|
|
|
if uv_array:
|
|
|
|
mesh_chunk.add_subchunk(make_uv_chunk(uv_array))
|
|
|
|
|
|
|
|
return mesh_chunk
|
2005-12-15 01:42:45 +00:00
|
|
|
|
2006-07-05 07:10:03 +00:00
|
|
|
""" # COMMENTED OUT FOR 2.42 RELEASE!! CRASHES 3DS MAX
|
Commited 3ds export enhancements from Mark Stijnman (beowulff)
Will need to do some updates, Mesh over NMesh and optimize some areas but it works and is a big improvement.
from
https://projects.blender.org/tracker/index.php?func=detail&aid=4156&group_id=9&atid=127
Detailed description:
Modified the 3ds export script 3ds_export.py:
- It now exports face UV correctly. 3ds only supports one UV coordinate per vertex. The script now duplicates vertices that had multiple UV pairs assigned to them so that each duplicate now only contains one and only one UV. Faces have their vertex indices adjusted accordingly.
- Quads are now split into triangles better. 3ds only supports triangles, so quads need to be split into two triangles. Instead of rather arbitrarily splitting along the diagonal between points 0 and 2, the script now splits along the shortest diagonal. This creates a higher quality triangular mesh, as well as better preservation of symmetry.
- Now creates an object node block, exporting object nodes, needed by some 3D importers. Among others, allows one to export object hierarchy.
- Now exports Empties as 3ds Dummies.
To be able to add all of the above new features, the script has been mostly rewritten and strongly restructured.
Motivation for the rewrite was the desire to be able to use Blender to produce custom 3d cars for Trackmania:Sunrise (TM:S). Previously, the TM:S importer could not correctly handle the 3ds files from the Blender 3ds export script. With this version, one can export cars complete with UV textures, correct wheel placement and light placement. To my knowledge, this script would make Blender the first fully free 3d modeller that allows one to export 3ds models for TM:S (expect a tutorial soon). The ability to have proper UV coordinates exported into the 3ds file should also be very welcome to many.
Add A Comment: Notepad
2006-05-02 11:26:32 +00:00
|
|
|
def make_kfdata(start=0, stop=0, curtime=0):
|
2006-07-05 07:10:03 +00:00
|
|
|
'''Make the basic keyframe data chunk'''
|
Commited 3ds export enhancements from Mark Stijnman (beowulff)
Will need to do some updates, Mesh over NMesh and optimize some areas but it works and is a big improvement.
from
https://projects.blender.org/tracker/index.php?func=detail&aid=4156&group_id=9&atid=127
Detailed description:
Modified the 3ds export script 3ds_export.py:
- It now exports face UV correctly. 3ds only supports one UV coordinate per vertex. The script now duplicates vertices that had multiple UV pairs assigned to them so that each duplicate now only contains one and only one UV. Faces have their vertex indices adjusted accordingly.
- Quads are now split into triangles better. 3ds only supports triangles, so quads need to be split into two triangles. Instead of rather arbitrarily splitting along the diagonal between points 0 and 2, the script now splits along the shortest diagonal. This creates a higher quality triangular mesh, as well as better preservation of symmetry.
- Now creates an object node block, exporting object nodes, needed by some 3D importers. Among others, allows one to export object hierarchy.
- Now exports Empties as 3ds Dummies.
To be able to add all of the above new features, the script has been mostly rewritten and strongly restructured.
Motivation for the rewrite was the desire to be able to use Blender to produce custom 3d cars for Trackmania:Sunrise (TM:S). Previously, the TM:S importer could not correctly handle the 3ds files from the Blender 3ds export script. With this version, one can export cars complete with UV textures, correct wheel placement and light placement. To my knowledge, this script would make Blender the first fully free 3d modeller that allows one to export 3ds models for TM:S (expect a tutorial soon). The ability to have proper UV coordinates exported into the 3ds file should also be very welcome to many.
Add A Comment: Notepad
2006-05-02 11:26:32 +00:00
|
|
|
kfdata = _3ds_chunk(KFDATA)
|
|
|
|
|
|
|
|
kfhdr = _3ds_chunk(KFDATA_KFHDR)
|
|
|
|
kfhdr.add_variable("revision", _3ds_short(0))
|
|
|
|
# Not really sure what filename is used for, but it seems it is usually used
|
|
|
|
# to identify the program that generated the .3ds:
|
|
|
|
kfhdr.add_variable("filename", _3ds_string("Blender"))
|
|
|
|
kfhdr.add_variable("animlen", _3ds_int(stop-start))
|
|
|
|
|
|
|
|
kfseg = _3ds_chunk(KFDATA_KFSEG)
|
|
|
|
kfseg.add_variable("start", _3ds_int(start))
|
|
|
|
kfseg.add_variable("stop", _3ds_int(stop))
|
|
|
|
|
|
|
|
kfcurtime = _3ds_chunk(KFDATA_KFCURTIME)
|
|
|
|
kfcurtime.add_variable("curtime", _3ds_int(curtime))
|
|
|
|
|
|
|
|
kfdata.add_subchunk(kfhdr)
|
|
|
|
kfdata.add_subchunk(kfseg)
|
|
|
|
kfdata.add_subchunk(kfcurtime)
|
|
|
|
return kfdata
|
2006-07-05 07:10:03 +00:00
|
|
|
"""
|
2005-12-15 01:42:45 +00:00
|
|
|
|
2007-05-06 02:19:43 +00:00
|
|
|
"""
|
Commited 3ds export enhancements from Mark Stijnman (beowulff)
Will need to do some updates, Mesh over NMesh and optimize some areas but it works and is a big improvement.
from
https://projects.blender.org/tracker/index.php?func=detail&aid=4156&group_id=9&atid=127
Detailed description:
Modified the 3ds export script 3ds_export.py:
- It now exports face UV correctly. 3ds only supports one UV coordinate per vertex. The script now duplicates vertices that had multiple UV pairs assigned to them so that each duplicate now only contains one and only one UV. Faces have their vertex indices adjusted accordingly.
- Quads are now split into triangles better. 3ds only supports triangles, so quads need to be split into two triangles. Instead of rather arbitrarily splitting along the diagonal between points 0 and 2, the script now splits along the shortest diagonal. This creates a higher quality triangular mesh, as well as better preservation of symmetry.
- Now creates an object node block, exporting object nodes, needed by some 3D importers. Among others, allows one to export object hierarchy.
- Now exports Empties as 3ds Dummies.
To be able to add all of the above new features, the script has been mostly rewritten and strongly restructured.
Motivation for the rewrite was the desire to be able to use Blender to produce custom 3d cars for Trackmania:Sunrise (TM:S). Previously, the TM:S importer could not correctly handle the 3ds files from the Blender 3ds export script. With this version, one can export cars complete with UV textures, correct wheel placement and light placement. To my knowledge, this script would make Blender the first fully free 3d modeller that allows one to export 3ds models for TM:S (expect a tutorial soon). The ability to have proper UV coordinates exported into the 3ds file should also be very welcome to many.
Add A Comment: Notepad
2006-05-02 11:26:32 +00:00
|
|
|
def make_track_chunk(ID, obj):
|
2006-07-05 07:10:03 +00:00
|
|
|
'''Make a chunk for track data.
|
Commited 3ds export enhancements from Mark Stijnman (beowulff)
Will need to do some updates, Mesh over NMesh and optimize some areas but it works and is a big improvement.
from
https://projects.blender.org/tracker/index.php?func=detail&aid=4156&group_id=9&atid=127
Detailed description:
Modified the 3ds export script 3ds_export.py:
- It now exports face UV correctly. 3ds only supports one UV coordinate per vertex. The script now duplicates vertices that had multiple UV pairs assigned to them so that each duplicate now only contains one and only one UV. Faces have their vertex indices adjusted accordingly.
- Quads are now split into triangles better. 3ds only supports triangles, so quads need to be split into two triangles. Instead of rather arbitrarily splitting along the diagonal between points 0 and 2, the script now splits along the shortest diagonal. This creates a higher quality triangular mesh, as well as better preservation of symmetry.
- Now creates an object node block, exporting object nodes, needed by some 3D importers. Among others, allows one to export object hierarchy.
- Now exports Empties as 3ds Dummies.
To be able to add all of the above new features, the script has been mostly rewritten and strongly restructured.
Motivation for the rewrite was the desire to be able to use Blender to produce custom 3d cars for Trackmania:Sunrise (TM:S). Previously, the TM:S importer could not correctly handle the 3ds files from the Blender 3ds export script. With this version, one can export cars complete with UV textures, correct wheel placement and light placement. To my knowledge, this script would make Blender the first fully free 3d modeller that allows one to export 3ds models for TM:S (expect a tutorial soon). The ability to have proper UV coordinates exported into the 3ds file should also be very welcome to many.
Add A Comment: Notepad
2006-05-02 11:26:32 +00:00
|
|
|
|
2006-07-05 07:10:03 +00:00
|
|
|
Depending on the ID, this will construct a position, rotation or scale track.'''
|
Commited 3ds export enhancements from Mark Stijnman (beowulff)
Will need to do some updates, Mesh over NMesh and optimize some areas but it works and is a big improvement.
from
https://projects.blender.org/tracker/index.php?func=detail&aid=4156&group_id=9&atid=127
Detailed description:
Modified the 3ds export script 3ds_export.py:
- It now exports face UV correctly. 3ds only supports one UV coordinate per vertex. The script now duplicates vertices that had multiple UV pairs assigned to them so that each duplicate now only contains one and only one UV. Faces have their vertex indices adjusted accordingly.
- Quads are now split into triangles better. 3ds only supports triangles, so quads need to be split into two triangles. Instead of rather arbitrarily splitting along the diagonal between points 0 and 2, the script now splits along the shortest diagonal. This creates a higher quality triangular mesh, as well as better preservation of symmetry.
- Now creates an object node block, exporting object nodes, needed by some 3D importers. Among others, allows one to export object hierarchy.
- Now exports Empties as 3ds Dummies.
To be able to add all of the above new features, the script has been mostly rewritten and strongly restructured.
Motivation for the rewrite was the desire to be able to use Blender to produce custom 3d cars for Trackmania:Sunrise (TM:S). Previously, the TM:S importer could not correctly handle the 3ds files from the Blender 3ds export script. With this version, one can export cars complete with UV textures, correct wheel placement and light placement. To my knowledge, this script would make Blender the first fully free 3d modeller that allows one to export 3ds models for TM:S (expect a tutorial soon). The ability to have proper UV coordinates exported into the 3ds file should also be very welcome to many.
Add A Comment: Notepad
2006-05-02 11:26:32 +00:00
|
|
|
track_chunk = _3ds_chunk(ID)
|
|
|
|
track_chunk.add_variable("track_flags", _3ds_short())
|
|
|
|
track_chunk.add_variable("unknown", _3ds_int())
|
|
|
|
track_chunk.add_variable("unknown", _3ds_int())
|
|
|
|
track_chunk.add_variable("nkeys", _3ds_int(1))
|
|
|
|
# Next section should be repeated for every keyframe, but for now, animation is not actually supported.
|
|
|
|
track_chunk.add_variable("tcb_frame", _3ds_int(0))
|
|
|
|
track_chunk.add_variable("tcb_flags", _3ds_short())
|
2006-12-25 09:17:23 +00:00
|
|
|
if obj.type=='Empty':
|
2006-05-14 03:11:55 +00:00
|
|
|
if ID==POS_TRACK_TAG:
|
|
|
|
# position vector:
|
|
|
|
track_chunk.add_variable("position", _3ds_point_3d(obj.getLocation()))
|
|
|
|
elif ID==ROT_TRACK_TAG:
|
|
|
|
# rotation (quaternion, angle first, followed by axis):
|
|
|
|
q = obj.getEuler().toQuat()
|
|
|
|
track_chunk.add_variable("rotation", _3ds_point_4d((q.angle, q.axis[0], q.axis[1], q.axis[2])))
|
|
|
|
elif ID==SCL_TRACK_TAG:
|
|
|
|
# scale vector:
|
|
|
|
track_chunk.add_variable("scale", _3ds_point_3d(obj.getSize()))
|
|
|
|
else:
|
|
|
|
# meshes have their transformations applied before
|
|
|
|
# exporting, so write identity transforms here:
|
|
|
|
if ID==POS_TRACK_TAG:
|
|
|
|
# position vector:
|
|
|
|
track_chunk.add_variable("position", _3ds_point_3d((0.0,0.0,0.0)))
|
|
|
|
elif ID==ROT_TRACK_TAG:
|
|
|
|
# rotation (quaternion, angle first, followed by axis):
|
|
|
|
track_chunk.add_variable("rotation", _3ds_point_4d((0.0, 1.0, 0.0, 0.0)))
|
|
|
|
elif ID==SCL_TRACK_TAG:
|
|
|
|
# scale vector:
|
|
|
|
track_chunk.add_variable("scale", _3ds_point_3d((1.0, 1.0, 1.0)))
|
Commited 3ds export enhancements from Mark Stijnman (beowulff)
Will need to do some updates, Mesh over NMesh and optimize some areas but it works and is a big improvement.
from
https://projects.blender.org/tracker/index.php?func=detail&aid=4156&group_id=9&atid=127
Detailed description:
Modified the 3ds export script 3ds_export.py:
- It now exports face UV correctly. 3ds only supports one UV coordinate per vertex. The script now duplicates vertices that had multiple UV pairs assigned to them so that each duplicate now only contains one and only one UV. Faces have their vertex indices adjusted accordingly.
- Quads are now split into triangles better. 3ds only supports triangles, so quads need to be split into two triangles. Instead of rather arbitrarily splitting along the diagonal between points 0 and 2, the script now splits along the shortest diagonal. This creates a higher quality triangular mesh, as well as better preservation of symmetry.
- Now creates an object node block, exporting object nodes, needed by some 3D importers. Among others, allows one to export object hierarchy.
- Now exports Empties as 3ds Dummies.
To be able to add all of the above new features, the script has been mostly rewritten and strongly restructured.
Motivation for the rewrite was the desire to be able to use Blender to produce custom 3d cars for Trackmania:Sunrise (TM:S). Previously, the TM:S importer could not correctly handle the 3ds files from the Blender 3ds export script. With this version, one can export cars complete with UV textures, correct wheel placement and light placement. To my knowledge, this script would make Blender the first fully free 3d modeller that allows one to export 3ds models for TM:S (expect a tutorial soon). The ability to have proper UV coordinates exported into the 3ds file should also be very welcome to many.
Add A Comment: Notepad
2006-05-02 11:26:32 +00:00
|
|
|
|
|
|
|
return track_chunk
|
2007-01-07 15:33:28 +00:00
|
|
|
"""
|
2007-05-06 02:19:43 +00:00
|
|
|
|
|
|
|
"""
|
Commited 3ds export enhancements from Mark Stijnman (beowulff)
Will need to do some updates, Mesh over NMesh and optimize some areas but it works and is a big improvement.
from
https://projects.blender.org/tracker/index.php?func=detail&aid=4156&group_id=9&atid=127
Detailed description:
Modified the 3ds export script 3ds_export.py:
- It now exports face UV correctly. 3ds only supports one UV coordinate per vertex. The script now duplicates vertices that had multiple UV pairs assigned to them so that each duplicate now only contains one and only one UV. Faces have their vertex indices adjusted accordingly.
- Quads are now split into triangles better. 3ds only supports triangles, so quads need to be split into two triangles. Instead of rather arbitrarily splitting along the diagonal between points 0 and 2, the script now splits along the shortest diagonal. This creates a higher quality triangular mesh, as well as better preservation of symmetry.
- Now creates an object node block, exporting object nodes, needed by some 3D importers. Among others, allows one to export object hierarchy.
- Now exports Empties as 3ds Dummies.
To be able to add all of the above new features, the script has been mostly rewritten and strongly restructured.
Motivation for the rewrite was the desire to be able to use Blender to produce custom 3d cars for Trackmania:Sunrise (TM:S). Previously, the TM:S importer could not correctly handle the 3ds files from the Blender 3ds export script. With this version, one can export cars complete with UV textures, correct wheel placement and light placement. To my knowledge, this script would make Blender the first fully free 3d modeller that allows one to export 3ds models for TM:S (expect a tutorial soon). The ability to have proper UV coordinates exported into the 3ds file should also be very welcome to many.
Add A Comment: Notepad
2006-05-02 11:26:32 +00:00
|
|
|
def make_kf_obj_node(obj, name_to_id):
|
2006-07-05 07:10:03 +00:00
|
|
|
'''Make a node chunk for a Blender object.
|
Commited 3ds export enhancements from Mark Stijnman (beowulff)
Will need to do some updates, Mesh over NMesh and optimize some areas but it works and is a big improvement.
from
https://projects.blender.org/tracker/index.php?func=detail&aid=4156&group_id=9&atid=127
Detailed description:
Modified the 3ds export script 3ds_export.py:
- It now exports face UV correctly. 3ds only supports one UV coordinate per vertex. The script now duplicates vertices that had multiple UV pairs assigned to them so that each duplicate now only contains one and only one UV. Faces have their vertex indices adjusted accordingly.
- Quads are now split into triangles better. 3ds only supports triangles, so quads need to be split into two triangles. Instead of rather arbitrarily splitting along the diagonal between points 0 and 2, the script now splits along the shortest diagonal. This creates a higher quality triangular mesh, as well as better preservation of symmetry.
- Now creates an object node block, exporting object nodes, needed by some 3D importers. Among others, allows one to export object hierarchy.
- Now exports Empties as 3ds Dummies.
To be able to add all of the above new features, the script has been mostly rewritten and strongly restructured.
Motivation for the rewrite was the desire to be able to use Blender to produce custom 3d cars for Trackmania:Sunrise (TM:S). Previously, the TM:S importer could not correctly handle the 3ds files from the Blender 3ds export script. With this version, one can export cars complete with UV textures, correct wheel placement and light placement. To my knowledge, this script would make Blender the first fully free 3d modeller that allows one to export 3ds models for TM:S (expect a tutorial soon). The ability to have proper UV coordinates exported into the 3ds file should also be very welcome to many.
Add A Comment: Notepad
2006-05-02 11:26:32 +00:00
|
|
|
|
|
|
|
Takes the Blender object as a parameter. Object id's are taken from the dictionary name_to_id.
|
2006-07-05 07:10:03 +00:00
|
|
|
Blender Empty objects are converted to dummy nodes.'''
|
Commited 3ds export enhancements from Mark Stijnman (beowulff)
Will need to do some updates, Mesh over NMesh and optimize some areas but it works and is a big improvement.
from
https://projects.blender.org/tracker/index.php?func=detail&aid=4156&group_id=9&atid=127
Detailed description:
Modified the 3ds export script 3ds_export.py:
- It now exports face UV correctly. 3ds only supports one UV coordinate per vertex. The script now duplicates vertices that had multiple UV pairs assigned to them so that each duplicate now only contains one and only one UV. Faces have their vertex indices adjusted accordingly.
- Quads are now split into triangles better. 3ds only supports triangles, so quads need to be split into two triangles. Instead of rather arbitrarily splitting along the diagonal between points 0 and 2, the script now splits along the shortest diagonal. This creates a higher quality triangular mesh, as well as better preservation of symmetry.
- Now creates an object node block, exporting object nodes, needed by some 3D importers. Among others, allows one to export object hierarchy.
- Now exports Empties as 3ds Dummies.
To be able to add all of the above new features, the script has been mostly rewritten and strongly restructured.
Motivation for the rewrite was the desire to be able to use Blender to produce custom 3d cars for Trackmania:Sunrise (TM:S). Previously, the TM:S importer could not correctly handle the 3ds files from the Blender 3ds export script. With this version, one can export cars complete with UV textures, correct wheel placement and light placement. To my knowledge, this script would make Blender the first fully free 3d modeller that allows one to export 3ds models for TM:S (expect a tutorial soon). The ability to have proper UV coordinates exported into the 3ds file should also be very welcome to many.
Add A Comment: Notepad
2006-05-02 11:26:32 +00:00
|
|
|
|
2006-12-25 09:17:23 +00:00
|
|
|
name = obj.name
|
Commited 3ds export enhancements from Mark Stijnman (beowulff)
Will need to do some updates, Mesh over NMesh and optimize some areas but it works and is a big improvement.
from
https://projects.blender.org/tracker/index.php?func=detail&aid=4156&group_id=9&atid=127
Detailed description:
Modified the 3ds export script 3ds_export.py:
- It now exports face UV correctly. 3ds only supports one UV coordinate per vertex. The script now duplicates vertices that had multiple UV pairs assigned to them so that each duplicate now only contains one and only one UV. Faces have their vertex indices adjusted accordingly.
- Quads are now split into triangles better. 3ds only supports triangles, so quads need to be split into two triangles. Instead of rather arbitrarily splitting along the diagonal between points 0 and 2, the script now splits along the shortest diagonal. This creates a higher quality triangular mesh, as well as better preservation of symmetry.
- Now creates an object node block, exporting object nodes, needed by some 3D importers. Among others, allows one to export object hierarchy.
- Now exports Empties as 3ds Dummies.
To be able to add all of the above new features, the script has been mostly rewritten and strongly restructured.
Motivation for the rewrite was the desire to be able to use Blender to produce custom 3d cars for Trackmania:Sunrise (TM:S). Previously, the TM:S importer could not correctly handle the 3ds files from the Blender 3ds export script. With this version, one can export cars complete with UV textures, correct wheel placement and light placement. To my knowledge, this script would make Blender the first fully free 3d modeller that allows one to export 3ds models for TM:S (expect a tutorial soon). The ability to have proper UV coordinates exported into the 3ds file should also be very welcome to many.
Add A Comment: Notepad
2006-05-02 11:26:32 +00:00
|
|
|
# main object node chunk:
|
|
|
|
kf_obj_node = _3ds_chunk(KFDATA_OBJECT_NODE_TAG)
|
|
|
|
# chunk for the object id:
|
|
|
|
obj_id_chunk = _3ds_chunk(OBJECT_NODE_ID)
|
|
|
|
# object id is from the name_to_id dictionary:
|
|
|
|
obj_id_chunk.add_variable("node_id", _3ds_short(name_to_id[name]))
|
|
|
|
|
|
|
|
# object node header:
|
|
|
|
obj_node_header_chunk = _3ds_chunk(OBJECT_NODE_HDR)
|
|
|
|
# object name:
|
2006-12-25 09:17:23 +00:00
|
|
|
if obj.type == 'Empty':
|
Commited 3ds export enhancements from Mark Stijnman (beowulff)
Will need to do some updates, Mesh over NMesh and optimize some areas but it works and is a big improvement.
from
https://projects.blender.org/tracker/index.php?func=detail&aid=4156&group_id=9&atid=127
Detailed description:
Modified the 3ds export script 3ds_export.py:
- It now exports face UV correctly. 3ds only supports one UV coordinate per vertex. The script now duplicates vertices that had multiple UV pairs assigned to them so that each duplicate now only contains one and only one UV. Faces have their vertex indices adjusted accordingly.
- Quads are now split into triangles better. 3ds only supports triangles, so quads need to be split into two triangles. Instead of rather arbitrarily splitting along the diagonal between points 0 and 2, the script now splits along the shortest diagonal. This creates a higher quality triangular mesh, as well as better preservation of symmetry.
- Now creates an object node block, exporting object nodes, needed by some 3D importers. Among others, allows one to export object hierarchy.
- Now exports Empties as 3ds Dummies.
To be able to add all of the above new features, the script has been mostly rewritten and strongly restructured.
Motivation for the rewrite was the desire to be able to use Blender to produce custom 3d cars for Trackmania:Sunrise (TM:S). Previously, the TM:S importer could not correctly handle the 3ds files from the Blender 3ds export script. With this version, one can export cars complete with UV textures, correct wheel placement and light placement. To my knowledge, this script would make Blender the first fully free 3d modeller that allows one to export 3ds models for TM:S (expect a tutorial soon). The ability to have proper UV coordinates exported into the 3ds file should also be very welcome to many.
Add A Comment: Notepad
2006-05-02 11:26:32 +00:00
|
|
|
# Empties are called "$$$DUMMY" and use the OBJECT_INSTANCE_NAME chunk
|
|
|
|
# for their name (see below):
|
|
|
|
obj_node_header_chunk.add_variable("name", _3ds_string("$$$DUMMY"))
|
|
|
|
else:
|
|
|
|
# Add the name:
|
2007-05-06 02:19:43 +00:00
|
|
|
obj_node_header_chunk.add_variable("name", _3ds_string(sane_name(name)))
|
Commited 3ds export enhancements from Mark Stijnman (beowulff)
Will need to do some updates, Mesh over NMesh and optimize some areas but it works and is a big improvement.
from
https://projects.blender.org/tracker/index.php?func=detail&aid=4156&group_id=9&atid=127
Detailed description:
Modified the 3ds export script 3ds_export.py:
- It now exports face UV correctly. 3ds only supports one UV coordinate per vertex. The script now duplicates vertices that had multiple UV pairs assigned to them so that each duplicate now only contains one and only one UV. Faces have their vertex indices adjusted accordingly.
- Quads are now split into triangles better. 3ds only supports triangles, so quads need to be split into two triangles. Instead of rather arbitrarily splitting along the diagonal between points 0 and 2, the script now splits along the shortest diagonal. This creates a higher quality triangular mesh, as well as better preservation of symmetry.
- Now creates an object node block, exporting object nodes, needed by some 3D importers. Among others, allows one to export object hierarchy.
- Now exports Empties as 3ds Dummies.
To be able to add all of the above new features, the script has been mostly rewritten and strongly restructured.
Motivation for the rewrite was the desire to be able to use Blender to produce custom 3d cars for Trackmania:Sunrise (TM:S). Previously, the TM:S importer could not correctly handle the 3ds files from the Blender 3ds export script. With this version, one can export cars complete with UV textures, correct wheel placement and light placement. To my knowledge, this script would make Blender the first fully free 3d modeller that allows one to export 3ds models for TM:S (expect a tutorial soon). The ability to have proper UV coordinates exported into the 3ds file should also be very welcome to many.
Add A Comment: Notepad
2006-05-02 11:26:32 +00:00
|
|
|
# Add Flag variables (not sure what they do):
|
|
|
|
obj_node_header_chunk.add_variable("flags1", _3ds_short(0))
|
|
|
|
obj_node_header_chunk.add_variable("flags2", _3ds_short(0))
|
|
|
|
|
|
|
|
# Check parent-child relationships:
|
2006-12-25 09:17:23 +00:00
|
|
|
parent = obj.parent
|
|
|
|
if (parent == None) or (parent.name not in name_to_id):
|
Commited 3ds export enhancements from Mark Stijnman (beowulff)
Will need to do some updates, Mesh over NMesh and optimize some areas but it works and is a big improvement.
from
https://projects.blender.org/tracker/index.php?func=detail&aid=4156&group_id=9&atid=127
Detailed description:
Modified the 3ds export script 3ds_export.py:
- It now exports face UV correctly. 3ds only supports one UV coordinate per vertex. The script now duplicates vertices that had multiple UV pairs assigned to them so that each duplicate now only contains one and only one UV. Faces have their vertex indices adjusted accordingly.
- Quads are now split into triangles better. 3ds only supports triangles, so quads need to be split into two triangles. Instead of rather arbitrarily splitting along the diagonal between points 0 and 2, the script now splits along the shortest diagonal. This creates a higher quality triangular mesh, as well as better preservation of symmetry.
- Now creates an object node block, exporting object nodes, needed by some 3D importers. Among others, allows one to export object hierarchy.
- Now exports Empties as 3ds Dummies.
To be able to add all of the above new features, the script has been mostly rewritten and strongly restructured.
Motivation for the rewrite was the desire to be able to use Blender to produce custom 3d cars for Trackmania:Sunrise (TM:S). Previously, the TM:S importer could not correctly handle the 3ds files from the Blender 3ds export script. With this version, one can export cars complete with UV textures, correct wheel placement and light placement. To my knowledge, this script would make Blender the first fully free 3d modeller that allows one to export 3ds models for TM:S (expect a tutorial soon). The ability to have proper UV coordinates exported into the 3ds file should also be very welcome to many.
Add A Comment: Notepad
2006-05-02 11:26:32 +00:00
|
|
|
# If no parent, or the parents name is not in the name_to_id dictionary,
|
|
|
|
# parent id becomes -1:
|
|
|
|
obj_node_header_chunk.add_variable("parent", _3ds_short(-1))
|
|
|
|
else:
|
|
|
|
# Get the parent's id from the name_to_id dictionary:
|
2006-12-25 09:17:23 +00:00
|
|
|
obj_node_header_chunk.add_variable("parent", _3ds_short(name_to_id[parent.name]))
|
Commited 3ds export enhancements from Mark Stijnman (beowulff)
Will need to do some updates, Mesh over NMesh and optimize some areas but it works and is a big improvement.
from
https://projects.blender.org/tracker/index.php?func=detail&aid=4156&group_id=9&atid=127
Detailed description:
Modified the 3ds export script 3ds_export.py:
- It now exports face UV correctly. 3ds only supports one UV coordinate per vertex. The script now duplicates vertices that had multiple UV pairs assigned to them so that each duplicate now only contains one and only one UV. Faces have their vertex indices adjusted accordingly.
- Quads are now split into triangles better. 3ds only supports triangles, so quads need to be split into two triangles. Instead of rather arbitrarily splitting along the diagonal between points 0 and 2, the script now splits along the shortest diagonal. This creates a higher quality triangular mesh, as well as better preservation of symmetry.
- Now creates an object node block, exporting object nodes, needed by some 3D importers. Among others, allows one to export object hierarchy.
- Now exports Empties as 3ds Dummies.
To be able to add all of the above new features, the script has been mostly rewritten and strongly restructured.
Motivation for the rewrite was the desire to be able to use Blender to produce custom 3d cars for Trackmania:Sunrise (TM:S). Previously, the TM:S importer could not correctly handle the 3ds files from the Blender 3ds export script. With this version, one can export cars complete with UV textures, correct wheel placement and light placement. To my knowledge, this script would make Blender the first fully free 3d modeller that allows one to export 3ds models for TM:S (expect a tutorial soon). The ability to have proper UV coordinates exported into the 3ds file should also be very welcome to many.
Add A Comment: Notepad
2006-05-02 11:26:32 +00:00
|
|
|
|
|
|
|
# Add pivot chunk:
|
|
|
|
obj_pivot_chunk = _3ds_chunk(OBJECT_PIVOT)
|
|
|
|
obj_pivot_chunk.add_variable("pivot", _3ds_point_3d(obj.getLocation()))
|
|
|
|
kf_obj_node.add_subchunk(obj_pivot_chunk)
|
|
|
|
|
|
|
|
# add subchunks for object id and node header:
|
|
|
|
kf_obj_node.add_subchunk(obj_id_chunk)
|
|
|
|
kf_obj_node.add_subchunk(obj_node_header_chunk)
|
|
|
|
|
|
|
|
# Empty objects need to have an extra chunk for the instance name:
|
2006-12-25 09:17:23 +00:00
|
|
|
if obj.type == 'Empty':
|
Commited 3ds export enhancements from Mark Stijnman (beowulff)
Will need to do some updates, Mesh over NMesh and optimize some areas but it works and is a big improvement.
from
https://projects.blender.org/tracker/index.php?func=detail&aid=4156&group_id=9&atid=127
Detailed description:
Modified the 3ds export script 3ds_export.py:
- It now exports face UV correctly. 3ds only supports one UV coordinate per vertex. The script now duplicates vertices that had multiple UV pairs assigned to them so that each duplicate now only contains one and only one UV. Faces have their vertex indices adjusted accordingly.
- Quads are now split into triangles better. 3ds only supports triangles, so quads need to be split into two triangles. Instead of rather arbitrarily splitting along the diagonal between points 0 and 2, the script now splits along the shortest diagonal. This creates a higher quality triangular mesh, as well as better preservation of symmetry.
- Now creates an object node block, exporting object nodes, needed by some 3D importers. Among others, allows one to export object hierarchy.
- Now exports Empties as 3ds Dummies.
To be able to add all of the above new features, the script has been mostly rewritten and strongly restructured.
Motivation for the rewrite was the desire to be able to use Blender to produce custom 3d cars for Trackmania:Sunrise (TM:S). Previously, the TM:S importer could not correctly handle the 3ds files from the Blender 3ds export script. With this version, one can export cars complete with UV textures, correct wheel placement and light placement. To my knowledge, this script would make Blender the first fully free 3d modeller that allows one to export 3ds models for TM:S (expect a tutorial soon). The ability to have proper UV coordinates exported into the 3ds file should also be very welcome to many.
Add A Comment: Notepad
2006-05-02 11:26:32 +00:00
|
|
|
obj_instance_name_chunk = _3ds_chunk(OBJECT_INSTANCE_NAME)
|
2007-05-06 02:19:43 +00:00
|
|
|
obj_instance_name_chunk.add_variable("name", _3ds_string(sane_name(name)))
|
Commited 3ds export enhancements from Mark Stijnman (beowulff)
Will need to do some updates, Mesh over NMesh and optimize some areas but it works and is a big improvement.
from
https://projects.blender.org/tracker/index.php?func=detail&aid=4156&group_id=9&atid=127
Detailed description:
Modified the 3ds export script 3ds_export.py:
- It now exports face UV correctly. 3ds only supports one UV coordinate per vertex. The script now duplicates vertices that had multiple UV pairs assigned to them so that each duplicate now only contains one and only one UV. Faces have their vertex indices adjusted accordingly.
- Quads are now split into triangles better. 3ds only supports triangles, so quads need to be split into two triangles. Instead of rather arbitrarily splitting along the diagonal between points 0 and 2, the script now splits along the shortest diagonal. This creates a higher quality triangular mesh, as well as better preservation of symmetry.
- Now creates an object node block, exporting object nodes, needed by some 3D importers. Among others, allows one to export object hierarchy.
- Now exports Empties as 3ds Dummies.
To be able to add all of the above new features, the script has been mostly rewritten and strongly restructured.
Motivation for the rewrite was the desire to be able to use Blender to produce custom 3d cars for Trackmania:Sunrise (TM:S). Previously, the TM:S importer could not correctly handle the 3ds files from the Blender 3ds export script. With this version, one can export cars complete with UV textures, correct wheel placement and light placement. To my knowledge, this script would make Blender the first fully free 3d modeller that allows one to export 3ds models for TM:S (expect a tutorial soon). The ability to have proper UV coordinates exported into the 3ds file should also be very welcome to many.
Add A Comment: Notepad
2006-05-02 11:26:32 +00:00
|
|
|
kf_obj_node.add_subchunk(obj_instance_name_chunk)
|
|
|
|
|
|
|
|
# Add track chunks for position, rotation and scale:
|
|
|
|
kf_obj_node.add_subchunk(make_track_chunk(POS_TRACK_TAG, obj))
|
|
|
|
kf_obj_node.add_subchunk(make_track_chunk(ROT_TRACK_TAG, obj))
|
|
|
|
kf_obj_node.add_subchunk(make_track_chunk(SCL_TRACK_TAG, obj))
|
2005-12-15 01:42:45 +00:00
|
|
|
|
Commited 3ds export enhancements from Mark Stijnman (beowulff)
Will need to do some updates, Mesh over NMesh and optimize some areas but it works and is a big improvement.
from
https://projects.blender.org/tracker/index.php?func=detail&aid=4156&group_id=9&atid=127
Detailed description:
Modified the 3ds export script 3ds_export.py:
- It now exports face UV correctly. 3ds only supports one UV coordinate per vertex. The script now duplicates vertices that had multiple UV pairs assigned to them so that each duplicate now only contains one and only one UV. Faces have their vertex indices adjusted accordingly.
- Quads are now split into triangles better. 3ds only supports triangles, so quads need to be split into two triangles. Instead of rather arbitrarily splitting along the diagonal between points 0 and 2, the script now splits along the shortest diagonal. This creates a higher quality triangular mesh, as well as better preservation of symmetry.
- Now creates an object node block, exporting object nodes, needed by some 3D importers. Among others, allows one to export object hierarchy.
- Now exports Empties as 3ds Dummies.
To be able to add all of the above new features, the script has been mostly rewritten and strongly restructured.
Motivation for the rewrite was the desire to be able to use Blender to produce custom 3d cars for Trackmania:Sunrise (TM:S). Previously, the TM:S importer could not correctly handle the 3ds files from the Blender 3ds export script. With this version, one can export cars complete with UV textures, correct wheel placement and light placement. To my knowledge, this script would make Blender the first fully free 3d modeller that allows one to export 3ds models for TM:S (expect a tutorial soon). The ability to have proper UV coordinates exported into the 3ds file should also be very welcome to many.
Add A Comment: Notepad
2006-05-02 11:26:32 +00:00
|
|
|
return kf_obj_node
|
2007-01-07 15:33:28 +00:00
|
|
|
"""
|
2005-12-15 01:42:45 +00:00
|
|
|
|
2009-09-29 15:27:00 +00:00
|
|
|
# import BPyMessages
|
|
|
|
def save_3ds(filename, context):
|
2006-07-05 07:10:03 +00:00
|
|
|
'''Save the Blender scene to a 3ds file.'''
|
2005-12-15 01:42:45 +00:00
|
|
|
# Time the export
|
2007-01-22 17:31:34 +00:00
|
|
|
|
|
|
|
if not filename.lower().endswith('.3ds'):
|
|
|
|
filename += '.3ds'
|
|
|
|
|
2009-09-29 15:27:00 +00:00
|
|
|
# XXX
|
|
|
|
# if not BPyMessages.Warning_SaveOver(filename):
|
|
|
|
# return
|
2007-01-22 17:31:34 +00:00
|
|
|
|
2009-09-29 15:27:00 +00:00
|
|
|
# XXX
|
|
|
|
time1 = time.clock()
|
|
|
|
# time1= Blender.sys.time()
|
|
|
|
# Blender.Window.WaitCursor(1)
|
|
|
|
|
|
|
|
sce = context.scene
|
|
|
|
# sce= bpy.data.scenes.active
|
2006-05-14 03:11:55 +00:00
|
|
|
|
Commited 3ds export enhancements from Mark Stijnman (beowulff)
Will need to do some updates, Mesh over NMesh and optimize some areas but it works and is a big improvement.
from
https://projects.blender.org/tracker/index.php?func=detail&aid=4156&group_id=9&atid=127
Detailed description:
Modified the 3ds export script 3ds_export.py:
- It now exports face UV correctly. 3ds only supports one UV coordinate per vertex. The script now duplicates vertices that had multiple UV pairs assigned to them so that each duplicate now only contains one and only one UV. Faces have their vertex indices adjusted accordingly.
- Quads are now split into triangles better. 3ds only supports triangles, so quads need to be split into two triangles. Instead of rather arbitrarily splitting along the diagonal between points 0 and 2, the script now splits along the shortest diagonal. This creates a higher quality triangular mesh, as well as better preservation of symmetry.
- Now creates an object node block, exporting object nodes, needed by some 3D importers. Among others, allows one to export object hierarchy.
- Now exports Empties as 3ds Dummies.
To be able to add all of the above new features, the script has been mostly rewritten and strongly restructured.
Motivation for the rewrite was the desire to be able to use Blender to produce custom 3d cars for Trackmania:Sunrise (TM:S). Previously, the TM:S importer could not correctly handle the 3ds files from the Blender 3ds export script. With this version, one can export cars complete with UV textures, correct wheel placement and light placement. To my knowledge, this script would make Blender the first fully free 3d modeller that allows one to export 3ds models for TM:S (expect a tutorial soon). The ability to have proper UV coordinates exported into the 3ds file should also be very welcome to many.
Add A Comment: Notepad
2006-05-02 11:26:32 +00:00
|
|
|
# Initialize the main chunk (primary):
|
|
|
|
primary = _3ds_chunk(PRIMARY)
|
|
|
|
# Add version chunk:
|
|
|
|
version_chunk = _3ds_chunk(VERSION)
|
|
|
|
version_chunk.add_variable("version", _3ds_int(3))
|
|
|
|
primary.add_subchunk(version_chunk)
|
|
|
|
|
|
|
|
# init main object info chunk:
|
|
|
|
object_info = _3ds_chunk(OBJECTINFO)
|
|
|
|
|
2006-07-05 07:10:03 +00:00
|
|
|
''' # COMMENTED OUT FOR 2.42 RELEASE!! CRASHES 3DS MAX
|
Commited 3ds export enhancements from Mark Stijnman (beowulff)
Will need to do some updates, Mesh over NMesh and optimize some areas but it works and is a big improvement.
from
https://projects.blender.org/tracker/index.php?func=detail&aid=4156&group_id=9&atid=127
Detailed description:
Modified the 3ds export script 3ds_export.py:
- It now exports face UV correctly. 3ds only supports one UV coordinate per vertex. The script now duplicates vertices that had multiple UV pairs assigned to them so that each duplicate now only contains one and only one UV. Faces have their vertex indices adjusted accordingly.
- Quads are now split into triangles better. 3ds only supports triangles, so quads need to be split into two triangles. Instead of rather arbitrarily splitting along the diagonal between points 0 and 2, the script now splits along the shortest diagonal. This creates a higher quality triangular mesh, as well as better preservation of symmetry.
- Now creates an object node block, exporting object nodes, needed by some 3D importers. Among others, allows one to export object hierarchy.
- Now exports Empties as 3ds Dummies.
To be able to add all of the above new features, the script has been mostly rewritten and strongly restructured.
Motivation for the rewrite was the desire to be able to use Blender to produce custom 3d cars for Trackmania:Sunrise (TM:S). Previously, the TM:S importer could not correctly handle the 3ds files from the Blender 3ds export script. With this version, one can export cars complete with UV textures, correct wheel placement and light placement. To my knowledge, this script would make Blender the first fully free 3d modeller that allows one to export 3ds models for TM:S (expect a tutorial soon). The ability to have proper UV coordinates exported into the 3ds file should also be very welcome to many.
Add A Comment: Notepad
2006-05-02 11:26:32 +00:00
|
|
|
# init main key frame data chunk:
|
|
|
|
kfdata = make_kfdata()
|
2006-07-05 07:10:03 +00:00
|
|
|
'''
|
Commited 3ds export enhancements from Mark Stijnman (beowulff)
Will need to do some updates, Mesh over NMesh and optimize some areas but it works and is a big improvement.
from
https://projects.blender.org/tracker/index.php?func=detail&aid=4156&group_id=9&atid=127
Detailed description:
Modified the 3ds export script 3ds_export.py:
- It now exports face UV correctly. 3ds only supports one UV coordinate per vertex. The script now duplicates vertices that had multiple UV pairs assigned to them so that each duplicate now only contains one and only one UV. Faces have their vertex indices adjusted accordingly.
- Quads are now split into triangles better. 3ds only supports triangles, so quads need to be split into two triangles. Instead of rather arbitrarily splitting along the diagonal between points 0 and 2, the script now splits along the shortest diagonal. This creates a higher quality triangular mesh, as well as better preservation of symmetry.
- Now creates an object node block, exporting object nodes, needed by some 3D importers. Among others, allows one to export object hierarchy.
- Now exports Empties as 3ds Dummies.
To be able to add all of the above new features, the script has been mostly rewritten and strongly restructured.
Motivation for the rewrite was the desire to be able to use Blender to produce custom 3d cars for Trackmania:Sunrise (TM:S). Previously, the TM:S importer could not correctly handle the 3ds files from the Blender 3ds export script. With this version, one can export cars complete with UV textures, correct wheel placement and light placement. To my knowledge, this script would make Blender the first fully free 3d modeller that allows one to export 3ds models for TM:S (expect a tutorial soon). The ability to have proper UV coordinates exported into the 3ds file should also be very welcome to many.
Add A Comment: Notepad
2006-05-02 11:26:32 +00:00
|
|
|
|
2006-05-14 03:11:55 +00:00
|
|
|
# Get all the supported objects selected in this scene:
|
2007-05-06 02:19:43 +00:00
|
|
|
# ob_sel= list(sce.objects.context)
|
|
|
|
# mesh_objects = [ (ob, me) for ob in ob_sel for me in (BPyMesh.getMeshFromObject(ob, None, True, False, sce),) if me ]
|
2007-01-07 15:33:28 +00:00
|
|
|
# empty_objects = [ ob for ob in ob_sel if ob.type == 'Empty' ]
|
2006-05-14 03:11:55 +00:00
|
|
|
|
|
|
|
# Make a list of all materials used in the selected meshes (use a dictionary,
|
|
|
|
# each material is added once):
|
2007-01-04 15:20:28 +00:00
|
|
|
materialDict = {}
|
2007-01-07 15:33:28 +00:00
|
|
|
mesh_objects = []
|
2009-09-29 15:27:00 +00:00
|
|
|
for ob in [ob for ob in context.scene.objects if ob.is_visible()]:
|
|
|
|
# for ob in sce.objects.context:
|
|
|
|
|
|
|
|
# get derived objects
|
|
|
|
free, derived = create_derived_objects(ob)
|
|
|
|
|
|
|
|
if derived == None: continue
|
|
|
|
|
|
|
|
for ob_derived, mat in derived:
|
|
|
|
# for ob_derived, mat in getDerivedObjects(ob, False):
|
|
|
|
|
|
|
|
if ob.type not in ('MESH', 'CURVE', 'SURFACE', 'TEXT', 'META'):
|
|
|
|
continue
|
|
|
|
|
|
|
|
data = ob_derived.create_mesh(True, 'PREVIEW')
|
|
|
|
# data = getMeshFromObject(ob_derived, None, True, False, sce)
|
2007-01-07 15:33:28 +00:00
|
|
|
if data:
|
2009-09-29 15:27:00 +00:00
|
|
|
data.transform(mat)
|
|
|
|
# data.transform(mat, recalc_normals=False)
|
2007-01-07 15:33:28 +00:00
|
|
|
mesh_objects.append((ob_derived, data))
|
2007-01-11 09:39:16 +00:00
|
|
|
mat_ls = data.materials
|
|
|
|
mat_ls_len = len(mat_ls)
|
2009-09-29 15:27:00 +00:00
|
|
|
|
2007-01-07 15:33:28 +00:00
|
|
|
# get material/image tuples.
|
2009-09-29 15:27:00 +00:00
|
|
|
if len(data.uv_textures):
|
|
|
|
# if data.faceUV:
|
2007-01-07 15:33:28 +00:00
|
|
|
if not mat_ls:
|
|
|
|
mat = mat_name = None
|
2007-01-04 15:20:28 +00:00
|
|
|
|
2009-09-29 15:27:00 +00:00
|
|
|
for f, uf in zip(data.faces, data.active_uv_texture.data):
|
2007-01-07 15:33:28 +00:00
|
|
|
if mat_ls:
|
2009-09-29 15:27:00 +00:00
|
|
|
mat_index = f.material_index
|
|
|
|
# mat_index = f.mat
|
2007-01-11 09:39:16 +00:00
|
|
|
if mat_index >= mat_ls_len:
|
|
|
|
mat_index = f.mat = 0
|
2007-05-06 02:19:43 +00:00
|
|
|
mat = mat_ls[mat_index]
|
2007-01-07 15:33:28 +00:00
|
|
|
if mat: mat_name = mat.name
|
|
|
|
else: mat_name = None
|
|
|
|
# else there alredy set to none
|
|
|
|
|
2009-09-29 15:27:00 +00:00
|
|
|
img = uf.image
|
|
|
|
# img = f.image
|
2007-01-07 15:33:28 +00:00
|
|
|
if img: img_name = img.name
|
|
|
|
else: img_name = None
|
|
|
|
|
2007-05-06 02:19:43 +00:00
|
|
|
materialDict.setdefault((mat_name, img_name), (mat, img) )
|
|
|
|
|
2007-01-04 15:20:28 +00:00
|
|
|
|
2007-01-07 15:33:28 +00:00
|
|
|
else:
|
2007-01-11 09:39:16 +00:00
|
|
|
for mat in mat_ls:
|
2007-01-07 15:33:28 +00:00
|
|
|
if mat: # material may be None so check its not.
|
2007-05-06 02:19:43 +00:00
|
|
|
materialDict.setdefault((mat.name, None), (mat, None) )
|
2007-01-11 09:39:16 +00:00
|
|
|
|
|
|
|
# Why 0 Why!
|
|
|
|
for f in data.faces:
|
2009-09-29 15:27:00 +00:00
|
|
|
if f.material_index >= mat_ls_len:
|
|
|
|
# if f.mat >= mat_ls_len:
|
|
|
|
f.material_index = 0
|
|
|
|
# f.mat = 0
|
|
|
|
|
|
|
|
if free:
|
|
|
|
free_derived_objects(ob)
|
|
|
|
|
2006-05-14 03:11:55 +00:00
|
|
|
|
|
|
|
# Make material chunks for all materials used in the meshes:
|
2009-09-29 15:27:00 +00:00
|
|
|
for mat_and_image in materialDict.values():
|
2007-05-06 02:19:43 +00:00
|
|
|
object_info.add_subchunk(make_material_chunk(mat_and_image[0], mat_and_image[1]))
|
Commited 3ds export enhancements from Mark Stijnman (beowulff)
Will need to do some updates, Mesh over NMesh and optimize some areas but it works and is a big improvement.
from
https://projects.blender.org/tracker/index.php?func=detail&aid=4156&group_id=9&atid=127
Detailed description:
Modified the 3ds export script 3ds_export.py:
- It now exports face UV correctly. 3ds only supports one UV coordinate per vertex. The script now duplicates vertices that had multiple UV pairs assigned to them so that each duplicate now only contains one and only one UV. Faces have their vertex indices adjusted accordingly.
- Quads are now split into triangles better. 3ds only supports triangles, so quads need to be split into two triangles. Instead of rather arbitrarily splitting along the diagonal between points 0 and 2, the script now splits along the shortest diagonal. This creates a higher quality triangular mesh, as well as better preservation of symmetry.
- Now creates an object node block, exporting object nodes, needed by some 3D importers. Among others, allows one to export object hierarchy.
- Now exports Empties as 3ds Dummies.
To be able to add all of the above new features, the script has been mostly rewritten and strongly restructured.
Motivation for the rewrite was the desire to be able to use Blender to produce custom 3d cars for Trackmania:Sunrise (TM:S). Previously, the TM:S importer could not correctly handle the 3ds files from the Blender 3ds export script. With this version, one can export cars complete with UV textures, correct wheel placement and light placement. To my knowledge, this script would make Blender the first fully free 3d modeller that allows one to export 3ds models for TM:S (expect a tutorial soon). The ability to have proper UV coordinates exported into the 3ds file should also be very welcome to many.
Add A Comment: Notepad
2006-05-02 11:26:32 +00:00
|
|
|
|
|
|
|
# Give all objects a unique ID and build a dictionary from object name to object id:
|
2007-01-07 15:33:28 +00:00
|
|
|
"""
|
Commited 3ds export enhancements from Mark Stijnman (beowulff)
Will need to do some updates, Mesh over NMesh and optimize some areas but it works and is a big improvement.
from
https://projects.blender.org/tracker/index.php?func=detail&aid=4156&group_id=9&atid=127
Detailed description:
Modified the 3ds export script 3ds_export.py:
- It now exports face UV correctly. 3ds only supports one UV coordinate per vertex. The script now duplicates vertices that had multiple UV pairs assigned to them so that each duplicate now only contains one and only one UV. Faces have their vertex indices adjusted accordingly.
- Quads are now split into triangles better. 3ds only supports triangles, so quads need to be split into two triangles. Instead of rather arbitrarily splitting along the diagonal between points 0 and 2, the script now splits along the shortest diagonal. This creates a higher quality triangular mesh, as well as better preservation of symmetry.
- Now creates an object node block, exporting object nodes, needed by some 3D importers. Among others, allows one to export object hierarchy.
- Now exports Empties as 3ds Dummies.
To be able to add all of the above new features, the script has been mostly rewritten and strongly restructured.
Motivation for the rewrite was the desire to be able to use Blender to produce custom 3d cars for Trackmania:Sunrise (TM:S). Previously, the TM:S importer could not correctly handle the 3ds files from the Blender 3ds export script. With this version, one can export cars complete with UV textures, correct wheel placement and light placement. To my knowledge, this script would make Blender the first fully free 3d modeller that allows one to export 3ds models for TM:S (expect a tutorial soon). The ability to have proper UV coordinates exported into the 3ds file should also be very welcome to many.
Add A Comment: Notepad
2006-05-02 11:26:32 +00:00
|
|
|
name_to_id = {}
|
2006-05-14 03:11:55 +00:00
|
|
|
for ob, data in mesh_objects:
|
|
|
|
name_to_id[ob.name]= len(name_to_id)
|
2007-01-07 15:33:28 +00:00
|
|
|
#for ob in empty_objects:
|
|
|
|
# name_to_id[ob.name]= len(name_to_id)
|
|
|
|
"""
|
Commited 3ds export enhancements from Mark Stijnman (beowulff)
Will need to do some updates, Mesh over NMesh and optimize some areas but it works and is a big improvement.
from
https://projects.blender.org/tracker/index.php?func=detail&aid=4156&group_id=9&atid=127
Detailed description:
Modified the 3ds export script 3ds_export.py:
- It now exports face UV correctly. 3ds only supports one UV coordinate per vertex. The script now duplicates vertices that had multiple UV pairs assigned to them so that each duplicate now only contains one and only one UV. Faces have their vertex indices adjusted accordingly.
- Quads are now split into triangles better. 3ds only supports triangles, so quads need to be split into two triangles. Instead of rather arbitrarily splitting along the diagonal between points 0 and 2, the script now splits along the shortest diagonal. This creates a higher quality triangular mesh, as well as better preservation of symmetry.
- Now creates an object node block, exporting object nodes, needed by some 3D importers. Among others, allows one to export object hierarchy.
- Now exports Empties as 3ds Dummies.
To be able to add all of the above new features, the script has been mostly rewritten and strongly restructured.
Motivation for the rewrite was the desire to be able to use Blender to produce custom 3d cars for Trackmania:Sunrise (TM:S). Previously, the TM:S importer could not correctly handle the 3ds files from the Blender 3ds export script. With this version, one can export cars complete with UV textures, correct wheel placement and light placement. To my knowledge, this script would make Blender the first fully free 3d modeller that allows one to export 3ds models for TM:S (expect a tutorial soon). The ability to have proper UV coordinates exported into the 3ds file should also be very welcome to many.
Add A Comment: Notepad
2006-05-02 11:26:32 +00:00
|
|
|
|
|
|
|
# Create object chunks for all meshes:
|
2007-01-07 15:33:28 +00:00
|
|
|
i = 0
|
2006-05-14 03:11:55 +00:00
|
|
|
for ob, blender_mesh in mesh_objects:
|
|
|
|
# create a new object chunk
|
Commited 3ds export enhancements from Mark Stijnman (beowulff)
Will need to do some updates, Mesh over NMesh and optimize some areas but it works and is a big improvement.
from
https://projects.blender.org/tracker/index.php?func=detail&aid=4156&group_id=9&atid=127
Detailed description:
Modified the 3ds export script 3ds_export.py:
- It now exports face UV correctly. 3ds only supports one UV coordinate per vertex. The script now duplicates vertices that had multiple UV pairs assigned to them so that each duplicate now only contains one and only one UV. Faces have their vertex indices adjusted accordingly.
- Quads are now split into triangles better. 3ds only supports triangles, so quads need to be split into two triangles. Instead of rather arbitrarily splitting along the diagonal between points 0 and 2, the script now splits along the shortest diagonal. This creates a higher quality triangular mesh, as well as better preservation of symmetry.
- Now creates an object node block, exporting object nodes, needed by some 3D importers. Among others, allows one to export object hierarchy.
- Now exports Empties as 3ds Dummies.
To be able to add all of the above new features, the script has been mostly rewritten and strongly restructured.
Motivation for the rewrite was the desire to be able to use Blender to produce custom 3d cars for Trackmania:Sunrise (TM:S). Previously, the TM:S importer could not correctly handle the 3ds files from the Blender 3ds export script. With this version, one can export cars complete with UV textures, correct wheel placement and light placement. To my knowledge, this script would make Blender the first fully free 3d modeller that allows one to export 3ds models for TM:S (expect a tutorial soon). The ability to have proper UV coordinates exported into the 3ds file should also be very welcome to many.
Add A Comment: Notepad
2006-05-02 11:26:32 +00:00
|
|
|
object_chunk = _3ds_chunk(OBJECT)
|
|
|
|
|
2006-05-14 03:11:55 +00:00
|
|
|
# set the object name
|
2007-05-06 02:19:43 +00:00
|
|
|
object_chunk.add_variable("name", _3ds_string(sane_name(ob.name)))
|
2005-12-15 01:42:45 +00:00
|
|
|
|
Commited 3ds export enhancements from Mark Stijnman (beowulff)
Will need to do some updates, Mesh over NMesh and optimize some areas but it works and is a big improvement.
from
https://projects.blender.org/tracker/index.php?func=detail&aid=4156&group_id=9&atid=127
Detailed description:
Modified the 3ds export script 3ds_export.py:
- It now exports face UV correctly. 3ds only supports one UV coordinate per vertex. The script now duplicates vertices that had multiple UV pairs assigned to them so that each duplicate now only contains one and only one UV. Faces have their vertex indices adjusted accordingly.
- Quads are now split into triangles better. 3ds only supports triangles, so quads need to be split into two triangles. Instead of rather arbitrarily splitting along the diagonal between points 0 and 2, the script now splits along the shortest diagonal. This creates a higher quality triangular mesh, as well as better preservation of symmetry.
- Now creates an object node block, exporting object nodes, needed by some 3D importers. Among others, allows one to export object hierarchy.
- Now exports Empties as 3ds Dummies.
To be able to add all of the above new features, the script has been mostly rewritten and strongly restructured.
Motivation for the rewrite was the desire to be able to use Blender to produce custom 3d cars for Trackmania:Sunrise (TM:S). Previously, the TM:S importer could not correctly handle the 3ds files from the Blender 3ds export script. With this version, one can export cars complete with UV textures, correct wheel placement and light placement. To my knowledge, this script would make Blender the first fully free 3d modeller that allows one to export 3ds models for TM:S (expect a tutorial soon). The ability to have proper UV coordinates exported into the 3ds file should also be very welcome to many.
Add A Comment: Notepad
2006-05-02 11:26:32 +00:00
|
|
|
# make a mesh chunk out of the mesh:
|
2007-01-04 15:20:28 +00:00
|
|
|
object_chunk.add_subchunk(make_mesh_chunk(blender_mesh, materialDict))
|
Commited 3ds export enhancements from Mark Stijnman (beowulff)
Will need to do some updates, Mesh over NMesh and optimize some areas but it works and is a big improvement.
from
https://projects.blender.org/tracker/index.php?func=detail&aid=4156&group_id=9&atid=127
Detailed description:
Modified the 3ds export script 3ds_export.py:
- It now exports face UV correctly. 3ds only supports one UV coordinate per vertex. The script now duplicates vertices that had multiple UV pairs assigned to them so that each duplicate now only contains one and only one UV. Faces have their vertex indices adjusted accordingly.
- Quads are now split into triangles better. 3ds only supports triangles, so quads need to be split into two triangles. Instead of rather arbitrarily splitting along the diagonal between points 0 and 2, the script now splits along the shortest diagonal. This creates a higher quality triangular mesh, as well as better preservation of symmetry.
- Now creates an object node block, exporting object nodes, needed by some 3D importers. Among others, allows one to export object hierarchy.
- Now exports Empties as 3ds Dummies.
To be able to add all of the above new features, the script has been mostly rewritten and strongly restructured.
Motivation for the rewrite was the desire to be able to use Blender to produce custom 3d cars for Trackmania:Sunrise (TM:S). Previously, the TM:S importer could not correctly handle the 3ds files from the Blender 3ds export script. With this version, one can export cars complete with UV textures, correct wheel placement and light placement. To my knowledge, this script would make Blender the first fully free 3d modeller that allows one to export 3ds models for TM:S (expect a tutorial soon). The ability to have proper UV coordinates exported into the 3ds file should also be very welcome to many.
Add A Comment: Notepad
2006-05-02 11:26:32 +00:00
|
|
|
object_info.add_subchunk(object_chunk)
|
2005-12-15 01:42:45 +00:00
|
|
|
|
2006-07-05 07:10:03 +00:00
|
|
|
''' # COMMENTED OUT FOR 2.42 RELEASE!! CRASHES 3DS MAX
|
Commited 3ds export enhancements from Mark Stijnman (beowulff)
Will need to do some updates, Mesh over NMesh and optimize some areas but it works and is a big improvement.
from
https://projects.blender.org/tracker/index.php?func=detail&aid=4156&group_id=9&atid=127
Detailed description:
Modified the 3ds export script 3ds_export.py:
- It now exports face UV correctly. 3ds only supports one UV coordinate per vertex. The script now duplicates vertices that had multiple UV pairs assigned to them so that each duplicate now only contains one and only one UV. Faces have their vertex indices adjusted accordingly.
- Quads are now split into triangles better. 3ds only supports triangles, so quads need to be split into two triangles. Instead of rather arbitrarily splitting along the diagonal between points 0 and 2, the script now splits along the shortest diagonal. This creates a higher quality triangular mesh, as well as better preservation of symmetry.
- Now creates an object node block, exporting object nodes, needed by some 3D importers. Among others, allows one to export object hierarchy.
- Now exports Empties as 3ds Dummies.
To be able to add all of the above new features, the script has been mostly rewritten and strongly restructured.
Motivation for the rewrite was the desire to be able to use Blender to produce custom 3d cars for Trackmania:Sunrise (TM:S). Previously, the TM:S importer could not correctly handle the 3ds files from the Blender 3ds export script. With this version, one can export cars complete with UV textures, correct wheel placement and light placement. To my knowledge, this script would make Blender the first fully free 3d modeller that allows one to export 3ds models for TM:S (expect a tutorial soon). The ability to have proper UV coordinates exported into the 3ds file should also be very welcome to many.
Add A Comment: Notepad
2006-05-02 11:26:32 +00:00
|
|
|
# make a kf object node for the object:
|
2006-05-14 03:11:55 +00:00
|
|
|
kfdata.add_subchunk(make_kf_obj_node(ob, name_to_id))
|
2006-07-05 07:10:03 +00:00
|
|
|
'''
|
2009-09-29 15:27:00 +00:00
|
|
|
# if not blender_mesh.users:
|
|
|
|
bpy.data.remove_mesh(blender_mesh)
|
|
|
|
# blender_mesh.verts = None
|
|
|
|
|
2007-01-07 15:33:28 +00:00
|
|
|
i+=i
|
2005-12-15 01:42:45 +00:00
|
|
|
|
Commited 3ds export enhancements from Mark Stijnman (beowulff)
Will need to do some updates, Mesh over NMesh and optimize some areas but it works and is a big improvement.
from
https://projects.blender.org/tracker/index.php?func=detail&aid=4156&group_id=9&atid=127
Detailed description:
Modified the 3ds export script 3ds_export.py:
- It now exports face UV correctly. 3ds only supports one UV coordinate per vertex. The script now duplicates vertices that had multiple UV pairs assigned to them so that each duplicate now only contains one and only one UV. Faces have their vertex indices adjusted accordingly.
- Quads are now split into triangles better. 3ds only supports triangles, so quads need to be split into two triangles. Instead of rather arbitrarily splitting along the diagonal between points 0 and 2, the script now splits along the shortest diagonal. This creates a higher quality triangular mesh, as well as better preservation of symmetry.
- Now creates an object node block, exporting object nodes, needed by some 3D importers. Among others, allows one to export object hierarchy.
- Now exports Empties as 3ds Dummies.
To be able to add all of the above new features, the script has been mostly rewritten and strongly restructured.
Motivation for the rewrite was the desire to be able to use Blender to produce custom 3d cars for Trackmania:Sunrise (TM:S). Previously, the TM:S importer could not correctly handle the 3ds files from the Blender 3ds export script. With this version, one can export cars complete with UV textures, correct wheel placement and light placement. To my knowledge, this script would make Blender the first fully free 3d modeller that allows one to export 3ds models for TM:S (expect a tutorial soon). The ability to have proper UV coordinates exported into the 3ds file should also be very welcome to many.
Add A Comment: Notepad
2006-05-02 11:26:32 +00:00
|
|
|
# Create chunks for all empties:
|
2006-07-05 07:10:03 +00:00
|
|
|
''' # COMMENTED OUT FOR 2.42 RELEASE!! CRASHES 3DS MAX
|
2006-05-14 03:11:55 +00:00
|
|
|
for ob in empty_objects:
|
Commited 3ds export enhancements from Mark Stijnman (beowulff)
Will need to do some updates, Mesh over NMesh and optimize some areas but it works and is a big improvement.
from
https://projects.blender.org/tracker/index.php?func=detail&aid=4156&group_id=9&atid=127
Detailed description:
Modified the 3ds export script 3ds_export.py:
- It now exports face UV correctly. 3ds only supports one UV coordinate per vertex. The script now duplicates vertices that had multiple UV pairs assigned to them so that each duplicate now only contains one and only one UV. Faces have their vertex indices adjusted accordingly.
- Quads are now split into triangles better. 3ds only supports triangles, so quads need to be split into two triangles. Instead of rather arbitrarily splitting along the diagonal between points 0 and 2, the script now splits along the shortest diagonal. This creates a higher quality triangular mesh, as well as better preservation of symmetry.
- Now creates an object node block, exporting object nodes, needed by some 3D importers. Among others, allows one to export object hierarchy.
- Now exports Empties as 3ds Dummies.
To be able to add all of the above new features, the script has been mostly rewritten and strongly restructured.
Motivation for the rewrite was the desire to be able to use Blender to produce custom 3d cars for Trackmania:Sunrise (TM:S). Previously, the TM:S importer could not correctly handle the 3ds files from the Blender 3ds export script. With this version, one can export cars complete with UV textures, correct wheel placement and light placement. To my knowledge, this script would make Blender the first fully free 3d modeller that allows one to export 3ds models for TM:S (expect a tutorial soon). The ability to have proper UV coordinates exported into the 3ds file should also be very welcome to many.
Add A Comment: Notepad
2006-05-02 11:26:32 +00:00
|
|
|
# Empties only require a kf object node:
|
2006-05-14 03:11:55 +00:00
|
|
|
kfdata.add_subchunk(make_kf_obj_node(ob, name_to_id))
|
2006-07-05 07:10:03 +00:00
|
|
|
pass
|
|
|
|
'''
|
Commited 3ds export enhancements from Mark Stijnman (beowulff)
Will need to do some updates, Mesh over NMesh and optimize some areas but it works and is a big improvement.
from
https://projects.blender.org/tracker/index.php?func=detail&aid=4156&group_id=9&atid=127
Detailed description:
Modified the 3ds export script 3ds_export.py:
- It now exports face UV correctly. 3ds only supports one UV coordinate per vertex. The script now duplicates vertices that had multiple UV pairs assigned to them so that each duplicate now only contains one and only one UV. Faces have their vertex indices adjusted accordingly.
- Quads are now split into triangles better. 3ds only supports triangles, so quads need to be split into two triangles. Instead of rather arbitrarily splitting along the diagonal between points 0 and 2, the script now splits along the shortest diagonal. This creates a higher quality triangular mesh, as well as better preservation of symmetry.
- Now creates an object node block, exporting object nodes, needed by some 3D importers. Among others, allows one to export object hierarchy.
- Now exports Empties as 3ds Dummies.
To be able to add all of the above new features, the script has been mostly rewritten and strongly restructured.
Motivation for the rewrite was the desire to be able to use Blender to produce custom 3d cars for Trackmania:Sunrise (TM:S). Previously, the TM:S importer could not correctly handle the 3ds files from the Blender 3ds export script. With this version, one can export cars complete with UV textures, correct wheel placement and light placement. To my knowledge, this script would make Blender the first fully free 3d modeller that allows one to export 3ds models for TM:S (expect a tutorial soon). The ability to have proper UV coordinates exported into the 3ds file should also be very welcome to many.
Add A Comment: Notepad
2006-05-02 11:26:32 +00:00
|
|
|
|
|
|
|
# Add main object info chunk to primary chunk:
|
|
|
|
primary.add_subchunk(object_info)
|
2006-07-05 07:10:03 +00:00
|
|
|
|
|
|
|
''' # COMMENTED OUT FOR 2.42 RELEASE!! CRASHES 3DS MAX
|
Commited 3ds export enhancements from Mark Stijnman (beowulff)
Will need to do some updates, Mesh over NMesh and optimize some areas but it works and is a big improvement.
from
https://projects.blender.org/tracker/index.php?func=detail&aid=4156&group_id=9&atid=127
Detailed description:
Modified the 3ds export script 3ds_export.py:
- It now exports face UV correctly. 3ds only supports one UV coordinate per vertex. The script now duplicates vertices that had multiple UV pairs assigned to them so that each duplicate now only contains one and only one UV. Faces have their vertex indices adjusted accordingly.
- Quads are now split into triangles better. 3ds only supports triangles, so quads need to be split into two triangles. Instead of rather arbitrarily splitting along the diagonal between points 0 and 2, the script now splits along the shortest diagonal. This creates a higher quality triangular mesh, as well as better preservation of symmetry.
- Now creates an object node block, exporting object nodes, needed by some 3D importers. Among others, allows one to export object hierarchy.
- Now exports Empties as 3ds Dummies.
To be able to add all of the above new features, the script has been mostly rewritten and strongly restructured.
Motivation for the rewrite was the desire to be able to use Blender to produce custom 3d cars for Trackmania:Sunrise (TM:S). Previously, the TM:S importer could not correctly handle the 3ds files from the Blender 3ds export script. With this version, one can export cars complete with UV textures, correct wheel placement and light placement. To my knowledge, this script would make Blender the first fully free 3d modeller that allows one to export 3ds models for TM:S (expect a tutorial soon). The ability to have proper UV coordinates exported into the 3ds file should also be very welcome to many.
Add A Comment: Notepad
2006-05-02 11:26:32 +00:00
|
|
|
# Add main keyframe data chunk to primary chunk:
|
|
|
|
primary.add_subchunk(kfdata)
|
2006-07-05 07:10:03 +00:00
|
|
|
'''
|
Commited 3ds export enhancements from Mark Stijnman (beowulff)
Will need to do some updates, Mesh over NMesh and optimize some areas but it works and is a big improvement.
from
https://projects.blender.org/tracker/index.php?func=detail&aid=4156&group_id=9&atid=127
Detailed description:
Modified the 3ds export script 3ds_export.py:
- It now exports face UV correctly. 3ds only supports one UV coordinate per vertex. The script now duplicates vertices that had multiple UV pairs assigned to them so that each duplicate now only contains one and only one UV. Faces have their vertex indices adjusted accordingly.
- Quads are now split into triangles better. 3ds only supports triangles, so quads need to be split into two triangles. Instead of rather arbitrarily splitting along the diagonal between points 0 and 2, the script now splits along the shortest diagonal. This creates a higher quality triangular mesh, as well as better preservation of symmetry.
- Now creates an object node block, exporting object nodes, needed by some 3D importers. Among others, allows one to export object hierarchy.
- Now exports Empties as 3ds Dummies.
To be able to add all of the above new features, the script has been mostly rewritten and strongly restructured.
Motivation for the rewrite was the desire to be able to use Blender to produce custom 3d cars for Trackmania:Sunrise (TM:S). Previously, the TM:S importer could not correctly handle the 3ds files from the Blender 3ds export script. With this version, one can export cars complete with UV textures, correct wheel placement and light placement. To my knowledge, this script would make Blender the first fully free 3d modeller that allows one to export 3ds models for TM:S (expect a tutorial soon). The ability to have proper UV coordinates exported into the 3ds file should also be very welcome to many.
Add A Comment: Notepad
2006-05-02 11:26:32 +00:00
|
|
|
|
|
|
|
# At this point, the chunk hierarchy is completely built.
|
|
|
|
|
|
|
|
# Check the size:
|
2005-12-15 01:42:45 +00:00
|
|
|
primary.get_size()
|
Commited 3ds export enhancements from Mark Stijnman (beowulff)
Will need to do some updates, Mesh over NMesh and optimize some areas but it works and is a big improvement.
from
https://projects.blender.org/tracker/index.php?func=detail&aid=4156&group_id=9&atid=127
Detailed description:
Modified the 3ds export script 3ds_export.py:
- It now exports face UV correctly. 3ds only supports one UV coordinate per vertex. The script now duplicates vertices that had multiple UV pairs assigned to them so that each duplicate now only contains one and only one UV. Faces have their vertex indices adjusted accordingly.
- Quads are now split into triangles better. 3ds only supports triangles, so quads need to be split into two triangles. Instead of rather arbitrarily splitting along the diagonal between points 0 and 2, the script now splits along the shortest diagonal. This creates a higher quality triangular mesh, as well as better preservation of symmetry.
- Now creates an object node block, exporting object nodes, needed by some 3D importers. Among others, allows one to export object hierarchy.
- Now exports Empties as 3ds Dummies.
To be able to add all of the above new features, the script has been mostly rewritten and strongly restructured.
Motivation for the rewrite was the desire to be able to use Blender to produce custom 3d cars for Trackmania:Sunrise (TM:S). Previously, the TM:S importer could not correctly handle the 3ds files from the Blender 3ds export script. With this version, one can export cars complete with UV textures, correct wheel placement and light placement. To my knowledge, this script would make Blender the first fully free 3d modeller that allows one to export 3ds models for TM:S (expect a tutorial soon). The ability to have proper UV coordinates exported into the 3ds file should also be very welcome to many.
Add A Comment: Notepad
2006-05-02 11:26:32 +00:00
|
|
|
# Open the file for writing:
|
2007-05-06 02:19:43 +00:00
|
|
|
file = open( filename, 'wb' )
|
Commited 3ds export enhancements from Mark Stijnman (beowulff)
Will need to do some updates, Mesh over NMesh and optimize some areas but it works and is a big improvement.
from
https://projects.blender.org/tracker/index.php?func=detail&aid=4156&group_id=9&atid=127
Detailed description:
Modified the 3ds export script 3ds_export.py:
- It now exports face UV correctly. 3ds only supports one UV coordinate per vertex. The script now duplicates vertices that had multiple UV pairs assigned to them so that each duplicate now only contains one and only one UV. Faces have their vertex indices adjusted accordingly.
- Quads are now split into triangles better. 3ds only supports triangles, so quads need to be split into two triangles. Instead of rather arbitrarily splitting along the diagonal between points 0 and 2, the script now splits along the shortest diagonal. This creates a higher quality triangular mesh, as well as better preservation of symmetry.
- Now creates an object node block, exporting object nodes, needed by some 3D importers. Among others, allows one to export object hierarchy.
- Now exports Empties as 3ds Dummies.
To be able to add all of the above new features, the script has been mostly rewritten and strongly restructured.
Motivation for the rewrite was the desire to be able to use Blender to produce custom 3d cars for Trackmania:Sunrise (TM:S). Previously, the TM:S importer could not correctly handle the 3ds files from the Blender 3ds export script. With this version, one can export cars complete with UV textures, correct wheel placement and light placement. To my knowledge, this script would make Blender the first fully free 3d modeller that allows one to export 3ds models for TM:S (expect a tutorial soon). The ability to have proper UV coordinates exported into the 3ds file should also be very welcome to many.
Add A Comment: Notepad
2006-05-02 11:26:32 +00:00
|
|
|
|
|
|
|
# Recursively write the chunks to file:
|
2005-12-15 01:42:45 +00:00
|
|
|
primary.write(file)
|
Commited 3ds export enhancements from Mark Stijnman (beowulff)
Will need to do some updates, Mesh over NMesh and optimize some areas but it works and is a big improvement.
from
https://projects.blender.org/tracker/index.php?func=detail&aid=4156&group_id=9&atid=127
Detailed description:
Modified the 3ds export script 3ds_export.py:
- It now exports face UV correctly. 3ds only supports one UV coordinate per vertex. The script now duplicates vertices that had multiple UV pairs assigned to them so that each duplicate now only contains one and only one UV. Faces have their vertex indices adjusted accordingly.
- Quads are now split into triangles better. 3ds only supports triangles, so quads need to be split into two triangles. Instead of rather arbitrarily splitting along the diagonal between points 0 and 2, the script now splits along the shortest diagonal. This creates a higher quality triangular mesh, as well as better preservation of symmetry.
- Now creates an object node block, exporting object nodes, needed by some 3D importers. Among others, allows one to export object hierarchy.
- Now exports Empties as 3ds Dummies.
To be able to add all of the above new features, the script has been mostly rewritten and strongly restructured.
Motivation for the rewrite was the desire to be able to use Blender to produce custom 3d cars for Trackmania:Sunrise (TM:S). Previously, the TM:S importer could not correctly handle the 3ds files from the Blender 3ds export script. With this version, one can export cars complete with UV textures, correct wheel placement and light placement. To my knowledge, this script would make Blender the first fully free 3d modeller that allows one to export 3ds models for TM:S (expect a tutorial soon). The ability to have proper UV coordinates exported into the 3ds file should also be very welcome to many.
Add A Comment: Notepad
2006-05-02 11:26:32 +00:00
|
|
|
|
|
|
|
# Close the file:
|
2005-12-15 01:42:45 +00:00
|
|
|
file.close()
|
Commited 3ds export enhancements from Mark Stijnman (beowulff)
Will need to do some updates, Mesh over NMesh and optimize some areas but it works and is a big improvement.
from
https://projects.blender.org/tracker/index.php?func=detail&aid=4156&group_id=9&atid=127
Detailed description:
Modified the 3ds export script 3ds_export.py:
- It now exports face UV correctly. 3ds only supports one UV coordinate per vertex. The script now duplicates vertices that had multiple UV pairs assigned to them so that each duplicate now only contains one and only one UV. Faces have their vertex indices adjusted accordingly.
- Quads are now split into triangles better. 3ds only supports triangles, so quads need to be split into two triangles. Instead of rather arbitrarily splitting along the diagonal between points 0 and 2, the script now splits along the shortest diagonal. This creates a higher quality triangular mesh, as well as better preservation of symmetry.
- Now creates an object node block, exporting object nodes, needed by some 3D importers. Among others, allows one to export object hierarchy.
- Now exports Empties as 3ds Dummies.
To be able to add all of the above new features, the script has been mostly rewritten and strongly restructured.
Motivation for the rewrite was the desire to be able to use Blender to produce custom 3d cars for Trackmania:Sunrise (TM:S). Previously, the TM:S importer could not correctly handle the 3ds files from the Blender 3ds export script. With this version, one can export cars complete with UV textures, correct wheel placement and light placement. To my knowledge, this script would make Blender the first fully free 3d modeller that allows one to export 3ds models for TM:S (expect a tutorial soon). The ability to have proper UV coordinates exported into the 3ds file should also be very welcome to many.
Add A Comment: Notepad
2006-05-02 11:26:32 +00:00
|
|
|
|
|
|
|
# Debugging only: report the exporting time:
|
2009-09-29 15:27:00 +00:00
|
|
|
# Blender.Window.WaitCursor(0)
|
|
|
|
print("3ds export time: %.2f" % (time.clock() - time1))
|
|
|
|
# print("3ds export time: %.2f" % (Blender.sys.time() - time1))
|
2005-12-15 01:42:45 +00:00
|
|
|
|
Commited 3ds export enhancements from Mark Stijnman (beowulff)
Will need to do some updates, Mesh over NMesh and optimize some areas but it works and is a big improvement.
from
https://projects.blender.org/tracker/index.php?func=detail&aid=4156&group_id=9&atid=127
Detailed description:
Modified the 3ds export script 3ds_export.py:
- It now exports face UV correctly. 3ds only supports one UV coordinate per vertex. The script now duplicates vertices that had multiple UV pairs assigned to them so that each duplicate now only contains one and only one UV. Faces have their vertex indices adjusted accordingly.
- Quads are now split into triangles better. 3ds only supports triangles, so quads need to be split into two triangles. Instead of rather arbitrarily splitting along the diagonal between points 0 and 2, the script now splits along the shortest diagonal. This creates a higher quality triangular mesh, as well as better preservation of symmetry.
- Now creates an object node block, exporting object nodes, needed by some 3D importers. Among others, allows one to export object hierarchy.
- Now exports Empties as 3ds Dummies.
To be able to add all of the above new features, the script has been mostly rewritten and strongly restructured.
Motivation for the rewrite was the desire to be able to use Blender to produce custom 3d cars for Trackmania:Sunrise (TM:S). Previously, the TM:S importer could not correctly handle the 3ds files from the Blender 3ds export script. With this version, one can export cars complete with UV textures, correct wheel placement and light placement. To my knowledge, this script would make Blender the first fully free 3d modeller that allows one to export 3ds models for TM:S (expect a tutorial soon). The ability to have proper UV coordinates exported into the 3ds file should also be very welcome to many.
Add A Comment: Notepad
2006-05-02 11:26:32 +00:00
|
|
|
# Debugging only: dump the chunk hierarchy:
|
|
|
|
#primary.dump()
|
2007-05-06 02:19:43 +00:00
|
|
|
|
|
|
|
|
2009-09-29 15:27:00 +00:00
|
|
|
# if __name__=='__main__':
|
|
|
|
# if struct:
|
|
|
|
# Blender.Window.FileSelector(save_3ds, "Export 3DS", Blender.sys.makename(ext='.3ds'))
|
|
|
|
# else:
|
|
|
|
# Blender.Draw.PupMenu("Error%t|This script requires a full python installation")
|
|
|
|
# # save_3ds('/test_b.3ds')
|
define operator properties in the class, similar to django fields
# Before
[
bpy.props.StringProperty(attr="path", name="File Path", description="File path used for exporting the PLY file", maxlen= 1024, default= ""),
bpy.props.BoolProperty(attr="use_modifiers", name="Apply Modifiers", description="Apply Modifiers to the exported mesh", default= True),
bpy.props.BoolProperty(attr="use_normals", name="Export Normals", description="Export Normals for smooth and hard shaded faces", default= True),
bpy.props.BoolProperty(attr="use_uvs", name="Export UVs", description="Exort the active UV layer", default= True),
bpy.props.BoolProperty(attr="use_colors", name="Export Vertex Colors", description="Exort the active vertex color layer", default= True)
]
# After
path = StringProperty(attr="", name="File Path", description="File path used for exporting the PLY file", maxlen= 1024, default= "")
use_modifiers = BoolProperty(attr="", name="Apply Modifiers", description="Apply Modifiers to the exported mesh", default= True)
use_normals = BoolProperty(attr="", name="Export Normals", description="Export Normals for smooth and hard shaded faces", default= True)
use_uvs = BoolProperty(attr="", name="Export UVs", description="Exort the active UV layer", default= True)
use_colors = BoolProperty(attr="", name="Export Vertex Colors", description="Exort the active vertex color layer", default= True)
2009-10-31 16:40:14 +00:00
|
|
|
from bpy.props import *
|
2009-11-04 18:35:32 +00:00
|
|
|
class Export3DS(bpy.types.Operator):
|
- add torus back from 2.4x as an operator
bpy.ops.mesh.primitive_torus_add(major_radius=1, minor_radius=0.25, major_segments=48, minor_segments=16)
- experemental dynamic menus, used for INFO_MT_file, INFO_MT_file_import, INFO_MT_file_export and INFO_MT_mesh_add. these can have items added from python.
eg.
- removed OBJECT_OT_mesh_add, use the python add menu instead.
- made mesh primitive ops - MESH_OT_primitive_plane_add, ...cube_add, etc. work in object mode.
- RNA scene.active_object wrapped
- bugfix [#19466] 2.5: Tweak menu only available for mesh objects added within Edit Mode
ED_object_exit_editmode was always doing an undo push, made this optional using the existing flag - EM_DO_UNDO, called everywhere except when adding primitives.
2009-10-10 21:23:20 +00:00
|
|
|
'''Export to 3DS file format (.3ds).'''
|
2009-10-31 13:31:23 +00:00
|
|
|
bl_idname = "export.autodesk_3ds"
|
|
|
|
bl_label = 'Export 3DS'
|
2009-09-29 15:27:00 +00:00
|
|
|
|
|
|
|
# List of operator properties, the attributes will be assigned
|
|
|
|
# to the class instance from the operator settings before calling.
|
|
|
|
|
define operator properties in the class, similar to django fields
# Before
[
bpy.props.StringProperty(attr="path", name="File Path", description="File path used for exporting the PLY file", maxlen= 1024, default= ""),
bpy.props.BoolProperty(attr="use_modifiers", name="Apply Modifiers", description="Apply Modifiers to the exported mesh", default= True),
bpy.props.BoolProperty(attr="use_normals", name="Export Normals", description="Export Normals for smooth and hard shaded faces", default= True),
bpy.props.BoolProperty(attr="use_uvs", name="Export UVs", description="Exort the active UV layer", default= True),
bpy.props.BoolProperty(attr="use_colors", name="Export Vertex Colors", description="Exort the active vertex color layer", default= True)
]
# After
path = StringProperty(attr="", name="File Path", description="File path used for exporting the PLY file", maxlen= 1024, default= "")
use_modifiers = BoolProperty(attr="", name="Apply Modifiers", description="Apply Modifiers to the exported mesh", default= True)
use_normals = BoolProperty(attr="", name="Export Normals", description="Export Normals for smooth and hard shaded faces", default= True)
use_uvs = BoolProperty(attr="", name="Export UVs", description="Exort the active UV layer", default= True)
use_colors = BoolProperty(attr="", name="Export Vertex Colors", description="Exort the active vertex color layer", default= True)
2009-10-31 16:40:14 +00:00
|
|
|
|
|
|
|
# filename = StringProperty(name="File Name", description="File name used for exporting the 3DS file", maxlen= 1024, default= ""),
|
|
|
|
path = StringProperty(name="File Path", description="File path used for exporting the 3DS file", maxlen= 1024, default= "")
|
|
|
|
|
2009-09-29 15:27:00 +00:00
|
|
|
|
|
|
|
def execute(self, context):
|
2009-11-19 17:12:08 +00:00
|
|
|
save_3ds(self.properties.path, context)
|
2009-09-29 15:27:00 +00:00
|
|
|
return ('FINISHED',)
|
|
|
|
|
|
|
|
def invoke(self, context, event):
|
|
|
|
wm = context.manager
|
2009-11-02 08:32:00 +00:00
|
|
|
wm.add_fileselect(self)
|
2009-09-29 15:27:00 +00:00
|
|
|
return ('RUNNING_MODAL',)
|
|
|
|
|
|
|
|
def poll(self, context): # Poll isnt working yet
|
|
|
|
return context.active_object != None
|
|
|
|
|
2009-11-04 18:35:32 +00:00
|
|
|
bpy.ops.add(Export3DS)
|
- add torus back from 2.4x as an operator
bpy.ops.mesh.primitive_torus_add(major_radius=1, minor_radius=0.25, major_segments=48, minor_segments=16)
- experemental dynamic menus, used for INFO_MT_file, INFO_MT_file_import, INFO_MT_file_export and INFO_MT_mesh_add. these can have items added from python.
eg.
- removed OBJECT_OT_mesh_add, use the python add menu instead.
- made mesh primitive ops - MESH_OT_primitive_plane_add, ...cube_add, etc. work in object mode.
- RNA scene.active_object wrapped
- bugfix [#19466] 2.5: Tweak menu only available for mesh objects added within Edit Mode
ED_object_exit_editmode was always doing an undo push, made this optional using the existing flag - EM_DO_UNDO, called everywhere except when adding primitives.
2009-10-10 21:23:20 +00:00
|
|
|
|
|
|
|
# Add to a menu
|
|
|
|
import dynamic_menu
|
2009-11-04 18:35:32 +00:00
|
|
|
|
|
|
|
def menu_func(self, context):
|
|
|
|
default_path = bpy.data.filename.replace(".blend", ".3ds")
|
2009-11-23 11:43:38 +00:00
|
|
|
self.layout.operator(Export3DS.bl_idname, text="Autodesk 3DS...").path = default_path
|
2009-11-04 18:35:32 +00:00
|
|
|
|
- add torus back from 2.4x as an operator
bpy.ops.mesh.primitive_torus_add(major_radius=1, minor_radius=0.25, major_segments=48, minor_segments=16)
- experemental dynamic menus, used for INFO_MT_file, INFO_MT_file_import, INFO_MT_file_export and INFO_MT_mesh_add. these can have items added from python.
eg.
- removed OBJECT_OT_mesh_add, use the python add menu instead.
- made mesh primitive ops - MESH_OT_primitive_plane_add, ...cube_add, etc. work in object mode.
- RNA scene.active_object wrapped
- bugfix [#19466] 2.5: Tweak menu only available for mesh objects added within Edit Mode
ED_object_exit_editmode was always doing an undo push, made this optional using the existing flag - EM_DO_UNDO, called everywhere except when adding primitives.
2009-10-10 21:23:20 +00:00
|
|
|
menu_item = dynamic_menu.add(bpy.types.INFO_MT_file_export, menu_func)
|