parameters: (scene, sceneNode, blenderScene, blenderObjectMesh)
docstring: convert a blender mesh to an alchemedia node
docstring_summary: convert a blender mesh to an alchemedia node
docstring_tokens: convert a blender mesh to an alchemedia node
function: def ExportMesh(scene, sceneNode, blenderScene, blenderObjectMesh):
  	'''convert a blender mesh to an alchemedia node'''
  	
  	# get the blender mesh from teh object
  	blenderMesh = blenderObjectMesh.data
  
  	# create the mesh node	
  	meshNode = scene.CreateMeshNode(sceneNode)
  	meshInfo = pyScene.pyMesh(scene, meshNode)
  	meshInfo.SetName (blenderObjectMesh.getName())
  	
  	# add the mesh materials
  	hasMaterial = False
  	materialMap = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1];
  	materials = blenderMesh.getMaterials (1)
  	for i, material in enumerate (materials):
  		if material != None:
  			hasMaterial = True
  			materialMap[i] = i;
  			materialNode = scene.CreateMaterialNode(meshNode, i)
  			materialInfo = pyScene.pyMaterial(scene, materialNode)
  			
  			# export any texture
  			for texture in material.getTextures():
  				if texture and texture.tex.type == Blender.Texture.Types.IMAGE:
  					image = texture.tex.image
  					if image != None:
  						# create a texture and attache to the material
  						name = image.getName()
  						textureNode = scene.CreateTextureNode(name)
  						scene.AddReference (materialNode, textureNode)
  						
  						# link the texture ID to and the materail
  						textureInfo = pyScene.pyTexture(scene, textureNode)
  						materialInfo.SetAmbientTextId (textureInfo.GetId())
  						materialInfo.SetDiffuseTextId (textureInfo.GetId())
  					
  					
  					
  			
  	
  	# if the mesh do not have material add a default material			
  	if hasMaterial == False:
  		materialMap[0] = 0;
  		materialNode = scene.CreateMaterialNode(meshNode, 0)
  	
  	# create the vertex List and face arrays
  	faceCount = len(blenderMesh.faces)	
  	vertexCount = len(blenderMesh.verts)
  	
  	faceIndexCountArray = pyScene.intArray(faceCount)
  	vertexArray = pyScene.doubleArray(vertexCount * 3)
  	faceMaterialIndexArray = pyScene.intArray(faceCount)	
  	vertexIndexArray = pyScene.intArray(faceCount * 4)
  	normalArray = pyScene.doubleArray(faceCount * 4 * 3)
  	uvArray = pyScene.doubleArray(faceCount * 4 * 2)
  	
  	# copy vertex points from the vertex list
  	for i, v in enumerate(blenderMesh.verts):
  		vertexArray[i * 3 + 0] = v.co.x 
  		vertexArray[i * 3 + 1] = v.co.y 
  		vertexArray[i * 3 + 2] = v.co.z 
  	
  
  	# copy face data from the face list
  	index = 0	
  	if blenderMesh.hasFaceUV() == True:
  		# mesh with uv mapping 
  		for i, face in enumerate(blenderMesh.faces):
  			pointCount = len(face.v)
  			faceMaterialIndexArray[i] = face.mat
  			faceIndexCountArray[i] = pointCount
  			
  			for j, point in enumerate(face):
  				vertexIndexArray[index + j] = point.index
  				
  				normalIndex = (index + j) * 3
  				normalArray[normalIndex + 0] = point.no.x
  				normalArray[normalIndex + 1] = point.no.y
  				normalArray[normalIndex + 2] = point.no.z
  				
  				uvIndex = (index + j) * 2
  				
  				uvArray[uvIndex + 0] = face.uv[j][0]
  				uvArray[uvIndex + 1] = face.uv[j][1]
  			index = index + pointCount
  	else:
  		# mesh have no uv mapping
  		for i, face in enumerate(blenderMesh.faces):
  			pointCount = len(face.v)
  			faceMaterialIndexArray[i] = face.mat
  			faceIndexCountArray[i] = pointCount
  			
  			for j, point in enumerate(face):
  				vertexIndexArray[index + j] = point.index
  				
  				normalIndex = (index + j) * 3
  				normalArray[normalIndex + 0] = point.no.x
  				normalArray[normalIndex + 1] = point.no.y
  				normalArray[normalIndex + 2] = point.no.z
  				
  				uvIndex = (index + j) * 2
  				uvArray[uvIndex + 0] = 0
  				uvArray[uvIndex + 1] = 0
  			index = index + pointCount
  				
  	# create the alchemedia mesh
  	meshInfo.BuildFromVertexListIndexList(faceCount, faceIndexCountArray, faceMaterialIndexArray, vertexArray, vertexIndexArray, normalArray, uvArray);
  	
  	# normal are completly bogus in blender, just recalculate proper normals 
  	#meshInfo.SmoothNormals (blenderMesh.degr)
  	meshInfo.SmoothNormals (30)
function_tokens: def ExportMesh ( scene , sceneNode , blenderScene , blenderObjectMesh ) : # get the blender mesh from teh object blenderMesh = blenderObjectMesh . data # create the mesh node	 meshNode = scene . CreateMeshNode ( sceneNode ) meshInfo = pyScene . pyMesh ( scene , meshNode ) meshInfo . SetName ( blenderObjectMesh . getName ( ) ) # add the mesh materials hasMaterial = False materialMap = [ - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 ] materials = blenderMesh . getMaterials ( 1 ) for i , material in enumerate ( materials ) : if material != None : hasMaterial = True materialMap [ i ] = i materialNode = scene . CreateMaterialNode ( meshNode , i ) materialInfo = pyScene . pyMaterial ( scene , materialNode ) # export any texture for texture in material . getTextures ( ) : if texture and texture . tex . type == Blender . Texture . Types . IMAGE : image = texture . tex . image if image != None : # create a texture and attache to the material name = image . getName ( ) textureNode = scene . CreateTextureNode ( name ) scene . AddReference ( materialNode , textureNode ) # link the texture ID to and the materail textureInfo = pyScene . pyTexture ( scene , textureNode ) materialInfo . SetAmbientTextId ( textureInfo . GetId ( ) ) materialInfo . SetDiffuseTextId ( textureInfo . GetId ( ) ) # if the mesh do not have material add a default material			 if hasMaterial == False : materialMap [ 0 ] = 0 materialNode = scene . CreateMaterialNode ( meshNode , 0 ) # create the vertex List and face arrays faceCount = len ( blenderMesh . faces ) vertexCount = len ( blenderMesh . verts ) faceIndexCountArray = pyScene . intArray ( faceCount ) vertexArray = pyScene . doubleArray ( vertexCount * 3 ) faceMaterialIndexArray = pyScene . intArray ( faceCount ) vertexIndexArray = pyScene . intArray ( faceCount * 4 ) normalArray = pyScene . doubleArray ( faceCount * 4 * 3 ) uvArray = pyScene . doubleArray ( faceCount * 4 * 2 ) # copy vertex points from the vertex list for i , v in enumerate ( blenderMesh . verts ) : vertexArray [ i * 3 + 0 ] = v . co . x vertexArray [ i * 3 + 1 ] = v . co . y vertexArray [ i * 3 + 2 ] = v . co . z # copy face data from the face list index = 0 if blenderMesh . hasFaceUV ( ) == True : # mesh with uv mapping  for i , face in enumerate ( blenderMesh . faces ) : pointCount = len ( face . v ) faceMaterialIndexArray [ i ] = face . mat faceIndexCountArray [ i ] = pointCount for j , point in enumerate ( face ) : vertexIndexArray [ index + j ] = point . index normalIndex = ( index + j ) * 3 normalArray [ normalIndex + 0 ] = point . no . x normalArray [ normalIndex + 1 ] = point . no . y normalArray [ normalIndex + 2 ] = point . no . z uvIndex = ( index + j ) * 2 uvArray [ uvIndex + 0 ] = face . uv [ j ] [ 0 ] uvArray [ uvIndex + 1 ] = face . uv [ j ] [ 1 ] index = index + pointCount else : # mesh have no uv mapping for i , face in enumerate ( blenderMesh . faces ) : pointCount = len ( face . v ) faceMaterialIndexArray [ i ] = face . mat faceIndexCountArray [ i ] = pointCount for j , point in enumerate ( face ) : vertexIndexArray [ index + j ] = point . index normalIndex = ( index + j ) * 3 normalArray [ normalIndex + 0 ] = point . no . x normalArray [ normalIndex + 1 ] = point . no . y normalArray [ normalIndex + 2 ] = point . no . z uvIndex = ( index + j ) * 2 uvArray [ uvIndex + 0 ] = 0 uvArray [ uvIndex + 1 ] = 0 index = index + pointCount # create the alchemedia mesh meshInfo . BuildFromVertexListIndexList ( faceCount , faceIndexCountArray , faceMaterialIndexArray , vertexArray , vertexIndexArray , normalArray , uvArray ) # normal are completly bogus in blender, just recalculate proper normals  #meshInfo.SmoothNormals (blenderMesh.degr) meshInfo . SmoothNormals ( 30 )