瀏覽代碼

Added 64-bit wrapper and zipstream

markcwm 8 年之前
父節點
當前提交
91c7e90d15

+ 3 - 4
assimp.mod/assimp.bmx

@@ -8,12 +8,11 @@ about: Assimp mesh loader and helper functions.
 End Rem
 Module Openb3dlibs.Assimp
 
-ModuleInfo "Version: 0.38"
+ModuleInfo "Version: 0.40"
 ModuleInfo "License: BSD-3-Clause"
 ModuleInfo "Copyright: Wrapper - 2009-2017 Peter Scheutz, Mark Mcvittie"
 ModuleInfo "Copyright: Library - 2006-2012 assimp team"
 ModuleInfo "Source: https://github.com/markcwm/openb3dlibs.mod"
-ModuleInfo "Source: https://github.com/Difference/blitzmax-assimp"
 
 Import Openb3d.B3dglgraphics
 Import Openb3dlibs.Assimplib
@@ -23,8 +22,8 @@ Include "types.bmx"
 Rem
 bbdoc: Like <a href="http://www.blitzbasic.com/b3ddocs/command.php?name=LoadMesh">LoadMesh</a> but without a parent parameter.
 End Rem
-Function aiLoadMesh:TMesh( filename:String )
-	Return aiLoader.LoadMesh( filename )
+Function aiLoadMesh:TMesh( filename:String, parent:TEntity=Null, flags:Int = -1 )
+	Return aiLoader.LoadMesh( filename, parent, flags )
 End Function
 
 Rem

+ 2 - 3
assimp.mod/doc/commands.html

@@ -34,16 +34,15 @@ Like <a href="http://www.blitzbasic.com/b3ddocs/command.php?name=LoadMesh">LoadM
 </table>
 <br>
 <table class=doc width=100% cellspacing=3 id=aiLoadMesh>
-<tr><td class=doctop colspan=2>Function aiLoadMesh:TMesh( filename:String )</td></tr>
+<tr><td class=doctop colspan=2>Function aiLoadMesh:TMesh( filename:String, parent:TEntity=Null, flags:Int = -1 )</td></tr>
 <tr><td class=docleft width=1%>Description</td><td class=docright>Like <a href="http://www.blitzbasic.com/b3ddocs/command.php?name=LoadMesh">LoadMesh</a> but without a parent parameter.</td></tr>
 </table>
 <br>
 <h2 id=modinfo>Module Information</h2>
 <table width=100%>
-<tr><th width=1%>Version</th><td>0.38</td></tr>
+<tr><th width=1%>Version</th><td>0.40</td></tr>
 <tr><th width=1%>License</th><td>BSD-3-Clause</td></tr>
 <tr><th width=1%>Copyright</th><td>Wrapper - 2009-2017 Peter Scheutz, Mark Mcvittie</td></tr>
 <tr><th width=1%>Copyright</th><td>Library - 2006-2012 assimp team</td></tr>
 <tr><th width=1%>Source</th><td>https://github.com/markcwm/openb3dlibs.mod</td></tr>
-<tr><th width=1%>Source</th><td>https://github.com/Difference/blitzmax-assimp</td></tr>
 </body></html>

+ 176 - 195
assimp.mod/types.bmx

@@ -1,58 +1,43 @@
 ' types.bmx
 
-' Mesh bounds values, used in FitAnimMesh()
+' mesh bounds values, used in FitAnimMesh()
 Type aiMinMax3D
 
-	Field maxx#,maxy#,maxz#
-	Field minx#,miny#,minz#
+	Field maxx#, maxy#, maxz#
+	Field minx#, miny#, minz#
 	
 End Type
 
-Rem
- Contains 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
+' assimp mesh loader
 Type aiLoader
 
-	Global meshflags:Int=0
-	
-	Function LoadMesh:TMesh( filename:String )
+	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 )
 		
-		Local flags:Int
-		If meshflags=0
-			flags = ..
-			aiProcess_Triangulate | ..
-			aiProcess_GenSmoothNormals | ..
-			aiProcess_SortByPType | ..
-			aiProcess_PreTransformVertices | ..
-			aiProcess_FlipUVs | ..
-			aiProcess_JoinIdenticalVertices
-		ElseIf meshflags=1
-			flags = ..
-			aiProcess_Triangulate | ..
-			aiProcess_GenNormals | ..
-			aiProcess_SortByPType | ..
-			aiProcess_CalcTangentSpace | ..
-			aiProcess_FindDegenerates | ..
-			aiProcess_FindInvalidData | ..
-			aiProcess_GenUVCoords | ..
-			aiProcess_TransformUVCoords | ..
-			aiProcess_FlipUVs | ..
-			aiProcess_PreTransformVertices
-		EndIf
-	'	aiProcess_SplitLargeMeshes | ..
-	'	aiProcess_ValidateDataStructure | ..
-	'	aiProcess_ImproveCacheLocality | ..
-	'	aiProcess_RemoveRedundantMaterials | ..	
-	'	aiProcess_ConvertToLeftHanded | ..	
+		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)
 		
@@ -62,20 +47,20 @@ Type aiLoader
 			Local i:Int
 			
 			For Local mat:aiMaterial = EachIn scene.Materials
-'Rem
+			
 				DebugLog " "
 				DebugLog " ----    Material Name " + mat.GetMaterialName()
 				DebugLog " ----    mat.IsTwoSided() " + mat.IsTwoSided()
 				DebugLog " ----    mat.GetShininess() " + mat.GetShininess()
 				DebugLog " ----    mat.GetAlpha() " + mat.GetAlpha()
-'EndRem
-'Rem
+				
+				'Rem
 				Local names:String[] = mat.GetPropertyNames()
 				
 				For Local s:String = EachIn names
+				
 					DebugLog "Property: *" + s + "*"
-					
-					'DebugLog "matbase " + mat.GetFloatValue(s)
+					'DebugLog "matbase " + mat.Properties[?].GetFloatValue(s)
 					
 					Select s
 						Case AI_MATKEY_TEXTURE_BASE
@@ -83,19 +68,20 @@ Type aiLoader
 					End Select
 					
 				Next
-'EndRem
+				'EndRem
+				
 				Local DiffuseColors:Float[] = mat.GetMaterialColor(AI_MATKEY_COLOR_DIFFUSE)	
 				
-				brushes[i] = CreateBrush(mat.GetDiffuseRed()*255,mat.GetDiffuseGreen()*255,mat.GetDiffuseBlue()*255)
+				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 doen't load
+				' 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
+					'BrushFX brushes[i], 16
 				EndIf
 				
 				Local texFilename:String = mat.GetMaterialTexture()
@@ -106,62 +92,62 @@ Type aiLoader
 				
 					' remove currentdir prefix, but leave relative subfolder path intact
 					If  texFilename[..2] = ".\" Or texFilename[..2] = "./"
-						texFilename = 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)
+					If Not FileType(texFilename)
+						texFilename = ExtractDir(filename) + "/" + StripDir(texFilename)
 					EndIf
 					
 					DebugLog texFilename
 					
-					If FileType(texFilename  )
+					If FileType(texFilename)
 						'DebugStop
 						Local tex:TTexture=LoadTexture(texFilename)
 						
 						If tex
-							BrushTexture brushes[i],tex	
+							BrushTexture brushes[i], tex	
 						EndIf
 						
 					EndIf
 					
 				EndIf
 				
-				i:+1
+				i:+ 1
 			Next
 			
 			' Make mesh - was ProccessAiNodeAndChildren()
 			
-			Local mesh:TMesh = CreateMesh()
+			Local mesh:TMesh = CreateMesh(parent)
 			
-			DebugLog "scene.numMeshes:  "  + scene.numMeshes
+			DebugLog "scene.numMeshes: " + scene.numMeshes
 			
 			For Local m:aiMesh = EachIn scene.meshes
 			
-				Local surf:TSurface = CreateSurface(mesh,brushes[m.MaterialIndex])
+				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)
+					'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))
+					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))
+						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))
+						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))
+						VertexTexCoords(surf, index, m.VertexU(i, 1), m.VertexV(i, 1), m.VertexW(i, 1))
 					EndIf
 					
 				Next
@@ -174,20 +160,22 @@ Type aiLoader
 					' on rare occasions with aiProcess_PreTransformVertices on.
 					Local validIndex:Int = True
 					
-					' added 3.1.1: fix for MAV when garbage index values < zero
+					' 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				
+					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))
+						AddTriangle(surf, m.TriangleVertex(i, 0), m.TriangleVertex(i, 1), m.TriangleVertex(i, 2))
 					Else
-						DebugLog "TriangleVertex index was out of range for triangle nr. : " + i
-						DebugLog "indexes: " + m.TriangleVertex(i,0) + " , "  + m.TriangleVertex(i,1) + " , "  + m.TriangleVertex(i,2)
+						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
@@ -208,22 +196,27 @@ Type aiLoader
 		
 End Type
 
-' helper functions
+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
 	
-	' Non-essential helper functions
-	
-	Function CountTrianglesAll:Int( ent:TEntity )
+	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 surf:TSurface = GetSurface(TMesh(ent), id)
 			Local nt% = CountTriangles(surf)
-			all:+nt
+			all:+ nt
 		Next
 		
 		Return all
@@ -231,15 +224,15 @@ Type aiHelper
 	End Function
 	
 	' renamed from FlipRot (applied to all children of an entity)
-	Function RotateEntityAxisAll( ent:TEntity, axis:Int )
+	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	
+				RotateEntityAxisAll(GetChild(ent, id), axis)
+			Next
 		EndIf
 		
 		Local rotX:Float = EntityPitch(ent)
@@ -250,60 +243,60 @@ Type aiHelper
 			Case 1
 				rotX = -rotX
 			Case 2
-				rotY = -rotY		
+				rotY = -rotY
 			Case 3
 				rotZ = -rotZ
 		End Select
 		
-		RotateEntity( ent,rotX,rotY,rotZ )
+		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 )
+	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) )
+				UpdateNormalsAll(GetChild(ent, id))
 			Next
 		EndIf
 		
 		If EntityClass(ent) = "Mesh"
-			UpdateNormals( TMesh(ent) )
+			UpdateNormals TMesh(ent)
 		EndIf
 		
 	End Function
 	
 	' renamed from FlipEntity (applied to all children of an entity)
-	Function FlipMeshAll( ent:TEntity )
+	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) )
+				FlipMeshAll(GetChild(ent, id))
 			Next
 		EndIf
 		
 		If EntityClass(ent) = "Mesh"
-			FlipMesh( TMesh(ent) )
+			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 )
+	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 )
+				ScaleMeshAxisAll(GetChild(ent, id), axis)
 			Next
 		EndIf
 		
@@ -321,65 +314,63 @@ Type aiHelper
 		End Select
 		
 		If EntityClass(ent) = "Mesh"
-			ScaleMesh( TMesh(ent),scaleX,scaleY,scaleZ )
+			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 )
+	Function FitAnimMesh(m:TEntity, x#, y#, z#, w#, h#, d#, uniform:Int=False)
 	
 		Local scalefactor#
-		Local xoff#,yoff#,zoff#
-		Local gFactor#=100000.0
+		Local xoff#, yoff#, zoff#
+		Local gFactor# = 100000.0
 		
-		mm.maxx=-100000
-		mm.maxy=-100000
-		mm.maxz=-100000
+		mm.maxx = -100000
+		mm.maxy = -100000
+		mm.maxz = -100000
 		
-		mm.minx=100000
-		mm.miny=100000
-		mm.minz=100000
+		mm.minx = 100000
+		mm.miny = 100000
+		mm.minz = 100000
 		
-		getAnimMeshMinMax( m,mm )
+		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()	
+		'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 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
+		Local xscale# = w / xspan
+		Local yscale# = h / yspan
+		Local zscale# = d / zspan
 		
-		'DebugLog "Scales: " + xscale + " , " +  yscale + " , " + zscale + " , " 
+		'DebugLog "Scales: " + xscale + ", " +  yscale + ", " + zscale 
 		
 		If uniform
-		
-			If xscale<yscale
-				yscale=xscale
+			If xscale < yscale
+				yscale = xscale
 			Else
-				xscale=yscale
+				xscale = yscale
 			EndIf
 			
-			If zscale<xscale
-				xscale=zscale
-				yscale=zscale			
+			If zscale < xscale
+				xscale = zscale
+				yscale = zscale			
 			Else
-				zscale=xscale
+				zscale = xscale
 			EndIf
-			
 		EndIf	
 		
-		'DebugLog "Scales: " + String(xscale).ToInt() + " , " +  String(yscale).ToInt() + " , " + String(zscale).ToInt() + " , " 
+		'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
+		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 )	
+		doFitAnimMesh(m, xoff, yoff, zoff, xscale, yscale, zscale)
 '		Delete mm
 		
 	End Function
@@ -387,141 +378,131 @@ Type aiHelper
 	' internal functions for FitAnimMesh
 	
 	' used in FitAnimMesh()
-	Function doFitAnimMesh( m:TEntity, xoff#, yoff#, zoff#, xscale#, yscale#, zscale# )
+	Function doFitAnimMesh(m:TEntity, xoff#, yoff#, zoff#, xscale#, yscale#, zscale#)
 	
 		Local c:Int
-		Local childcount:Int=CountChildren(m)
+		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# )
+			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
 		EndIf
 		
-		myFitEntity( m,xoff#,yoff#,zoff#,xscale#,yscale#,zscale# )
+		myFitEntity(m, xoff#, yoff#, zoff#, xscale#, yscale#, zscale#)
 		
 	End Function
 	
 Rem
-	Function doFitAnimMeshOLD( m:TEntity, xoff#, yoff#, zoff#, xscale#, yscale#, zscale# )
+	Function doFitAnimMeshOLD(m:TEntity, xoff#, yoff#, zoff#, xscale#, yscale#, zscale#)
 	
 		Local c:Int
-		Local childcount:Int=CountChildren(m)
+		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# )
+			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# )
-		
+			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# )
+	Function myFitEntity(e:TEntity, xoff#, yoff#, zoff#, xscale#, yscale#, zscale#)
 	
-		Local x#,y#,z#
-		Local x2#,y2#,z2#
-		Local txoff#,tyoff#,tzoff#
+		Local x#, y#, z#
+		Local x2#, y2#, z2#
+		Local txoff#, tyoff#, tzoff#
 		
-		TFormPoint( 0,0,0,e,Null )
+		TFormPoint(0, 0, 0, e, Null)
 		
-		x2=TFormedX()
-		y2=TFormedY()
-		z2=TFormedZ()
+		x2 = TFormedX()
+		y2 = TFormedY()
+		z2 = TFormedZ()
 		
-		TFormPoint( x2+xoff,y2+yoff,z2+zoff,Null,e )
+		TFormPoint(x2 + xoff, y2 + yoff, z2 + zoff, Null, e)
 		
-		txoff=TFormedX() 
-		tyoff=TFormedY()
-		tzoff=TFormedZ()
+		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 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)
+				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
+					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 )
+		PositionEntity(e, EntityX(e) * xscale, EntityY(e) * yscale, EntityZ(e) * zscale)
 		
 	End Function
 	
 	' used in FitAnimMesh()
-	Function getAnimMeshMinMax#( m:TEntity, mm:aiMinMax3D )
+	Function getAnimMeshMinMax#(m:TEntity, mm:aiMinMax3D)
 	
 		Local c:Int
-		Local wfac#,hfac#,dfac#
+		Local wfac#, hfac#, dfac#
 		'Local tfactor
-		Local cc:Int=CountChildren(m)
+		Local cc:Int = CountChildren(m)
 		
 		If EntityClass(m) = "Mesh"
-		
 			'If m.class = "Mesh" 
-			mm = getEntityMinMax( TMesh(m),mm )
+			mm = getEntityMinMax(TMesh(m), mm)
 			'Else
 			'	DebugLog "Class -- " + m.class
 			'Endif
-			
 		EndIf
 		
 		If cc
-			For c=1 To cc
-				getAnimMeshMinMax( GetChild(m,c),mm )
+			For c = 1 To cc
+				getAnimMeshMinMax(GetChild(m, c), mm)
 			Next
-	'	Else
 		EndIf
 		
 	End Function
-
+	
 	' used in getAnimMeshMinMax()
-	Function getEntityMinMax:aiMinMax3D( m:TMesh, mm:aiMinMax3D )
+	Function getEntityMinMax:aiMinMax3D(m:TMesh, mm:aiMinMax3D)
 	
-		Local x#,y#,z#
+		Local x#, y#, z#
 		Local sc:Int
 		Local vc:Int
 		Local s:TSurface	
 		
-		For sc=1 To CountSurfaces(m)
-			s=GetSurface(m,sc)	
+		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)
+			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()
+				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.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
+				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
@@ -531,33 +512,33 @@ EndRem
 	End Function
 	
 	' Creates a list of valid files to load
-	Function EnumFiles( list:TList, dir:String, skipExt:TList )
+	Function EnumFiles(list:TList, dir:String, skipExt:TList)
 	
-		Local folder:Byte Ptr=ReadDir(dir)
+		Local folder:Byte Ptr = ReadDir(dir)
 		Local file:String
 		
 		Repeat
-			file=NextFile(folder)
+			file = NextFile(folder)
 			
 			If (file <> ".") And (file <> "..") And (file)
 			
-				Local fullPath:String=RealPath(dir+"/"+file)
+				Local fullPath:String = RealPath(dir + "/" + file)
 				
-				If FileType(fullPath)=FILETYPE_DIR
+				If FileType(fullPath) = FILETYPE_DIR
 				
 					'DebugLog file
 					'If(dir[0]) <> "."
-						EnumFiles( list,fullPath,skipExt )
+						EnumFiles(list, fullPath, skipExt)
 					'EndIf
 					
 				Else
 				
 					DebugLog "fullpath: " + fullPath
 					
-					If aiIsExtensionSupported( Lower(ExtractExt(fullPath)) )
+					If aiIsExtensionSupported(Lower(ExtractExt(fullPath)))
 					
 						'DebugStop
-						If Not skipExt.Contains( Lower(ExtractExt(fullPath)) ) ' Filter out nff for now
+						If Not skipExt.Contains(Lower(ExtractExt(fullPath))) ' Filter out nff for now
 							' assimp author is looking into a fix
 							list.AddLast(fullPath)
 						EndIf
@@ -568,7 +549,7 @@ EndRem
 				
 			EndIf
 			
-		Until file=Null
+		Until file = Null
 		CloseDir folder
 		
 	End Function

+ 11 - 8
assimplib.mod/assimplib.bmx

@@ -4,28 +4,31 @@ Strict
 
 Rem
 bbdoc: Assimp
-about: Wrapper for Open Asset Import library. Requires BaH.Boost.
+about: Wrapper for Open Asset Import library. Requires BaH.Boost and Koriolis.Zipstream.
 End Rem
 Module Openb3dlibs.Assimplib
 
-ModuleInfo "Version: 0.38"
+ModuleInfo "Version: 0.40"
 ModuleInfo "License: BSD-3-Clause"
 ModuleInfo "Copyright: Wrapper - 2009-2017 Peter Scheutz, Mark Mcvittie"
 ModuleInfo "Copyright: Library - 2006-2012 assimp team"
 ModuleInfo "Source: https://github.com/markcwm/openb3dlibs.mod"
-ModuleInfo "Source: https://github.com/Difference/blitzmax-assimp"
+ModuleInfo "Source: https://github.com/maxmods/bah.mod/tree/master/boost.mod"
+ModuleInfo "Source: https://github.com/maxmods/koriolis.mod"
 
-ModuleInfo "History: 0.38 Release on Jul 2017 - added source wrapper, mesh streams"
-ModuleInfo "History: 0.36 Release on Sep 2014 - library wrapper, update to assimp v3.1.1"
-ModuleInfo "History: 0.30 Release on Apr 2011"
-ModuleInfo "History: 0.22 Release on Nov 2009"
-ModuleInfo "History: 0.07 Initial Release on Jan 2009"
+ModuleInfo "History: 0.40 Release Aug 2017 - added zipstream, 64-bit wrapper"
+ModuleInfo "History: 0.38 Release Jul 2017 - added source wrapper, incbin streams"
+ModuleInfo "History: 0.36 Release Sep 2014 - library wrapper, update to assimp v3.1.1"
+ModuleInfo "History: 0.30 Release Apr 2011"
+ModuleInfo "History: 0.22 Release Nov 2009"
+ModuleInfo "History: 0.07 Initial Release Jan 2009"
 
 ModuleInfo "CC_OPTS: -fexceptions"
 'ModuleInfo "CC_OPTS: -DASSIMP_ENABLE_BOOST_WORKAROUND"
 
 Import Brl.Math
 Import Brl.Retro
+Import Koriolis.Zipstream
 
 Import "source.bmx"
 Import "common.bmx"

+ 8 - 0
assimplib.mod/common.bmx

@@ -1,5 +1,13 @@
 ' 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:

+ 24 - 25
assimplib.mod/doc/commands.html

@@ -9,7 +9,7 @@
 <td class=small width=1%><a href='../../../../mod/openb3dlibs.mod/assimplib.mod/assimplib.bmx' class=small>Source</a></td>
 <td class=small>&nbsp;</td></tr></table>
 <h1>Assimp</h1>
-Wrapper for Open Asset Import library. Requires BaH.Boost.
+Wrapper for Open Asset Import library. Requires BaH.Boost and Koriolis.Zipstream.
 <h2><a name=functions></a>Functions Summary</h2><table class=doc width=100%>
 <tr><td class=docleft width=1%><a href=#aiGetMaterialColor>aiGetMaterialColor</a></td><td class=docright>
 Get a color (3 or 4 floats) from the material.
@@ -44,7 +44,7 @@ Releases all resources associated with the given import process.
 </table>
 <h2><a name=types></a>Types Summary</h2><table class=doc width=100%>
 <tr><td class=docleft width=1%><a href=#aiMesh>aiMesh</a></td><td class=docright>
-A mesh represents a geometry Or model with a single material.
+A mesh represents a geometry or model with a single material.
 </td></tr>
 </table>
 <h2
@@ -125,37 +125,36 @@ and <a href="http://assimp.sourceforge.net/lib_html/cimport_8h.html">cimport.h</
 </h2>
 <table class=doc width=100% cellspacing=3 id=aiMesh>
 <tr><td class=doctop colspan=2>Type aiMesh</td></tr>
-<tr><td class=docleft width=1%>Description</td><td class=docright>A mesh represents a geometry Or model with a single material.</td></tr>
-<tr><td class=docleft width=1%>Information</td><td class=docright>* It usually consists of a number of vertices And a series of primitives/faces
-* referencing the vertices. In addition there might be a series of bones, each
-* of them addressing a number of vertices with a certain weight. Vertex data
-* is presented in channels with each channel containing a single per-vertex
-* information such as a set of texture coords Or a normal vector.
-* If a data pointer is non-Null, the corresponding data stream is present.
-* From C++-programs you can also use the comfort functions Has*() To
-* test For the presence of various data streams.
-*
-* A Mesh uses only a single material which is referenced by a material ID.
-* <b>note</b> The mPositions member is usually Not optional. However, vertex positions
-* *could* be missing If the AI_SCENE_FLAGS_INCOMPLETE flag is set in
-* <b>code</b>
-* aiScene::mFlags
-* <b>endcode</b>
+<tr><td class=docleft width=1%>Description</td><td class=docright>A mesh represents a geometry or model with a single material.</td></tr>
+<tr><td class=docleft width=1%>Information</td><td class=docright>It usually consists of a number of vertices and a series of primitives/faces
+referencing the vertices. In addition there might be a series of bones, each
+of them addressing a number of vertices with a certain weight. Vertex data
+is presented in channels with each channel containing a single per-vertex
+information such as a set of texture coords or a normal vector.
+If a data pointer is non-null, the corresponding data stream is present.
+From C++ programs you can also use the comfort functions Has*() to
+test for the presence of various data streams.
+<br><br>
+A mesh uses only a single material which is referenced by a material ID.
+<b>note</b> The mPositions member is usually not optional. However, vertex positions
+*could* be missing if the AI_SCENE_FLAGS_INCOMPLETE flag is set in aiScene::mFlags.
 */</td></tr>
 </table>
 <br>
 <h2 id=modinfo>Module Information</h2>
 <table width=100%>
-<tr><th width=1%>Version</th><td>0.38</td></tr>
+<tr><th width=1%>Version</th><td>0.40</td></tr>
 <tr><th width=1%>License</th><td>BSD-3-Clause</td></tr>
 <tr><th width=1%>Copyright</th><td>Wrapper - 2009-2017 Peter Scheutz, Mark Mcvittie</td></tr>
 <tr><th width=1%>Copyright</th><td>Library - 2006-2012 assimp team</td></tr>
 <tr><th width=1%>Source</th><td>https://github.com/markcwm/openb3dlibs.mod</td></tr>
-<tr><th width=1%>Source</th><td>https://github.com/Difference/blitzmax-assimp</td></tr>
-<tr><th width=1%>History</th><td>0.38 Release on Jul 2017 - added source wrapper, mesh streams</td></tr>
-<tr><th width=1%>History</th><td>0.36 Release on Sep 2014 - library wrapper, update to assimp v3.1.1</td></tr>
-<tr><th width=1%>History</th><td>0.30 Release on Apr 2011</td></tr>
-<tr><th width=1%>History</th><td>0.22 Release on Nov 2009</td></tr>
-<tr><th width=1%>History</th><td>0.07 Initial Release on Jan 2009</td></tr>
+<tr><th width=1%>Source</th><td>https://github.com/maxmods/bah.mod/tree/master/boost.mod</td></tr>
+<tr><th width=1%>Source</th><td>https://github.com/maxmods/koriolis.mod</td></tr>
+<tr><th width=1%>History</th><td>0.40 Release Aug 2017 - added zipstream, 64-bit wrapper</td></tr>
+<tr><th width=1%>History</th><td>0.38 Release Jul 2017 - added source wrapper, incbin streams</td></tr>
+<tr><th width=1%>History</th><td>0.36 Release Sep 2014 - library wrapper, update to assimp v3.1.1</td></tr>
+<tr><th width=1%>History</th><td>0.30 Release Apr 2011</td></tr>
+<tr><th width=1%>History</th><td>0.22 Release Nov 2009</td></tr>
+<tr><th width=1%>History</th><td>0.07 Initial Release Jan 2009</td></tr>
 <tr><th width=1%>CC_OPTS</th><td>-fexceptions</td></tr>
 </body></html>

+ 254 - 200
assimplib.mod/types.bmx

@@ -2,32 +2,26 @@
 
 Type aiMatrix3x3
 
-	Field a1:Float , a2:Float , a3:Float
-	Field b1:Float , b2:Float , b3:Float
-	Field c1:Float , c2:Float , c3:Float
+	Field a1:Float, a2:Float, a3:Float
+	Field b1:Float, b2:Float, b3:Float
+	Field c1:Float, c2:Float, c3:Float
 	
 End Type
 
 Type aiMatrix4x4
 
-	Field a1:Float , a2:Float , a3:Float , a4:Float
-	Field b1:Float , b2:Float , b3:Float , b4:Float
-	Field c1:Float , c2:Float , c3:Float , c4:Float
-	Field d1:Float , d2:Float , d3:Float , d4:Float
+	Field a1:Float, a2:Float, a3:Float, a4:Float
+	Field b1:Float, b2:Float, b3:Float, b4:Float
+	Field c1:Float, c2:Float, c3:Float, c4:Float
+	Field d1:Float, d2:Float, d3:Float, d4:Float
 	
 	Field heading:Float
 	Field attitude:Float
 	Field bank:Float
 	
-	Field Tx:Float
-	Field Ty:Float
-	Field Tz:Float
-	Field Sx:Float
-	Field Sy:Float
-	Field Sz:Float	
-	Field Rx:Float
-	Field Ry:Float
-	Field Rz:Float
+	Field Tx:Float, Ty:Float, Tz:Float
+	Field Sx:Float, Sy:Float, Sz:Float
+	Field Rx:Float, Ry:Float, Rz:Float
 	
 	Function Create:aiMatrix4x4(p:Float Ptr)
 	
@@ -49,24 +43,24 @@ Type aiMatrix4x4
 		m.b2 = p[5]
 		m.b3 = p[6]
 		m.b4 = p[7]
-
+		
 		m.c1 = p[8]
 		m.c2 = p[9]
 		m.c3 = p[10]
 		m.c4 = p[11]
-
+		
 		m.d1 = p[12]
 		m.d2 = p[13]
 		m.d3 = p[14]
 		m.d4 = p[15]
 		
-		Return m									
+		Return m
 		
 	End Function
 	
 	Method Decompose()
 	
-		_Decompose()		
+		_Decompose()
 		
 		rx = heading
 		ry = attitude
@@ -80,15 +74,15 @@ Type aiMatrix4x4
 		Ty = b4 
 		Tz = c4
 		
-		Sx = Sqr( a1*a1 + a2*a2 + a3*a3 )
-		Sy = Sqr( b1*b1 + b2*b2 + b3*b3 ) 
-		Sz = Sqr( c1*c1 + c2*c2 + c3*c3 )
+		Sx = Sqr(a1*a1 + a2*a2 + a3*a3)
+		Sy = Sqr(b1*b1 + b2*b2 + b3*b3) 
+		Sz = Sqr(c1*c1 + c2*c2 + c3*c3)
 		
-		Local D:Float = a1 * (b2 * c3 - c2 * b3) - b1 * (a2 * c3 - c2 * a3) + c1 * (a2 * b3 - b2 * a3);
+		Local D:Float = a1 * (b2 * c3 - c2 * b3) - b1 * (a2 * c3 - c2 * a3) + c1 * (a2 * b3 - b2 * a3)
 		
-		Sx:* Sgn( D )
-		Sy:* Sgn( D )
-		Sz:* Sgn( D )
+		Sx:* Sgn(D)
+		Sy:* Sgn(D)
+		Sz:* Sgn(D)
 		
 		Local rm:aiMatrix3x3 = New aiMatrix3x3	
 		
@@ -97,23 +91,23 @@ Type aiMatrix4x4
 		rm.c1 = c1 ; rm.c2 = c2 ; rm.c3 = c3		
 		
 		If sx Then
-			rm.a1:/sx	
-			rm.a2:/sx	
-			rm.a3:/sx	
+			rm.a1:/ sx	
+			rm.a2:/ sx	
+			rm.a3:/ sx	
 		EndIf
 		If sy Then
-			rm.b1:/sy
-			rm.b2:/sy	
-			rm.b3:/sy	
+			rm.b1:/ sy
+			rm.b2:/ sy	
+			rm.b3:/ sy	
 		EndIf
 		If sz Then
-			rm.c1:/sz
-			rm.c2:/sz	
-			rm.c3:/sz	
+			rm.c1:/ sz
+			rm.c2:/ sz	
+			rm.c3:/ sz	
 		EndIf
 		
 		If (b1 > 0.998) ' singularity at north pole
-			heading = ATan2(rm.a3,rm.c3)
+			heading = ATan2(rm.a3, rm.c3)
 			attitude = 90 'Pi/2
 			bank = 0
 			'DebugLog "' singularity at north pole **"
@@ -121,15 +115,15 @@ Type aiMatrix4x4
 		EndIf
 		
 		If (b1 < -0.998) ' singularity at south pole
-			heading = ATan2(rm.a3,rm.c3)
-			attitude = - 90 '-Pi/2
+			heading = ATan2(rm.a3, rm.c3)
+			attitude = -90 '-Pi/2
 			bank = 0
 			'DebugLog "' singularity at south pole **"
 			Return
 		EndIf
 		
-		heading = ATan2(-rm.c1,rm.a1)
-		bank = ATan2(-rm.b3,rm.b2)
+		heading = ATan2(-rm.c1, rm.a1)
+		bank = ATan2(-rm.b3, rm.b2)
 		attitude = ASin(rm.b1)	
 		
 	End Method
@@ -179,7 +173,7 @@ Type aiMaterial
 	Method GetAlpha:Float()
 	
 		Local values:Float[] = GetMaterialFloatArray(AI_MATKEY_OPACITY)
-		If values.length Then
+		If values.length
 			Return values[0]	
 		Else		
 			Return 1.0
@@ -190,7 +184,7 @@ Type aiMaterial
 	Method GetShininess:Float()
 	
 		Local values:Float[] = GetMaterialFloatArray(AI_MATKEY_SHININESS)
-		If values.length Then
+		If values.length
 			Return values[0]	
 		Else		
 			Return 1.0
@@ -236,18 +230,19 @@ Type aiMaterial
 	Method GetPropertyNames:String[]()
 	
 		Local names:String[NumProperties]	
-		For Local i:Int = 0 To NumProperties - 1
-		
-			names[i] = Properties[i].mKey
-			'DebugLog "Property name: " + Properties[i].mKey
-			'DebugLog "Property type: " + Properties[i].mType
-			'DebugLog "Property Index " + Properties[i].Index
-			'DebugLog "Property length " + Properties[i].DataLength
-			'DebugLog "Property Semantic: " + Properties[i].Semantic
+		For Local id:Int = 0 To NumProperties - 1
+		
+			names[id] = Properties[id].mKey
+			
+			DebugLog "Property name: " + Properties[id].mKey
+			DebugLog "Property type: " + Properties[id].mType
+			DebugLog "Property Index " + Properties[id].Index
+			DebugLog "Property length " + Properties[id].DataLength
+			DebugLog "Property Semantic: " + Properties[id].Semantic
 			
-			Select Properties[i].mType
+			Select Properties[id].mType
 				Case aiPTI_Float
-					For Local i:Int = 0 Until Properties[i].DataLength / 4 
+					For Local i:Int = 0 Until (Properties[id].DataLength / 4)
 				'		DebugLog "FLOAT: " + Properties[i].GetFloatValue(i)
 					Next
 				Case aiPTI_String
@@ -259,6 +254,7 @@ Type aiMaterial
 			End Select
 			
 		Next
+		
 		Return names
 		
 	End Method	
@@ -267,14 +263,14 @@ Type aiMaterial
 	
 	Method GetMaterialString:String(Key:String)
 	
-		Local s:Byte[4+MAXLEN]
+		Local s:Byte[MAXLEN + (4 * PAD)]
 		'Local kp:Byte Ptr = Key.ToCstring()
 		
-		Local retVal:Int = aiGetMaterialString(pMaterial,Key,0,0,Varptr s[0])
+		Local retVal:Int = aiGetMaterialString(pMaterial, Key, 0, 0, Varptr s[0])
 		'MemFree kp
 		
 		If retVal = AI_SUCCESS
-			Return String.FromCString(Varptr s[4])
+			Return String.FromCString(Varptr s[4 * PAD])
 		'Else
 			'DebugLog "mat. aiGetMaterialString failed with code " + retVal
 		EndIf
@@ -284,18 +280,18 @@ Type aiMaterial
 	Method GetMaterialColor:Float[](Key:String)	
 	
 		Local colors:Float[4]
-		If aiGetMaterialColor(pMaterial,Key,0,0,colors)	= AI_SUCCESS
+		If aiGetMaterialColor(pMaterial, Key, 0, 0, colors)	= AI_SUCCESS
 			Return colors
 		EndIf
 		
 	End Method
 	
 	Method GetMaterialIntegerArray:Int[](Key:String)
-		
-		Local size:Int = 1024
+	
+		Local size:Int = MAXLEN
 		Local values:Int[size]
 		
-		If aiGetMaterialIntegerArray(pMaterial,Key,0,0,values,Varptr size)	= AI_SUCCESS
+		If aiGetMaterialIntegerArray(pMaterial, Key, 0, 0, values, Varptr size)	= AI_SUCCESS
 			values = values[..size]
 			Return values
 		EndIf
@@ -304,26 +300,26 @@ Type aiMaterial
 	
 	Method GetMaterialFloatArray:Float[](Key:String)
 	
-		Local size:Int = 1024
+		Local size:Int = MAXLEN
 		Local values:Float[size]
 		
-		If aiGetMaterialFloatArray(pMaterial,Key,0,0,values,Varptr size)	= AI_SUCCESS
+		If aiGetMaterialFloatArray(pMaterial, Key, 0, 0, values, Varptr size) = AI_SUCCESS
 			values = values[..size]
 			Return values
 		EndIf
 		
-	End Method	
+	End Method
 	
-	Method GetMaterialTexture:String(index:Int=0)
+	Method GetMaterialTexture:String(index:Int = 0)
 	
-		Local s:Byte[4+MAXLEN]
-		Local retval:Int = aiGetMaterialTexture(pMaterial,aiTextureType_DIFFUSE,index,Varptr s[0])
+		Local s:Byte[MAXLEN + (4 * PAD)]
+		Local retval:Int = aiGetMaterialTexture(pMaterial, aiTextureType_DIFFUSE, index, Varptr s[0])
 		
 		If retVal = AI_SUCCESS			
-			Return String.FromCString(Varptr s[4])
+			Return String.FromCString(Varptr s[4 * PAD])
 		Else
 			DebugLog "mat. GetMaterialTexture failed with code " + retVal
-		EndIf	
+		EndIf
 		
 	End Method
 	
@@ -337,41 +333,47 @@ Type aiMaterialProperty
 	Field Index:Int
 	Field DataLength:Int
 	Field mType:Int				
-	Field mData:Byte Ptr		
+	Field mData:Byte Ptr
 	
 	Function Create:aiMaterialProperty(pProps:Byte Ptr)
 	
 		Local mp:aiMaterialProperty = New aiMaterialProperty
 		
-		mp.mKey = String.FromCString(pProps + 4)
+		mp.mKey = String.FromCString(pProps + (4 * PAD))
 		
-		Local pVars:Int Ptr = Int Ptr(pProps + MAXLEN + 4 )
+		Local pVars:Int Ptr = Int Ptr(pProps + MAXLEN + (4 * PAD))
 		
-		mp.Semantic:Int = pVars[0]
+		mp.Semantic = pVars[0]
 		mp.Index = pVars[1]
 		mp.DataLength = pVars[2]
 		mp.mType = pVars[3]
 		mp.mData = Byte Ptr pVars[4]
 		
+		'DebugLog "mp.Semantic="+mp.Semantic
+		'DebugLog "mp.Index ="+mp.Index 
+		'DebugLog "mp.DataLength ="+mp.DataLength 
+		'DebugLog "mp.mType ="+mp.mType 
+		'DebugLog "mp.mData ="+mp.mData 
+		
 		Return mp
 		
 	End Function
 	
 	Method GetFloatValue:Float(index:Int)
 	
-		Return Float Ptr (mData)[index]
+		Return Float Ptr(mData)[index]
 		
 	End Method
 	
 	Method GetStringValue:String()
 	
-		Return String.FromCString(mData + 4 )
+		Return String.FromCString(mData + (4 * PAD))
 		
 	End Method
 	
 	Method GetIntegerValue:Int (index:Int)
 	
-		Return Int Ptr (mData)[index]
+		Return Int Ptr(mData)[index]
 		
 	End Method
 	
@@ -384,24 +386,19 @@ Type aiMaterialProperty
 End Type
 
 Rem
-bbdoc: A mesh represents a geometry Or model with a single material.
-	about:
-
-* It usually consists of a number of vertices And a series of primitives/faces 
-* referencing the vertices. In addition there might be a series of bones, each 
-* of them addressing a number of vertices with a certain weight. Vertex data 
-* is presented in channels with each channel containing a single per-vertex 
-* information such as a set of texture coords Or a normal vector.
-* If a data pointer is non-Null, the corresponding data stream is present.
-* From C++-programs you can also use the comfort functions Has*() To
-* test For the presence of various data streams.
-*
-* A Mesh uses only a single material which is referenced by a material ID.
-* @note The mPositions member is usually Not optional. However, vertex positions 
-* *could* be missing If the AI_SCENE_FLAGS_INCOMPLETE flag is set in 
-* @code
-* aiScene::mFlags
-* @endcode
+bbdoc: A mesh represents a geometry or model with a single material.
+about: It usually consists of a number of vertices and a series of primitives/faces 
+referencing the vertices. In addition there might be a series of bones, each 
+of them addressing a number of vertices with a certain weight. Vertex data 
+is presented in channels with each channel containing a single per-vertex 
+information such as a set of texture coords or a normal vector.
+If a data pointer is non-null, the corresponding data stream is present.
+From C++ programs you can also use the comfort functions Has*() to
+test for the presence of various data streams.
+<br><br>
+A mesh uses only a single material which is referenced by a material ID.
+@note The mPositions member is usually not optional. However, vertex positions 
+*could* be missing if the AI_SCENE_FLAGS_INCOMPLETE flag is set in aiScene::mFlags.
 */
 EndRem
 Type aiMesh
@@ -413,8 +410,8 @@ Type aiMesh
 	Field pNormals:Float Ptr
 	Field pTangents:Byte Ptr
 	Field pBitangents:Byte Ptr
-	Field pColors:Byte Ptr[AI_MAX_NUMBER_OF_COLOR_SETS]
-	Field pTextureCoords:Byte Ptr[AI_MAX_NUMBER_OF_TEXTURECOORDS]
+	Field pColors:Byte Ptr[AI_MAX_NUMBER_OF_COLOR_SETS * PAD]
+	Field pTextureCoords:Byte Ptr[AI_MAX_NUMBER_OF_TEXTURECOORDS * PAD]
 	Field NumUVComponents:Int[AI_MAX_NUMBER_OF_TEXTURECOORDS]
 	Field pFaces:Int Ptr
 	Field NumBones:Int
@@ -425,19 +422,19 @@ Type aiMesh
 	
 	Method VertexX:Float(index:Int)
 	
-		Return pVertices[index*3]
+		Return pVertices[index * 3]
 		
 	End Method
 	
 	Method VertexY:Float(index:Int)
 	
-		Return pVertices[index*3+1]
+		Return pVertices[(index * 3) + 1]
 		
 	End Method
 	
 	Method VertexZ:Float(index:Int)
 	
-		Return pVertices[index*3+2]
+		Return pVertices[(index * 3) + 2]
 		
 	End Method
 	
@@ -445,63 +442,63 @@ Type aiMesh
 	
 	Method VertexNX:Float(index:Int)
 	
-		Return pNormals[index*3]
+		Return pNormals[index * 3]
 		
 	End Method
 	
 	Method VertexNY:Float(index:Int)
 	
-		Return pNormals[index*3+1]
+		Return pNormals[(index * 3) + 1]
 		
 	End Method
 	
 	Method VertexNZ:Float(index:Int)
 	
-		Return pNormals[index*3+2]
+		Return pNormals[(index * 3) + 2]
 		
 	End Method
 	
 	' texcoords - funky :-)
 	
-	Method VertexU:Float(index:Int,coord_set:Int=0)
+	Method VertexU:Float(index:Int, coord_set:Int = 0)
 	
-		Return Float Ptr(pTextureCoords[coord_set])[index*3]
+		Return Float Ptr(pTextureCoords[coord_set])[index * 3]
 		
 	End Method
-
-	Method VertexV:Float(index:Int,coord_set:Int=0)
 	
-		Return Float Ptr(pTextureCoords[coord_set])[index*3 + 1]
+	Method VertexV:Float(index:Int, coord_set:Int = 0)
+	
+		Return Float Ptr(pTextureCoords[coord_set])[(index * 3) + 1]
 		
 	End Method
-
-	Method VertexW:Float(index:Int,coord_set:Int=0)
 	
-		Return Float Ptr(pTextureCoords[coord_set])[index*3 + 2 ]
+	Method VertexW:Float(index:Int, coord_set:Int = 0)
+	
+		Return Float Ptr(pTextureCoords[coord_set])[(index * 3) + 2]
 		
 	End Method
 	
-	Method VertexRed:Float(index:Int,color_set:Int=0)
+	Method VertexRed:Float(index:Int, color_set:Int = 0)
 	
-		Return Float Ptr(pColors[color_set])[index*4]
+		Return Float Ptr(pColors[color_set])[index * 4]
 		
 	End Method
 	
-	Method VertexGreen:Float(index:Int,color_set:Int=0)
+	Method VertexGreen:Float(index:Int, color_set:Int = 0)
 	
-		Return Float Ptr(pColors[color_set])[index*4 + 1]
+		Return Float Ptr(pColors[color_set])[(index * 4) + 1]
 		
 	End Method
 	
-	Method VertexBlue:Float(index:Int,color_set:Int=0)
+	Method VertexBlue:Float(index:Int, color_set:Int = 0)
 	
-		Return Float Ptr(pColors[color_set])[index*4 + 2]
+		Return Float Ptr(pColors[color_set])[(index * 4) + 2]
 		
 	End Method
 	
-	Method VertexAlpha:Float(index:Int,color_set:Int=0)
+	Method VertexAlpha:Float(index:Int, color_set:Int = 0)
 	
-		Return Float Ptr(pColors[color_set])[index*4 + 3]
+		Return Float Ptr(pColors[color_set])[(index * 4) + 3]
 		
 	End Method		
 	
@@ -541,7 +538,7 @@ Type aiMesh
 		
 	End Method
 	
-	Method HasVertexColors:Int( color_set:Int)
+	Method HasVertexColors:Int(color_set:Int)
 	
 		If NumVertices <= 0 Then Return False
 		If color_set >= AI_MAX_NUMBER_OF_COLOR_SETS Then Return False
@@ -549,28 +546,28 @@ Type aiMesh
 		
 	End Method	
 	
-	Method TriangleVertex:Int(index:Int,corner:Int)
+	Method TriangleVertex:Int(index:Int, corner:Int)
 	
-		Local faceIndexes:Int Ptr = Int Ptr pFaces[index*2+1]
+		Local faceIndexes:Int Ptr = Int Ptr pFaces[((index * 2) + 1) * PAD]
 		Return faceIndexes[corner]
 		
 	End Method
 	
 	Method GetTriangularFaces:Int[,]()
 	
-		Local faces:Int[NumFaces,3]
+		Local faces:Int[NumFaces, 3]
 		Local index:Int
 		
 		For Local count:Int = 0 To NumFaces - 1
-			Local faceCount:Int = pFaces[index]
-			Local faceIndexes:Int Ptr = Int Ptr pFaces[index+1]
+			Local faceCount:Int = pFaces[index * PAD]
+			Local faceIndexes:Int Ptr = Int Ptr pFaces[(index + 1) * PAD]
 			
 			' TODO for nontriangular faces: faceCount could be other than 3
 			For Local n:Int = 0 To 2
-				faces[count , n] = faceIndexes[n]
+				faces[count, n] = faceIndexes[n]
 			Next
 			
-			index:+2
+			index:+ 2
 		Next
 		
 		Return faces
@@ -591,47 +588,58 @@ Type aiNode
 	Field MeshIndexes:Int[]
 	Field Parent:aiNode
 	
-	Function Create:aiNode(pointer:Byte Ptr,parent:aiNode = Null)
+	Function Create:aiNode(pointer:Byte Ptr, parent:aiNode = Null)
 	
-		Local n:aiNode = New aiNode
-		n.Parent = parent
-		n.pointer = pointer
-		n.name = String.FromCString(pointer + 4)
+		Local node:aiNode = New aiNode
+		node.Parent = parent
+		node.pointer = pointer
 		
-		'DebugLog "Nodename " + n.name
-
-		n.transformation = aiMatrix4x4.Create(Float Ptr (Byte Ptr pointer + MAXLEN + 4))
+		node.name = String.FromCString(pointer + (4 * PAD))
+		
+		DebugLog "Nodename " + node.name
+		
+		node.transformation = aiMatrix4x4.Create(Float Ptr (Byte Ptr pointer + MAXLEN + (4 * PAD)))
 		
-		Local pBase:Int Ptr = Int Ptr(Byte Ptr pointer + MAXLEN + 4 + 16*4)
+		Local pBase:Int Ptr = Int Ptr(Byte Ptr pointer + MAXLEN + (4 * PAD) + (16 * 4))
+		
+		'For Local i:Int = 0 To 11
+		'	DebugLog "pBase " + i + "=" + pBase[i]
+		'Next
 		
 		'Rem
-		n.NumMeshes = pBase[3]
+		node.NumMeshes = pBase[3 * PAD] ' int 3/6
 		
-		'DebugLog "Mesh count for this node: " + n.NumMeshes
+		DebugLog "Mesh count for this node: " + node.NumMeshes
 		
-		Local pMeshIndexArray:Int Ptr = Int Ptr pBase[4]
+		Local pMeshIndexArray:Int Ptr = Int Ptr pBase[4 * PAD] ' ptr 4/8
 		
-		n.MeshIndexes = n.MeshIndexes[..n.NumMeshes ]
+		node.MeshIndexes = node.MeshIndexes[..node.NumMeshes]
 		
-		For Local i:Int = 0 To n.NumMeshes - 1
-			n.MeshIndexes[i] = pMeshIndexArray[i]
+		For Local id:Int = 0 To node.NumMeshes - 1
+			node.MeshIndexes[id] = pMeshIndexArray[id * PAD]
 		Next
 		'End Rem
 		
 		' get child nodes
-		n.NumChildren = pBase[1]
+		node.NumChildren = pBase[1 * PAD] ' int 1/2
+		
+		DebugLog "node.NumChildren=" + node.NumChildren
 		
-		If n.NumChildren		
-			Local pChildArray:Int Ptr = Int Ptr pBase[2]
+		If node.NumChildren
+			Local pChildArray:Int Ptr = Int Ptr pBase[2 * PAD] ' ptr 2/4
+			
+			'For Local i:Int = 0 To 11
+			'	DebugLog "pChildArray " + i + "=" + pChildArray[i]
+			'Next
 			
-			n.Children = n.Children[..n.NumChildren]
+			node.Children = node.Children[..node.NumChildren]
 			
-			For Local i:Int = 0 To n.NumChildren - 1
-				n.Children[i] = aiNode.Create(Byte Ptr pChildArray[i],n)
+			For Local id:Int = 0 To node.NumChildren - 1
+				node.Children[id] = aiNode.Create(Byte Ptr pChildArray[id * PAD], node)
 			Next
 		EndIf
 		
-		Return n
+		Return node
 		
 	End Function
 	
@@ -641,111 +649,157 @@ Type aiScene
 
 	Field pointer:Int Ptr
 	Field flags:Int
-	
 	Field rootNode:aiNode
 	Field numMeshes:Int
 	Field meshes:aiMesh[]
 	Field NumMaterials:Int
 	Field materials:aiMaterial[]
 	
-	' aiImportFileFromMemory by Happy Cat (JM) - Jan 2013
-	Method ImportFile:Int Ptr( filename:String,readflags:Int )
+	Method ImportFile:Int Ptr(fileName:String, readflags:Int)
 	
-		If (Left(filename, 8) = "incbin::")
+		If (Left(filename, 5) = "zip::") ' load zip mesh (ram stream by Pertubatio)
 		
-			Local binName:String = Mid(filename, 9)
-			Local binPtr:Byte Ptr = IncbinPtr(binName)
-			Local binLen:Int = IncbinLen(binName)
+			Local fileStream:TStream = CreateBufferedStream(fileName)
+			Local bufLen:Int = StreamSize(fileStream)
+			Local buffer:Byte Ptr = MemAlloc(bufLen)
+			Local ramStream:TRamStream = CreateRamStream(buffer, bufLen, True, True)
+			CopyStream(fileStream, ramStream)
 			
-			If (binPtr = Null Or binLen = 0) Then Return Null
+			pointer = aiImportFileFromMemory(buffer, bufLen, readFlags, Right(fileName, 3))
 			
-			pointer = aiImportFileFromMemory(binPtr, binLen, readFlags, Right(fileName, 3))
+			MemFree(buffer)
+			CloseStream(fileStream)
+			CloseStream(ramStream)
+			
+		ElseIf (Left(filename, 8) = "incbin::") ' load incbin mesh by Happy Cat - Jan 2013
+		
+			Local binName:String = Mid(filename, 9)
+			Local buffer:Byte Ptr = IncbinPtr(binName)
+			Local bufLen:Int = IncbinLen(binName)
+			If (buffer = Null Or bufLen = 0) Then Return Null
+			
+			pointer = aiImportFileFromMemory(buffer, bufLen, readFlags, Right(fileName, 3))
 			
 		Else
-		?win32	
+		?win32
 			' TODO this is a fix for wavefront mtl not being found
 			' does this mess up UNC paths or something else?
-			filename = filename.Replace("/","\")
+			filename = filename.Replace("/", "\")
 		?
-			'DebugLog "filename " + filename
-			
 			pointer = aiImportFile(filename, readflags)
+			
 		EndIf
 		
 		If pointer <> Null
 		
 			flags = pointer[0]
 			
-			rootNode = aiNode.Create(Byte Ptr pointer[1])
-			numMeshes = pointer[2]
+			'For Local n:Int = 0 To 23
+			'	DebugLog "pointer " + n + "=" + pointer[n]
+			'Next
 			
-			Local pMeshArray:Int Ptr = Int Ptr pointer[3]
+			rootNode = aiNode.Create(Byte Ptr pointer[1 * PAD]) ' 1/2
+			numMeshes = pointer[2 * PAD] ' 2/4
+			
+			Local pMeshArray:Int Ptr = Int Ptr pointer[3 * PAD] ' 3/6
 			meshes = meshes[..numMeshes]
 			
-			For Local i:Int = 0 To numMeshes - 1 
-				Local pMesh:Int Ptr = Int Ptr pMeshArray[i]
+			DebugLog "flags = " + flags
+			DebugLog "rootNode.pointer = " + rootNode.pointer
+			DebugLog "numMeshes = " + numMeshes ' 1/3
+			DebugLog "pMeshArray = " + pMeshArray ' 2/5
+			
+			For Local id:Int = 0 To numMeshes - 1
+				Local pMesh:Int Ptr = Int Ptr pMeshArray[id * PAD]
+				
+				'For Local n:Int = 0 To 13
+				'	DebugLog "pmesh " + n + "=" + pMesh[n]
+				'Next
 				
-				meshes[i] = New aiMesh
-				meshes[i].PrimitiveTypes = pMesh[0]
-				meshes[i].NumVertices = pMesh[1]
-				meshes[i].NumFaces = pMesh[2]
+				meshes[id] = New aiMesh
+				meshes[id].PrimitiveTypes = pMesh[0]
+				meshes[id].NumVertices = pMesh[1]
+				meshes[id].NumFaces = pMesh[2]
 				
-				meshes[i].pVertices = Float Ptr pMesh[3]
-				meshes[i].pNormals = Float Ptr pMesh[4]
-				meshes[i].pTangents = Byte Ptr pMesh[5]
-				meshes[i].pBitangents = Byte Ptr pMesh[6]
+				meshes[id].pVertices = Float Ptr pMesh[(2 * PAD) + ONE32] ' 3/4 - calculate 32/64 offsets
+				meshes[id].pNormals = Float Ptr pMesh[(3 * PAD) + ONE32] ' 4/6
+				meshes[id].pTangents = Byte Ptr pMesh[(4 * PAD) + ONE32] ' 5/8
+				meshes[id].pBitangents = Byte Ptr pMesh[(5 * PAD) + ONE32] ' 6/10
 				
-				Local pMeshPointerOffset:Int = 7
+				DebugLog "meshes[" + id + "].PrimitiveTypes = " + meshes[id].PrimitiveTypes 
+				DebugLog "meshes[" + id + "].NumVertices = " + meshes[id].NumVertices 
+				DebugLog "meshes[" + id + "].NumFaces = " + meshes[id].NumFaces 
+				DebugLog "meshes[" + id + "].pVertices = " + meshes[id].pVertices 
+				DebugLog "meshes[" + id + "].pNormals = " + meshes[id].pNormals 
+				DebugLog "meshes[" + id + "].pTangents = " + meshes[id].pTangents 
+				DebugLog "meshes[" + id + "].pBitangents = " + meshes[id].pBitangents 
+				
+				Local pMeshPointerOffset:Int = (6 * PAD) + ONE32 ' 7/12
 				
 				For Local n:Int = 0 To AI_MAX_NUMBER_OF_COLOR_SETS - 1
-					meshes[i].pColors[n] = Byte Ptr pMesh[pMeshPointerOffset + n]
+					meshes[id].pColors[n] = Byte Ptr pMesh[pMeshPointerOffset + n] ' ptr arr - twice the size in 64-bit
+					'DebugLog "meshes[" + id + "].pColors[n] = " + meshes[id].pColors[n]
 				Next
 				
-				pMeshPointerOffset:+ AI_MAX_NUMBER_OF_COLOR_SETS
+				pMeshPointerOffset:+ (AI_MAX_NUMBER_OF_COLOR_SETS * PAD) ' 15/28
 				
 				For Local n:Int = 0 To AI_MAX_NUMBER_OF_TEXTURECOORDS - 1
-					meshes[i].pTextureCoords[n] = Byte Ptr pMesh[pMeshPointerOffset + n]
+					meshes[id].pTextureCoords[n] = Byte Ptr pMesh[pMeshPointerOffset + n] ' ptr arr
+					'DebugLog "meshes[" + id + "].pTextureCoords[n] = " + meshes[id].pTextureCoords[n]
 				Next 
 				
-				pMeshPointerOffset:+ AI_MAX_NUMBER_OF_TEXTURECOORDS
+				pMeshPointerOffset:+ (AI_MAX_NUMBER_OF_TEXTURECOORDS * PAD) ' 23/44
 				
 				For Local n:Int = 0 To AI_MAX_NUMBER_OF_TEXTURECOORDS - 1
-					meshes[i].NumUVComponents[n] = pMesh[pMeshPointerOffset + n]
+					meshes[id].NumUVComponents[n] = pMesh[pMeshPointerOffset + n] ' int arr - same size as 32-bit
+					'DebugLog "meshes[" + id + "].NumUVComponents[n] = " + meshes[id].NumUVComponents[n]
 				Next
 				
-				pMeshPointerOffset:+ AI_MAX_NUMBER_OF_TEXTURECOORDS
+				pMeshPointerOffset:+ AI_MAX_NUMBER_OF_TEXTURECOORDS ' 31/52
+				
+				meshes[id].pFaces = Int Ptr pMesh[pMeshPointerOffset]
+				meshes[id].NumBones = pMesh[pMeshPointerOffset + (1 * PAD)] ' 32/54
+				meshes[id].pBones = Byte Ptr pMesh[pMeshPointerOffset + (2 * PAD)] ' 33/55
+				meshes[id].MaterialIndex = pMesh[pMeshPointerOffset + (3 * PAD)] ' 34/57
 				
-				meshes[i].pFaces = Int Ptr pMesh[pMeshPointerOffset]
-				meshes[i].NumBones = pMesh[pMeshPointerOffset+1]
-				meshes[i].pBones = Byte Ptr pMesh[pMeshPointerOffset+2]
-				meshes[i].MaterialIndex = pMesh[pMeshPointerOffset+3]
+				'For Local n:Int = 0 To meshes[id].NumFaces - 1
+				'	DebugLog "meshes[id].pFaces " + n + "="+meshes[id].pFaces[n]
+				'Next
+				
+				DebugLog "meshes[" + id + "].pFaces = " + meshes[id].pFaces
+				DebugLog "meshes[" + id + "].NumBones = " + meshes[id].NumBones 
+				DebugLog "meshes[" + id + "].pBones = " + meshes[id].pBones 
+				DebugLog "meshes[" + id + "].MaterialIndex = " + meshes[id].MaterialIndex
 				
 			Next
 			
-			NumMaterials = pointer[4]
+			NumMaterials = pointer[4 * PAD] ' 4/8
 			
-			Local pMaterialArray:Int Ptr = Int Ptr pointer[5]
+			Local pMaterialArray:Int Ptr = Int Ptr pointer[5 * PAD] ' 5/10
 			materials = materials[..NumMaterials]
 			
-			For Local i:Int = 0 To NumMaterials - 1 
-				'DebugLog "Material found"
+			DebugLog "NumMaterials = " + NumMaterials
+			DebugLog "pMaterialArray = " + pMaterialArray
+			
+			For Local id:Int = 0 To NumMaterials - 1 
+				DebugLog "Material found"
 				
-				materials [i] = New aiMaterial 
-				materials [i].pMaterial = Int Ptr pMaterialArray[i]
-				materials [i].NumProperties = materials [i].pMaterial[1]
-				materials [i].NumAllocated = materials [i].pMaterial[2]	
+				materials[id] = New aiMaterial
+				materials[id].pMaterial = Int Ptr pMaterialArray[id * PAD]
+				materials[id].NumProperties = materials[id].pMaterial[1 * PAD]
+				materials[id].NumAllocated = materials[id].pMaterial[2 * PAD]
 				
-				'Rem ' loading properties is not needed, but I do it for now to make a list of loaded properties
+				'Rem
+				' loading properties is not needed, but I do it for now to make a list of loaded properties
 				' redim
-				materials [i].Properties = materials [i].Properties[..materials [i].pMaterial[1]]
+				materials[id].Properties = materials[id].Properties[..materials[id].pMaterial[1 * PAD]]
 				
-				Local pMaterialPropertyArray:Int Ptr = Int Ptr materials [i].pMaterial[0]	
+				Local pMaterialPropertyArray:Int Ptr = Int Ptr materials[id].pMaterial[0]	
 				
-				For Local p:Int = 0 To materials [i].NumProperties - 1
-					'DebugLog "Materialproperty found"
-					materials [i].Properties[p] = aiMaterialProperty.Create(Byte Ptr pMaterialPropertyArray[p])
+				For Local pid:Int = 0 To materials[id].NumProperties - 1
+					DebugLog "Materialproperty found"
+					materials[id].Properties[pid] = aiMaterialProperty.Create(Byte Ptr pMaterialPropertyArray[pid * PAD])
 				Next
-				
 				'EndRem
 			Next
 			
@@ -768,5 +822,5 @@ Type aiScene
 		flags = 0
 	
 	End Method
-		
+	
 End Type

+ 10 - 12
examples/assimp/showall.bmx

@@ -3,11 +3,11 @@
 
 Strict
 
-Import Openb3dlibs.Assimp
+Framework Openb3d.Openb3d
+Import Openb3dLibs.Assimp
 
 Graphics3D DesktopWidth(),DesktopHeight(),0,2
 
-
 Local cam:TCamera=CreateCamera()
 PositionEntity cam,0,150,-145
 
@@ -35,14 +35,15 @@ If FileSize(path)=-1 Then Print "Error: path not found"
 'skipExt.addlast("irrmesh")
 
 Local test%=0
+
 Select test
-	Case 0 ' load all
+	Case 0 ' load all formats
 		aiEnumFiles( filelist,path,skipExt )
 	Case 1 ' specify a format
 		aiEnumFiles( filelist,path+"/OBJ",skipExt )
-	Case 2 ' current directory
+	Case 2 ' use current directory
 		aiEnumFiles( filelist,"./",skipExt )
-	Case 3 ' load path
+	Case 3 ' use file requester
 		path=RequestDir( "Select a Folder",CurrentDir() )
 		If FileType(path$) = 2 Then aiEnumFiles( filelist,path,skipExt )
 End Select
@@ -63,7 +64,7 @@ Local mesh:TMesh = CreateCube()
 PointEntity cam,mesh
 
 ' slideshow
-Local go:Int =1
+Local go:Int = 1
 Local lastslideTime:Int = MilliSecs()
 Local slideDuration:Int = 1000
 Local slideshow:Int = False
@@ -95,15 +96,13 @@ While Not KeyDown(KEY_ESCAPE)
 		If aiIsExtensionSupported( ExtractExt(String(filearray[fileNUmber])) )
 
 			currentFile = String(filearray[fileNUmber])
-			
 			If mesh Then FreeEntity mesh ; mesh = Null
-			
 			mesh = aiLoadMesh( String(filearray[fileNUmber]) )
 			
 			If mesh
-			'	EntityPickMode( mesh,2 )
-				aiFitAnimMesh mesh,-100,-100,-100,200,200,200,True
-			'	FitMesh mesh,-100,-100,-100,200,200,200,True
+				'EntityPickMode( mesh,2 )
+				aiFitAnimMesh mesh,-100,-100,-100,200,200,200,True	
+				'FitMesh mesh,-100,-100,-100,200,200,200,True
 			EndIf
 		EndIf
 		
@@ -137,4 +136,3 @@ While Not KeyDown(KEY_ESCAPE)
 	
 Wend
 End
-

+ 8 - 11
examples/assimp/showallhierarchy.bmx

@@ -3,11 +3,11 @@
 
 Strict
 
-Import Openb3dlibs.Assimp
+Framework Openb3d.Openb3d
+Import Openb3dLibs.Assimp
 
 Graphics3D DesktopWidth(),DesktopHeight(),0,2
 
-
 Local cam:TCamera=CreateCamera()
 PositionEntity cam,0,150,-145
 
@@ -22,8 +22,8 @@ Local filelist:TList = New TList
 Local skipExt:TList = New TList
 
 Local path$
-path = "../../assimplib.mod/assimp/test/models-nonbsd"
-'path = "../../assimplib.mod/assimp/test/models"
+'path = "../../assimplib.mod/assimp/test/models-nonbsd"
+path = "../../assimplib.mod/assimp/test/models"
 If FileSize(path)=-1 Then Print "Error: path not found"
 
 'skipExt.addlast("xml")
@@ -35,14 +35,15 @@ If FileSize(path)=-1 Then Print "Error: path not found"
 'skipExt.addlast("irrmesh")
 
 Local test%=0
+
 Select test
-	Case 0 ' load all
+	Case 0 ' load all formats
 		aiEnumFiles( filelist,path,skipExt )
 	Case 1 ' specify a format
 		aiEnumFiles( filelist,path+"/OBJ",skipExt )
-	Case 2 ' current directory
+	Case 2 ' use current directory
 		aiEnumFiles( filelist,"./",skipExt )
-	Case 3 ' load path
+	Case 3 ' use file requester
 		path=RequestDir( "Select a Folder",CurrentDir() )
 		If FileType(path$) = 2 Then aiEnumFiles( filelist,path,skipExt )
 End Select
@@ -124,11 +125,8 @@ While Not KeyDown(KEY_ESCAPE)
 		If aiIsExtensionSupported( ExtractExt(String(filearray[fileNUmber])) )
 		
 			currentModel = String(filearray[fileNUmber])
-			
 			If mainEnt Then FreeEntity mainEnt ; mainEnt = Null
-			
 			mainEnt = aiLoadMesh( String(filearray[fileNUmber]) )
-			
 			If mainEnt Then aiFitAnimMesh mainEnt,-100,-100,-100,200,200,200,True	
 			
 		EndIf
@@ -165,4 +163,3 @@ While Not KeyDown(KEY_ESCAPE)
 	
 Wend
 End
-

+ 147 - 0
examples/assimp/showdebug.bmx

@@ -0,0 +1,147 @@
+' showdebug.bmx
+
+Strict
+
+Framework Openb3d.Openb3d
+Import Openb3dLibs.Assimp
+
+'Include "typeslib.bmx"
+'Include "types.bmx"
+
+Local width%=DesktopWidth(),height%=DesktopHeight(),depth%=0,Mode%=2
+
+Graphics3D width,height,depth,Mode
+
+Local cam:TCamera=CreateCamera()
+PositionEntity cam,0,10,-15
+
+Local light:TLight=CreateLight()
+
+Local sphere:TMesh=CreateSphere()
+HideEntity sphere
+
+Local path$ = "../../assimplib.mod/assimp/test/models"
+Local ent:TMesh
+
+Local test%=2
+
+Select test
+
+	Case 1 ' load assimp mesh
+		Local time:Int=MilliSecs()
+		Local file:String = "../media/zombie.b3d"
+		ent = aiLoader.LoadMesh(file, Null, -2)
+		DebugLog "assimp time="+(time-MilliSecs())
+		
+	' debugging
+	Case 2 ' model trouble
+		DebugLog "modeltrouble test:"
+		ent=aiLoader.LoadMesh("modeltrouble/assimp301/house.dae")
+		FitMesh ent,-10,0,-10,20,20,20,True
+		
+	Case 3
+		DebugLog "modeltrouble test:"
+		ent=aiLoader.LoadMesh("modeltrouble/assimp303/model.obj")
+		FitMesh ent,-10,0,-10,20,20,20,True
+		
+	Case 4 ' ascii cob bug test
+		DebugLog "cob test:"
+		ent=aiLoader.LoadMesh(path+"COB/dwarf_ascii.cob")
+		If ent=Null Then ent=sphere
+		FitMesh ent,-10,0,-10,20,20,20,True
+		
+	Case 5
+		DebugLog "cob test:"
+		ent=aiLoader.LoadMesh(path+"COB/molecule_ascii.cob")
+		If ent=Null Then ent=sphere
+		FitMesh ent,-10,0,-10,20,20,20,True
+		
+	Case 6 ' blend bug test
+		' error: terminate called after throwing an instance of 'Assimp::Blender::Error'
+		' what(): BlendDNA: Did not find a field named `angle` in structure `Camera`
+		DebugLog "blend test:"
+		ent=aiLoader.LoadMesh(path+"BLEND/4Cubes4Mats_248.blend")
+		If ent=Null Then ent=sphere
+		FitMesh ent,-10,0,-10,20,20,20,True
+		
+	Case 7
+		DebugLog "blend test:"
+		ent=aiLoader.LoadMesh(path+"BLEND/blender_269_regress1.blend")
+		If ent=Null Then ent=sphere
+		FitMesh ent,-10,0,-10,20,20,20,True
+End Select
+
+' child entity variables
+Local child_ent:TEntity ' this will store child entity of anim mesh
+Local child_no%=1 ' used to select child entity
+Local count_children%=TEntity.CountAllChildren(ent) ' total no. of children belonging to entity
+
+' marker entity. will be used to highlight selected child entity (with zombie anim mesh it will be a bone)
+Local marker_ent:TMesh=CreateSphere(8)
+EntityColor marker_ent,255,255,0
+ScaleEntity marker_ent,.25,.25,.25
+EntityOrder marker_ent,-1
+
+' anim time - this will be incremented/decremented each frame and then supplied to SetAnimTime to animate entity
+Local anim_time#=0
+
+' used by fps code
+Local old_ms%=MilliSecs()
+Local renders%=0, fps%=0
+
+
+While Not KeyDown(KEY_ESCAPE)		
+
+	If KeyHit(KEY_ENTER) Then DebugStop
+	
+	If KeyDown(KEY_LEFT) Then TurnEntity ent,0,3,0
+	If KeyDown(KEY_RIGHT) Then TurnEntity ent,0,-3,0
+	
+	' control camera
+	MoveEntity cam,KeyDown(KEY_D)-KeyDown(KEY_A),0,KeyDown(KEY_W)-KeyDown(KEY_S)
+
+	' change anim time values
+	If KeyDown(KEY_MINUS) Then anim_time#=anim_time#-0.1
+	If KeyDown(KEY_EQUALS) Then anim_time#=anim_time#+0.1
+	
+	' animte entity
+	SetAnimTime(ent,anim_time#)
+
+	' select child entity
+	If KeyHit(KEY_OPENBRACKET) Then child_no=child_no-1
+	If KeyHit(KEY_CLOSEBRACKET) Then child_no=child_no+1
+	If child_no<1 Then child_no=1
+	If child_no>count_children Then child_no=count_children
+	
+	' get child entity
+	Local count%=0 ' this is just a count variable needed by GetChildFromAll. must be set to 0.
+	child_ent=ent.GetChildFromAll(child_no,count) ' get child entity
+
+	' position marker entity at child entity position
+	If child_ent<>Null
+		PositionEntity marker_ent,EntityX(child_ent,True),EntityY(child_ent,True),EntityZ(child_ent,True)
+	EndIf
+
+	RenderWorld
+	renders=renders+1
+	
+	' calculate fps
+	If MilliSecs()-old_ms>=1000
+		old_ms=MilliSecs()
+		fps=renders
+		renders=0
+	EndIf
+	
+	Text 0,0,"FPS: "+fps
+	Text 0,20,"+/- to animate"
+	Text 0,40,"[] to select different child entity (bone)"
+	Text 0,60,"WSAD move camera, LR arrows turn entity"
+	If child_ent<>Null
+		Text 0,80,"Child Name: "+EntityName(child_ent)
+	EndIf
+	Text 0,100,"No children: "+count_children
+
+	Flip
+	
+Wend
+End

+ 49 - 57
examples/assimp/showsingle.bmx

@@ -1,15 +1,17 @@
 ' showsingle.bmx
-' bones.bmx from Minib3d (no animation)
+' based on minib3d bones example
 
 Strict
 
+Framework Openb3d.Openb3d
 Import Openb3dLibs.Assimp
 
-Incbin "media/zombie.b3d"
-Incbin "media/Zombie.jpg"
+Incbin "../media/zombie.b3d"
+Incbin "../media/Zombie.jpg"
 
-Graphics3D DesktopWidth(),DesktopHeight(),0,2
+Local width%=DesktopWidth(),height%=DesktopHeight(),depth%=0,Mode%=2
 
+Graphics3D width,height,depth,Mode
 
 Local cam:TCamera=CreateCamera()
 PositionEntity cam,0,10,-15
@@ -18,56 +20,47 @@ Local light:TLight=CreateLight()
 
 Local sphere:TMesh=CreateSphere()
 HideEntity sphere
+
 Local ent:TMesh
-Local path$ = "../../assimplib.mod/assimp/test/models"
 
-Local test%=1
+Local zipfile:String = "../media/zombie.zip"
+
+' Note: you can load password protected zips but these are easily opened with 7zip as the filenames are not encrypted, 
+' a zip inside a password zip is encrypted but zipstream can't open these, so use custom pak file to protect assets.
+'SetZipStreamPassword zipfile,"blitzmax"
+
+Local test%=3
+
 Select test
-	' load anim mesh
-	Case 0
-		ent=LoadAnimMesh("media/zombie.b3d")
-	' load incbin mesh and texture
-	Case 1
-		aiLoader.meshflags=0 ' 0=smooth normals, 1=flat shaded
-		ent=aiLoadMesh("incbin::media/zombie.b3d")
-		Local tex:TTexture=LoadTexture("incbin::media/Zombie.jpg",9,True) ' set usepixmap for incbin
+
+	Case 1 ' load assimp mesh
+		Local time:Int=MilliSecs()
+		Local file:String = "../media/zombie.b3d"
+		ent = aiLoadMesh(file, Null, -2) ' -2 = flat shaded
+		DebugLog "assimp time="+(time-MilliSecs())
+		
+	Case 2 ' load incbin mesh (and texture as file not found)
+		Local time:Int=MilliSecs()
+		Local file:String = "incbin::../media/zombie.b3d"
+		ent=aiLoadMesh(file)
+		file = "incbin::../media/Zombie.jpg"
+		Local tex:TTexture=LoadTexture(file,9,True)
+		EntityTexture ent,tex
+		DebugLog "incbin time="+(time-MilliSecs())
+		
+	Case 3 ' load zip mesh (and texture as file not found)
+		Local time:Int=MilliSecs()
+		Local file:String = "zip::"+zipfile+"//zombie.b3d"
+		ent = aiLoadMesh(file)
+		file = "zip::"+zipfile+"//Zombie.jpg"
+		Local tex:TTexture=LoadTexture(file,9,True)
 		EntityTexture ent,tex
-		RotateEntity ent,0,180,0
-	' model trouble
-	Case 2
-		ent=aiLoadMesh("modeltrouble/assimp301/house.dae")
-		RotateEntity ent,0,180,0
-		FitMesh ent,-10,0,-10,20,20,20,True
-	Case 3
-		ent=aiLoadMesh("modeltrouble/assimp303/model.obj")
-		RotateEntity ent,0,180,0
-		FitMesh ent,-10,0,-10,20,20,20,True
-	Rem
-	' ascii cob bug test
-	Case 4
-		ent=aiLoadMesh(path+"COB/dwarf_ascii.cob")
-		If ent=Null Then ent=sphere
-		RotateEntity ent,0,180,0
-		FitMesh ent,-10,0,-10,20,20,20,True
-	Case 5
-		ent=aiLoadMesh(path+"COB/molecule_ascii.cob")
-		If ent=Null Then ent=sphere
-		RotateEntity ent,0,180,0
-		FitMesh ent,-10,0,-10,20,20,20,True
-	' mac .a bug test (.dylib works)
-	' error: terminate called after throwing an instance of 'Assimp::Blender::Error'
-	' what(): BlendDNA: Did not find a field named `angle` in structure `Camera`
-	Case 6
-		ent=aiLoadMesh(path+"BLEND/4Cubes4Mats_248.blend")
-		If ent=Null Then ent=sphere
-		RotateEntity ent,0,180,0
-		FitMesh ent,-10,0,-10,20,20,20,True
-	Case 7
-		ent=aiLoadMesh(path+"BLEND/blender_269_regress1.blend")
-		If ent=Null Then ent=sphere
-		RotateEntity ent,0,180,0
-		FitMesh ent,-10,0,-10,20,20,20,True
-	EndRem
+		DebugLog "zip time="+(time-MilliSecs())
+		
+	Default ' load openb3d mesh
+		Local time:Int=MilliSecs()
+		ent=LoadAnimMesh("../media/zombie.b3d")
+		DebugLog "openb3d time="+(time-MilliSecs())
 End Select
 
 ' child entity variables
@@ -131,17 +124,16 @@ While Not KeyDown(KEY_ESCAPE)
 		renders=0
 	EndIf
 	
-	Text 0,20,"FPS: "+fps
-	Text 0,40,"+/- to animate"
-	Text 0,60,"[] to select different child entity (bone)"
-	Text 0,80,"WSAD move camera, LR arrows turn entity"
+	Text 0,0,"FPS: "+fps
+	Text 0,20,"+/- to animate"
+	Text 0,40,"[] to select different child entity (bone)"
+	Text 0,60,"WSAD move camera, LR arrows turn entity"
 	If child_ent<>Null
-		Text 0,100,"Child Name: "+EntityName(child_ent)
+		Text 0,80,"Child Name: "+EntityName(child_ent)
 	EndIf
-	Text 0,120,"No children: "+count_children
+	Text 0,100,"No children: "+count_children
 
 	Flip
 	
 Wend
 End
-

二進制
examples/media/zombie.zip