Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
blender-addons
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
blender
blender-addons
Commits
9fdd6366
Commit
9fdd6366
authored
13 years ago
by
Chris Foster
Browse files
Options
Downloads
Patches
Plain Diff
- Updated Blender version and revision number to 2.58 r37702.
parent
a54291cd
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
io_export_directx_x.py
+26
-41
26 additions, 41 deletions
io_export_directx_x.py
with
26 additions
and
41 deletions
io_export_directx_x.py
+
26
−
41
View file @
9fdd6366
...
@@ -16,13 +16,13 @@
...
@@ -16,13 +16,13 @@
# ***** GPL LICENSE BLOCK *****
# ***** GPL LICENSE BLOCK *****
bl_info
=
{
bl_info
=
{
"
name
"
:
"
DirectX Model Format (.x)
"
,
"
name
"
:
"
Export
DirectX Model Format (.x)
"
,
"
author
"
:
"
Chris Foster (Kira Vakaan)
"
,
"
author
"
:
"
Chris Foster (Kira Vakaan)
"
,
"
version
"
:
(
2
,
1
,
1
),
"
version
"
:
(
2
,
1
),
"
blender
"
:
(
2
,
5
,
7
),
"
blender
"
:
(
2
,
5
,
8
),
"
api
"
:
3
6339
,
"
api
"
:
3
7702
,
"
location
"
:
"
File > Export
> DirectX (.x)
"
,
"
location
"
:
"
File > Export
"
,
"
description
"
:
"
Export DirectX Model Format (.x)
"
,
"
description
"
:
"
Export
to the
DirectX Model Format (.x)
"
,
"
warning
"
:
""
,
"
warning
"
:
""
,
"
wiki_url
"
:
"
http://wiki.blender.org/index.php/Extensions:2.5/Py/
"
\
"
wiki_url
"
:
"
http://wiki.blender.org/index.php/Extensions:2.5/Py/
"
\
"
Scripts/Import-Export/DirectX_Exporter
"
,
"
Scripts/Import-Export/DirectX_Exporter
"
,
...
@@ -66,15 +66,8 @@ class DirectXExporterSettings:
...
@@ -66,15 +66,8 @@ class DirectXExporterSettings:
def
LegalName
(
Name
):
def
LegalName
(
Name
):
NewName
=
Name
.
replace
(
"
.
"
,
"
_
"
)
def
ReplaceSet
(
String
,
OldSet
,
NewChar
):
NewName
=
NewName
.
replace
(
"
"
,
"
_
"
)
for
OldChar
in
OldSet
:
String
=
String
.
replace
(
OldChar
,
NewChar
)
return
String
import
string
NewName
=
ReplaceSet
(
Name
,
string
.
punctuation
,
"
_
"
)
if
NewName
[
0
].
isdigit
()
or
NewName
in
[
"
ARRAY
"
,
if
NewName
[
0
].
isdigit
()
or
NewName
in
[
"
ARRAY
"
,
"
DWORD
"
,
"
DWORD
"
,
"
UCHAR
"
,
"
UCHAR
"
,
...
@@ -104,7 +97,7 @@ def ExportDirectX(Config):
...
@@ -104,7 +97,7 @@ def ExportDirectX(Config):
print
(
"
Done
"
)
print
(
"
Done
"
)
if
Config
.
Verbose
:
if
Config
.
Verbose
:
print
(
"
Generating Object list for export...
(Root parents only)
"
)
print
(
"
Generating Object list for export...
"
)
if
Config
.
ExportMode
==
1
:
if
Config
.
ExportMode
==
1
:
Config
.
ExportList
=
[
Object
for
Object
in
Config
.
context
.
scene
.
objects
Config
.
ExportList
=
[
Object
for
Object
in
Config
.
context
.
scene
.
objects
if
Object
.
type
in
(
"
ARMATURE
"
,
"
EMPTY
"
,
"
MESH
"
)
if
Object
.
type
in
(
"
ARMATURE
"
,
"
EMPTY
"
,
"
MESH
"
)
...
@@ -115,7 +108,7 @@ def ExportDirectX(Config):
...
@@ -115,7 +108,7 @@ def ExportDirectX(Config):
Config
.
ExportList
=
[
Object
for
Object
in
ExportList
Config
.
ExportList
=
[
Object
for
Object
in
ExportList
if
Object
.
parent
not
in
ExportList
]
if
Object
.
parent
not
in
ExportList
]
if
Config
.
Verbose
:
if
Config
.
Verbose
:
print
(
"
List: {}
\n
Done
"
.
format
(
Config
.
ExportList
)
)
print
(
"
Done
"
)
if
Config
.
Verbose
:
if
Config
.
Verbose
:
print
(
"
Setting up...
"
)
print
(
"
Setting up...
"
)
...
@@ -153,9 +146,6 @@ def ExportDirectX(Config):
...
@@ -153,9 +146,6 @@ def ExportDirectX(Config):
Config
.
Whitespace
-=
1
Config
.
Whitespace
-=
1
Config
.
File
.
write
(
"
{}}} //End of Root Frame
\n
"
.
format
(
"
"
*
Config
.
Whitespace
))
Config
.
File
.
write
(
"
{}}} //End of Root Frame
\n
"
.
format
(
"
"
*
Config
.
Whitespace
))
if
Config
.
Verbose
:
print
(
"
Objects Exported: {}
"
.
format
(
Config
.
ExportList
))
if
Config
.
ExportAnimation
:
if
Config
.
ExportAnimation
:
if
Config
.
IncludeFrameRate
:
if
Config
.
IncludeFrameRate
:
...
@@ -266,11 +256,8 @@ def WriteObjects(Config, ObjectList):
...
@@ -266,11 +256,8 @@ def WriteObjects(Config, ObjectList):
WriteArmatureBones
(
Config
,
Object
,
ParentList
)
WriteArmatureBones
(
Config
,
Object
,
ParentList
)
if
Config
.
Verbose
:
if
Config
.
Verbose
:
print
(
"
Done
"
)
print
(
"
Done
"
)
ChildList
=
GetObjectChildren
(
Object
)
ChildList
=
GetObjectChildren
(
Object
)
if
Config
.
ExportMode
==
2
:
#Selected Objects Only
ChildList
=
[
Child
for
Child
in
ChildList
if
Child
in
Config
.
context
.
selected_objects
]
if
Config
.
Verbose
:
if
Config
.
Verbose
:
print
(
"
Writing Children...
"
)
print
(
"
Writing Children...
"
)
WriteObjects
(
Config
,
ChildList
)
WriteObjects
(
Config
,
ChildList
)
...
@@ -287,11 +274,11 @@ def WriteObjects(Config, ObjectList):
...
@@ -287,11 +274,11 @@ def WriteObjects(Config, ObjectList):
Object2
=
Object
.
copy
()
Object2
=
Object
.
copy
()
for
Modifier
in
[
Modifier
for
Modifier
in
Object2
.
modifiers
if
Modifier
.
type
==
"
ARMATURE
"
]:
for
Modifier
in
[
Modifier
for
Modifier
in
Object2
.
modifiers
if
Modifier
.
type
==
"
ARMATURE
"
]:
Object2
.
modifiers
.
remove
(
Modifier
)
Object2
.
modifiers
.
remove
(
Modifier
)
Mesh
=
Object2
.
to
_mesh
(
bpy
.
context
.
scene
,
True
,
"
PREVIEW
"
)
Mesh
=
Object2
.
create
_mesh
(
bpy
.
context
.
scene
,
True
,
"
PREVIEW
"
)
else
:
else
:
Mesh
=
Object
.
to
_mesh
(
bpy
.
context
.
scene
,
True
,
"
PREVIEW
"
)
Mesh
=
Object
.
create
_mesh
(
bpy
.
context
.
scene
,
True
,
"
PREVIEW
"
)
else
:
else
:
Mesh
=
Object
.
to
_mesh
(
bpy
.
context
.
scene
,
False
,
"
PREVIEW
"
)
Mesh
=
Object
.
create
_mesh
(
bpy
.
context
.
scene
,
False
,
"
PREVIEW
"
)
if
Config
.
Verbose
:
if
Config
.
Verbose
:
print
(
"
Done
"
)
print
(
"
Done
"
)
print
(
"
Writing Mesh...
"
)
print
(
"
Writing Mesh...
"
)
...
@@ -502,20 +489,20 @@ def WriteMaterial(Config, Material=None):
...
@@ -502,20 +489,20 @@ def WriteMaterial(Config, Material=None):
Config
.
File
.
write
(
"
{}Material {} {{
\n
"
.
format
(
"
"
*
Config
.
Whitespace
,
LegalName
(
Material
.
name
)))
Config
.
File
.
write
(
"
{}Material {} {{
\n
"
.
format
(
"
"
*
Config
.
Whitespace
,
LegalName
(
Material
.
name
)))
Config
.
Whitespace
+=
1
Config
.
Whitespace
+=
1
Diffuse
=
list
(
Vector
(
Material
.
diffuse_color
)
*
Material
.
diffuse_intensity
)
Diffuse
=
list
(
Material
.
diffuse_color
)
Diffuse
.
append
(
Material
.
alpha
)
Diffuse
.
append
(
Material
.
alpha
)
Specularity
=
1000
*
(
Material
.
specular_
hardness
-
1.0
)
/
(
511.0
-
1.0
)
# Map Blender's range of 1 - 511 to 0 - 1000
Specularity
=
Material
.
specular_
intensity
Specular
=
list
(
Vector
(
Material
.
specular_color
)
*
Material
.
specular_intensity
)
Specular
=
list
(
Material
.
specular_color
)
Config
.
File
.
write
(
"
{}{:9f};{:9f};{:9f};{:9f};;
\n
"
.
format
(
"
"
*
Config
.
Whitespace
,
Diffuse
[
0
],
Diffuse
[
1
],
Diffuse
[
2
],
Diffuse
[
3
]))
Config
.
File
.
write
(
"
{}{:9f};{:9f};{:9f};{:9f};;
\n
"
.
format
(
"
"
*
Config
.
Whitespace
,
Diffuse
[
0
],
Diffuse
[
1
],
Diffuse
[
2
],
Diffuse
[
3
]))
Config
.
File
.
write
(
"
{}
{:9f};
\n
"
.
format
(
"
"
*
Config
.
Whitespace
,
Specularity
))
Config
.
File
.
write
(
"
{}{:9f};
\n
"
.
format
(
"
"
*
Config
.
Whitespace
,
2
*
(
1.0
-
Specularity
))
)
Config
.
File
.
write
(
"
{}{:9f};{:9f};{:9f};;
\n
"
.
format
(
"
"
*
Config
.
Whitespace
,
Specular
[
0
],
Specular
[
1
],
Specular
[
2
]))
Config
.
File
.
write
(
"
{}{:9f};{:9f};{:9f};;
\n
"
.
format
(
"
"
*
Config
.
Whitespace
,
Specular
[
0
],
Specular
[
1
],
Specular
[
2
]))
else
:
else
:
Config
.
File
.
write
(
"
{}Material Default_Material {{
\n
"
.
format
(
"
"
*
Config
.
Whitespace
))
Config
.
File
.
write
(
"
{}Material Default_Material {{
\n
"
.
format
(
"
"
*
Config
.
Whitespace
))
Config
.
Whitespace
+=
1
Config
.
Whitespace
+=
1
Config
.
File
.
write
(
"
{}
0.8
00000;
0.8
00000;
0.8
00000;
0.8
00000;;
\n
"
.
format
(
"
"
*
Config
.
Whitespace
))
Config
.
File
.
write
(
"
{}
1.0
00000;
1.0
00000;
1.0
00000;
1.0
00000;;
\n
"
.
format
(
"
"
*
Config
.
Whitespace
))
Config
.
File
.
write
(
"
{}
96.078431
;
\n
"
.
format
(
"
"
*
Config
.
Whitespace
))
# 1000 * (50 - 1) / (511 - 1)
Config
.
File
.
write
(
"
{}
1.500000
;
\n
"
.
format
(
"
"
*
Config
.
Whitespace
))
Config
.
File
.
write
(
"
{}
0.5
00000;
0.5
00000;
0.5
00000;;
\n
"
.
format
(
"
"
*
Config
.
Whitespace
))
Config
.
File
.
write
(
"
{}
1.0
00000;
1.0
00000;
1.0
00000;;
\n
"
.
format
(
"
"
*
Config
.
Whitespace
))
Config
.
File
.
write
(
"
{} 0.000000; 0.000000; 0.000000;;
\n
"
.
format
(
"
"
*
Config
.
Whitespace
))
Config
.
File
.
write
(
"
{} 0.000000; 0.000000; 0.000000;;
\n
"
.
format
(
"
"
*
Config
.
Whitespace
))
if
Config
.
ExportTextures
:
if
Config
.
ExportTextures
:
Texture
=
GetMaterialTexture
(
Material
)
Texture
=
GetMaterialTexture
(
Material
)
...
@@ -1206,8 +1193,10 @@ class DirectXExporter(bpy.types.Operator):
...
@@ -1206,8 +1193,10 @@ class DirectXExporter(bpy.types.Operator):
Verbose
=
BoolProperty
(
name
=
"
Verbose
"
,
description
=
"
Run the exporter in debug mode. Check the console for output.
"
,
default
=
False
)
Verbose
=
BoolProperty
(
name
=
"
Verbose
"
,
description
=
"
Run the exporter in debug mode. Check the console for output.
"
,
default
=
False
)
def
execute
(
self
,
context
):
def
execute
(
self
,
context
):
#Append .x
#Append .x if needed
FilePath
=
os
.
path
.
splitext
(
self
.
filepath
)[
0
]
+
"
.x
"
FilePath
=
self
.
filepath
if
not
FilePath
.
lower
().
endswith
(
"
.x
"
):
FilePath
+=
"
.x
"
Config
=
DirectXExporterSettings
(
context
,
Config
=
DirectXExporterSettings
(
context
,
FilePath
,
FilePath
,
...
@@ -1236,16 +1225,12 @@ def menu_func(self, context):
...
@@ -1236,16 +1225,12 @@ def menu_func(self, context):
def
register
():
def
register
():
bpy
.
utils
.
register_module
(
__name__
)
bpy
.
types
.
INFO_MT_file_export
.
append
(
menu_func
)
bpy
.
types
.
INFO_MT_file_export
.
append
(
menu_func
)
def
unregister
():
def
unregister
():
bpy
.
utils
.
unregister_module
(
__name__
)
bpy
.
types
.
INFO_MT_file_export
.
remove
(
menu_func
)
bpy
.
types
.
INFO_MT_file_export
.
remove
(
menu_func
)
if
__name__
==
"
__main__
"
:
if
__name__
==
"
__main__
"
:
register
()
register
()
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment