Exemplo n.º 1
0
	Mesh	*LoadCM3DFile( char const *file )
	{
		int const	nVertices = 3;

		// DUMMY DATA ---------------------------------------------------------
		// create vertices
		XMFLOAT3A	pos[nVertices];
		pos[0] = XMFLOAT3A(0.0f,  .5f, -1.0f);
		pos[1] = XMFLOAT3A( -.5f,  -.5f, -1.0f);
		pos[2] = XMFLOAT3A(0.5f, -0.5f, -1.0f);

		// colors
		XMFLOAT4	colors[nVertices] =
		{
			XMFLOAT4(1, 1, 1, 1), XMFLOAT4(1, 0, 0, 1), XMFLOAT4(0, 0, 1, 1)
		};

		// 1)	load mesh file
		// 2)	parse mesh file
		// 3)	mesh is made up of N subsets
		// 4)	for each subset:
		//			- get subset material
		//			- get subset geom info (vertex start, count, indices...)
		//			- create input element and add it to the mesh
		// 5)	load the shaders and create the input layout

		// fill the Mesh object with geom data (positions, normals...) --------
		(void)file;
		Mesh *mesh = new Mesh(/*nVertices*/);

		VertexElement	*vePos = new VertexElement(sizeof(XMFLOAT3A), nVertices);
		vePos->elementDesc.SemanticName = SemanticName::Position;
		vePos->elementDesc.InputSlot = 0;
		vePos->elementDesc.Format = DXGI_FORMAT_R32G32B32_FLOAT;
		vePos->elementDesc.InputSlot = 0;
		vePos->SetData((float *)pos);
		
		VertexElement	*veClr = new VertexElement(sizeof(XMFLOAT4), nVertices);
		veClr->elementDesc.SemanticName = SemanticName::Color;
		veClr->elementDesc.InputSlot = 0;
		veClr->elementDesc.Format = DXGI_FORMAT_R32G32B32A32_FLOAT;
		veClr->elementDesc.InputSlot = 0;
		veClr->elementDesc.AlignedByteOffset = D3D11_APPEND_ALIGNED_ELEMENT;
		veClr->SetData((float *)colors);

		mesh->AddVertexElement(vePos);
		mesh->AddVertexElement(veClr);
		//mesh->LoadToBuffers();

		return mesh;
	}