For advanced users only assimp..
You have to learn the C API self.
Some importers are complete and stable some are not stable nor complete..
Supported 3d model / scene / game and motion capture formats:
Collada ( .dae )
Blender 3D ( .blend )
3ds Max 3DS ( .3ds )
3ds Max ASE ( .ase )
Wavefront Object ( .obj )
Industry Foundation Classes (IFC/Step) ( .ifc )
XGL ( .xgl,.zgl )
Stanford Polygon Library ( .ply )
AutoCAD DXF ( .dxf )
LightWave ( .lwo )
LightWave Scene ( .lws )
Modo ( .lxo )
Stereolithography ( .stl )
DirectX X ( .x )
AC3D ( .ac )
Milkshape 3D ( .ms3d )
TrueSpace ( .cob,.scn )
Biovision BVH ( .bvh )
CharacterStudio Motion ( .csm )
Ogre XML ( .xml )
Irrlicht Mesh ( .irrmesh )
Irrlicht Scene ( .irr )
Quake I ( .mdl )
Quake II ( .md2 )
Quake III Mesh ( .md3 )
Quake III Map/BSP ( .pk3 )
Return to Castle Wolfenstein ( .mdc )
Doom 3 ( .md5* )
Valve Model ( .smd,.vta )
Starcraft II M3 ( .m3 )
Unreal ( .3d )
BlitzBasic 3D ( .b3d )
Quick3D ( .q3d,.q3s )
Neutral File Format ( .nff )
Sense8 WorldToolKit ( .nff )
Object File Format ( .off )
PovRAY Raw ( .raw )
Terragen Terrain ( .ter )
3D GameStudio (3DGS) ( .mdl )
3D GameStudio (3DGS) Terrain ( .hmp )
Izware Nendo ( .ndo )
Windows and Linux (32/64-bit).
download: assimp-3.1.1.zip
Source code with Code::Blocks project file.
download: assimp-3.1.1-src.zip
Joshy
file: test01.bas
Code: Select all
#include "inc/assimp-c.bi"
'const as string file = "media/test_cube_compressed.x"
'const as string file = "media/jeep1.ms3d"
'const as string file = "media/test.obj"
const as string file = "media/shadow.obj"
'const as string file = "media/test.3ds"
'const as string file = "media/test.dae"
sub processMesh(byval mesh as aiMesh ptr,byval scene as const aiScene ptr)
dim as aiColor4D col
if mesh->mName.length>0 then
print "Mesh name: " & mesh->mName.data
print
end if
dim as aiMaterial ptr mat=scene->mMaterials[mesh->mMaterialIndex]
if mat then
if aiGetMaterialColor(mat,AI_MATKEY_COLOR_DIFFUSE,@col)=aiReturn_SUCCESS then
print "material diffuse :" & col.r & "," & col.g & "," & col.b & "," & col.a
end if
if aiGetMaterialColor(mat,AI_MATKEY_COLOR_AMBIENT,@col)=aiReturn_SUCCESS then
print "material ambient :" & col.r & "," & col.g & "," & col.b & "," & col.a
end if
if aiGetMaterialColor(mat,AI_MATKEY_COLOR_SPECULAR,@col)=aiReturn_SUCCESS then
print "material specular :" & col.r & "," & col.g & "," & col.b & "," & col.a
end if
print
end if
if mesh->mNumVertices then
print "mNumVertices: " & mesh->mNumVertices
for i as long=0 to mesh->mNumVertices-1
if i<10 then print "position: [" & i & "] " & mesh->mVertices[i].x & "," & mesh->mVertices[i].y & "," & mesh->mVertices[i].y
if (mesh->mNormals) then
if i<10 then print "normal : [" & i & "] " & mesh->mNormals[i].x & "," & mesh->mNormals[i].y & "," & mesh->mNormals[i].y
end if
if (mesh->mTangents) then
if i<10 then print "tangent : [" & i & "] " & mesh->mTangents[i].x & "," & mesh->mTangents[i].y & "," & mesh->mTangents[i].z
end if
if (mesh->mBitangents) then
if i<10 then print "bitangent [" & i & "] " & mesh->mBitangents[i].x & "," & mesh->mBitangents[i].y & "," & mesh->mBitangents[i].z
end if
for c as long = 0 to AI_MAX_NUMBER_OF_COLOR_SETS-1
dim as aiColor4D ptr col=mesh->mColors(c)
if col=0 then exit for
if i<10 then print "color : [" & i & "] " & col[i].r & "," & col[i].g & "," & col[i].b & "," & col[i].a
next
for t as long=0 to AI_MAX_NUMBER_OF_TEXTURECOORDS-1
dim as aiVector3D ptr v=mesh->mTextureCoords(t)
if v=0 then exit for
if i<10 then print "texture : [" & i & "] " & v[i].x & "," & v[i].y
next
next
if mesh->mNumVertices>9 then print "<CUT>"
print
end if
if mesh->mNumFaces then
print "mNumFaces: " & mesh->mNumFaces
for i as long=0 to mesh->mNumFaces-1
if i<10 then
dim as aiFace face=mesh->mFaces[i]
print "face[" & i & "].mNumIndices: " & face.mNumIndices & " < ";
for j as long = 0 to face.mNumIndices-1
print face.mIndices[j] & " ";
next
print ">"
end if
next
if mesh->mNumFaces>9 then print "<CUT>"
print
end if
for typ as long=0 to AI_TEXTURE_TYPE_MAX-1
dim as long tc = aiGetMaterialTextureCount(mat,typ) ' aiTextureType_DIFFUSE)
if tc>0 then
print "texturecount: " & tc
for i as long = 0 to tc-1
dim as aiString path
if aiGetMaterialTexture(mat,aiTextureType_DIFFUSE,i,@path)=aiReturn_SUCCESS then
print "loadTexture('" & left(path.data,path.length) & "')"
end if
next
print
end if
next
print
end sub
dim shared as long nMeshes,nChilds
sub recursiveProcess(byval node as aiNode ptr,byval scene as const aiScene ptr)
if node->mNumMeshes>0 then
print "Transformation:"
print node->mTransformation
for i as long=0 to node->mNumMeshes-1
dim as aiMesh ptr mesh=scene->mMeshes[node->mMeshes[i]]
processMesh(mesh,scene)
next
end if
if node->mNumChildren>0 then
for child as long=0 to node->mNumChildren-1
' !!! recursion !!!
recursiveProcess(node->mChildren[child],scene)
next
end if
end sub
chdir exepath
' optional
dim as aiLogStream stream
stream = aiGetPredefinedLogStream(aiDefaultLogStream_STDOUT,0)
aiAttachLogStream(@stream)
dim as const aiScene ptr scene = aiImportFile(file,aiProcessPreset_TargetRealtime_MaxQuality)
if scene=0 then
print "error: " & *aiGetErrorString()
beep : sleep : end
end if
nMeshes=0
nChilds=0
recursiveProcess(scene->mRootNode,scene)
sleep