OSDN Git Service
(root)
/
meshio
/
meshio.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
52bfc6a
)
fix bone.
author
ousttrue
<ousttrue@gmail.com>
Sun, 13 Jun 2010 14:32:07 +0000
(23:32 +0900)
committer
ousttrue
<ousttrue@gmail.com>
Sun, 13 Jun 2010 14:32:07 +0000
(23:32 +0900)
include/pmd.h
patch
|
blob
|
history
src/pmd.cpp
patch
|
blob
|
history
swig/blender/bl24.py
patch
|
blob
|
history
swig/blender/bl25.py
patch
|
blob
|
history
swig/blender/pmd_export.py
patch
|
blob
|
history
swig/blender/pmd_import.py
patch
|
blob
|
history
diff --git
a/include/pmd.h
b/include/pmd.h
index
573882f
..
ac706b3
100644
(file)
--- a/
include/pmd.h
+++ b/
include/pmd.h
@@
-248,6
+248,8
@@
struct Morph
void append(int index, float x, float y, float z);
std::wstring getName()const;
void append(int index, float x, float y, float z);
std::wstring getName()const;
+ void setName(const char *src);
+ void setEnglishName(const char *src);
};
inline std::ostream &operator<<(std::ostream &os, const Morph &rhs)
{
};
inline std::ostream &operator<<(std::ostream &os, const Morph &rhs)
{
@@
-267,8
+269,8
@@
struct BoneDisplayName
char name[50];
char english_name[50];
char name[50];
char english_name[50];
- void setName(const char *
name
);
- void setEnglishName(const char *
english
);
+ void setName(const char *
src
);
+ void setEnglishName(const char *
src
);
};
////////////////////////////////////////////////////////////
};
////////////////////////////////////////////////////////////
diff --git
a/src/pmd.cpp
b/src/pmd.cpp
index
bb20068
..
17397b6
100644
(file)
--- a/
src/pmd.cpp
+++ b/
src/pmd.cpp
@@
-704,6
+704,11
@@
const Vector2* IO::getUV(int index)const
return &vertices[index].uv;
}
return &vertices[index].uv;
}
+void Bone::setName(const char *src)
+{
+ strncpy(name, src, 20);
+}
+
void BoneDisplayName::setName(const char *src)
{
strncpy(name, src, 20);
void BoneDisplayName::setName(const char *src)
{
strncpy(name, src, 20);
@@
-714,11
+719,16
@@
void BoneDisplayName::setEnglishName(const char *src)
strncpy(english_name, src, 20);
}
strncpy(english_name, src, 20);
}
-void
Bone
::setName(const char *src)
+void
Morph
::setName(const char *src)
{
strncpy(name, src, 20);
}
{
strncpy(name, src, 20);
}
+void Morph::setEnglishName(const char *src)
+{
+ strncpy(english_name, src, 20);
+}
+
} // namespace
} // namespace
} // namespace
} // namespace
diff --git
a/swig/blender/bl24.py
b/swig/blender/bl24.py
index
f08ff30
..
5209561
100644
(file)
--- a/
swig/blender/bl24.py
+++ b/
swig/blender/bl24.py
@@
-813,7
+813,7
@@
def boneIsConnected(b):
return Blender.Armature.CONNECTED in b.options
def constraintIsIKSolver(c):
return Blender.Armature.CONNECTED in b.options
def constraintIsIKSolver(c):
- return c.type==Blender.Constraint.Type.IKSOLVER
:
+ return c.type==Blender.Constraint.Type.IKSOLVER
def ikChainLen(c):
return c[Blender.Constraint.Settings.CHAINLEN]
def ikChainLen(c):
return c[Blender.Constraint.Settings.CHAINLEN]
@@
-827,3
+827,9
@@
def ikItration(c):
def ikRotationWeight(c):
return c[Blender.Constraint.Settings.ROTWEIGHT]
def ikRotationWeight(c):
return c[Blender.Constraint.Settings.ROTWEIGHT]
+def shapeKeyGet(b, index):
+ return b.data[index]
+
+def shapeKeys(b):
+ return b.data
+
diff --git
a/swig/blender/bl25.py
b/swig/blender/bl25.py
index
8c02157
..
a8bc8e5
100644
(file)
--- a/
swig/blender/bl25.py
+++ b/
swig/blender/bl25.py
@@
-468,3
+468,10
@@
def ikItration(c):
def ikRotationWeight(c):
return c.weight
def ikRotationWeight(c):
return c.weight
+def shapeKeyGet(b, index):
+ return b.data[index].co
+
+def shapeKeys(b):
+ for k in b.data:
+ yield k.co
+
diff --git
a/swig/blender/pmd_export.py
b/swig/blender/pmd_export.py
index
c0e52cb
..
433cf5b
100644
(file)
--- a/
swig/blender/pmd_export.py
+++ b/
swig/blender/pmd_export.py
@@
-373,14
+373,14
@@
class OneSkinMesh(object):
if bl.objectHasShapeKey(obj):
# base
for b in bl.objectShapeKeys(obj):
if bl.objectHasShapeKey(obj):
# base
for b in bl.objectShapeKeys(obj):
- if b.name==
'Basis'
:
+ if b.name==
BASE_SHAPE_NAME
:
print(b.name)
baseMorph=self.__getOrCreateMorph('base', 0)
relativeIndex=0
basis=b
for index in bl.meshVertexGroup(obj, MMD_SHAPE_GROUP_NAME):
print(b.name)
baseMorph=self.__getOrCreateMorph('base', 0)
relativeIndex=0
basis=b
for index in bl.meshVertexGroup(obj, MMD_SHAPE_GROUP_NAME):
- v=b
.data[index]
+ v=b
l.shapeKeyGet(b, index)
pos=[v[0], v[1], v[2]]
indices=self.vertexArray.getMappedIndices(index)
for i in indices:
pos=[v[0], v[1], v[2]]
indices=self.vertexArray.getMappedIndices(index)
for i in indices:
@@
-395,24
+395,23
@@
class OneSkinMesh(object):
baseMorph.sort()
# shape keys
baseMorph.sort()
# shape keys
- vg=obj.getData(mesh=True).getVertsFromGroup(
- MMD_SHAPE_GROUP_NAME)
- for b in obj.getData(mesh=True).key.blocks:
- if b.name=='Basis':
+ vg=bl.meshVertexGroup(obj, MMD_SHAPE_GROUP_NAME)
+ for b in bl.objectShapeKeys(obj):
+ if b.name==BASE_SHAPE_NAME:
continue
print(b.name)
morph=self.__getOrCreateMorph(b.name, 4)
for index, src, dst in zip(
xrange(len(blenderMesh.verts)),
continue
print(b.name)
morph=self.__getOrCreateMorph(b.name, 4)
for index, src, dst in zip(
xrange(len(blenderMesh.verts)),
- b
asis.data
,
- b
.data
):
+ b
l.shapeKeys(basis)
,
+ b
l.shapeKeys(b)
):
offset=[dst[0]-src[0], dst[1]-src[1], dst[2]-src[2]]
if index in vg:
indices=self.vertexArray.getMappedIndices(index)
for i in indices:
morph.add(indexRelativeMap[i], offset)
offset=[dst[0]-src[0], dst[1]-src[1], dst[2]-src[2]]
if index in vg:
indices=self.vertexArray.getMappedIndices(index)
for i in indices:
morph.add(indexRelativeMap[i], offset)
- assert(len(morph.offsets)==len(baseMorph.offsets))
+
#
assert(len(morph.offsets)==len(baseMorph.offsets))
# sort skinmap
original=self.morphList[:]
# sort skinmap
original=self.morphList[:]
@@
-796,9
+795,8
@@
class PmdExporter(object):
v=englishmap.getUnicodeSkinName(m.name)
assert(v)
cp932=v[1].encode('cp932')
v=englishmap.getUnicodeSkinName(m.name)
assert(v)
cp932=v[1].encode('cp932')
- morph.name="%s\n" % cp932
-
- morph.english_name="%s\n" % m.name
+ morph.setName(cp932)
+ morph.setEnglishName(m.name.encode('cp932'))
m.type=v[2]
morph.type=v[2]
for index, offset in m.offsets:
m.type=v[2]
morph.type=v[2]
for index, offset in m.offsets:
@@
-828,9
+826,8
@@
class PmdExporter(object):
boneDisplayName.name=name.decode('utf-8').encode('cp932')
boneDisplayName.english_name=english
else:
boneDisplayName.name=name.decode('utf-8').encode('cp932')
boneDisplayName.english_name=english
else:
- # ToDo
- boneDisplayName.name=english
- boneDisplayName.english_name=english
+ boneDisplayName.setName(name.encode('cp932'))
+ boneDisplayName.setEnglishName(english.encode('cp932'))
boneDisplayName=createBoneDisplayName("IK\n", "IK\n")
boneDisplayName=createBoneDisplayName("体(上)\n", "Body[u]\n")
boneDisplayName=createBoneDisplayName("髪\n", "Hair\n")
boneDisplayName=createBoneDisplayName("IK\n", "IK\n")
boneDisplayName=createBoneDisplayName("体(上)\n", "Body[u]\n")
boneDisplayName=createBoneDisplayName("髪\n", "Hair\n")
diff --git
a/swig/blender/pmd_import.py
b/swig/blender/pmd_import.py
index
3919753
..
08c1d63
100644
(file)
--- a/
swig/blender/pmd_import.py
+++ b/
swig/blender/pmd_import.py
@@
-120,10
+120,15
@@
def __importShape(obj, l, vertex_map):
bl.meshAddVertexGroup(obj, MMD_SHAPE_GROUP_NAME)
hasShape=False
for i in s.indices:
bl.meshAddVertexGroup(obj, MMD_SHAPE_GROUP_NAME)
hasShape=False
for i in s.indices:
- if i in vertex_map:
+ if isBlender24():
+ if i in vertex_map:
+ hasShape=True
+ bl.meshAssignVertexGroup(
+ obj, MMD_SHAPE_GROUP_NAME, vertex_map[i], 0)
+ else:
hasShape=True
bl.meshAssignVertexGroup(
hasShape=True
bl.meshAssignVertexGroup(
- obj, MMD_SHAPE_GROUP_NAME,
vertex_map[i]
, 0)
+ obj, MMD_SHAPE_GROUP_NAME,
i
, 0)
if not hasShape:
return
assert(base)
if not hasShape:
return
assert(base)
@@
-546,13
+551,13
@@
def __importMesh(scene, io, tex_dir):
face_map, tex_dir)
# enter Edit Mode
face_map, tex_dir)
# enter Edit Mode
- bl.enterEditMode()
+
#
bl.enterEditMode()
# crete shape key
__importShape(meshObject, io, vertex_map)
# exit Edit Mode
# crete shape key
__importShape(meshObject, io, vertex_map)
# exit Edit Mode
- bl.exitEditMode()
+
#
bl.exitEditMode()
mesh.update()
material_offset+=16
mesh.update()
material_offset+=16