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
ddf01b98
Commit
ddf01b98
authored
14 years ago
by
John Phan
Browse files
Options
Downloads
Patches
Plain Diff
menu error panel fixed and other few minors.
parent
c7230ef0
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
export_unreal_psk_psa.py
+36
-21
36 additions, 21 deletions
export_unreal_psk_psa.py
with
36 additions
and
21 deletions
export_unreal_psk_psa.py
+
36
−
21
View file @
ddf01b98
...
@@ -14,11 +14,10 @@
...
@@ -14,11 +14,10 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# All rights reserved.
# All rights reserved.
# ***** GPL LICENSE BLOCK *****
# ***** GPL LICENSE BLOCK *****
"""
"""
Name:
'
Unreal Skeletal Mesh/Animation (.psk and .psa) Export
'
Name:
'
Unreal Skeletal Mesh/Animation (.psk and .psa) Export
'
Blender: 250
Blender: 250
Group:
'
Import/
Export
'
Group:
'
Export
'
Tooltip:
'
Unreal Skeletal Mesh and Animation Export (*.psk, *.psa)
'
Tooltip:
'
Unreal Skeletal Mesh and Animation Export (*.psk, *.psa)
'
"""
"""
...
@@ -90,11 +89,9 @@ bl_addon_info = {
...
@@ -90,11 +89,9 @@ bl_addon_info = {
'
version
'
:
'
2.0
'
,
'
version
'
:
'
2.0
'
,
'
blender
'
:
(
2
,
5
,
3
),
'
blender
'
:
(
2
,
5
,
3
),
'
location
'
:
'
File > Export > Skeletal Mesh/Animation Data (.psk/.psa)
'
,
'
location
'
:
'
File > Export > Skeletal Mesh/Animation Data (.psk/.psa)
'
,
'
wiki_
url
'
:
'
http://wiki.blender.org/index.php/Extensions:2.5/Py/
'
\
'
url
'
:
'
http://wiki.blender.org/index.php/Extensions:2.5/Py/
'
\
'
Scripts/File_I-O/Unreal_psk_psa
'
,
'
Scripts/File_I-O/Unreal_psk_psa
'
,
'
tracker_url
'
:
'
https://projects.blender.org/tracker/index.php?
'
\
'
category
'
:
'
Export
'
}
'
func=detail&aid=21366&group_id=153&atid=469
'
,
'
category
'
:
'
Import/Export
'
}
# REFERENCE MATERIAL JUST IN CASE:
# REFERENCE MATERIAL JUST IN CASE:
#
#
...
@@ -697,6 +694,7 @@ def parse_meshes(blender_meshes, psk_file):
...
@@ -697,6 +694,7 @@ def parse_meshes(blender_meshes, psk_file):
for
current_obj
in
blender_meshes
:
#number of mesh that should be one mesh here
for
current_obj
in
blender_meshes
:
#number of mesh that should be one mesh here
current_obj
=
triangulateNMesh
(
current_obj
)
current_obj
=
triangulateNMesh
(
current_obj
)
#print(dir(current_obj))
print
(
"
Mesh Name:
"
,
current_obj
.
name
)
print
(
"
Mesh Name:
"
,
current_obj
.
name
)
current_mesh
=
current_obj
.
data
current_mesh
=
current_obj
.
data
...
@@ -714,7 +712,7 @@ def parse_meshes(blender_meshes, psk_file):
...
@@ -714,7 +712,7 @@ def parse_meshes(blender_meshes, psk_file):
#print current_face.uv_textures
#print current_face.uv_textures
if
len
(
current_face
.
verts
)
!=
3
:
if
len
(
current_face
.
verts
)
!=
3
:
raise
RuntimeError
(
"
Non-triangular face (%i)
"
%
len
(
current_face
.
v
))
raise
RuntimeError
(
"
Non-triangular face (%i)
"
%
len
(
current_face
.
v
erts
))
#No Triangulate Yet
#No Triangulate Yet
# if len(current_face.verts) != 3:
# if len(current_face.verts) != 3:
...
@@ -744,7 +742,13 @@ def parse_meshes(blender_meshes, psk_file):
...
@@ -744,7 +742,13 @@ def parse_meshes(blender_meshes, psk_file):
if
len
(
current_mesh
.
uv_textures
)
>
0
:
if
len
(
current_mesh
.
uv_textures
)
>
0
:
has_UV
=
True
has_UV
=
True
faceUV
=
current_mesh
.
active_uv_texture
.
data
[
face_index
]
#UVs for current face
#print("face index: ",face_index)
#faceUV = current_mesh.active_uv_texture.data[face_index]#UVs for current face
#faceUV = current_mesh.active_uv_texture.data[0]#UVs for current face
#print(face_index,"<[FACE NUMBER")
uv_layer
=
current_mesh
.
active_uv_texture
faceUV
=
uv_layer
.
data
[
face_index
]
#print("============================")
#size(data) is number of texture faces. Each face has UVs
#size(data) is number of texture faces. Each face has UVs
#print("DATA face uv: ",len(faceUV.uv), " >> ",(faceUV.uv[0][0]))
#print("DATA face uv: ",len(faceUV.uv), " >> ",(faceUV.uv[0][0]))
...
@@ -792,7 +796,7 @@ def parse_meshes(blender_meshes, psk_file):
...
@@ -792,7 +796,7 @@ def parse_meshes(blender_meshes, psk_file):
# Transform position for export
# Transform position for export
#vpos = vert.co * object_material_index
#vpos = vert.co * object_material_index
vpos
=
vert
.
co
*
current_obj
.
matrix_
world
vpos
=
vert
.
co
*
current_obj
.
matrix_
local
# Create the point
# Create the point
p
=
VPoint
()
p
=
VPoint
()
p
.
Point
.
X
=
vpos
.
x
p
.
Point
.
X
=
vpos
.
x
...
@@ -891,7 +895,7 @@ def parse_meshes(blender_meshes, psk_file):
...
@@ -891,7 +895,7 @@ def parse_meshes(blender_meshes, psk_file):
vert_weight
=
vgroup
.
weight
vert_weight
=
vgroup
.
weight
if
(
bonegroup
.
index
==
vgroup
.
group
):
if
(
bonegroup
.
index
==
vgroup
.
group
):
p
=
VPoint
()
p
=
VPoint
()
vpos
=
current_vert
.
co
*
current_obj
.
matrix_
world
vpos
=
current_vert
.
co
*
current_obj
.
matrix_
local
p
.
Point
.
X
=
vpos
.
x
p
.
Point
.
X
=
vpos
.
x
p
.
Point
.
Y
=
vpos
.
y
p
.
Point
.
Y
=
vpos
.
y
p
.
Point
.
Z
=
vpos
.
z
p
.
Point
.
Z
=
vpos
.
z
...
@@ -908,7 +912,7 @@ def parse_meshes(blender_meshes, psk_file):
...
@@ -908,7 +912,7 @@ def parse_meshes(blender_meshes, psk_file):
print
(
"
Remove tmp Mesh [
"
,
current_obj
.
name
,
"
] from scene >
"
,(
bpy
.
context
.
scene
.
unrealtriangulatebool
))
print
(
"
Remove tmp Mesh [
"
,
current_obj
.
name
,
"
] from scene >
"
,(
bpy
.
context
.
scene
.
unrealtriangulatebool
))
bpy
.
ops
.
object
.
mode_set
(
mode
=
'
OBJECT
'
)
# set it in object
bpy
.
ops
.
object
.
mode_set
(
mode
=
'
OBJECT
'
)
# set it in object
bpy
.
context
.
scene
.
objects
.
unlink
(
current_obj
)
bpy
.
context
.
scene
.
objects
.
unlink
(
current_obj
)
def
make_fquat
(
bquat
):
def
make_fquat
(
bquat
):
quat
=
FQuat
()
quat
=
FQuat
()
...
@@ -951,9 +955,6 @@ def parse_bone(blender_bone, psk_file, psa_file, parent_id, is_root_bone, parent
...
@@ -951,9 +955,6 @@ def parse_bone(blender_bone, psk_file, psa_file, parent_id, is_root_bone, parent
else
:
else
:
print
(
"
--Bone Name:
"
,
blender_bone
.
name
,
"
parent: None
"
,
"
ID:
"
,
nbone
)
print
(
"
--Bone Name:
"
,
blender_bone
.
name
,
"
parent: None
"
,
"
ID:
"
,
nbone
)
if
child_parent
!=
None
:
if
child_parent
!=
None
:
quat_root
=
blender_bone
.
matrix
quat_root
=
blender_bone
.
matrix
quat
=
make_fquat
(
quat_root
.
to_quat
())
quat
=
make_fquat
(
quat_root
.
to_quat
())
...
@@ -1053,7 +1054,7 @@ def parse_armature(blender_armature, psk_file, psa_file):
...
@@ -1053,7 +1054,7 @@ def parse_armature(blender_armature, psk_file, psa_file):
"""
"""
for
current_bone
in
current_armature
.
bones
:
#list the bone. #note this will list all the bones.
for
current_bone
in
current_armature
.
bones
:
#list the bone. #note this will list all the bones.
if
(
current_bone
.
parent
==
None
):
if
(
current_bone
.
parent
==
None
):
parse_bone
(
current_bone
,
psk_file
,
psa_file
,
0
,
0
,
current_obj
.
matrix_
world
,
None
)
parse_bone
(
current_bone
,
psk_file
,
psa_file
,
0
,
0
,
current_obj
.
matrix_
local
,
None
)
break
break
# get blender objects by type
# get blender objects by type
...
@@ -1089,11 +1090,20 @@ def parse_animation(blender_scene, blender_armatures, psa_file):
...
@@ -1089,11 +1090,20 @@ def parse_animation(blender_scene, blender_armatures, psa_file):
#need to check if there animation
#need to check if there animation
#need to check if animation is has one frame then exit it
#need to check if animation is has one frame then exit it
print
(
'
\n
----- parsing animation -----
'
)
print
(
'
\n
----- parsing animation -----
'
)
#print(dir(blender_scene.render))
##print(dir(blender_scene))
#print(dir(blender_armatures))
render_data
=
blender_scene
.
render
render_data
=
blender_scene
.
render
bHaveAction
=
True
bHaveAction
=
True
anim_rate
=
render_data
.
fps
anim_rate
=
render_data
.
fps
#print("dir:",dir(blender_scene))
#print(dir(bpy.data.actions))
#print("dir:",dir(bpy.data.actions[0]))
print
(
"
==== Blender Settings ====
"
)
print
(
"
==== Blender Settings ====
"
)
print
(
'
Scene: %s Start Frame: %i, End Frame: %i
'
%
(
blender_scene
.
name
,
blender_scene
.
frame_start
,
blender_scene
.
frame_end
))
print
(
'
Scene: %s Start Frame: %i, End Frame: %i
'
%
(
blender_scene
.
name
,
blender_scene
.
frame_start
,
blender_scene
.
frame_end
))
print
(
'
Frames Per Sec: %i
'
%
anim_rate
)
print
(
'
Frames Per Sec: %i
'
%
anim_rate
)
...
@@ -1107,6 +1117,8 @@ def parse_animation(blender_scene, blender_armatures, psa_file):
...
@@ -1107,6 +1117,8 @@ def parse_animation(blender_scene, blender_armatures, psa_file):
#list of armature objects
#list of armature objects
for
arm
in
blender_armatures
:
for
arm
in
blender_armatures
:
#check if there animation data from armature or something
#check if there animation data from armature or something
#print(dir(arm.animation_data))
#print("[["+dir(arm.animation_data.action))
if
not
arm
.
animation_data
:
if
not
arm
.
animation_data
:
print
(
"
======================================
"
)
print
(
"
======================================
"
)
print
(
"
Check Animation Data: None
"
)
print
(
"
Check Animation Data: None
"
)
...
@@ -1495,13 +1507,14 @@ class ExportUDKAnimData(bpy.types.Operator):
...
@@ -1495,13 +1507,14 @@ class ExportUDKAnimData(bpy.types.Operator):
def
invoke
(
self
,
context
,
event
):
def
invoke
(
self
,
context
,
event
):
wm
=
context
.
manager
wm
=
context
.
manager
wm
.
add_fileselect
(
self
)
wm
.
add_fileselect
(
self
)
return
{
'
RUNNING_MODAL
'
}
return
{
'
RUNNING_MODAL
'
}
def
menu_func
(
self
,
context
):
def
menu_func
(
self
,
context
):
bpy
.
context
.
scene
.
unrealexportpsk
=
True
bpy
.
context
.
scene
.
unrealexportpsk
=
True
bpy
.
context
.
scene
.
unrealexportpsa
=
True
bpy
.
context
.
scene
.
unrealexportpsa
=
True
default_path
=
bpy
.
data
.
filepath
.
replace
(
"
.blend
"
,
"
.psk
"
)
default_path
=
bpy
.
data
.
filepath
.
replace
(
"
.blend
"
,
"
.psk
"
)
self
.
layout
.
operator
(
"
export.udk_anim_data
"
,
text
=
"
Skeleton Mesh / Animation Data (.psk/.psa)
"
).
filepath
=
default_path
self
.
layout
.
operator
(
"
export.udk_anim_data
"
,
text
=
"
Skeleton Mesh / Animation Data (.psk/.psa)
"
).
filepath
=
default_path
class
VIEW3D_PT_unrealtools_objectmode
(
bpy
.
types
.
Panel
):
class
VIEW3D_PT_unrealtools_objectmode
(
bpy
.
types
.
Panel
):
bl_space_type
=
"
VIEW_3D
"
bl_space_type
=
"
VIEW_3D
"
...
@@ -1523,7 +1536,6 @@ class VIEW3D_PT_unrealtools_objectmode(bpy.types.Panel):
...
@@ -1523,7 +1536,6 @@ class VIEW3D_PT_unrealtools_objectmode(bpy.types.Panel):
#FPS #it use the real data from your scene
#FPS #it use the real data from your scene
layout
.
prop
(
rd
.
render
,
"
fps
"
)
layout
.
prop
(
rd
.
render
,
"
fps
"
)
layout
.
prop
(
rd
,
"
unrealactionexportall
"
)
layout
.
prop
(
rd
,
"
unrealactionexportall
"
)
#row = layout.row()
#row = layout.row()
#row.label(text="Action Set(s)(not build)")
#row.label(text="Action Set(s)(not build)")
...
@@ -1551,7 +1563,7 @@ class OBJECT_OT_UnrealExport(bpy.types.Operator):
...
@@ -1551,7 +1563,7 @@ class OBJECT_OT_UnrealExport(bpy.types.Operator):
__doc__
=
"
Select export setting for .psk/.psa or both.
"
__doc__
=
"
Select export setting for .psk/.psa or both.
"
def
invoke
(
self
,
context
,
event
):
def
invoke
(
self
,
context
,
event
):
file
path
=
StringProperty
(
name
=
"
File Path
"
,
description
=
"
Filepath used for exporting the PSA file
"
,
maxlen
=
1024
,
default
=
""
)
#
path = StringProperty(name="File Path", description="File
path used for exporting the PSA file", maxlen= 1024, default= "")
print
(
"
Init Export Script:
"
)
print
(
"
Init Export Script:
"
)
if
(
int
(
bpy
.
context
.
scene
.
unrealexport_settings
)
==
0
):
if
(
int
(
bpy
.
context
.
scene
.
unrealexport_settings
)
==
0
):
bpy
.
context
.
scene
.
unrealexportpsk
=
True
bpy
.
context
.
scene
.
unrealexportpsk
=
True
...
@@ -1566,8 +1578,11 @@ class OBJECT_OT_UnrealExport(bpy.types.Operator):
...
@@ -1566,8 +1578,11 @@ class OBJECT_OT_UnrealExport(bpy.types.Operator):
bpy
.
context
.
scene
.
unrealexportpsa
=
True
bpy
.
context
.
scene
.
unrealexportpsa
=
True
print
(
"
Exporting ALL...
"
)
print
(
"
Exporting ALL...
"
)
default_path
=
bpy
.
data
.
filepath
.
replace
(
"
.blend
"
,
"
.psk
"
)
default_path
=
bpy
.
data
.
filepath
.
replace
(
"
.blend
"
,
"
.psk
"
)
print
(
dir
(
bpy
.
data
.
filepath
))
fs_callback
(
default_path
,
bpy
.
context
,
False
)
fs_callback
(
default_path
,
bpy
.
context
,
False
)
self
.
report
({
'
WARNING
'
,
'
INFO
'
},
exportmessage
)
#self.report({'WARNING', 'INFO'}, exportmessage)
self
.
report
({
'
INFO
'
},
exportmessage
)
return
{
'
FINISHED
'
}
return
{
'
FINISHED
'
}
def
register
():
def
register
():
...
@@ -1587,4 +1602,4 @@ def unregister():
...
@@ -1587,4 +1602,4 @@ def unregister():
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