2
0
Эх сурвалжийг харах

aiIsExtensionSupported crash fix

markcwm 8 жил өмнө
parent
commit
0d941862a2

+ 556 - 557
assimp.mod/types.bmx

@@ -1,557 +1,556 @@
-' types.bmx
-
-' mesh bounds values, used in FitAnimMesh()
-Type aiMinMax3D
-
-	Field maxx#, maxy#, maxz#
-	Field minx#, miny#, minz#
-	
-End Type
-
-' assimp mesh loader
-Type aiLoader
-
-	Function LoadMesh:TMesh(filename:String, parent:TEntity=Null, flags:Int = -1)
-	
-		Local scene:aiScene = New aiScene
-		
-		' removed, caused crash
-		'aiSetImportPropertyInteger(aipropertystore?, AI_CONFIG_PP_SBP_REMOVE, aiPrimitiveType_LINE | aiPrimitiveType_POINT )
-		
-		Select flags
-			Case -1 ' smooth shaded
-				flags = aiProcess_Triangulate | ..
-				aiProcess_GenSmoothNormals | ..
-				aiProcess_SortByPType | ..
-				aiProcess_PreTransformVertices | ..
-				aiProcess_ConvertToLeftHanded | ..
-				aiProcess_JoinIdenticalVertices
-			Case -2 ' flat shaded
-				flags = aiProcess_Triangulate | ..
-				aiProcess_GenNormals | ..
-				aiProcess_SortByPType | ..
-				aiProcess_PreTransformVertices | ..
-				aiProcess_ConvertToLeftHanded | ..
-				aiProcess_CalcTangentSpace | ..
-				aiProcess_FindDegenerates | ..
-				aiProcess_FindInvalidData | ..
-				aiProcess_GenUVCoords | ..
-				aiProcess_TransformUVCoords
-		EndSelect
-		
-		If scene.ImportFile(filename, flags)
-		
-			' Make brushes
-			
-			Local brushes:TBrush[scene.NumMaterials]
-			Local i:Int
-			
-			For Local mat:aiMaterial = EachIn scene.Materials
-			
-				DebugLog " "
-				DebugLog " ----    Material Name " + mat.GetMaterialName()
-				DebugLog " ----    mat.IsTwoSided() " + mat.IsTwoSided()
-				DebugLog " ----    mat.GetShininess() " + mat.GetShininess()
-				DebugLog " ----    mat.GetAlpha() " + mat.GetAlpha()
-				
-				'Rem
-				Local names:String[] = mat.GetPropertyNames()
-				
-				For Local s:String = EachIn names
-				
-					DebugLog "Property: *" + s + "*"
-					'DebugLog "matbase " + mat.Properties[?].GetFloatValue(s)
-					
-					Select s
-						Case AI_MATKEY_TEXTURE_BASE
-							DebugLog "matbase " +  mat.GetMaterialString(s)
-					End Select
-					
-				Next
-				'EndRem
-				
-				Local DiffuseColors:Float[] = mat.GetMaterialColor(AI_MATKEY_COLOR_DIFFUSE)	
-				
-				brushes[i] = CreateBrush(mat.GetDiffuseRed() * 255,mat.GetDiffuseGreen() * 255,mat.GetDiffuseBlue() * 255)
-				
-				' seems alpha comes in different places denpending om model format.
-				' seems wavefront obj alpha doesn't load
-				'BrushAlpha brushes[i],mat.GetAlpha()' * mat.GetDiffuseAlpha() (might be 0 so not good)
-				
-				BrushShininess brushes[i],mat.GetShininess()
-				
-				If mat.IsTwoSided()
-					'BrushFX brushes[i], 16
-				EndIf
-				
-				Local texFilename:String = mat.GetMaterialTexture()
-				
-				DebugLog "TEXTURE filename: " + texFilename
-				
-				If Len(texFilename)
-				
-					' remove currentdir prefix, but leave relative subfolder path intact
-					If  texFilename[..2] = ".\" Or texFilename[..2] = "./"
-						texFilename = texFilename[2..]
-					EndIf
-					
-					'assume the texture names are stored relative to the file
-					texFilename  = ExtractDir(filename) + "/" + texFilename
-					
-					If Not FileType(texFilename)
-						texFilename = ExtractDir(filename) + "/" + StripDir(texFilename)
-					EndIf
-					
-					DebugLog texFilename
-					
-					If FileType(texFilename)
-						'DebugStop
-						Local tex:TTexture=LoadTexture(texFilename)
-						
-						If tex
-							BrushTexture brushes[i], tex	
-						EndIf
-						
-					EndIf
-					
-				EndIf
-				
-				i:+ 1
-			Next
-			
-			' Make mesh - was ProccessAiNodeAndChildren()
-			
-			Local mesh:TMesh = CreateMesh(parent)
-			
-			DebugLog "scene.numMeshes: " + scene.numMeshes
-			
-			For Local m:aiMesh = EachIn scene.meshes
-			
-				Local surf:TSurface = CreateSurface(mesh, brushes[m.MaterialIndex])
-				
-				' vertices, normals and texturecoords - was MakeAiMesh()
-				
-				For i = 0 To m.NumVertices - 1
-				
-					'DebugLog  m.VertexX(i) + ", " + m.VertexY(i) + ", " + m.VertexZ(i)
-					
-					Local index:Int
-					index = AddVertex(surf, m.VertexX(i), m.VertexY(i), m.VertexZ(i))
-					
-					If m.HasNormals()
-						VertexNormal(surf, index, m.VertexNX(i), m.VertexNY(i), m.VertexNZ(i))
-					EndIf
-					
-					If m.HasTextureCoords(0)
-						VertexTexCoords(surf, index, m.VertexU(i), m.VertexV(i), m.VertexW(i))
-					EndIf
-					
-					If m.HasTextureCoords(1)
-						VertexTexCoords(surf, index, m.VertexU(i, 1), m.VertexV(i, 1), m.VertexW(i, 1))
-					EndIf
-					
-				Next
-				
-				For i = 0 To m.NumFaces - 1
-				
-					'DebugLog  m.TriangleVertex(i,0) + " , "  + m.TriangleVertex(i,1) + " , "  + m.TriangleVertex(i,2)
-					
-					' this check is only in because assimp seems to be returning out of range indexes
-					' on rare occasions with aiProcess_PreTransformVertices on.
-					Local validIndex:Int = True
-					
-					' added 0.36 - fix for MAV when garbage index values < zero
-					'Rem
-					If m.TriangleVertex(i,0) < 0 Then validIndex = False
-					If m.TriangleVertex(i,1) < 0 Then validIndex = False
-					If m.TriangleVertex(i,2) < 0 Then validIndex = False
-					
-					If m.TriangleVertex(i,0) >=m.NumVertices Then validIndex = False
-					If m.TriangleVertex(i,1) >=m.NumVertices Then validIndex = False
-					If m.TriangleVertex(i,2) >=m.NumVertices Then validIndex = False
-					'EndRem
-					
-					If validIndex
-						AddTriangle(surf, m.TriangleVertex(i, 0), m.TriangleVertex(i, 1), m.TriangleVertex(i, 2))
-					Else
-						DebugLog "TriangleVertex index was out of range for triangle num: " + i
-						DebugLog "indexes: "+m.TriangleVertex(i, 0)+", "+m.TriangleVertex(i, 1)+", "+m.TriangleVertex(i, 2)
-					EndIf
-					
-				Next
-				
-			Next
-			
-			Return mesh	
-			
-		Else
-		
-			DebugLog "nothing imported"
-			
-		EndIf
-		
-		Scene.ReleaseImport()
-		
-	End Function
-		
-End Type
-
-Rem
- Non-essential helper functions which apply to all children of an entity:
- CountTrianglesAll:Int( mesh:TMesh )
- RotateEntityAxisAll ent:TEntity, axis:Int
- UpdateNormalsAll ent:TEntity
- FlipMeshAll ent:TEntity
- ScaleMeshAxisAll ent:TEntity, axis:Int
-EndRem
-Type aiHelper
-
-	Global mm:aiMinMax3D=New aiMinMax3D
-	
-	Function CountTrianglesAll:Int(ent:TEntity)
-	
-		If ent = Null Then Return 0
-		Local all%
-		
-		For Local id% = 1 To CountSurfaces(TMesh(ent))
-			Local surf:TSurface = GetSurface(TMesh(ent), id)
-			Local nt% = CountTriangles(surf)
-			all:+ nt
-		Next
-		
-		Return all
-		
-	End Function
-	
-	' renamed from FlipRot (applied to all children of an entity)
-	Function RotateEntityAxisAll(ent:TEntity, axis:Int)
-	
-		If ent = Null Then Return
-		Local cc:Int = CountChildren(ent)
-		
-		If cc
-			For Local id:Int = 1 To cc
-				RotateEntityAxisAll(GetChild(ent, id), axis)
-			Next
-		EndIf
-		
-		Local rotX:Float = EntityPitch(ent)
-		Local rotY:Float = EntityYaw(ent)
-		Local rotZ:Float = EntityRoll(ent)
-		
-		Select axis
-			Case 1
-				rotX = -rotX
-			Case 2
-				rotY = -rotY
-			Case 3
-				rotZ = -rotZ
-		End Select
-		
-		RotateEntity ent, rotX, rotY, rotZ
-		
-	End Function
-	
-	' dirty x model fixer - renamed from UpdateEntityNormals (applied to all children of an entity)
-	Function UpdateNormalsAll(ent:TEntity)
-	
-		If ent = Null Then Return
-		Local childcount:Int = CountChildren(ent)
-		
-		If childcount
-			For Local id:Int = 1 To childcount
-				UpdateNormalsAll(GetChild(ent, id))
-			Next
-		EndIf
-		
-		If EntityClass(ent) = "Mesh"
-			UpdateNormals TMesh(ent)
-		EndIf
-		
-	End Function
-	
-	' renamed from FlipEntity (applied to all children of an entity)
-	Function FlipMeshAll(ent:TEntity)
-	
-		If ent = Null Then Return
-		Local childcount:Int = CountChildren(ent)
-		
-		If childcount
-			For Local id:Int = 1 To childcount
-				FlipMeshAll(GetChild(ent, id))
-			Next
-		EndIf
-		
-		If EntityClass(ent) = "Mesh"
-			FlipMesh TMesh(ent)
-		EndIf
-		
-	End Function
-	
-	' dirty x model fixer - renamed from ScaleFlipEntity (applied to all children of an entity)
-	Function ScaleMeshAxisAll(ent:TEntity, axis:Int)
-	
-		If ent = Null Then Return
-		Local childcount:Int = CountChildren(ent)
-		
-		If childcount
-			For Local id:Int = 1 To childcount
-				ScaleMeshAxisAll(GetChild(ent, id), axis)
-			Next
-		EndIf
-		
-		Local scaleX:Float = 1
-		Local scaleY:Float = 1
-		Local scaleZ:Float = 1
-		
-		Select axis
-			Case 1
-				scaleX = -scaleX
-			Case 2
-				scaleY = -scaleY		
-			Case 3
-				scaleZ = -scaleZ
-		End Select
-		
-		If EntityClass(ent) = "Mesh"
-			ScaleMesh TMesh(ent), scaleX, scaleY, scaleZ
-		EndIf
-		
-	End Function
-	
-	' uses doFitAnimMesh() and getAnimMeshMinMax()
-	Function FitAnimMesh(m:TEntity, x#, y#, z#, w#, h#, d#, uniform:Int=False)
-	
-		Local scalefactor#
-		Local xoff#, yoff#, zoff#
-		Local gFactor# = 100000.0
-		
-		mm.maxx = -100000
-		mm.maxy = -100000
-		mm.maxz = -100000
-		
-		mm.minx = 100000
-		mm.miny = 100000
-		mm.minz = 100000
-		
-		getAnimMeshMinMax(m, mm)
-		
-		'DebugLog "getAnimMeshMinMax "+String(mm.minx).ToInt()+", "+String(mm.miny).ToInt()+", "+..
-		' String(mm.minz).ToInt()+", "+String(mm.maxx).ToInt()+", "+String(mm.Maxy).ToInt()+", "+String(mm.maxz).ToInt()	
-		
-		Local xspan# = (mm.maxx - mm.minx)
-		Local yspan# = (mm.maxy - mm.miny)
-		Local zspan# = (mm.maxz - mm.minz)
-		
-		Local xscale# = w / xspan
-		Local yscale# = h / yspan
-		Local zscale# = d / zspan
-		
-		'DebugLog "Scales: " + xscale + ", " +  yscale + ", " + zscale 
-		
-		If uniform
-			If xscale < yscale
-				yscale = xscale
-			Else
-				xscale = yscale
-			EndIf
-			
-			If zscale < xscale
-				xscale = zscale
-				yscale = zscale			
-			Else
-				zscale = xscale
-			EndIf
-		EndIf	
-		
-		'DebugLog "Scales: " + String(xscale).ToInt() + ", " + String(yscale).ToInt() + ", " + String(zscale).ToInt()
-		
-		xoff# = -mm.minx * xscale - (xspan / 2.0) * xscale + x + w / 2.0
-		yoff# = -mm.miny * yscale - (yspan / 2.0) * yscale + y + h / 2.0
-		zoff# = -mm.minz * zscale - (zspan / 2.0) * zscale + z + d / 2.0
-		
-		doFitAnimMesh(m, xoff, yoff, zoff, xscale, yscale, zscale)
-'		Delete mm
-		
-	End Function
-	
-	' internal functions for FitAnimMesh
-	
-	' used in FitAnimMesh()
-	Function doFitAnimMesh(m:TEntity, xoff#, yoff#, zoff#, xscale#, yscale#, zscale#)
-	
-		Local c:Int
-		Local childcount:Int = CountChildren(m)
-		
-		If childcount
-			For c = 1 To childcount
-				'myFitEntity(m, xoff#, yoff#, zoff#, xscale#, yscale#, zscale#)
-				doFitAnimMesh(GetChild(m, c), xoff#, yoff#, zoff#, xscale#, yscale#, zscale#)
-			Next
-		EndIf
-		
-		myFitEntity(m, xoff#, yoff#, zoff#, xscale#, yscale#, zscale#)
-		
-	End Function
-	
-Rem
-	Function doFitAnimMeshOLD(m:TEntity, xoff#, yoff#, zoff#, xscale#, yscale#, zscale#)
-	
-		Local c:Int
-		Local childcount:Int = CountChildren(m)
-		
-		If childcount
-			For c = 1 To childcount
-				myFitEntity(m, xoff#, yoff#, zoff#, xscale#, yscale#, zscale#)
-				doFitAnimMesh(GetChild(m, c), xoff#, yoff#, zoff#, xscale#, yscale#, zscale#)
-			Next
-		Else
-			myFitEntity(m, xoff#, yoff#, zoff#, xscale#, yscale#, zscale#)
-		EndIf
-		
-	End Function
-EndRem
-	
-	' used in doFitAnimMesh()
-	Function myFitEntity(e:TEntity, xoff#, yoff#, zoff#, xscale#, yscale#, zscale#)
-	
-		Local x#, y#, z#
-		Local x2#, y2#, z2#
-		Local txoff#, tyoff#, tzoff#
-		
-		TFormPoint(0, 0, 0, e, Null)
-		
-		x2 = TFormedX()
-		y2 = TFormedY()
-		z2 = TFormedZ()
-		
-		TFormPoint(x2 + xoff, y2 + yoff, z2 + zoff, Null, e)
-		
-		txoff = TFormedX() 
-		tyoff = TFormedY()
-		tzoff = TFormedZ()
-		
-		Local m:TMesh = TMesh(e)
-		
-		If m 'only if it's a mesh
-		
-			For Local sc:Int = 1 To CountSurfaces(m)
-				Local s:TSurface = GetSurface(m, sc)
-				
-				For Local vc:Int = 0 To CountVertices(s) - 1
-					x = VertexX(s, vc)
-					y = VertexY(s, vc)
-					z = VertexZ(s, vc)
-					
-					VertexCoords s, vc, x * xscale + txoff,y * yscale + tyoff,z * zscale + tzoff
-				Next
-				
-			Next
-			
-		EndIf
-		
-		PositionEntity(e, EntityX(e) * xscale, EntityY(e) * yscale, EntityZ(e) * zscale)
-		
-	End Function
-	
-	' used in FitAnimMesh()
-	Function getAnimMeshMinMax#(m:TEntity, mm:aiMinMax3D)
-	
-		Local c:Int
-		Local wfac#, hfac#, dfac#
-		'Local tfactor
-		Local cc:Int = CountChildren(m)
-		
-		If EntityClass(m) = "Mesh"
-			'If m.class = "Mesh" 
-			mm = getEntityMinMax(TMesh(m), mm)
-			'Else
-			'	DebugLog "Class -- " + m.class
-			'Endif
-		EndIf
-		
-		If cc
-			For c = 1 To cc
-				getAnimMeshMinMax(GetChild(m, c), mm)
-			Next
-		EndIf
-		
-	End Function
-	
-	' used in getAnimMeshMinMax()
-	Function getEntityMinMax:aiMinMax3D(m:TMesh, mm:aiMinMax3D)
-	
-		Local x#, y#, z#
-		Local sc:Int
-		Local vc:Int
-		Local s:TSurface	
-		
-		For sc = 1 To CountSurfaces(m)
-			s = GetSurface(m, sc)	
-			
-			For vc = 0 To CountVertices(s) - 1
-				TFormPoint(VertexX(s, vc), VertexY(s, vc), VertexZ(s, vc), m, Null)
-				
-				x = TFormedX()
-				y = TFormedY()
-				z = TFormedZ()
-				
-				If x < mm.minx Then mm.minx = x
-				If y < mm.miny Then mm.miny = y
-				If z < mm.minz Then mm.minz = z				
-				
-				If x > mm.maxx Then mm.maxx = x
-				If y > mm.maxy Then mm.maxy = y
-				If z > mm.maxz Then mm.maxz = z
-			Next
-			
-		Next
-		
-		Return mm
-		
-	End Function
-	
-	' Creates a list of valid files to load
-	Function EnumFiles(list:TList, dir:String, skipExt:TList)
-	
-		Local folder:Byte Ptr = ReadDir(dir)
-		Local file:String
-		
-		Repeat
-			file = NextFile(folder)
-			
-			If (file <> ".") And (file <> "..") And (file)
-			
-				Local fullPath:String = RealPath(dir + "/" + file)
-				
-				If FileType(fullPath) = FILETYPE_DIR
-				
-					'DebugLog file
-					'If(dir[0]) <> "."
-						EnumFiles(list, fullPath, skipExt)
-					'EndIf
-					
-				Else
-				
-					DebugLog "fullpath: " + fullPath
-					
-					If aiIsExtensionSupported(Lower(ExtractExt(fullPath)))
-					
-						'DebugStop
-						If Not skipExt.Contains(Lower(ExtractExt(fullPath))) ' Filter out nff for now
-							' assimp author is looking into a fix
-							list.AddLast(fullPath)
-						EndIf
-						
-					EndIf
-					
-				EndIf
-				
-			EndIf
-			
-		Until file = Null
-		CloseDir folder
-		
-	End Function
-	
-End Type
+' types.bmx
+
+' mesh bounds values, used in FitAnimMesh()
+Type aiMinMax3D
+
+	Field maxx#, maxy#, maxz#
+	Field minx#, miny#, minz#
+	
+End Type
+
+' assimp mesh loader
+Type aiLoader
+
+	Function LoadMesh:TMesh(filename:String, parent:TEntity=Null, flags:Int = -1)
+	
+		Local scene:aiScene = New aiScene
+		
+		' removed, caused crash
+		'aiSetImportPropertyInteger(aipropertystore?, AI_CONFIG_PP_SBP_REMOVE, aiPrimitiveType_LINE | aiPrimitiveType_POINT )
+		
+		Select flags
+			Case -1 ' smooth shaded
+				flags = aiProcess_Triangulate | ..
+				aiProcess_GenSmoothNormals | ..
+				aiProcess_SortByPType | ..
+				aiProcess_PreTransformVertices | ..
+				aiProcess_ConvertToLeftHanded | ..
+				aiProcess_JoinIdenticalVertices
+			Case -2 ' flat shaded
+				flags = aiProcess_Triangulate | ..
+				aiProcess_GenNormals | ..
+				aiProcess_SortByPType | ..
+				aiProcess_PreTransformVertices | ..
+				aiProcess_ConvertToLeftHanded | ..
+				aiProcess_CalcTangentSpace | ..
+				aiProcess_FindDegenerates | ..
+				aiProcess_FindInvalidData | ..
+				aiProcess_GenUVCoords | ..
+				aiProcess_TransformUVCoords
+		EndSelect
+		
+		If scene.ImportFile(filename, flags)
+		
+			' Make brushes
+			
+			Local brushes:TBrush[scene.NumMaterials]
+			Local i:Int
+			
+			For Local mat:aiMaterial = EachIn scene.Materials
+			
+				DebugLog " "
+				DebugLog " ----    Material Name " + mat.GetMaterialName()
+				DebugLog " ----    mat.IsTwoSided() " + mat.IsTwoSided()
+				DebugLog " ----    mat.GetShininess() " + mat.GetShininess()
+				DebugLog " ----    mat.GetAlpha() " + mat.GetAlpha()
+				
+				'Rem
+				Local names:String[] = mat.GetPropertyNames()
+				
+				For Local s:String = EachIn names
+				
+					DebugLog "Property: *" + s + "*"
+					'DebugLog "matbase " + mat.Properties[?].GetFloatValue(s)
+					
+					Select s
+						Case AI_MATKEY_TEXTURE_BASE
+							DebugLog "matbase " +  mat.GetMaterialString(s)
+					End Select
+					
+				Next
+				'EndRem
+				
+				Local DiffuseColors:Float[] = mat.GetMaterialColor(AI_MATKEY_COLOR_DIFFUSE)	
+				
+				brushes[i] = CreateBrush(mat.GetDiffuseRed() * 255,mat.GetDiffuseGreen() * 255,mat.GetDiffuseBlue() * 255)
+				
+				' seems alpha comes in different places denpending om model format.
+				' seems wavefront obj alpha doesn't load
+				'BrushAlpha brushes[i],mat.GetAlpha()' * mat.GetDiffuseAlpha() (might be 0 so not good)
+				
+				BrushShininess brushes[i],mat.GetShininess()
+				
+				If mat.IsTwoSided()
+					'BrushFX brushes[i], 16
+				EndIf
+				
+				Local texFilename:String = mat.GetMaterialTexture()
+				
+				DebugLog "TEXTURE filename: " + texFilename
+				
+				If Len(texFilename)
+				
+					' remove currentdir prefix, but leave relative subfolder path intact
+					If  texFilename[..2] = ".\" Or texFilename[..2] = "./"
+						texFilename = texFilename[2..]
+					EndIf
+					
+					'assume the texture names are stored relative to the file
+					texFilename  = ExtractDir(filename) + "/" + texFilename
+					
+					If Not FileType(texFilename)
+						texFilename = ExtractDir(filename) + "/" + StripDir(texFilename)
+					EndIf
+					
+					DebugLog texFilename
+					
+					If FileType(texFilename)
+						'DebugStop
+						Local tex:TTexture=LoadTexture(texFilename)
+						
+						If tex
+							BrushTexture brushes[i], tex	
+						EndIf
+						
+					EndIf
+					
+				EndIf
+				
+				i:+ 1
+			Next
+			
+			' Make mesh - was ProccessAiNodeAndChildren()
+			
+			Local mesh:TMesh = CreateMesh(parent)
+			
+			DebugLog "scene.numMeshes: " + scene.numMeshes
+			
+			For Local m:aiMesh = EachIn scene.meshes
+			
+				Local surf:TSurface = CreateSurface(mesh, brushes[m.MaterialIndex])
+				
+				' vertices, normals and texturecoords - was MakeAiMesh()
+				
+				For i = 0 To m.NumVertices - 1
+				
+					'DebugLog  m.VertexX(i) + ", " + m.VertexY(i) + ", " + m.VertexZ(i)
+					
+					Local index:Int
+					index = AddVertex(surf, m.VertexX(i), m.VertexY(i), m.VertexZ(i))
+					
+					If m.HasNormals()
+						VertexNormal(surf, index, m.VertexNX(i), m.VertexNY(i), m.VertexNZ(i))
+					EndIf
+					
+					If m.HasTextureCoords(0)
+						VertexTexCoords(surf, index, m.VertexU(i), m.VertexV(i), m.VertexW(i))
+					EndIf
+					
+					If m.HasTextureCoords(1)
+						VertexTexCoords(surf, index, m.VertexU(i, 1), m.VertexV(i, 1), m.VertexW(i, 1))
+					EndIf
+					
+				Next
+				
+				For i = 0 To m.NumFaces - 1
+				
+					'DebugLog  m.TriangleVertex(i,0) + " , "  + m.TriangleVertex(i,1) + " , "  + m.TriangleVertex(i,2)
+					
+					' this check is only in because assimp seems to be returning out of range indexes
+					' on rare occasions with aiProcess_PreTransformVertices on.
+					Local validIndex:Int = True
+					
+					' added 0.36 - fix for MAV when garbage index values < zero
+					'Rem
+					If m.TriangleVertex(i,0) < 0 Then validIndex = False
+					If m.TriangleVertex(i,1) < 0 Then validIndex = False
+					If m.TriangleVertex(i,2) < 0 Then validIndex = False
+					
+					If m.TriangleVertex(i,0) >=m.NumVertices Then validIndex = False
+					If m.TriangleVertex(i,1) >=m.NumVertices Then validIndex = False
+					If m.TriangleVertex(i,2) >=m.NumVertices Then validIndex = False
+					'EndRem
+					
+					If validIndex
+						AddTriangle(surf, m.TriangleVertex(i, 0), m.TriangleVertex(i, 1), m.TriangleVertex(i, 2))
+					Else
+						DebugLog "TriangleVertex index was out of range for triangle num: " + i
+						DebugLog "indexes: "+m.TriangleVertex(i, 0)+", "+m.TriangleVertex(i, 1)+", "+m.TriangleVertex(i, 2)
+					EndIf
+					
+				Next
+				
+			Next
+			
+			Return mesh	
+			
+		Else
+		
+			DebugLog "nothing imported"
+			
+		EndIf
+		
+		Scene.ReleaseImport()
+		
+	End Function
+		
+End Type
+
+Rem
+ Non-essential helper functions which apply to all children of an entity:
+ CountTrianglesAll:Int( mesh:TMesh )
+ RotateEntityAxisAll ent:TEntity, axis:Int
+ UpdateNormalsAll ent:TEntity
+ FlipMeshAll ent:TEntity
+ ScaleMeshAxisAll ent:TEntity, axis:Int
+EndRem
+Type aiHelper
+
+	Global mm:aiMinMax3D=New aiMinMax3D
+	
+	Function CountTrianglesAll:Int(ent:TEntity)
+	
+		If ent = Null Then Return 0
+		Local all%
+		
+		For Local id% = 1 To CountSurfaces(TMesh(ent))
+			Local surf:TSurface = GetSurface(TMesh(ent), id)
+			Local nt% = CountTriangles(surf)
+			all:+ nt
+		Next
+		
+		Return all
+		
+	End Function
+	
+	' renamed from FlipRot (applied to all children of an entity)
+	Function RotateEntityAxisAll(ent:TEntity, axis:Int)
+	
+		If ent = Null Then Return
+		Local cc:Int = CountChildren(ent)
+		
+		If cc
+			For Local id:Int = 1 To cc
+				RotateEntityAxisAll(GetChild(ent, id), axis)
+			Next
+		EndIf
+		
+		Local rotX:Float = EntityPitch(ent)
+		Local rotY:Float = EntityYaw(ent)
+		Local rotZ:Float = EntityRoll(ent)
+		
+		Select axis
+			Case 1
+				rotX = -rotX
+			Case 2
+				rotY = -rotY
+			Case 3
+				rotZ = -rotZ
+		End Select
+		
+		RotateEntity ent, rotX, rotY, rotZ
+		
+	End Function
+	
+	' dirty x model fixer - renamed from UpdateEntityNormals (applied to all children of an entity)
+	Function UpdateNormalsAll(ent:TEntity)
+	
+		If ent = Null Then Return
+		Local childcount:Int = CountChildren(ent)
+		
+		If childcount
+			For Local id:Int = 1 To childcount
+				UpdateNormalsAll(GetChild(ent, id))
+			Next
+		EndIf
+		
+		If EntityClass(ent) = "Mesh"
+			UpdateNormals TMesh(ent)
+		EndIf
+		
+	End Function
+	
+	' renamed from FlipEntity (applied to all children of an entity)
+	Function FlipMeshAll(ent:TEntity)
+	
+		If ent = Null Then Return
+		Local childcount:Int = CountChildren(ent)
+		
+		If childcount
+			For Local id:Int = 1 To childcount
+				FlipMeshAll(GetChild(ent, id))
+			Next
+		EndIf
+		
+		If EntityClass(ent) = "Mesh"
+			FlipMesh TMesh(ent)
+		EndIf
+		
+	End Function
+	
+	' dirty x model fixer - renamed from ScaleFlipEntity (applied to all children of an entity)
+	Function ScaleMeshAxisAll(ent:TEntity, axis:Int)
+	
+		If ent = Null Then Return
+		Local childcount:Int = CountChildren(ent)
+		
+		If childcount
+			For Local id:Int = 1 To childcount
+				ScaleMeshAxisAll(GetChild(ent, id), axis)
+			Next
+		EndIf
+		
+		Local scaleX:Float = 1
+		Local scaleY:Float = 1
+		Local scaleZ:Float = 1
+		
+		Select axis
+			Case 1
+				scaleX = -scaleX
+			Case 2
+				scaleY = -scaleY		
+			Case 3
+				scaleZ = -scaleZ
+		End Select
+		
+		If EntityClass(ent) = "Mesh"
+			ScaleMesh TMesh(ent), scaleX, scaleY, scaleZ
+		EndIf
+		
+	End Function
+	
+	' uses doFitAnimMesh() and getAnimMeshMinMax()
+	Function FitAnimMesh(m:TEntity, x#, y#, z#, w#, h#, d#, uniform:Int=False)
+	
+		Local scalefactor#
+		Local xoff#, yoff#, zoff#
+		Local gFactor# = 100000.0
+		
+		mm.maxx = -100000
+		mm.maxy = -100000
+		mm.maxz = -100000
+		
+		mm.minx = 100000
+		mm.miny = 100000
+		mm.minz = 100000
+		
+		getAnimMeshMinMax(m, mm)
+		
+		'DebugLog "getAnimMeshMinMax "+String(mm.minx).ToInt()+", "+String(mm.miny).ToInt()+", "+..
+		' String(mm.minz).ToInt()+", "+String(mm.maxx).ToInt()+", "+String(mm.Maxy).ToInt()+", "+String(mm.maxz).ToInt()	
+		
+		Local xspan# = (mm.maxx - mm.minx)
+		Local yspan# = (mm.maxy - mm.miny)
+		Local zspan# = (mm.maxz - mm.minz)
+		
+		Local xscale# = w / xspan
+		Local yscale# = h / yspan
+		Local zscale# = d / zspan
+		
+		'DebugLog "Scales: " + xscale + ", " +  yscale + ", " + zscale 
+		
+		If uniform
+			If xscale < yscale
+				yscale = xscale
+			Else
+				xscale = yscale
+			EndIf
+			
+			If zscale < xscale
+				xscale = zscale
+				yscale = zscale			
+			Else
+				zscale = xscale
+			EndIf
+		EndIf	
+		
+		'DebugLog "Scales: " + String(xscale).ToInt() + ", " + String(yscale).ToInt() + ", " + String(zscale).ToInt()
+		
+		xoff# = -mm.minx * xscale - (xspan / 2.0) * xscale + x + w / 2.0
+		yoff# = -mm.miny * yscale - (yspan / 2.0) * yscale + y + h / 2.0
+		zoff# = -mm.minz * zscale - (zspan / 2.0) * zscale + z + d / 2.0
+		
+		doFitAnimMesh(m, xoff, yoff, zoff, xscale, yscale, zscale)
+'		Delete mm
+		
+	End Function
+	
+	' internal functions for FitAnimMesh
+	
+	' used in FitAnimMesh()
+	Function doFitAnimMesh(m:TEntity, xoff#, yoff#, zoff#, xscale#, yscale#, zscale#)
+	
+		Local c:Int
+		Local childcount:Int = CountChildren(m)
+		
+		If childcount
+			For c = 1 To childcount
+				'myFitEntity(m, xoff#, yoff#, zoff#, xscale#, yscale#, zscale#)
+				doFitAnimMesh(GetChild(m, c), xoff#, yoff#, zoff#, xscale#, yscale#, zscale#)
+			Next
+		EndIf
+		
+		myFitEntity(m, xoff#, yoff#, zoff#, xscale#, yscale#, zscale#)
+		
+	End Function
+	
+Rem
+	Function doFitAnimMeshOLD(m:TEntity, xoff#, yoff#, zoff#, xscale#, yscale#, zscale#)
+	
+		Local c:Int
+		Local childcount:Int = CountChildren(m)
+		
+		If childcount
+			For c = 1 To childcount
+				myFitEntity(m, xoff#, yoff#, zoff#, xscale#, yscale#, zscale#)
+				doFitAnimMesh(GetChild(m, c), xoff#, yoff#, zoff#, xscale#, yscale#, zscale#)
+			Next
+		Else
+			myFitEntity(m, xoff#, yoff#, zoff#, xscale#, yscale#, zscale#)
+		EndIf
+		
+	End Function
+EndRem
+	
+	' used in doFitAnimMesh()
+	Function myFitEntity(e:TEntity, xoff#, yoff#, zoff#, xscale#, yscale#, zscale#)
+	
+		Local x#, y#, z#
+		Local x2#, y2#, z2#
+		Local txoff#, tyoff#, tzoff#
+		
+		TFormPoint(0, 0, 0, e, Null)
+		
+		x2 = TFormedX()
+		y2 = TFormedY()
+		z2 = TFormedZ()
+		
+		TFormPoint(x2 + xoff, y2 + yoff, z2 + zoff, Null, e)
+		
+		txoff = TFormedX() 
+		tyoff = TFormedY()
+		tzoff = TFormedZ()
+		
+		Local m:TMesh = TMesh(e)
+		
+		If m 'only if it's a mesh
+		
+			For Local sc:Int = 1 To CountSurfaces(m)
+				Local s:TSurface = GetSurface(m, sc)
+				
+				For Local vc:Int = 0 To CountVertices(s) - 1
+					x = VertexX(s, vc)
+					y = VertexY(s, vc)
+					z = VertexZ(s, vc)
+					
+					VertexCoords s, vc, x * xscale + txoff,y * yscale + tyoff,z * zscale + tzoff
+				Next
+				
+			Next
+			
+		EndIf
+		
+		PositionEntity(e, EntityX(e) * xscale, EntityY(e) * yscale, EntityZ(e) * zscale)
+		
+	End Function
+	
+	' used in FitAnimMesh()
+	Function getAnimMeshMinMax#(m:TEntity, mm:aiMinMax3D)
+	
+		Local c:Int
+		Local wfac#, hfac#, dfac#
+		'Local tfactor
+		Local cc:Int = CountChildren(m)
+		
+		If EntityClass(m) = "Mesh"
+			'If m.class = "Mesh" 
+			mm = getEntityMinMax(TMesh(m), mm)
+			'Else
+			'	DebugLog "Class -- " + m.class
+			'Endif
+		EndIf
+		
+		If cc
+			For c = 1 To cc
+				getAnimMeshMinMax(GetChild(m, c), mm)
+			Next
+		EndIf
+		
+	End Function
+	
+	' used in getAnimMeshMinMax()
+	Function getEntityMinMax:aiMinMax3D(m:TMesh, mm:aiMinMax3D)
+	
+		Local x#, y#, z#
+		Local sc:Int
+		Local vc:Int
+		Local s:TSurface	
+		
+		For sc = 1 To CountSurfaces(m)
+			s = GetSurface(m, sc)	
+			
+			For vc = 0 To CountVertices(s) - 1
+				TFormPoint(VertexX(s, vc), VertexY(s, vc), VertexZ(s, vc), m, Null)
+				
+				x = TFormedX()
+				y = TFormedY()
+				z = TFormedZ()
+				
+				If x < mm.minx Then mm.minx = x
+				If y < mm.miny Then mm.miny = y
+				If z < mm.minz Then mm.minz = z				
+				
+				If x > mm.maxx Then mm.maxx = x
+				If y > mm.maxy Then mm.maxy = y
+				If z > mm.maxz Then mm.maxz = z
+			Next
+			
+		Next
+		
+		Return mm
+		
+	End Function
+	
+	' Creates a list of valid files to load
+	Function EnumFiles(list:TList, dir:String, skipExt:TList)
+	
+		Local folder:Byte Ptr = ReadDir(dir)
+		Local file:String
+		
+		DebugLog "dir: " + dir
+		
+		Repeat
+			file = NextFile(folder)
+			
+			If (file <> ".") And (file <> "..") And (file)
+			
+				Local fullPath:String = RealPath(dir + "/" + file)
+				
+				If FileType(fullPath) = FILETYPE_DIR
+				
+					DebugLog "file: " + file
+					
+					'If(dir[0]) <> "."
+						EnumFiles(list, fullPath, skipExt)
+					'EndIf
+				Else
+					DebugLog "fullPath: " + fullPath
+					
+					If aiIsExtensionSupported("." + Lower(ExtractExt(fullPath)))
+					
+						If Not skipExt.Contains(Lower(ExtractExt(fullPath))) ' Filter out formats
+							list.AddLast(fullPath)
+						EndIf
+						
+					EndIf
+					
+				EndIf
+				
+			EndIf
+			
+		Until file = Null
+		CloseDir folder
+		
+	End Function
+	
+End Type

+ 13 - 0
assimplib.mod/assimplib.bmx

@@ -34,3 +34,16 @@ Import "source.bmx"
 Import "common.bmx"
 
 Include "types.bmx"
+
+Function aiIsExtensionSupported:Int( pFile:String )
+	Return aiIsExtensionSupported_( pFile )
+End Function
+
+Rem
+ Memo:
+ aiSetImportPropertyInteger caused crash, was missing p parameter
+ changed aiGetMaterialTexture pMat:Int Ptr to :Byte Ptr
+ changed aiImportFile:Int Ptr to :Byte Ptr
+ added aiImportFileFromMemory
+ unwrapped aiIsExtensionSupported caused "double free or corruption" error in ubuntu x64
+EndRem

+ 263 - 270
assimplib.mod/common.bmx

@@ -1,270 +1,263 @@
-' common.bmx
-
-?ptr64
-Const PAD:Int=2 ' 64-bit padding
-Const ONE32:Int=0
-?Not ptr64
-Const PAD:Int=1
-Const ONE32:Int=1
-?
-
-' config.h
-
-' Input parameter to the #aiProcess_SortByPType step:
-' Specifies which primitive types are removed by the step
-Const AI_CONFIG_PP_SBP_REMOVE:String = "PP_SBP_REMOVE"
-
-' types.h
-
-' just for backwards compatibility, don't use these constants anymore
-Const AI_SUCCESS:Int = $0
-Const AI_FAILURE:Int = -$1
-Const AI_OUTOFMEMORY:Int = -$3
-Const AI_INVALIDFILE:Int = -$2
-Const AI_INVALIDARG:Int = -$4
-
-' Maximum dimension for strings, ASSIMP strings are zero terminated.
-Const MAXLEN:Int = 1024
-
-' postprocess.h
-
-' enum aiPostProcessSteps - Defines the flags for all possible post processing step
-
-Const aiProcess_CalcTangentSpace:Int = $1
-Const aiProcess_JoinIdenticalVertices:Int = $2
-Const aiProcess_MakeLeftHanded:Int = $4
-Const aiProcess_Triangulate:Int = $8
-Const aiProcess_RemoveComponent:Int = $10
-Const aiProcess_GenNormals:Int = $20
-Const aiProcess_GenSmoothNormals:Int = $40
-Const aiProcess_SplitLargeMeshes:Int = $80
-Const aiProcess_PreTransformVertices:Int = $100
-Const aiProcess_LimitBoneWeights:Int = $200
-Const aiProcess_ValidateDataStructure:Int = $400
-Const aiProcess_ImproveCacheLocality:Int = $800
-Const aiProcess_RemoveRedundantMaterials:Int = $1000
-Const aiProcess_FixInfacingNormals:Int = $2000
-Const aiProcess_SortByPType:Int = $8000
-Const aiProcess_FindDegenerates:Int = $10000
-Const aiProcess_FindInvalidData:Int = $20000
-Const aiProcess_GenUVCoords:Int = $40000
-Const aiProcess_TransformUVCoords:Int = $80000
-Const aiProcess_FindInstances:Int = $100000
-Const aiProcess_OptimizeMeshes:Int = $200000 
-Const aiProcess_OptimizeGraph:Int = $400000
-Const aiProcess_FlipUVs:Int = $800000
-Const aiProcess_FlipWindingOrder:Int = $1000000
-Const aiProcess_SplitByBoneCount:Int = $2000000
-Const aiProcess_Debone:Int = $4000000
-
-' Shortcut to match Direct3D conventions: left-handed geometry, top-left origin for UV coords and clockwise face order
-Const aiProcess_ConvertToLeftHanded:Int = aiProcess_MakeLeftHanded | aiProcess_FlipUVs | aiProcess_FlipWindingOrder
-
-' mesh.h
-
-' Limits. These values are required to match the settings Assimp was compiled against.
-
-' Supported number of vertex color sets per mesh
-Const AI_MAX_NUMBER_OF_COLOR_SETS:Int = $8
-
-' Supported number of texture coord sets (UV(W) channels) per mesh
-Const AI_MAX_NUMBER_OF_TEXTURECOORDS:Int = $8
-
-' enum aiPrimitiveType - Enumerates the types of geometric primitives supported by Assimp.
-Const aiPrimitiveType_POINT:Int = $1
-Const aiPrimitiveType_LINE:Int = $2
-Const aiPrimitiveType_TRIANGLE:Int = $4
-Const aiPrimitiveType_POLYGON:Int = $8
-
-' material.h
-
-' enum aiTextureOp
-' enum aiTextureMapMode
-' enum aiTextureMapping
-' enum aiTextureType - Defines the purpose of a texture 
-
-' Dummy value.
-' No texture, but the value to be used as 'texture semantic' (#aiMaterialProperty::mSemantic)
-' for all material properties *not* related to textures.
-Const aiTextureType_NONE:Int = $0
-
-' The texture is combined with the result of the diffuse lighting equation.
-Const aiTextureType_DIFFUSE:Int = $1
-
-' The texture is combined with the result of the specular lighting equation.
-Const aiTextureType_SPECULAR:Int = $2
-
-' The texture is combined with the result of the ambient lighting equation.
-Const aiTextureType_AMBIENT:Int = $3
-
-' The texture is added to the result of the lighting calculation.
-' It isn't influenced by incoming light.
-Const aiTextureType_EMISSIVE:Int = $4
-
-' The texture is a height map.
-' By convention, higher grey-scale values stand for higher elevations from the base height.
-Const aiTextureType_HEIGHT:Int = $5
-
-' The texture is a (tangent space) normal-map.
-' Again, there are several conventions for tangent-space normal maps.
-' Assimp does (intentionally) not differenciate here.
-Const aiTextureType_NORMALS:Int = $6
-
-' The texture defines the glossiness of the material.
-' The glossiness is in fact the exponent of the specular (phong) lighting equation.
-' Usually there is a conversion function defined to map the linear color values in the texture
-' to a suitable exponent. Have fun.
-Const aiTextureType_SHININESS:Int = $7
-
-' The texture defines per-pixel opacity.
-' Usually 'white' means opaque and 'black' means 'transparency'. Or quite the opposite. Have fun.
-Const aiTextureType_OPACITY:Int = $8
-
-' Displacement texture.
-' The exact purpose and format is application-dependent.
-' Higher color values stand for higher vertex displacements.
-Const aiTextureType_DISPLACEMENT:Int = $9
-
-' Lightmap texture (aka Ambient Occlusion).
-' Both 'Lightmaps' and dedicated 'ambient occlusion maps' are covered by this material property.
-' The texture contains a scaling value for the final color value of a pixel.
-' It's intensity is not affected by incoming light.
-Const aiTextureType_LIGHTMAP:Int = $A
-
-' Reflection texture.
-' Contains the color of a perfect mirror reflection.
-' Rarely used, almost never for real-time applications.
-Const aiTextureType_REFLECTION:Int = $B
-
-' Unknown texture.
-' A texture reference that does not match any of the definitions above is considered to be 'unknown'.
-' It is still imported, but is excluded from any further postprocessing.
-Const aiTextureType_UNKNOWN:Int = $C
-
-' enum aiShadingMode
-' enum aiTextureFlags
-' enum aiBlendMode
-' enum aiPropertyTypeInfo - material property buffer content type
-
-Const aiPTI_Float:Int = $1
-Const aiPTI_String:Int = $3
-Const aiPTI_Integer:Int = $4
-Const aiPTI_Buffer:Int = $5
-
-' a few of the many matkey constants
-
-Const AI_MATKEY_NAME:String = "?mat.name"
-Const AI_MATKEY_TWOSIDED:String = "$mat.twosided"
-Const AI_MATKEY_OPACITY:String = "$mat.opacity"
-Const AI_MATKEY_SHININESS:String = "$mat.shininess"
-
-Const AI_MATKEY_COLOR_DIFFUSE:String = "$clr.diffuse"
-Const AI_MATKEY_COLOR_AMBIENT:String = "$clr.ambient"
-Const AI_MATKEY_COLOR_SPECULAR:String = "$clr.specular"
-Const AI_MATKEY_COLOR_EMISSIVE:String = "$clr.emissive"
-Const AI_MATKEY_COLOR_TRANSPARENT:String = "$clr.transparent"
-Const AI_MATKEY_COLOR_REFLECTIVE:String = "$clr.reflective"
-
-' Pure key names for all texture-related properties
-
-Const AI_MATKEY_TEXTURE_BASE:String = "$tex.file"
-Const AI_MATKEY_UVWSRC_BASE:String = "$tex.uvwsrc"
-Const AI_MATKEY_TEXOP_BASE:String = "$tex.op"
-Const AI_MATKEY_MAPPING_BASE:String = "$tex.mapping"
-Const AI_MATKEY_TEXBLEND_BASE:String = "$tex.blend"
-Const AI_MATKEY_MAPPINGMODE_U_BASE:String = "$tex.mapmodeu"
-Const AI_MATKEY_MAPPINGMODE_V_BASE:String = "$tex.mapmodev"
-Const AI_MATKEY_TEXMAP_AXIS_BASE:String = "$tex.mapaxis"
-Const AI_MATKEY_UVTRANSFORM_BASE:String = "$tex.uvtrafo"
-Const AI_MATKEY_TEXFLAGS_BASE:String = "$tex.flags"
-
-Extern
-
-' Assimp.cpp
-
-Rem
-bbdoc: Reads the given file and returns its content.
-about: See <a href="http://assimp.sourceforge.net/lib_html/class_assimp_1_1_importer.html">Assimp.cpp</a>
-and <a href="http://assimp.sourceforge.net/lib_html/cimport_8h.html">cimport.h</a>.
-End Rem
-	Function aiImportFile:Byte Ptr( pFile$z, pFlags:Int ) = "aiImportFile"
-
-Rem
-bbdoc: Reads the given file from a given memory buffer.
-about: See <a href="http://assimp.sourceforge.net/lib_html/class_assimp_1_1_importer.html">Assimp.cpp</a>
-and <a href="http://assimp.sourceforge.net/lib_html/cimport_8h.html">cimport.h</a>.
-End Rem
-	Function aiImportFileFromMemory:Byte Ptr( pBuffer:Byte Ptr,pLength:Int,pFlags:Int,pHint$z ) = "aiImportFileFromMemory"
-
-Rem
-bbdoc: Releases all resources associated with the given import process.
-about: See <a href="http://assimp.sourceforge.net/lib_html/class_assimp_1_1_importer.html">Assimp.cpp</a>
-and <a href="http://assimp.sourceforge.net/lib_html/cimport_8h.html">cimport.h</a>.
-End Rem
-	Function aiReleaseImport( pScene:Byte Ptr ) = "aiReleaseImport"
-
-Rem
-bbdoc: Returns the error text of the last failed import process.
-about: See <a href="http://assimp.sourceforge.net/lib_html/class_assimp_1_1_importer.html">Assimp.cpp</a>
-and <a href="http://assimp.sourceforge.net/lib_html/cimport_8h.html">cimport.h</a>.
-End Rem
-	Function aiIsExtensionSupported:Int( pFile$z ) = "aiIsExtensionSupported"
-
-' MaterialSystem.cpp
-
-Rem
-bbdoc: Get a color (3 or 4 floats) from the material.
-about: See <a href="http://assimp.sourceforge.net/lib_html/structai_material.html">MaterialSystem.cpp</a>
-and <a href="http://assimp.sourceforge.net/lib_html/material_8h.html">material.h</a>.
-End Rem
-	Function aiGetMaterialColor:Int( pMat:Byte Ptr, pKey$z, iType:Int, ..
-				index:Int, pOut:Byte Ptr ) = "aiGetMaterialColor"
-				
-Rem
-bbdoc: Get a string from the material.
-about: See <a href="http://assimp.sourceforge.net/lib_html/structai_material.html">MaterialSystem.cpp</a>
-and <a href="http://assimp.sourceforge.net/lib_html/material_8h.html">material.h</a>.
-End Rem
-	Function aiGetMaterialString:Int( pMat:Byte Ptr, pKey$z, iType:Int, ..
-				index:Int, pOut:Byte Ptr ) = "aiGetMaterialString"
-				
-Rem
-bbdoc: Get an array of integer values from the material.
-about: See <a href="http://assimp.sourceforge.net/lib_html/structai_material.html">MaterialSystem.cpp</a>
-and <a href="http://assimp.sourceforge.net/lib_html/material_8h.html">material.h</a>.
-End Rem
-	Function aiGetMaterialIntegerArray:Int( pMat:Byte Ptr, pKey$z, iType:Int, ..
-				index:Int, pOut:Int Ptr, pMax:Int Ptr ) = "aiGetMaterialIntegerArray"
-				
-Rem
-bbdoc: Get an array of floating-point values from the material.
-about: See <a href="http://assimp.sourceforge.net/lib_html/structai_material.html">MaterialSystem.cpp</a>
-and <a href="http://assimp.sourceforge.net/lib_html/material_8h.html">material.h</a>.
-End Rem
-	Function aiGetMaterialFloatArray:Int( pMat:Byte Ptr, pKey$z, iType:Int, ..
-				index:Int, pOut:Float Ptr, pMax:Int Ptr ) = "aiGetMaterialFloatArray"
-				
-Rem
-bbdoc: Get all values pertaining to a particular texture slot from the material.
-about: See <a href="http://assimp.sourceforge.net/lib_html/structai_material.html">MaterialSystem.cpp</a>
-and <a href="http://assimp.sourceforge.net/lib_html/material_8h.html">material.h</a>.
-End Rem
-	Function aiGetMaterialTexture:Int( pMat:Byte Ptr, texType:Int, index:Int, path:Byte Ptr, ..
-				mapping:Byte Ptr=Null, uvindex:Int Ptr=Null, blend:Float Ptr=Null, ..
-				op:Byte Ptr=Null, mapmode:Byte Ptr=Null, flags:Int Ptr=Null ) = "aiGetMaterialTexture"
-				
-Rem
-bbdoc: Get the number of textures for a particular texture type.
-about: See <a href="http://assimp.sourceforge.net/lib_html/structai_material.html">MaterialSystem.cpp</a>
-and <a href="http://assimp.sourceforge.net/lib_html/material_8h.html">material.h</a>.
-End Rem
-	Function aiGetMaterialTextureCount:Int( pMat:Byte Ptr, texType:Int ) = "aiGetMaterialTextureCount"
-	
-End Extern
-
-Rem
- aiSetImportPropertyInteger caused crash, was missing p parameter
- changed aiGetMaterialTexture pMat:Int Ptr to :Byte Ptr
- changed aiImportFile:Int Ptr to :Byte Ptr
- added aiImportFileFromMemory
-EndRem
+' common.bmx
+
+?ptr64
+Const PAD:Int=2 ' 64-bit padding
+Const ONE32:Int=0
+?Not ptr64
+Const PAD:Int=1
+Const ONE32:Int=1
+?
+
+' config.h
+
+' Input parameter to the #aiProcess_SortByPType step:
+' Specifies which primitive types are removed by the step
+Const AI_CONFIG_PP_SBP_REMOVE:String = "PP_SBP_REMOVE"
+
+' types.h
+
+' just for backwards compatibility, don't use these constants anymore
+Const AI_SUCCESS:Int = $0
+Const AI_FAILURE:Int = -$1
+Const AI_OUTOFMEMORY:Int = -$3
+Const AI_INVALIDFILE:Int = -$2
+Const AI_INVALIDARG:Int = -$4
+
+' Maximum dimension for strings, ASSIMP strings are zero terminated.
+Const MAXLEN:Int = 1024
+
+' postprocess.h
+
+' enum aiPostProcessSteps - Defines the flags for all possible post processing step
+
+Const aiProcess_CalcTangentSpace:Int = $1
+Const aiProcess_JoinIdenticalVertices:Int = $2
+Const aiProcess_MakeLeftHanded:Int = $4
+Const aiProcess_Triangulate:Int = $8
+Const aiProcess_RemoveComponent:Int = $10
+Const aiProcess_GenNormals:Int = $20
+Const aiProcess_GenSmoothNormals:Int = $40
+Const aiProcess_SplitLargeMeshes:Int = $80
+Const aiProcess_PreTransformVertices:Int = $100
+Const aiProcess_LimitBoneWeights:Int = $200
+Const aiProcess_ValidateDataStructure:Int = $400
+Const aiProcess_ImproveCacheLocality:Int = $800
+Const aiProcess_RemoveRedundantMaterials:Int = $1000
+Const aiProcess_FixInfacingNormals:Int = $2000
+Const aiProcess_SortByPType:Int = $8000
+Const aiProcess_FindDegenerates:Int = $10000
+Const aiProcess_FindInvalidData:Int = $20000
+Const aiProcess_GenUVCoords:Int = $40000
+Const aiProcess_TransformUVCoords:Int = $80000
+Const aiProcess_FindInstances:Int = $100000
+Const aiProcess_OptimizeMeshes:Int = $200000 
+Const aiProcess_OptimizeGraph:Int = $400000
+Const aiProcess_FlipUVs:Int = $800000
+Const aiProcess_FlipWindingOrder:Int = $1000000
+Const aiProcess_SplitByBoneCount:Int = $2000000
+Const aiProcess_Debone:Int = $4000000
+
+' Shortcut to match Direct3D conventions: left-handed geometry, top-left origin for UV coords and clockwise face order
+Const aiProcess_ConvertToLeftHanded:Int = aiProcess_MakeLeftHanded | aiProcess_FlipUVs | aiProcess_FlipWindingOrder
+
+' mesh.h
+
+' Limits. These values are required to match the settings Assimp was compiled against.
+
+' Supported number of vertex color sets per mesh
+Const AI_MAX_NUMBER_OF_COLOR_SETS:Int = $8
+
+' Supported number of texture coord sets (UV(W) channels) per mesh
+Const AI_MAX_NUMBER_OF_TEXTURECOORDS:Int = $8
+
+' enum aiPrimitiveType - Enumerates the types of geometric primitives supported by Assimp.
+Const aiPrimitiveType_POINT:Int = $1
+Const aiPrimitiveType_LINE:Int = $2
+Const aiPrimitiveType_TRIANGLE:Int = $4
+Const aiPrimitiveType_POLYGON:Int = $8
+
+' material.h
+
+' enum aiTextureOp
+' enum aiTextureMapMode
+' enum aiTextureMapping
+' enum aiTextureType - Defines the purpose of a texture 
+
+' Dummy value.
+' No texture, but the value to be used as 'texture semantic' (#aiMaterialProperty::mSemantic)
+' for all material properties *not* related to textures.
+Const aiTextureType_NONE:Int = $0
+
+' The texture is combined with the result of the diffuse lighting equation.
+Const aiTextureType_DIFFUSE:Int = $1
+
+' The texture is combined with the result of the specular lighting equation.
+Const aiTextureType_SPECULAR:Int = $2
+
+' The texture is combined with the result of the ambient lighting equation.
+Const aiTextureType_AMBIENT:Int = $3
+
+' The texture is added to the result of the lighting calculation.
+' It isn't influenced by incoming light.
+Const aiTextureType_EMISSIVE:Int = $4
+
+' The texture is a height map.
+' By convention, higher grey-scale values stand for higher elevations from the base height.
+Const aiTextureType_HEIGHT:Int = $5
+
+' The texture is a (tangent space) normal-map.
+' Again, there are several conventions for tangent-space normal maps.
+' Assimp does (intentionally) not differenciate here.
+Const aiTextureType_NORMALS:Int = $6
+
+' The texture defines the glossiness of the material.
+' The glossiness is in fact the exponent of the specular (phong) lighting equation.
+' Usually there is a conversion function defined to map the linear color values in the texture
+' to a suitable exponent. Have fun.
+Const aiTextureType_SHININESS:Int = $7
+
+' The texture defines per-pixel opacity.
+' Usually 'white' means opaque and 'black' means 'transparency'. Or quite the opposite. Have fun.
+Const aiTextureType_OPACITY:Int = $8
+
+' Displacement texture.
+' The exact purpose and format is application-dependent.
+' Higher color values stand for higher vertex displacements.
+Const aiTextureType_DISPLACEMENT:Int = $9
+
+' Lightmap texture (aka Ambient Occlusion).
+' Both 'Lightmaps' and dedicated 'ambient occlusion maps' are covered by this material property.
+' The texture contains a scaling value for the final color value of a pixel.
+' It's intensity is not affected by incoming light.
+Const aiTextureType_LIGHTMAP:Int = $A
+
+' Reflection texture.
+' Contains the color of a perfect mirror reflection.
+' Rarely used, almost never for real-time applications.
+Const aiTextureType_REFLECTION:Int = $B
+
+' Unknown texture.
+' A texture reference that does not match any of the definitions above is considered to be 'unknown'.
+' It is still imported, but is excluded from any further postprocessing.
+Const aiTextureType_UNKNOWN:Int = $C
+
+' enum aiShadingMode
+' enum aiTextureFlags
+' enum aiBlendMode
+' enum aiPropertyTypeInfo - material property buffer content type
+
+Const aiPTI_Float:Int = $1
+Const aiPTI_String:Int = $3
+Const aiPTI_Integer:Int = $4
+Const aiPTI_Buffer:Int = $5
+
+' a few of the many matkey constants
+
+Const AI_MATKEY_NAME:String = "?mat.name"
+Const AI_MATKEY_TWOSIDED:String = "$mat.twosided"
+Const AI_MATKEY_OPACITY:String = "$mat.opacity"
+Const AI_MATKEY_SHININESS:String = "$mat.shininess"
+
+Const AI_MATKEY_COLOR_DIFFUSE:String = "$clr.diffuse"
+Const AI_MATKEY_COLOR_AMBIENT:String = "$clr.ambient"
+Const AI_MATKEY_COLOR_SPECULAR:String = "$clr.specular"
+Const AI_MATKEY_COLOR_EMISSIVE:String = "$clr.emissive"
+Const AI_MATKEY_COLOR_TRANSPARENT:String = "$clr.transparent"
+Const AI_MATKEY_COLOR_REFLECTIVE:String = "$clr.reflective"
+
+' Pure key names for all texture-related properties
+
+Const AI_MATKEY_TEXTURE_BASE:String = "$tex.file"
+Const AI_MATKEY_UVWSRC_BASE:String = "$tex.uvwsrc"
+Const AI_MATKEY_TEXOP_BASE:String = "$tex.op"
+Const AI_MATKEY_MAPPING_BASE:String = "$tex.mapping"
+Const AI_MATKEY_TEXBLEND_BASE:String = "$tex.blend"
+Const AI_MATKEY_MAPPINGMODE_U_BASE:String = "$tex.mapmodeu"
+Const AI_MATKEY_MAPPINGMODE_V_BASE:String = "$tex.mapmodev"
+Const AI_MATKEY_TEXMAP_AXIS_BASE:String = "$tex.mapaxis"
+Const AI_MATKEY_UVTRANSFORM_BASE:String = "$tex.uvtrafo"
+Const AI_MATKEY_TEXFLAGS_BASE:String = "$tex.flags"
+
+Extern
+
+' Assimp.cpp
+
+Rem
+bbdoc: Reads the given file and returns its content.
+about: See <a href="http://assimp.sourceforge.net/lib_html/class_assimp_1_1_importer.html">Assimp.cpp</a>
+and <a href="http://assimp.sourceforge.net/lib_html/cimport_8h.html">cimport.h</a>.
+End Rem
+	Function aiImportFile:Byte Ptr( pFile$z, pFlags:Int ) = "aiImportFile"
+
+Rem
+bbdoc: Reads the given file from a given memory buffer.
+about: See <a href="http://assimp.sourceforge.net/lib_html/class_assimp_1_1_importer.html">Assimp.cpp</a>
+and <a href="http://assimp.sourceforge.net/lib_html/cimport_8h.html">cimport.h</a>.
+End Rem
+	Function aiImportFileFromMemory:Byte Ptr( pBuffer:Byte Ptr,pLength:Int,pFlags:Int,pHint$z ) = "aiImportFileFromMemory"
+
+Rem
+bbdoc: Releases all resources associated with the given import process.
+about: See <a href="http://assimp.sourceforge.net/lib_html/class_assimp_1_1_importer.html">Assimp.cpp</a>
+and <a href="http://assimp.sourceforge.net/lib_html/cimport_8h.html">cimport.h</a>.
+End Rem
+	Function aiReleaseImport( pScene:Byte Ptr ) = "aiReleaseImport"
+
+Rem
+bbdoc: Returns the error text of the last failed import process.
+about: See <a href="http://assimp.sourceforge.net/lib_html/class_assimp_1_1_importer.html">Assimp.cpp</a>
+and <a href="http://assimp.sourceforge.net/lib_html/cimport_8h.html">cimport.h</a>.
+End Rem
+	Function aiIsExtensionSupported_:Int( pFile$z ) = "aiIsExtensionSupported"
+
+' MaterialSystem.cpp
+
+Rem
+bbdoc: Get a color (3 or 4 floats) from the material.
+about: See <a href="http://assimp.sourceforge.net/lib_html/structai_material.html">MaterialSystem.cpp</a>
+and <a href="http://assimp.sourceforge.net/lib_html/material_8h.html">material.h</a>.
+End Rem
+	Function aiGetMaterialColor:Int( pMat:Byte Ptr, pKey$z, iType:Int, ..
+				index:Int, pOut:Byte Ptr ) = "aiGetMaterialColor"
+				
+Rem
+bbdoc: Get a string from the material.
+about: See <a href="http://assimp.sourceforge.net/lib_html/structai_material.html">MaterialSystem.cpp</a>
+and <a href="http://assimp.sourceforge.net/lib_html/material_8h.html">material.h</a>.
+End Rem
+	Function aiGetMaterialString:Int( pMat:Byte Ptr, pKey$z, iType:Int, ..
+				index:Int, pOut:Byte Ptr ) = "aiGetMaterialString"
+				
+Rem
+bbdoc: Get an array of integer values from the material.
+about: See <a href="http://assimp.sourceforge.net/lib_html/structai_material.html">MaterialSystem.cpp</a>
+and <a href="http://assimp.sourceforge.net/lib_html/material_8h.html">material.h</a>.
+End Rem
+	Function aiGetMaterialIntegerArray:Int( pMat:Byte Ptr, pKey$z, iType:Int, ..
+				index:Int, pOut:Int Ptr, pMax:Int Ptr ) = "aiGetMaterialIntegerArray"
+				
+Rem
+bbdoc: Get an array of floating-point values from the material.
+about: See <a href="http://assimp.sourceforge.net/lib_html/structai_material.html">MaterialSystem.cpp</a>
+and <a href="http://assimp.sourceforge.net/lib_html/material_8h.html">material.h</a>.
+End Rem
+	Function aiGetMaterialFloatArray:Int( pMat:Byte Ptr, pKey$z, iType:Int, ..
+				index:Int, pOut:Float Ptr, pMax:Int Ptr ) = "aiGetMaterialFloatArray"
+				
+Rem
+bbdoc: Get all values pertaining to a particular texture slot from the material.
+about: See <a href="http://assimp.sourceforge.net/lib_html/structai_material.html">MaterialSystem.cpp</a>
+and <a href="http://assimp.sourceforge.net/lib_html/material_8h.html">material.h</a>.
+End Rem
+	Function aiGetMaterialTexture:Int( pMat:Byte Ptr, texType:Int, index:Int, path:Byte Ptr, ..
+				mapping:Byte Ptr=Null, uvindex:Int Ptr=Null, blend:Float Ptr=Null, ..
+				op:Byte Ptr=Null, mapmode:Byte Ptr=Null, flags:Int Ptr=Null ) = "aiGetMaterialTexture"
+				
+Rem
+bbdoc: Get the number of textures for a particular texture type.
+about: See <a href="http://assimp.sourceforge.net/lib_html/structai_material.html">MaterialSystem.cpp</a>
+and <a href="http://assimp.sourceforge.net/lib_html/material_8h.html">material.h</a>.
+End Rem
+	Function aiGetMaterialTextureCount:Int( pMat:Byte Ptr, texType:Int ) = "aiGetMaterialTextureCount"
+	
+End Extern