texture coordinates
git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@149 67173fc5-114c-0410-ac8e-9d2fd5bffc1fpull/1/head
parent
4b013dbeba
commit
d7bc843ae6
|
@ -156,8 +156,14 @@ class Mesh(AssimpBase):
|
||||||
#vertex color sets
|
#vertex color sets
|
||||||
self.colors = self._load_colors(mesh)
|
self.colors = self._load_colors(mesh)
|
||||||
|
|
||||||
#number of texture coordinates
|
#number of coordinates per uv-channel
|
||||||
self.numuv = self._load_uv_component_count(mesh) #FIXME
|
self.uvsize = self._load_uv_component_count(mesh)
|
||||||
|
|
||||||
|
#number of uv channels
|
||||||
|
self.texcoords = self._load_texture_coords(mesh)
|
||||||
|
|
||||||
|
#the used material
|
||||||
|
self.material_index = mesh.mMaterialIndex
|
||||||
|
|
||||||
|
|
||||||
def _load_uv_component_count(self, mesh):
|
def _load_uv_component_count(self, mesh):
|
||||||
|
@ -172,6 +178,24 @@ class Mesh(AssimpBase):
|
||||||
for i in range(structs.MESH.AI_MAX_NUMBER_OF_TEXTURECOORDS))
|
for i in range(structs.MESH.AI_MAX_NUMBER_OF_TEXTURECOORDS))
|
||||||
|
|
||||||
|
|
||||||
|
def _load_texture_coords(self, mesh):
|
||||||
|
"""
|
||||||
|
Loads texture coordinates.
|
||||||
|
|
||||||
|
mesh - mesh-data
|
||||||
|
|
||||||
|
result texture coordinates
|
||||||
|
"""
|
||||||
|
result = []
|
||||||
|
|
||||||
|
for i in range(structs.MESH.AI_MAX_NUMBER_OF_TEXTURECOORDS):
|
||||||
|
result.append(self._load_array(mesh.mTextureCoords[i],
|
||||||
|
mesh.mNumVertices,
|
||||||
|
lambda x: (x.x, x.y, x.z)))
|
||||||
|
|
||||||
|
return result
|
||||||
|
|
||||||
|
|
||||||
def _load_colors(self, mesh):
|
def _load_colors(self, mesh):
|
||||||
"""
|
"""
|
||||||
Loads color sets.
|
Loads color sets.
|
||||||
|
|
|
@ -224,7 +224,7 @@ class MESH(Structure):
|
||||||
#Vertex texture coords, also known as UV channels.
|
#Vertex texture coords, also known as UV channels.
|
||||||
#A mesh may contain 0 to AI_MAX_NUMBER_OF_TEXTURECOORDS per
|
#A mesh may contain 0 to AI_MAX_NUMBER_OF_TEXTURECOORDS per
|
||||||
#vertex. NULL if not present. The array is mNumVertices in size.
|
#vertex. NULL if not present. The array is mNumVertices in size.
|
||||||
("mTextureCoords", POINTER(VECTOR3D)*AI_MAX_NUMBER_OF_TEXTURECOORDS),
|
("mTextureCoords", POINTER(VECTOR3D)*AI_MAX_NUMBER_OF_TEXTURECOORDS),#OK
|
||||||
|
|
||||||
#Specifies the number of components for a given UV channel.
|
#Specifies the number of components for a given UV channel.
|
||||||
#Up to three channels are supported (UVW, for accessing volume
|
#Up to three channels are supported (UVW, for accessing volume
|
||||||
|
@ -232,7 +232,7 @@ class MESH(Structure):
|
||||||
#component p.z of mTextureCoords[n][p] is set to 0.0f.
|
#component p.z of mTextureCoords[n][p] is set to 0.0f.
|
||||||
#If the value is 1 for a given channel, p.y is set to 0.0f, too.
|
#If the value is 1 for a given channel, p.y is set to 0.0f, too.
|
||||||
#@note 4D coords are not supported
|
#@note 4D coords are not supported
|
||||||
("mNumUVComponents", c_uint*AI_MAX_NUMBER_OF_TEXTURECOORDS),
|
("mNumUVComponents", c_uint*AI_MAX_NUMBER_OF_TEXTURECOORDS), #OK
|
||||||
|
|
||||||
#The faces the mesh is contstructed from.
|
#The faces the mesh is contstructed from.
|
||||||
#Each face referres to a number of vertices by their indices.
|
#Each face referres to a number of vertices by their indices.
|
||||||
|
@ -253,7 +253,7 @@ class MESH(Structure):
|
||||||
#A mesh does use only a single material. If an imported model uses
|
#A mesh does use only a single material. If an imported model uses
|
||||||
#multiple materials, the import splits up the mesh. Use this value
|
#multiple materials, the import splits up the mesh. Use this value
|
||||||
#as index into the scene's material list.
|
#as index into the scene's material list.
|
||||||
("mMaterialIndex", c_uint)
|
("mMaterialIndex", c_uint) #OK
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@ import os
|
||||||
#get a model out of assimp's test-data
|
#get a model out of assimp's test-data
|
||||||
MODEL = os.path.join(os.path.dirname(__file__),
|
MODEL = os.path.join(os.path.dirname(__file__),
|
||||||
"..", "..",
|
"..", "..",
|
||||||
"test", "ASEFiles", "MotionCaptureROM.ase")
|
"test", "3DSFiles", "test1.3ds")
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
scene = pyassimp.load(MODEL)
|
scene = pyassimp.load(MODEL)
|
||||||
|
@ -31,7 +31,12 @@ def main():
|
||||||
print " vertices:", len(mesh.vertices)
|
print " vertices:", len(mesh.vertices)
|
||||||
print " first:", mesh.vertices[:3]
|
print " first:", mesh.vertices[:3]
|
||||||
print " colors:", len(mesh.colors)
|
print " colors:", len(mesh.colors)
|
||||||
print " uv-counts:", mesh.numuv
|
tc = mesh.texcoords
|
||||||
|
print " texture-coords 1:", len(tc[0]), "first:", tc[0][:3]
|
||||||
|
print " texture-coords 2:", len(tc[1]), "first:", tc[1][:3]
|
||||||
|
print " texture-coords 3:", len(tc[2]), "first:", tc[2][:3]
|
||||||
|
print " texture-coords 4:", len(tc[3]), "first:", tc[3][:3]
|
||||||
|
print " uv-counts:", mesh.uvsize
|
||||||
print
|
print
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue