#!/usr/bin/env python
# coding: utf-8
"""
========================
MikuMikuDance PMX format
========================
file format
~~~~~~~~~~~
* PMDEditor's Lib/PMX仕様/PMX仕様.txt
specs
~~~~~
* textencoding: unicode
* coordinate: left handed y-up(DirectX)
* uv origin:
* face: only triangle
* backculling:
"""
__author__="ousttrue"
__license__="zlib"
__versioon__="1.0.0"
import io
import os
import struct
from .. import common
class Ik(common.Diff):
"""ik info
"""
__slots__=[
'target_index',
'loop',
'limit_radian',
'link',
]
def __init__(self, target_index, loop, limit_radian, link=None):
self.target_index=target_index
self.loop=loop
self.limit_radian=limit_radian
self.link=link or []
def __eq__(self, rhs):
return (
self.target_index==rhs.target_index
and self.loop==rhs.loop
and self.limit_radian==rhs.limit_radian
and self.link==rhs.link
)
def diff(self, rhs):
self._diff(rhs, 'target_index')
self._diff(rhs, 'loop')
self._diff(rhs, 'limit_radian')
self._diff_array(rhs, 'link')
class IkLink(common.Diff):
"""ik link info
"""
__slots__=[
'bone_index',
'limit_angle',
'limit_min',
'limit_max',
]
def __init__(self, bone_index, limit_angle, limit_min=None, limit_max=None):
self.bone_index=bone_index
self.limit_angle=limit_angle
self.limit_min=limit_min or common.Vector3()
self.limit_max=limit_max or common.Vector3()
def __eq__(self, rhs):
return (
self.bone_index==rhs.bone_index
and self.limit_angle==rhs.limit_angle
and self.limit_min==rhs.limit_min
and self.limit_max==rhs.limit_max
)
def diff(self, rhs):
self._diff(rhs, 'bone_index')
self._diff(rhs, 'limit_angle')
self._diff(rhs, 'limit_min')
self._diff(rhs, 'limit_max')
BONEFLAG_TAILPOS_IS_BONE=0x0001
BONEFLAG_CAN_ROTATE=0x0002
BONEFLAG_CAN_TRANSLATE=0x0004
BONEFLAG_IS_VISIBLE=0x0008
BONEFLAG_CAN_MANIPULATE=0x0010
BONEFLAG_IS_IK=0x0020
BONEFLAG_IS_EXTERNAL_ROTATION=0x0100
BONEFLAG_IS_EXTERNAL_TRANSLATION=0x0200
BONEFLAG_HAS_FIXED_AXIS=0x0400
BONEFLAG_HAS_LOCAL_COORDINATE=0x0800
BONEFLAG_IS_AFTER_PHYSICS_DEFORM=0x1000
BONEFLAG_IS_EXTERNAL_PARENT_DEFORM=0x2000
class Bone(common.Diff):
"""material
Bone: see __init__
"""
__slots__=[
'name',
'english_name',
'position',
'parent_index',
'layer',
'flag',
'tail_position',
'tail_index',
'effect_index',
'effect_factor',
'fixed_axis',
'local_x_vector',
'local_z_vector',
'external_key',
'ik',
'index',
]
def __init__(self,
name,
english_name,
position,
parent_index,
layer,
flag,
tail_position=None,
tail_index=-1,
effect_index=-1,
effect_factor=0.0,
fixed_axis=None,
local_x_vector=None,
local_z_vector=None,
external_key=-1,
ik=None
):
self.name=name
self.english_name=english_name
self.position=position
self.parent_index=parent_index
self.layer=layer
self.flag=flag
self.tail_position=tail_position or common.Vector3()
self.tail_index=tail_index
self.effect_index=effect_index
self.effect_factor=effect_factor
self.fixed_axis=fixed_axis or common.Vector3()
self.local_x_vector=local_x_vector or common.Vector3()
self.local_z_vector=local_z_vector or common.Vector3()
self.external_key=external_key
self.ik=ik
self.index=-1
def __str__(self):
return ("<pmx.Bone {name}>".format(
name=self.name
))
def __eq__(self, rhs):
return (
self.name==rhs.name
and self.english_name==rhs.english_name
and self.position==rhs.position
and self.parent_index==rhs.parent_index
and self.layer==rhs.layer
and self.flag==rhs.flag
)
def __ne__(self, rhs):
return not self.__eq__(rhs)
def diff(self, rhs):
self._diff(rhs, 'name')
self._diff(rhs, 'english_name')
self._diff(rhs, 'position')
self._diff(rhs, 'parent_index')
#self._diff(rhs, 'layer')
self._diff(rhs, 'flag')
self._diff(rhs, 'tail_position')
self._diff(rhs, 'tail_index')
self._diff(rhs, 'effect_index')
self._diff(rhs, 'effect_factor')
self._diff(rhs, 'fixed_axis')
self._diff(rhs, 'local_x_vector')
self._diff(rhs, 'local_z_vector')
self._diff(rhs, 'external_key')
if self.ik and rhs.ik:
self.ik.diff(rhs.ik)
else:
self._diff(rhs, 'ik')
def hasFlag(self, flag):
return (self.flag & flag)!=0
def setFlag(self, flag, enable):
if enable:
self.flag |= flag
else:
self.flag &= ~flag
def getConnectionFlag(self):
return self.hasFlag(BONEFLAG_TAILPOS_IS_BONE)
def getRotatable(self):
return self.hasFlag(BONEFLAG_CAN_ROTATE)
def getTranslatable(self):
return self.hasFlag(BONEFLAG_CAN_TRANSLATE)
def getVisibleFlag(self):
return self.hasFlag(BONEFLAG_IS_VISIBLE)
def getManipulatable(self):
return self.hasFlag(BONEFLAG_CAN_MANIPULATE)
def getIkFlag(self):
return self.hasFlag(BONEFLAG_IS_IK)
def getExternalRotationFlag(self):
return self.hasFlag(BONEFLAG_IS_EXTERNAL_ROTATION)
def getExternalTranslationFlag(self):
return self.hasFlag(BONEFLAG_IS_EXTERNAL_TRANSLATION)
def getFixedAxisFlag(self):
return self.hasFlag(BONEFLAG_HAS_FIXED_AXIS)
def getLocalCoordinateFlag(self):
return self.hasFlag(BONEFLAG_HAS_LOCAL_COORDINATE)
def getAfterPhysicsDeformFlag(self):
return self.hasFlag(BONEFLAG_IS_AFTER_PHYSICS_DEFORM)
def getExternalParentDeformFlag(self):
return self.hasFlag(BONEFLAG_IS_EXTERNAL_PARENT_DEFORM)
MATERIALFLAG_BOTHFACE=0x01
MATERIALFLAG_GROUNDSHADOW=0x02
MATERIALFLAG_SELFSHADOWMAP=0x04
MATERIALFLAG_SELFSHADOW=0x08
MATERIALFLAG_EDGE=0x10
MATERIALSPHERE_NONE=0
MATERIALSPHERE_SPH=1
MATERIALSPHERE_SPA=2
class Material(common.Diff):
"""material
Attributes: see __init__
"""
__slots__=[
'name',
'english_name',
'diffuse_color',
'alpha',
'specular_color',
'specular_factor',
'ambient_color',
'flag',
'edge_color',
'edge_size',
'texture_index',
'sphere_texture_index',
'sphere_mode',
'toon_sharing_flag',
'toon_texture_index',
'comment',
'vertex_count',
]
def __init__(self,
name,
english_name,
diffuse_color,
alpha,
specular_factor,
specular_color,
ambient_color,
flag,
edge_color,
edge_size,
texture_index,
sphere_texture_index,
sphere_mode,
toon_sharing_flag,
toon_texture_index=0,
comment=common.unicode(""),
vertex_count=0,
):
self.name=name
self.english_name=english_name
self.diffuse_color=diffuse_color
self.alpha=alpha
self.specular_c
没有合适的资源?快使用搜索试试~ 我知道了~
资源详情
资源评论
资源推荐
收起资源包目录
用于python的3d模型读写器 pymeshio-master.zip (67个子文件)
pymeshio-master
MANIFEST.in 89B
README.rst 7KB
msbuild.proj 470B
pymeshio.sln 818B
test
pmd_test.py 2KB
convert_test.py 1KB
x_test.py 486B
fixture.py 213B
export_pmx_test.py 820B
__init__.py 359B
pmx_test.py 3KB
mqo_test.py 511B
pmm_test.py 442B
export_pmd_test.py 909B
obj_test.py 942B
resources
cube.mtl 237B
cube.obj 835B
Makefile.dev 110B
pymeshio
common.py 15KB
pmm
__init__.py 3KB
reader.py 14KB
main.py 1KB
pmd
__init__.py 22KB
writer.py 6KB
reader.py 8KB
obj
__init__.py 2KB
reader.py 5KB
vpd.py 2KB
pmx
__init__.py 33KB
writer.py 13KB
reader.py 15KB
mqo
__init__.py 6KB
reader.py 6KB
__init__.py 343B
englishmap.py 7KB
konbu.py 3KB
x
__init__.py 1019B
writer.py 3KB
reader.py 9KB
converter.py 15KB
vmd
__init__.py 2KB
writer.py 1KB
reader.py 3KB
examples
pymeshviewer
xbuilder.py 1KB
pmxbuilder.py 2KB
opengl
vertexarray.py 7KB
shader.py 1KB
rokuro.py 2KB
material.py 1KB
vertexarraymap.py 4KB
__init__.py 2KB
baseview.py 1KB
coord.py 615B
triangle.py 412B
texture.py 2KB
pmdbuilder.py 2KB
togl.py 2KB
pymeshviewer.py 4KB
mqobuilder.py 2KB
setup.py 2KB
.gitignore 161B
bench.py 933B
pymeshio.pyproj 13KB
Backup
pymeshio.sln 818B
ChangeLog 719B
.vscode
launch.json 7KB
setup.cfg.py2 85B
共 67 条
- 1
局外狗
- 粉丝: 64
- 资源: 1万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0