5 Replies - 1170 Views - Last Post: 24 August 2013 - 08:31 AM Rate Topic: -----

#1 Fanie  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 8
  • Joined: 19-August 13

Assimp

Posted 20 August 2013 - 01:20 AM

Good day.

I'm still sort off new to game development and I was learning from a book called Introduction to DirecX 10 by Frank Luna. Quite a good book. Now Iím done with all the graphics stuff and have no problem with it. My other book from the same author for DirectX 11 has an assignment to import a model with Open Asset Import Library or Assimp. The objective is to create a 3d model with 3ds Max, Maya, Blender or what so ever, and load it into the DirectX application.
My application is doing the following:
Load Model through assimp.
Export model in file format introduced in the book.
Load it from there into any program supporting my file format.
Now Iíve encountered some minor problems and overcame them but I have one big problem that I do not know the answer for.
If I load 2 Cubes it works perfectly fine. If Ďn try to load a more complex model, nothing is rendered. Iíll add some code to explain:
 
const aiScene* pScene = Importer.ReadFile(pFile.c_str(),
			    aiProcess_ConvertToLeftHanded|
				aiProcess_CalcTangentSpace|
				aiProcess_GenSmoothNormals|
				aiProcess_Triangulate|
				aiProcess_JoinIdenticalVertices|
				aiProcess_PreTransformVertices |
				aiProcess_FixInfacingNormals|
				aiProcess_FindInvalidData |
				aiProcess_ValidateDataStructure 
				);


Ok, I'm using directX so convert to lefthanded is added, gen normals and tangents, join vertices that are identical like on a cube. Now I had a problem that when I render all the objects in the scene is render from the same offste. I figured out that PreTransformVertices will add the correct offset matrix to the correct mesh so I did that. The rest is just cleanup.
Then I proceed loading the model and storing it in this data structure:
struct S_SUBSETS
{
int TextureIndex;
string TextureName;
std::vector <VertexPNT> VertexBuffer;
std::vector <int> IndexBuffer;
};
//And vertex structure to store all needed info
//Vertex strukture om data in te stoor
struct VertexPNT
{
D3DXVECTOR3 Pos;
D3DXVECTOR3 Tangent;
D3DXVECTOR3 Normal;
D3DXVECTOR2 Tex;
};


Ok so now I have a vector of all the vertex data stored arranged by subset. So for material one we have a entry with all its vertices and indices, the same for material two and so on.
std::vector <S_SUBSETS> AIModelDataBuffer;


Ok now I'll include the whole export function:
void C_MAIN::ExportNaf3d()
{
//Begin van die file skryf prosedure
//Now I start writing to my file
int iNumSubsets = AIModelDataBuffer.size();
	//Create file===================================
    ofstream file("EersteOutputToets.f3d");
	ofstream Debugger ("DebugOutput.txt");
	file<<"************Model_Formaat_.f3d_deur_Fanie_Lombard*************\n";
	//Create file===================================
    //Bereken die aantal hoekpunte
//I have three variables that I collected during the assimp load. First the amount of materials
//then the amount of vertices in the whole model
//then the number of triangles in the whole model
	file<<"#Materiale "<<iAantalMateriale<<"\n";
	file<<"#Hoekpunte "<<iAantalHoekpunte<<"\n";
	file<<"#Driehoekke "<<iAantalDriehoekke<<"\n";
	file<<"\n";
//Now I write my teture details
	file<<"********************Teksture********************"<<"\n";
	for(int i = 0; i < AIModelDataBuffer.size();i++)
	{
		file<<AIModelDataBuffer[AIModelDataBuffer[i].TextureIndex].TextureName<<"\n";
		file<<"default_spec.dds"<<"\n";
		file<<"default_normal.dds"<<"\n";
		file<<"Reflectivity 0 0 0"<<"\n";
		file<<"\n";
	}
//Now all te vertex data of the whole model
	file<<"********************Hoekpunt_Data********************"<<"\n";//Skryf opskrif
	
	//Loop deur die Mesh array en onttrek die data en skryf in
	for (int i = 0; i < iNumSubsets; i++)
	{
		for (int j = 0; j < AIModelDataBuffer[i].VertexBuffer.size(); j++)
		{
			std::stringstream Outs;//Toets
			//Hoekpunt
			Outs<<"Posisie: "<<AIModelDataBuffer[i].VertexBuffer[j].Pos.x
				               <<" "
							   <<AIModelDataBuffer[i].VertexBuffer[j].Pos.y
							   <<" "
							   <<AIModelDataBuffer[i].VertexBuffer[j].Pos.z<<"\n";

			file<<Outs.str();
            //Tangent
			file<<"Tangent: "<<AIModelDataBuffer[i].VertexBuffer[j].Tangent.x<<" "
				             <<AIModelDataBuffer[i].VertexBuffer[j].Tangent.y<<" "
							 <<AIModelDataBuffer[i].VertexBuffer[j].Tangent.z<<"\n";
             //Die Normaal
			file<<"Normaal: "<<AIModelDataBuffer[i].VertexBuffer[j].Normal.x<<" "
				             <<AIModelDataBuffer[i].VertexBuffer[j].Normal.y<<" "
							 <<AIModelDataBuffer[i].VertexBuffer[j].Normal.z<<"\n";
             //Die UV koordinate
			file<<"UV_Koord: "<<AIModelDataBuffer[i].VertexBuffer[j].Tex.x<<" "
				              <<AIModelDataBuffer[i].VertexBuffer[j].Tex.y<<"\n";

			file<<"\n";
		}
	}
//And finaly all the index data
	//Skryf die Indeks gegewens in vir die hele model
	file<<"********************Indeks_Data********************"<<"\n";
	int Size = 0;
	for (int i = 0; i < AIModelDataBuffer.size();i++)
	{
		
		for (int j = 0; j < AIModelDataBuffer[i].IndexBuffer.size(); j += 3)
		{
//Because each Mesh's indices start from 0, I comensate by adding the number of indices of the previouce mesh to each
//index.  It works by the way.
			//Omdat elke indeks array elke keer by 0 begin moet ek kompenseer daarvoor deur die 
			//grootte van die vorige arra by elke indeks in die nuwe een te tel.
			int I1 = AIModelDataBuffer[i].IndexBuffer[j] + Size;
            int I2 = AIModelDataBuffer[i].IndexBuffer[j + 1]  + Size;
			int I3 = AIModelDataBuffer[i].IndexBuffer[j + 2]  + Size;
			file<<I1<<" "
				<<I2<<" "
				<<I3
			    <<" "<<i<<"\n";
		}
		Size += AIModelDataBuffer[i].VertexBuffer.size();
	}
    //sluit af
	file.close();
};

xv
Ok so thats my export code. Im going to add two files to explain my problem:
First a simple model consisting of two cubes stacked on top of each other.
************Model_Formaat_.f3d_deur_Fanie_Lombard*************//Header
#Materiale 1//No of materials
#Hoekpunte 48//Number of vertices
#Driehoekke 24//Number of triangles

********************Teksture********************
Default_Diffuse.jpg//Texture for subset
default_spec.dds
default_normal.dds
Reflectivity 0 0 0

********************Hoekpunt_Data********************
Posisie: -2.5 0 -2.5//Vertex data position
Tangent: -1 0 -0//Vertex data Tangent
Normaal: 0 -1 -0//Vertex data Normal
UV_Koord: 1 1//Vertex data UV coordinates

Posisie: -2.5 0 2.5
Tangent: -1 0 -0
Normaal: 0 -1 -0
UV_Koord: 1 0

Posisie: 2.5 0 2.5
Tangent: -1 0 -0
Normaal: 0 -1 -0
UV_Koord: 0 0

Posisie: 2.5 0 -2.5
Tangent: -1 0 -0
Normaal: 0 -1 -0
UV_Koord: 0 1

Posisie: -2.5 5 -2.5
Tangent: 1 0 -0
Normaal: 0 1 -0
UV_Koord: 0 1

Posisie: 2.5 5 -2.5
Tangent: 1 0 -0
Normaal: 0 1 -0
UV_Koord: 1 1

Posisie: 2.5 5 2.5
Tangent: 1 0 -0
Normaal: 0 1 -0
UV_Koord: 1 0

Posisie: -2.5 5 2.5
Tangent: 1 0 -0
Normaal: 0 1 -0
UV_Koord: 0 0

Posisie: -2.5 0 -2.5
Tangent: 1 0 -0
Normaal: 0 0 -1
UV_Koord: 0 1

Posisie: 2.5 0 -2.5
Tangent: 1 0 -0
Normaal: 0 0 -1
UV_Koord: 1 1

Posisie: 2.5 5 -2.5
Tangent: 1 0 -0
Normaal: 0 0 -1
UV_Koord: 1 0

Posisie: -2.5 5 -2.5
Tangent: 1 0 -0
Normaal: 0 0 -1
UV_Koord: 0 0

Posisie: 2.5 0 -2.5
Tangent: 0 0 1
Normaal: 1 0 -0
UV_Koord: 0 1

Posisie: 2.5 0 2.5
Tangent: 0 0 1
Normaal: 1 0 -0
UV_Koord: 1 1

Posisie: 2.5 5 2.5
Tangent: 0 0 1
Normaal: 1 0 -0
UV_Koord: 1 0

Posisie: 2.5 5 -2.5
Tangent: 0 0 1
Normaal: 1 0 -0
UV_Koord: 0 0

Posisie: 2.5 0 2.5
Tangent: -1 0 -0
Normaal: 0 0 1
UV_Koord: 0 1

Posisie: -2.5 0 2.5
Tangent: -1 0 -0
Normaal: 0 0 1
UV_Koord: 1 1

Posisie: -2.5 5 2.5
Tangent: -1 0 -0
Normaal: 0 0 1
UV_Koord: 1 0

Posisie: 2.5 5 2.5
Tangent: -1 0 -0
Normaal: 0 0 1
UV_Koord: 0 0

Posisie: -2.5 0 2.5
Tangent: 0 0 -1
Normaal: -1 0 -0
UV_Koord: 0 1

Posisie: -2.5 0 -2.5
Tangent: 0 0 -1
Normaal: -1 0 -0
UV_Koord: 1 1

Posisie: -2.5 5 -2.5
Tangent: 0 0 -1
Normaal: -1 0 -0
UV_Koord: 1 0

Posisie: -2.5 5 2.5
Tangent: 0 0 -1
Normaal: -1 0 -0
UV_Koord: 0 0

Posisie: -2 5 -2
Tangent: -1 0 -0
Normaal: 0 -1 -0
UV_Koord: 1 1

Posisie: -2 5 2
Tangent: -1 0 -0
Normaal: 0 -1 -0
UV_Koord: 1 0

Posisie: 2 5 2
Tangent: -1 0 -0
Normaal: 0 -1 -0
UV_Koord: 0 0

Posisie: 2 5 -2
Tangent: -1 0 -0
Normaal: 0 -1 -0
UV_Koord: 0 1

Posisie: -2 9 -2
Tangent: 1 0 -0
Normaal: 0 1 -0
UV_Koord: 0 1

Posisie: 2 9 -2
Tangent: 1 0 -0
Normaal: 0 1 -0
UV_Koord: 1 1

Posisie: 2 9 2
Tangent: 1 0 -0
Normaal: 0 1 -0
UV_Koord: 1 0

Posisie: -2 9 2
Tangent: 1 0 -0
Normaal: 0 1 -0
UV_Koord: 0 0

Posisie: -2 5 -2
Tangent: 1 0 -0
Normaal: 0 0 -1
UV_Koord: 0 1

Posisie: 2 5 -2
Tangent: 1 0 -0
Normaal: 0 0 -1
UV_Koord: 1 1

Posisie: 2 9 -2
Tangent: 1 0 -0
Normaal: 0 0 -1
UV_Koord: 1 0

Posisie: -2 9 -2
Tangent: 1 0 -0
Normaal: 0 0 -1
UV_Koord: 0 0

Posisie: 2 5 -2
Tangent: 0 0 1
Normaal: 1 0 -0
UV_Koord: 0 1

Posisie: 2 5 2
Tangent: 0 0 1
Normaal: 1 0 -0
UV_Koord: 1 1

Posisie: 2 9 2
Tangent: 0 0 1
Normaal: 1 0 -0
UV_Koord: 1 0

Posisie: 2 9 -2
Tangent: 0 0 1
Normaal: 1 0 -0
UV_Koord: 0 0

Posisie: 2 5 2
Tangent: -1 0 -0
Normaal: 0 0 1
UV_Koord: 0 1

Posisie: -2 5 2
Tangent: -1 0 -0
Normaal: 0 0 1
UV_Koord: 1 1

Posisie: -2 9 2
Tangent: -1 0 -0
Normaal: 0 0 1
UV_Koord: 1 0

Posisie: 2 9 2
Tangent: -1 0 -0
Normaal: 0 0 1
UV_Koord: 0 0

Posisie: -2 5 2
Tangent: 0 0 -1
Normaal: -1 0 -0
UV_Koord: 0 1

Posisie: -2 5 -2
Tangent: 0 0 -1
Normaal: -1 0 -0
UV_Koord: 1 1

Posisie: -2 9 -2
Tangent: 0 0 -1
Normaal: -1 0 -0
UV_Koord: 1 0

Posisie: -2 9 2
Tangent: 0 0 -1
Normaal: -1 0 -0
UV_Koord: 0 0

********************Indeks_Data********************//Now my indeks data
2 1 0 0//The first three is the vertices for the triangle and the 4th is the subset it belongs to.
0 3 2 0
6 5 4 0
4 7 6 0
10 9 8 0
8 11 10 0
14 13 12 0
12 15 14 0
18 17 16 0
16 19 18 0
22 21 20 0
20 23 22 0
26 25 24 0
24 27 26 0
30 29 28 0
28 31 30 0
34 33 32 0
32 35 34 0
38 37 36 0
36 39 38 0
42 41 40 0
40 43 42 0
46 45 44 0
44 47 46 0


Now this model loads perfect.
Ok so I create another simple object consisting of a cube and a cone stacked on top.
Now it does not render! And I can't see why!
Here's the file:
************Model_Formaat_.f3d_deur_Fanie_Lombard*************
#Materiale 1
#Hoekpunte 68
#Driehoekke 84

********************Teksture********************
Default_Diffuse.jpg
default_spec.dds
default_normal.dds
Reflectivity 0 0 0

********************Hoekpunt_Data********************
Posisie: -2.5 0 -2.5
Tangent: -0.942809 0.235702 0.235702
Normaal: -0.333333 -0.666667 -0.666667
UV_Koord: 1 1

Posisie: -2.5 0 2.5
Tangent: -0.57735 0.57735 -0.57735
Normaal: -0.816497 -0.408248 0.408248
UV_Koord: 1 0

Posisie: 2.5 0 2.5
Tangent: -0.942809 -0.235702 0.235702
Normaal: 0.333333 -0.666667 0.666667
UV_Koord: 0 0

Posisie: 2.5 0 -2.5
Tangent: -0.57735 -0.57735 -0.57735
Normaal: 0.816497 -0.408248 -0.408248
UV_Koord: 0 1

Posisie: -2.5 5 -2.5
Tangent: 0.745356 0.596285 -0.298142
Normaal: -0.666667 0.666667 -0.333333
UV_Koord: 0 1

Posisie: 2.5 5 -2.5
Tangent: 0.912871 -0.182574 0.365148
Normaal: 0.408248 0.408248 -0.816497
UV_Koord: 1 1

Posisie: 2.5 5 2.5
Tangent: 0.745356 -0.596285 -0.298142
Normaal: 0.666667 0.666667 0.333333
UV_Koord: 1 0

Posisie: -2.5 5 2.5
Tangent: 0.912871 0.182574 0.365148
Normaal: -0.408248 0.408248 0.816497
UV_Koord: 0 0

Posisie: -2.5 0 -2.5
Tangent: 0.942809 -0.235702 -0.235702
Normaal: -0.333333 -0.666667 -0.666667
UV_Koord: 0 1

Posisie: 2.5 0 -2.5
Tangent: 0.57735 0.57735 0.57735
Normaal: 0.816497 -0.408248 -0.408248
UV_Koord: 1 1

Posisie: 2.5 5 -2.5
Tangent: 0.912871 -0.182574 0.365148
Normaal: 0.408248 0.408248 -0.816497
UV_Koord: 1 0

Posisie: -2.5 5 -2.5
Tangent: 0.745356 0.596285 -0.298142
Normaal: -0.666667 0.666667 -0.333333
UV_Koord: 0 0

Posisie: 2.5 0 -2.5
Tangent: 0.365148 -0.182574 0.912871
Normaal: 0.816497 -0.408248 -0.408248
UV_Koord: 0 1

Posisie: 2.5 0 2.5
Tangent: -0.298142 0.596285 0.745356
Normaal: 0.333333 -0.666667 0.666667
UV_Koord: 1 1

Posisie: 2.5 5 2.5
Tangent: -0.235702 -0.235702 0.942809
Normaal: 0.666667 0.666667 0.333333
UV_Koord: 1 0

Posisie: 2.5 5 -2.5
Tangent: 0.57735 0.57735 0.57735
Normaal: 0.408248 0.408248 -0.816497
UV_Koord: 0 0

Posisie: 2.5 0 2.5
Tangent: -0.942809 -0.235702 0.235702
Normaal: 0.333333 -0.666667 0.666667
UV_Koord: 0 1

Posisie: -2.5 0 2.5
Tangent: -0.57735 0.57735 -0.57735
Normaal: -0.816497 -0.408248 0.408248
UV_Koord: 1 1

Posisie: -2.5 5 2.5
Tangent: -0.912871 -0.182574 -0.365148
Normaal: -0.408248 0.408248 0.816497
UV_Koord: 1 0

Posisie: 2.5 5 2.5
Tangent: -0.745356 0.596285 0.298142
Normaal: 0.666667 0.666667 0.333333
UV_Koord: 0 0

Posisie: -2.5 0 2.5
Tangent: -0.365148 -0.182574 -0.912871
Normaal: -0.816497 -0.408248 0.408248
UV_Koord: 0 1

Posisie: -2.5 0 -2.5
Tangent: 0.298142 0.596285 -0.745356
Normaal: -0.333333 -0.666667 -0.666667
UV_Koord: 1 1

Posisie: -2.5 5 -2.5
Tangent: 0.235702 -0.235702 -0.942809
Normaal: -0.666667 0.666667 -0.333333
UV_Koord: 1 0

Posisie: -2.5 5 2.5
Tangent: -0.57735 0.57735 -0.57735
Normaal: -0.408248 0.408248 0.816497
UV_Koord: 0 0

Posisie: 0 5 -0
Tangent: -1.#IND -1.#IND -1.#IND
Normaal: 0 -1 -0
UV_Koord: 0.5 1

Posisie: 4.33013 5 2.5
Tangent: -1.#IND -1.#IND -1.#IND
Normaal: 0.817448 0.0402246 0.574596
UV_Koord: 0.833333 1

Posisie: 5 5 -0
Tangent: -1.#IND -1.#IND -1.#IND
Normaal: 0.995229 0.0402246 0.0888902
UV_Koord: 0.75 1

Posisie: 2.5 5 4.33013
Tangent: -1.#IND -1.#IND -1.#IND
Normaal: 0.420633 0.0402246 0.906339
UV_Koord: 0.916667 1

Posisie: 0 5 -0
Tangent: -1.#IND -1.#IND -1.#IND
Normaal: 0 -1 -0
UV_Koord: 0.5 1

Posisie: -2.18557e-007 5 5
Tangent: -1.#IND -1.#IND -1.#IND
Normaal: -0.0888904 0.0402246 0.995229
UV_Koord: 3.79455e-008 1

Posisie: 2.5 5 4.33013
Tangent: -1.#IND -1.#IND -1.#IND
Normaal: 0.420633 0.0402246 0.906339
UV_Koord: -0.0833333 1

Posisie: -2.5 5 4.33013
Tangent: -1.#IND -1.#IND -1.#IND
Normaal: -0.574596 0.0402246 0.817448
UV_Koord: 0.0833334 1

Posisie: 0 5 -0
Tangent: -1.#IND -1.#IND -1.#IND
Normaal: 0 -1 -0
UV_Koord: 0.5 1

Posisie: -4.33013 5 2.5
Tangent: -1.#IND -1.#IND -1.#IND
Normaal: -0.906339 0.0402247 0.420633
UV_Koord: 0.166667 1

Posisie: -5 5 7.54979e-007
Tangent: -1.#IND -1.#IND -1.#IND
Normaal: -0.995229 0.0402246 -0.0888901
UV_Koord: 0.25 1

Posisie: 0 5 -0
Tangent: -1.#IND -1.#IND -1.#IND
Normaal: 0 -1 -0
UV_Koord: 0.5 1

Posisie: -4.33013 5 -2.5
Tangent: -1.#IND -1.#IND -1.#IND
Normaal: -0.817449 0.0402246 -0.574595
UV_Koord: 0.333333 1

Posisie: -2.5 5 -4.33013
Tangent: -1.#IND -1.#IND -1.#IND
Normaal: -0.420634 0.0402247 -0.906338
UV_Koord: 0.416667 1

Posisie: -2.32456e-006 5 -5
Tangent: -1.#IND -1.#IND -1.#IND
Normaal: 0.0888897 0.0402247 -0.995229
UV_Koord: 0.5 1

Posisie: 2.5 5 -4.33013
Tangent: -1.#IND -1.#IND -1.#IND
Normaal: 0.574595 0.0402247 -0.817449
UV_Koord: 0.583333 1

Posisie: 4.33013 5 -2.5
Tangent: -1.#IND -1.#IND -1.#IND
Normaal: 0.906338 0.0402246 -0.420634
UV_Koord: 0.666667 1

Posisie: 5 5 -0
Tangent: -0.0890255 0.00158137 0.996028
Normaal: 0.995229 0.0402246 0.0888902
UV_Koord: 0.75 1

Posisie: 2.16506 7.5 1.25
Tangent: -1.#IND -1.#IND -1.#IND
Normaal: 0.630867 0.7066 0.320506
UV_Koord: 0.833333 0.5

Posisie: 2.5 7.5 -0
Tangent: -1.#IND -1.#IND -1.#IND
Normaal: 0.7066 0.7066 -0.0378667
UV_Koord: 0.75 0.5

Posisie: 4.33013 5 2.5
Tangent: -0.57493 -0.00384927 0.818194
Normaal: 0.817448 0.0402246 0.574596
UV_Koord: 0.833333 1

Posisie: 1.25 7.5 2.16506
Tangent: -1.#IND -1.#IND -1.#IND
Normaal: 0.386093 0.7066 0.593
UV_Koord: 0.916667 0.5

Posisie: 2.5 5 4.33013
Tangent: -0.907001 -0.00384927 0.421111
Normaal: 0.420633 0.0402246 0.906339
UV_Koord: 0.916667 1

Posisie: 2.5 5 4.33013
Tangent: -0.907001 -0.00384927 0.421111
Normaal: 0.420633 0.0402246 0.906339
UV_Koord: -0.0833333 1

Posisie: -1.09278e-007 7.5 2.5
Tangent: -1.#IND -1.#IND -1.#IND
Normaal: 0.0378665 0.7066 0.7066
UV_Koord: 3.79455e-008 0.5

Posisie: 1.25 7.5 2.16506
Tangent: -1.#IND -1.#IND -1.#IND
Normaal: 0.386093 0.7066 0.593
UV_Koord: -0.0833333 0.5

Posisie: -2.18557e-007 5 5
Tangent: -0.996041 -0.00384927 -0.0888074
Normaal: -0.0888904 0.0402246 0.995229
UV_Koord: 3.79455e-008 1

Posisie: -1.25 7.5 2.16506
Tangent: -1.#IND -1.#IND -1.#IND
Normaal: -0.320506 0.7066 0.630867
UV_Koord: 0.0833334 0.5

Posisie: -2.5 5 4.33013
Tangent: -0.818193 -0.00384927 -0.57493
Normaal: -0.574596 0.0402246 0.817448
UV_Koord: 0.0833334 1

Posisie: -2.16506 7.5 1.25
Tangent: -1.#IND -1.#IND -1.#IND
Normaal: -0.593 0.7066 0.386093
UV_Koord: 0.166667 0.5

Posisie: -4.33013 5 2.5
Tangent: -0.421111 -0.00384927 -0.907001
Normaal: -0.906339 0.0402247 0.420633
UV_Koord: 0.166667 1

Posisie: -2.5 7.5 3.77489e-007
Tangent: -1.#IND -1.#IND -1.#IND
Normaal: -0.7066 0.7066 0.0378667
UV_Koord: 0.25 0.5

Posisie: -5 5 7.54979e-007
Tangent: 0.0888071 -0.00384927 -0.996041
Normaal: -0.995229 0.0402246 -0.0888901
UV_Koord: 0.25 1

Posisie: -2.16506 7.5 -1.25
Tangent: -1.#IND -1.#IND -1.#IND
Normaal: -0.630867 0.7066 -0.320506
UV_Koord: 0.333333 0.5

Posisie: -4.33013 5 -2.5
Tangent: 0.57493 -0.00384927 -0.818194
Normaal: -0.817449 0.0402246 -0.574595
UV_Koord: 0.333333 1

Posisie: -1.25 7.5 -2.16506
Tangent: -1.#IND -1.#IND -1.#IND
Normaal: -0.386093 0.7066 -0.593
UV_Koord: 0.416667 0.5

Posisie: -2.5 5 -4.33013
Tangent: 0.907001 -0.00384928 -0.421112
Normaal: -0.420634 0.0402247 -0.906338
UV_Koord: 0.416667 1

Posisie: -1.16228e-006 7.5 -2.5
Tangent: -1.#IND -1.#IND -1.#IND
Normaal: -0.0378669 0.7066 -0.7066
UV_Koord: 0.5 0.5

Posisie: -2.32456e-006 5 -5
Tangent: 0.996041 -0.00384927 0.0888067
Normaal: 0.0888897 0.0402247 -0.995229
UV_Koord: 0.5 1

Posisie: 1.25 7.5 -2.16506
Tangent: -1.#IND -1.#IND -1.#IND
Normaal: 0.320506 0.7066 -0.630867
UV_Koord: 0.583333 0.5

Posisie: 2.5 5 -4.33013
Tangent: 0.818194 -0.00384928 0.57493
Normaal: 0.574595 0.0402247 -0.817449
UV_Koord: 0.583333 1

Posisie: 2.16506 7.5 -1.25
Tangent: -1.#IND -1.#IND -1.#IND
Normaal: 0.593 0.7066 -0.386093
UV_Koord: 0.666667 0.5

Posisie: 4.33013 5 -2.5
Tangent: 0.421112 -0.00384927 0.907001
Normaal: 0.906338 0.0402246 -0.420634
UV_Koord: 0.666667 1

Posisie: 0 10 -0
Tangent: -1.#IND -1.#IND -1.#IND
Normaal: -1.35839e-007 1 -1.25115e-008
UV_Koord: 0.5 0

********************Indeks_Data********************
2 1 0 0
0 3 2 0
6 5 4 0
4 7 6 0
10 9 8 0
8 11 10 0
14 13 12 0
12 15 14 0
18 17 16 0
16 19 18 0
22 21 20 0
20 23 22 0
26 25 24 0
25 27 24 0
30 29 28 0
29 31 28 0
31 33 32 0
33 34 32 0
34 36 35 0
36 37 35 0
37 38 24 0
38 39 24 0
39 40 24 0
40 26 24 0
43 42 41 0
42 44 41 0
42 45 44 0
45 46 44 0
49 48 47 0
48 50 47 0
48 51 50 0
51 52 50 0
51 53 52 0
53 54 52 0
53 55 54 0
55 56 54 0
55 57 56 0
57 58 56 0
57 59 58 0
59 60 58 0
59 61 60 0
61 62 60 0
61 63 62 0
63 64 62 0
63 65 64 0
65 66 64 0
65 43 66 0
43 41 66 0
67 67 43 0
67 42 43 0
67 67 42 0
67 45 42 0
67 67 45 0
67 48 49 0
67 67 48 0
67 51 48 0
67 67 51 0
67 53 51 0
67 67 53 0
67 55 53 0
67 67 55 0
67 57 55 0
67 67 57 0
67 59 57 0
67 67 59 0
67 61 59 0
67 67 61 0
67 63 61 0
67 67 63 0
67 65 63 0
67 67 65 0
67 43 65 0
67 67 67 0
67 67 67 0
67 67 67 0
67 67 67 0
67 67 67 0
67 67 67 0
67 67 67 0
67 67 67 0
67 67 67 0
67 67 67 0
67 67 67 0
67 67 67 0


Its not the model. Assimp view doesn't have any problem loading it.
All I can see is that my indices is not correct. Using 67 in one triangle but I don't know why. Is there any one that could sugest some reading material or is this a know problem?

Thank you

Is This A Good Question/Topic? 0
  • +

Replies To: Assimp

#2 anonymous26  Icon User is offline

  • D.I.C Lover

Reputation: 0
  • View blog
  • Posts: 3,638
  • Joined: 26-November 10

Re: Assimp

Posted 23 August 2013 - 10:47 AM

Are you running this code in debug or release mode?
Was This Post Helpful? 0
  • +
  • -

#3 Fanie  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 8
  • Joined: 19-August 13

Re: Assimp

Posted 23 August 2013 - 12:22 PM

No. Iím not quite sure what you mean by debug release mode? Iím still working on it to test out and try out stuff. Any case, I found the source of the error to be in my file exporter. If I use Assimp to directly create my Direct3D Mesh, I do get the graphics on screen. But if I export to my file and import it again I donít. So the problem is somewhere in my exporter but donít know where yet.
Here is my direct importe code:
{
//'n Tydelike S_OBJECT structure om data in te stoor.
//A temporary S_Object struct to fill out
S_OBJECT TempObject;
TempObject.sNaam = Naam;//Name I gave to my object
TempObject.mxWorld = World;//Its world matrix
TempObject.iNoSubsets = AIModelDataBuffer.size();//Number of sunbsets
//Create die mesh
//Ok now we create the mesh.
D3D10_INPUT_ELEMENT_DESC layout[] = {
		{"POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0,  D3D10_INPUT_PER_VERTEX_DATA, 0},
		{"TANGENT",  0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 12, D3D10_INPUT_PER_VERTEX_DATA, 0},
		{"NORMAL",   0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 24, D3D10_INPUT_PER_VERTEX_DATA, 0},
		{"TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 36,D3D10_INPUT_PER_VERTEX_DATA, 0}
};
HR(D3DX10CreateMesh(md3dDevice,layout,4,layout[0].SemanticName,NumVertices,
				 NumTriangles,D3DX10_MESH_32_BIT,&TempObject.Mesh));

//Laai die materiale
//Load our materials
for(int i = 0; i < AIModelDataBuffer.size(); i++)
{
	std::wstring wstrTemp(AIModelDataBuffer[i].TextureName.begin(),AIModelDataBuffer[i].TextureName.end());
	MessageBox(hwnd,wstrTemp.c_str(),0,0);
	std::wstring Diffuse = wstrTemp;
//I donít support these for now.
	std::wstring Spec = L"default_spec.dds";
	std::wstring Normal = L"default_normal.dds";
	D3DXVECTOR3 reflectivity = D3DXVECTOR3(0.0f,0.0f,0.0f);
	int ID = AddTexture(CalcFilePath(PathToTextures,Diffuse),CalcFilePath(PathToTextures,Spec),
		CalcFilePath(PathToTextures,Normal),reflectivity);
	TempObject.iTexID.push_back(ID);
}

//Lees die vertices in
//Load vertices and create my buffer
VertexPNT* verts = new VertexPNT[NumVertices];
int Teller = 0;
for (int i = 0; i < AIModelDataBuffer.size(); i++)
{
	for (int j = 0; j < AIModelDataBuffer[i].VertexBuffer.size(); j++)
	{
		verts[Teller].Pos = AIModelDataBuffer[i].VertexBuffer[j].Pos;
		verts[Teller].Normal = AIModelDataBuffer[i].VertexBuffer[j].Normal;
		verts[Teller].Tangent = AIModelDataBuffer[i].VertexBuffer[j].Tangent;
		verts[Teller].Tex = AIModelDataBuffer[i].VertexBuffer[j].Tex;
		Teller++;
}
}
//Sit vertex data in die Mesh
//Add Vertex data to mesh
TempObject.Mesh->SetVertexData(0,verts);
delete[] verts;

//Laai nou die indices en hulle spesefieke subset
//Load indices and the subset they belong to.
Teller = 0;//Counter
int TellerA = 0;//'n Teller vir die Attrebute buffer.  Counter for atribute buffer
DWORD* indices = new DWORD[NumTriangles*3];
UINT* AttributeBuffer = new UINT[NumTriangles*3];
	int Size = 0;
	for (int i = 0; i < AIModelDataBuffer.size();i++)
	{
		for (int j = 0; j < AIModelDataBuffer[i].IndexBuffer.size(); j += 3)
		{
			//Omdat elke indeks array elke keer by 0 begin moet ek kompenseer daarvoor deur die 
			//grootte van die vorige arra by elke indeks in die nuwe een te tel.
//I compensate for the index buffer starting at 0 for every subset by adding its size to the index
			int I1 = AIModelDataBuffer[i].IndexBuffer[j] + Size;
            int I2 = AIModelDataBuffer[i].IndexBuffer[j + 1]  + Size;
			int I3 = AIModelDataBuffer[i].IndexBuffer[j + 2]  + Size;
            indices[Teller] = I1;
			indices[Teller + 1] = I2;
			indices[Teller + 2] = I3;
			AttributeBuffer[TellerA] = i;
			TellerA++;
			Teller = Teller + 3;
		}
		
		Size += AIModelDataBuffer[i].VertexBuffer.size();
	}
//Add indices en subsets in die mesh
//Add indices and subsets to the mesh
TempObject.Mesh->SetIndexData(indices,NumTriangles*3);
TempObject.Mesh->SetAttributeData(AttributeBuffer);
//Free memory
delete[] indices;
delete[] AttributeBuffer;
//Final mesh setup
TempObject.Mesh->GenerateAdjacencyAndPointReps(0.001f);
TempObject.Mesh->Optimize(D3DX10_MESHOPT_ATTR_SORT|D3DX10_MESHOPT_VERTEX_CACHE,0,0);
TempObject.Mesh->CommitToDevice();

S_Objects.push_back(TempObject);
//Ons release nie die TempObject.Mesh nie omdat dit 'n pointer is wat nou in S_Objects is.  Beide
//S_OBjects en Temp object verwys na dieselfde memory location.  Indien ons die Pointer delete in
//TempObject delete ons ook die een in S_Objects.
//Just some pointer note.
iNumObjects = iNumObjects + 1;



This way I get perfect results. Just need to find the error in the exporter. The assimp guys recommend that you donít use it to load files in your actual game as it is to slow apparently. I donít know thatís just what I read. Not like my text base file format is faster but ok haha.
Was This Post Helpful? 0
  • +
  • -

#4 anonymous26  Icon User is offline

  • D.I.C Lover

Reputation: 0
  • View blog
  • Posts: 3,638
  • Joined: 26-November 10

Re: Assimp

Posted 23 August 2013 - 12:44 PM

If you're using Visual Studio you have the option of running code in either 'debug' or 'release' mode. Basically (very basically!) the release mode lets you release code standalone because it removes the hooks into the debugger, so there are no dependencies on the debugger to execute. But, when you run in release mode you expose 'uncaught exceptions' that highlight issues that were compensated for by the debugging environment. So try running in release and see if your code blows up! :)

Quote

The assimp guys recommend that you donít use it to load files in your actual game as it is to slow apparently.


By 'in your actual game' I'm assuming within the game loop? True. Loading models is part of the initialization procedure.
Was This Post Helpful? 0
  • +
  • -

#5 Fanie  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 8
  • Joined: 19-August 13

Re: Assimp

Posted 23 August 2013 - 09:55 PM

View PostButchDean, on 23 August 2013 - 12:44 PM, said:

If you're using Visual Studio you have the option of running code in either 'debug' or 'release' mode. Basically (very basically!) the release mode lets you release code standalone because it removes the hooks into the debugger, so there are no dependencies on the debugger to execute. But, when you run in release mode you expose 'uncaught exceptions' that highlight issues that were compensated for by the debugging environment. So try running in release and see if your code blows up! :)/>

Quote

The assimp guys recommend that you donít use it to load files in your actual game as it is to slow apparently.


By 'in your actual game' I'm assuming within the game loop? True. Loading models is part of the initialization procedure.


Ok, Iíve ran it in Release mode but all works fine. I think I have a problem in how I write the file. But assimp realy works awesome. I realy do like the library. It makes things simple. Lot less work for the programmer. By actual game meaning in the release. The product that others receive. Like for instance Iím playing in one level and running through a tunnel, while that is happening I want to load the other side of the tunnel to render. So it takes too long. But Iíve heard that text based files are also slow?
Was This Post Helpful? 0
  • +
  • -

#6 anonymous26  Icon User is offline

  • D.I.C Lover

Reputation: 0
  • View blog
  • Posts: 3,638
  • Joined: 26-November 10

Re: Assimp

Posted 24 August 2013 - 08:31 AM

View PostFanie, on 24 August 2013 - 01:55 AM, said:

But Iíve heard that text based files are also slow?

Yes, because you are traversing a tree structure of some kind that is normally formatted in XML or JSON. I also suggest you look into callback mechanisms, it will make your life easier in the future with managing activities both inside and outside your game loop.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1