Jump to content

  • Log In with Google      Sign In   
  • Create Account


kolarz3

Member Since 10 Jun 2013
Offline Last Active Jun 26 2014 07:33 AM
-----

#5131843 Problem with creating "blanc" ID3D11Texture2D

Posted by kolarz3 on 16 February 2014 - 04:49 PM

bool ModelData::createDefaultMaterial()
{
	struct Pix
	{
		float r,g,b,a;
	};
	Pix* img;
	img=new Pix[256*256];

	for(int y=0;y<256;y++)for(int x=0;x<256;x++){img[y*256+x].r=1.0;img[y*256+x].g=0.0;img[y*256+x].b=0.0;img[y*256+x].a=1.0;}
	D3D11_TEXTURE2D_DESC desc; 
	ZeroMemory( &desc, sizeof(desc)); 
	desc.Width = 256; 
	desc.Height = 256; 
	desc.MipLevels = desc.ArraySize = 1; 
	desc.Format = DXGI_FORMAT_R32G32B32A32_FLOAT; 
	desc.SampleDesc.Count = 1; 
	desc.Usage = D3D11_USAGE_DYNAMIC; 
	desc.BindFlags = D3D11_BIND_SHADER_RESOURCE; 
	desc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE; 

	ID3D11Texture2D *pTexture = NULL; 
	engine.d3d11Device->CreateTexture2D( &desc, NULL, &pTexture ); 

	D3D11_MAPPED_SUBRESOURCE mapResource;
	engine.d3d11DevCon->Map(pTexture,0,D3D11_MAP_WRITE_DISCARD,0,&mapResource);
	BYTE* mappedData = reinterpret_cast<BYTE*>(mapResource.pData);
	memcpy(mappedData, img, 256*256*4*sizeof(float));
	engine.d3d11DevCon->Unmap(pTexture, 0);
	D3DX11SaveTextureToFile(engine.d3d11DevCon,pTexture,D3DX11_IFF_PNG,L"nazwaa.png");
	return TRUE;
}

Problem is solved. I must change Format to DXGI_FORMAT_R32G32B32A32_FLOAT




#5073162 Assimp loading model

Posted by kolarz3 on 27 June 2013 - 01:36 AM

Maybe i dont known how to generate corectly normals in blender. Now I generate normals in assimp. But I have still problem. This is my model http://pastebin.com/MQ5pWACz . This have 176 vertex and 348 indi. I noticed strange behaviour of assimp. He split my model into 2 meshes. First have 488 vert and 54 indi, second have 120 vert and 294 indi. Sum of indi is 348 and is correct, but sum of vertex is 608. Still I have strange mix of triangle. This is my full code of loading mesh :

#include "Model.h"
int Model::loadFromFileModelAndInit(char *fileName)
{
	Assimp::Importer importer;
	const aiScene *scene = importer.ReadFile(fileName,aiProcessPreset_TargetRealtime_Fast|aiProcess_GenNormals);
	aiMesh *mesh = scene->mMeshes[0];
	for(unsigned int i=0;i<mesh->mNumFaces;i++)
	{
					const aiFace& face = mesh->mFaces[i];
					Indi.push_back(face.mIndices[0]);
					Indi.push_back(face.mIndices[1]);
					Indi.push_back(face.mIndices[2]);
	}
	numIndi=mesh->mNumFaces;
	for (unsigned int i = 0 ; i < mesh->mNumVertices ; i++) 
	{
		Vert.push_back(Vertex( mesh->mVertices[i].x, mesh->mVertices[i].y, mesh->mVertices[i].z,1.0,1.0,mesh->mNormals[i].x,mesh->mNormals[i].y,mesh->mNormals[i].z));
	}
	numVert=mesh->mNumVertices;
	sizeVert=sizeof(Vertex);
	return 1;
}



#5073060 Assimp loading model

Posted by kolarz3 on 26 June 2013 - 03:14 PM

Now I have model with 2676 vertex and 892 indi. Normals are per vertex. Assimp return that i have only 554 vertex.




#5073043 Assimp loading model

Posted by kolarz3 on 26 June 2013 - 02:05 PM

How can i get real number of vertex ?




#5073031 Assimp loading model

Posted by kolarz3 on 26 June 2013 - 12:48 PM

I try to load with assimp simple box. But assimp return wrong number of vertex. I try several formats(didnt help). This is my model :

xof 0303txt 0032

Frame Root {
  FrameTransformMatrix {
     1.000000, 0.000000, 0.000000, 0.000000,
     0.000000,-0.000000, 1.000000, 0.000000,
     0.000000, 1.000000, 0.000000, 0.000000,
     0.000000, 0.000000, 0.000000, 1.000000;;
  }
  Frame Cube {
    FrameTransformMatrix {
       1.000000, 0.000000, 0.000000, 0.000000,
       0.000000, 1.000000, 0.000000, 0.000000,
       0.000000, 0.000000, 1.000000, 0.000000,
       0.000000, 0.000000, 0.000000, 1.000000;;
    }
    Mesh { // Cube mesh
      8;
       1.000000; 1.000000;-1.000000;,
       1.000000;-1.000000;-1.000000;,
      -1.000000;-1.000000;-1.000000;,
      -1.000000; 1.000000;-1.000000;,
       1.000000; 0.999999; 1.000000;,
       0.999999;-1.000001; 1.000000;,
      -1.000000;-1.000000; 1.000000;,
      -1.000000; 1.000000; 1.000000;;
      12;
      3;3,1,0,,
      3;5,7,4,,
      3;1,4,0,,
      3;6,5,1,,
      3;7,6,2,,
      3;3,0,4,,
      3;3,2,1,,
      3;5,6,7,,
      3;6,1,2,,
      3;7,2,3,,
      3;3,4,7,,
      3;1,5,4,;
      MeshNormals { // Cube normals
        12;
         0.000000; 0.000000;-1.000000;,
        -0.000000;-0.000000; 1.000000;,
         1.000000; 0.000000;-0.000000;,
        -0.000000;-1.000000;-0.000000;,
        -1.000000; 0.000000;-0.000000;,
         0.000000; 1.000000; 0.000000;,
         0.000000;-0.000000;-1.000000;,
         0.000000;-0.000000; 1.000000;,
        -0.000000;-1.000000; 0.000000;,
        -1.000000; 0.000000;-0.000000;,
         0.000000; 1.000000; 0.000000;,
         1.000000;-0.000001; 0.000000;;
        12;
        3;0,0,0,,
        3;1,1,1,,
        3;2,2,2,,
        3;3,3,3,,
        3;4,4,4,,
        3;5,5,5,,
        3;6,6,6,,
        3;7,7,7,,
        3;8,8,8,,
        3;9,9,9,,
        3;10,10,10,,
        3;11,11,11,;
      } // End of Cube normals
      MeshMaterialList { // Cube material list
        1;
        12;
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0;;
        Material Material {
           0.640000; 0.640000; 0.640000; 1.000000;;
           96.078431;
           0.500000; 0.500000; 0.500000;;
           0.000000; 0.000000; 0.000000;;
        }
      } // End of Cube material list
    } // End of Cube mesh
  } // End of Cube
} // End of Root

Model have 8 Vertex, when I call mesh->mNumVertices I get 24. This code loading vertex :

	for (unsigned int i = 0 ; i < mesh->mNumVertices ; i++) 
	{
Vert.push_back(Vertex( mesh->mVertices[i].x, mesh->mVertices[i].y, mesh->mVertices[i].z,mesh->mTextureCoords[0][i].x,mesh->mTextureCoords[0][i].y,mesh->mNormals[i].x,mesh->mNormals[i].y,mesh->mNormals[i].z));
	}

7b4c677ec2005.png




#5072442 Easy GUI for 3D engine

Posted by kolarz3 on 24 June 2013 - 02:18 AM

I search easy GUI library for DirectX (vs2010). I looking for wxwidgets and qt but they seem complexity. Do you known some other ?




PARTNERS