MD2
- fixed UV coords - added further test models Collada - fixed invalid aiStrings git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@343 67173fc5-114c-0410-ac8e-9d2fd5bffc1fpull/1/head
parent
e5b06832b7
commit
fd9769eae6
|
@ -187,7 +187,7 @@ aiNode* ColladaLoader::BuildHierarchy( const ColladaParser& pParser, const Colla
|
||||||
if (!pNode->mLights.empty() || !pNode->mCameras.empty()) {
|
if (!pNode->mLights.empty() || !pNode->mCameras.empty()) {
|
||||||
|
|
||||||
::strcpy(node->mName.data,"$ColladaAutoName$_");
|
::strcpy(node->mName.data,"$ColladaAutoName$_");
|
||||||
node->mName.length = 18 + ASSIMP_itoa10(node->mName.data+18,MAXLEN-18,(uint32_t)clock());
|
node->mName.length = 17 + ASSIMP_itoa10(node->mName.data+18,MAXLEN-18,(uint32_t)clock());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -144,8 +144,8 @@ struct Frame
|
||||||
*/
|
*/
|
||||||
struct TexCoord
|
struct TexCoord
|
||||||
{
|
{
|
||||||
int16_t s;
|
uint16_t s;
|
||||||
int16_t t;
|
uint16_t t;
|
||||||
} PACK_STRUCT;
|
} PACK_STRUCT;
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
|
|
@ -275,19 +275,19 @@ void MD2Importer::InternReadFile( const std::string& pFile,
|
||||||
pcMesh->mVertices = new aiVector3D[pcMesh->mNumVertices];
|
pcMesh->mVertices = new aiVector3D[pcMesh->mNumVertices];
|
||||||
pcMesh->mNormals = new aiVector3D[pcMesh->mNumVertices];
|
pcMesh->mNormals = new aiVector3D[pcMesh->mNumVertices];
|
||||||
|
|
||||||
// not sure whether there are MD2 files without texture coordinates
|
// Not sure whether there are MD2 files without texture coordinates
|
||||||
// NOTE: texture coordinates can be there without a texture,
|
// NOTE: texture coordinates can be there without a texture,
|
||||||
// but a texture can't be there without a valid UV channel
|
// but a texture can't be there without a valid UV channel
|
||||||
|
MaterialHelper* pcHelper = (MaterialHelper*)pScene->mMaterials[0];
|
||||||
|
const int iMode = (int)aiShadingMode_Gouraud;
|
||||||
|
pcHelper->AddProperty<int>(&iMode, 1, AI_MATKEY_SHADING_MODEL);
|
||||||
|
|
||||||
if (m_pcHeader->numTexCoords && m_pcHeader->numSkins)
|
if (m_pcHeader->numTexCoords && m_pcHeader->numSkins)
|
||||||
{
|
{
|
||||||
// navigate to the first texture associated with the mesh
|
// navigate to the first texture associated with the mesh
|
||||||
const MD2::Skin* pcSkins = (const MD2::Skin*) ((unsigned char*)m_pcHeader +
|
const MD2::Skin* pcSkins = (const MD2::Skin*) ((unsigned char*)m_pcHeader +
|
||||||
m_pcHeader->offsetSkins);
|
m_pcHeader->offsetSkins);
|
||||||
|
|
||||||
const int iMode = (int)aiShadingMode_Gouraud;
|
|
||||||
MaterialHelper* pcHelper = (MaterialHelper*)pScene->mMaterials[0];
|
|
||||||
pcHelper->AddProperty<int>(&iMode, 1, AI_MATKEY_SHADING_MODEL);
|
|
||||||
|
|
||||||
aiColor3D clr;
|
aiColor3D clr;
|
||||||
clr.b = clr.g = clr.r = 1.0f;
|
clr.b = clr.g = clr.r = 1.0f;
|
||||||
pcHelper->AddProperty<aiColor3D>(&clr, 1,AI_MATKEY_COLOR_DIFFUSE);
|
pcHelper->AddProperty<aiColor3D>(&clr, 1,AI_MATKEY_COLOR_DIFFUSE);
|
||||||
|
@ -306,18 +306,13 @@ void MD2Importer::InternReadFile( const std::string& pFile,
|
||||||
|
|
||||||
pcHelper->AddProperty(&szString,AI_MATKEY_TEXTURE_DIFFUSE(0));
|
pcHelper->AddProperty(&szString,AI_MATKEY_TEXTURE_DIFFUSE(0));
|
||||||
}
|
}
|
||||||
else
|
else{
|
||||||
{
|
|
||||||
DefaultLogger::get()->warn("Texture file name has zero length. It will be skipped.");
|
DefaultLogger::get()->warn("Texture file name has zero length. It will be skipped.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// apply a default material
|
// apply a default material
|
||||||
const int iMode = (int)aiShadingMode_Gouraud;
|
|
||||||
MaterialHelper* pcHelper = (MaterialHelper*)pScene->mMaterials[0];
|
|
||||||
pcHelper->AddProperty<int>(&iMode, 1, AI_MATKEY_SHADING_MODEL);
|
|
||||||
|
|
||||||
aiColor3D clr;
|
aiColor3D clr;
|
||||||
clr.b = clr.g = clr.r = 0.6f;
|
clr.b = clr.g = clr.r = 0.6f;
|
||||||
pcHelper->AddProperty<aiColor3D>(&clr, 1,AI_MATKEY_COLOR_DIFFUSE);
|
pcHelper->AddProperty<aiColor3D>(&clr, 1,AI_MATKEY_COLOR_DIFFUSE);
|
||||||
|
@ -327,16 +322,22 @@ void MD2Importer::InternReadFile( const std::string& pFile,
|
||||||
pcHelper->AddProperty<aiColor3D>(&clr, 1,AI_MATKEY_COLOR_AMBIENT);
|
pcHelper->AddProperty<aiColor3D>(&clr, 1,AI_MATKEY_COLOR_AMBIENT);
|
||||||
|
|
||||||
aiString szName;
|
aiString szName;
|
||||||
szName.Set(AI_DEFAULT_MATERIAL_NAME);
|
szName.Set("MD2Default");
|
||||||
pcHelper->AddProperty(&szName,AI_MATKEY_NAME);
|
pcHelper->AddProperty(&szName,AI_MATKEY_NAME);
|
||||||
|
|
||||||
|
aiString sz;
|
||||||
|
|
||||||
|
// TODO: Try to guess the name of the texture file from the model file name
|
||||||
|
|
||||||
|
sz.Set("texture_dummmy.bmp");
|
||||||
|
pcHelper->AddProperty(&sz,AI_MATKEY_TEXTURE_DIFFUSE(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// now read all triangles of the first frame, apply scaling and translation
|
// now read all triangles of the first frame, apply scaling and translation
|
||||||
unsigned int iCurrent = 0;
|
unsigned int iCurrent = 0;
|
||||||
|
|
||||||
float fDivisorU = 1.0f;
|
float fDivisorU = 1.0f,fDivisorV = 1.0f;
|
||||||
float fDivisorV = 1.0f;
|
|
||||||
if (m_pcHeader->numTexCoords)
|
if (m_pcHeader->numTexCoords)
|
||||||
{
|
{
|
||||||
// allocate storage for texture coordinates, too
|
// allocate storage for texture coordinates, too
|
||||||
|
@ -345,30 +346,25 @@ void MD2Importer::InternReadFile( const std::string& pFile,
|
||||||
|
|
||||||
// check whether the skin width or height are zero (this would
|
// check whether the skin width or height are zero (this would
|
||||||
// cause a division through zero)
|
// cause a division through zero)
|
||||||
if (!m_pcHeader->skinWidth)
|
if (!m_pcHeader->skinWidth) {
|
||||||
{
|
DefaultLogger::get()->error("MD2: No valid skin width given");
|
||||||
DefaultLogger::get()->error("Skin width is zero but there are "
|
|
||||||
"valid absolute texture coordinates");
|
|
||||||
}
|
}
|
||||||
else fDivisorU = (float)m_pcHeader->skinWidth;
|
else fDivisorU = (float)m_pcHeader->skinWidth;
|
||||||
if (!m_pcHeader->skinHeight)
|
if (!m_pcHeader->skinHeight){
|
||||||
{
|
DefaultLogger::get()->error("MD2: No valid skin height given");
|
||||||
DefaultLogger::get()->error("Skin height is zero but there are "
|
|
||||||
"valid absolute texture coordinates ");
|
|
||||||
}
|
}
|
||||||
else fDivisorV = (float)m_pcHeader->skinHeight;
|
else fDivisorV = (float)m_pcHeader->skinHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (unsigned int i = 0; i < (unsigned int)m_pcHeader->numTriangles;++i)
|
for (unsigned int i = 0; i < (unsigned int)m_pcHeader->numTriangles;++i)
|
||||||
{
|
{
|
||||||
// allocate the face
|
// Allocate the face
|
||||||
pScene->mMeshes[0]->mFaces[i].mIndices = new unsigned int[3];
|
pScene->mMeshes[0]->mFaces[i].mIndices = new unsigned int[3];
|
||||||
pScene->mMeshes[0]->mFaces[i].mNumIndices = 3;
|
pScene->mMeshes[0]->mFaces[i].mNumIndices = 3;
|
||||||
|
|
||||||
// copy texture coordinates
|
// copy texture coordinates
|
||||||
// check whether they are different from the previous value at this index.
|
// check whether they are different from the previous value at this index.
|
||||||
// In this case, create a full separate set of vertices/normals/texcoords
|
// In this case, create a full separate set of vertices/normals/texcoords
|
||||||
unsigned int iTemp = iCurrent;
|
|
||||||
for (unsigned int c = 0; c < 3;++c,++iCurrent)
|
for (unsigned int c = 0; c < 3;++c,++iCurrent)
|
||||||
{
|
{
|
||||||
// validate vertex indices
|
// validate vertex indices
|
||||||
|
@ -385,10 +381,8 @@ void MD2Importer::InternReadFile( const std::string& pFile,
|
||||||
vec.x = (float)pcVerts[iIndex].vertex[0] * pcFrame->scale[0];
|
vec.x = (float)pcVerts[iIndex].vertex[0] * pcFrame->scale[0];
|
||||||
vec.x += pcFrame->translate[0];
|
vec.x += pcFrame->translate[0];
|
||||||
|
|
||||||
// invert y
|
|
||||||
vec.y = (float)pcVerts[iIndex].vertex[1] * pcFrame->scale[1];
|
vec.y = (float)pcVerts[iIndex].vertex[1] * pcFrame->scale[1];
|
||||||
vec.y += pcFrame->translate[1];
|
vec.y += pcFrame->translate[1];
|
||||||
vec.y *= -1.0f;
|
|
||||||
|
|
||||||
vec.z = (float)pcVerts[iIndex].vertex[2] * pcFrame->scale[2];
|
vec.z = (float)pcVerts[iIndex].vertex[2] * pcFrame->scale[2];
|
||||||
vec.z += pcFrame->translate[2];
|
vec.z += pcFrame->translate[2];
|
||||||
|
@ -396,14 +390,15 @@ void MD2Importer::InternReadFile( const std::string& pFile,
|
||||||
// read the normal vector from the precalculated normal table
|
// read the normal vector from the precalculated normal table
|
||||||
aiVector3D& vNormal = pcMesh->mNormals[iCurrent];
|
aiVector3D& vNormal = pcMesh->mNormals[iCurrent];
|
||||||
LookupNormalIndex(pcVerts[iIndex].lightNormalIndex,vNormal);
|
LookupNormalIndex(pcVerts[iIndex].lightNormalIndex,vNormal);
|
||||||
vNormal.y *= -1.0f;
|
|
||||||
|
|
||||||
if (m_pcHeader->numTexCoords)
|
// invert z for proper output coordinate system
|
||||||
{
|
vNormal.z *= -1.0f;
|
||||||
|
vec.z *= -1.0f;
|
||||||
|
|
||||||
|
if (m_pcHeader->numTexCoords) {
|
||||||
// validate texture coordinates
|
// validate texture coordinates
|
||||||
iIndex = pcTriangles[iIndex].textureIndices[c];
|
iIndex = pcTriangles[i].textureIndices[c];
|
||||||
if (iIndex >= m_pcHeader->numTexCoords)
|
if (iIndex >= m_pcHeader->numTexCoords) {
|
||||||
{
|
|
||||||
DefaultLogger::get()->error("MD2: UV index is outside the allowed range");
|
DefaultLogger::get()->error("MD2: UV index is outside the allowed range");
|
||||||
iIndex = m_pcHeader->numTexCoords-1;
|
iIndex = m_pcHeader->numTexCoords-1;
|
||||||
}
|
}
|
||||||
|
@ -412,14 +407,11 @@ void MD2Importer::InternReadFile( const std::string& pFile,
|
||||||
|
|
||||||
// the texture coordinates are absolute values but we
|
// the texture coordinates are absolute values but we
|
||||||
// need relative values between 0 and 1
|
// need relative values between 0 and 1
|
||||||
pcOut.y = pcTexCoords[iIndex].s / fDivisorU;
|
pcOut.x = pcTexCoords[iIndex].s / fDivisorU;
|
||||||
pcOut.x = pcTexCoords[iIndex].t / fDivisorV;
|
pcOut.y = 1.f-pcTexCoords[iIndex].t / fDivisorV;
|
||||||
}
|
}
|
||||||
|
pScene->mMeshes[0]->mFaces[i].mIndices[c] = iCurrent;
|
||||||
}
|
}
|
||||||
// FIX: flip the face order for use with OpenGL
|
|
||||||
pScene->mMeshes[0]->mFaces[i].mIndices[0] = iTemp+2;
|
|
||||||
pScene->mMeshes[0]->mFaces[i].mIndices[1] = iTemp+1;
|
|
||||||
pScene->mMeshes[0]->mFaces[i].mIndices[2] = iTemp+0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -509,14 +509,12 @@ void TextureTransformStep::Execute( aiScene* pScene)
|
||||||
it2 = it;++it2;
|
it2 = it;++it2;
|
||||||
for (unsigned int m = n+1; m < size;++m, ++it2)
|
for (unsigned int m = n+1; m < size;++m, ++it2)
|
||||||
{
|
{
|
||||||
if ((*it2).uvIndex == n)
|
if ((*it2).uvIndex == n){
|
||||||
{
|
|
||||||
it2 = trafo.begin();
|
it2 = trafo.begin();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (it2 == trafo.begin())
|
if (it2 == trafo.begin()){
|
||||||
{
|
|
||||||
mesh->mTextureCoords[n] = new aiVector3D[mesh->mNumVertices];
|
mesh->mTextureCoords[n] = new aiVector3D[mesh->mNumVertices];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -557,9 +555,7 @@ void TextureTransformStep::Execute( aiScene* pScene)
|
||||||
m5.a3 += trl.x; m5.b3 += trl.y;
|
m5.a3 += trl.x; m5.b3 += trl.y;
|
||||||
matrix = m2 * m4 * matrix * m3 * m5;
|
matrix = m2 * m4 * matrix * m3 * m5;
|
||||||
|
|
||||||
|
for (src = dest; src != end; ++src) {
|
||||||
for (src = dest; src != end; ++src)
|
|
||||||
{
|
|
||||||
src->z = 1.f;
|
src->z = 1.f;
|
||||||
*src = matrix * *src;
|
*src = matrix * *src;
|
||||||
src->x /= src->z;
|
src->x /= src->z;
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
#define SVNRevision 335
|
#define SVNRevision 342
|
||||||
|
|
|
@ -0,0 +1,24 @@
|
||||||
|
|
||||||
|
From IRRLICHT/media
|
||||||
|
|
||||||
|
|
||||||
|
The Irrlicht Engine License
|
||||||
|
===========================
|
||||||
|
|
||||||
|
Copyright (C) 2002-2007 Nikolaus Gebhardt
|
||||||
|
|
||||||
|
This software is provided 'as-is', without any express or implied
|
||||||
|
warranty. In no event will the authors be held liable for any damages
|
||||||
|
arising from the use of this software.
|
||||||
|
|
||||||
|
Permission is granted to anyone to use this software for any purpose,
|
||||||
|
including commercial applications, and to alter it and redistribute it
|
||||||
|
freely, subject to the following restrictions:
|
||||||
|
|
||||||
|
1. The origin of this software must not be misrepresented; you must not
|
||||||
|
claim that you wrote the original software. If you use this software
|
||||||
|
in a product, an acknowledgement in the product documentation would be
|
||||||
|
appreciated but is not required.
|
||||||
|
2. Altered source versions must be clearly marked as such, and must not be
|
||||||
|
misrepresented as being the original software.
|
||||||
|
3. This notice may not be removed or altered from any source distribution.
|
Binary file not shown.
Binary file not shown.
After Width: | Height: | Size: 42 KiB |
|
@ -0,0 +1,24 @@
|
||||||
|
|
||||||
|
From IRRLICHT/media
|
||||||
|
|
||||||
|
|
||||||
|
The Irrlicht Engine License
|
||||||
|
===========================
|
||||||
|
|
||||||
|
Copyright (C) 2002-2007 Nikolaus Gebhardt
|
||||||
|
|
||||||
|
This software is provided 'as-is', without any express or implied
|
||||||
|
warranty. In no event will the authors be held liable for any damages
|
||||||
|
arising from the use of this software.
|
||||||
|
|
||||||
|
Permission is granted to anyone to use this software for any purpose,
|
||||||
|
including commercial applications, and to alter it and redistribute it
|
||||||
|
freely, subject to the following restrictions:
|
||||||
|
|
||||||
|
1. The origin of this software must not be misrepresented; you must not
|
||||||
|
claim that you wrote the original software. If you use this software
|
||||||
|
in a product, an acknowledgement in the product documentation would be
|
||||||
|
appreciated but is not required.
|
||||||
|
2. Altered source versions must be clearly marked as such, and must not be
|
||||||
|
misrepresented as being the original software.
|
||||||
|
3. This notice may not be removed or altered from any source distribution.
|
Binary file not shown.
After Width: | Height: | Size: 59 KiB |
Binary file not shown.
|
@ -1156,6 +1156,42 @@ void InitUI()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//-------------------------------------------------------------------------------
|
||||||
|
// Message prcoedure for the smooth normals dialog
|
||||||
|
//-------------------------------------------------------------------------------
|
||||||
|
INT_PTR CALLBACK SMMessageProc(HWND hwndDlg,UINT uMsg,
|
||||||
|
WPARAM wParam,LPARAM lParam)
|
||||||
|
{
|
||||||
|
UNREFERENCED_PARAMETER(lParam);
|
||||||
|
switch (uMsg)
|
||||||
|
{
|
||||||
|
case WM_INITDIALOG:
|
||||||
|
char s[30];
|
||||||
|
::sprintf(s,"%.2f",g_smoothAngle);
|
||||||
|
SetDlgItemText(hwndDlg,IDC_EDITSM,s);
|
||||||
|
return TRUE;
|
||||||
|
|
||||||
|
case WM_CLOSE:
|
||||||
|
EndDialog(hwndDlg,0);
|
||||||
|
return TRUE;
|
||||||
|
|
||||||
|
case WM_COMMAND:
|
||||||
|
|
||||||
|
if (IDOK == LOWORD(wParam)) {
|
||||||
|
char s[30];
|
||||||
|
GetDlgItemText(hwndDlg,IDC_EDITSM,s,30);
|
||||||
|
g_smoothAngle = atof(s);
|
||||||
|
|
||||||
|
EndDialog(hwndDlg,0);
|
||||||
|
}
|
||||||
|
else if (IDCANCEL == LOWORD(wParam)) {
|
||||||
|
EndDialog(hwndDlg,1);
|
||||||
|
}
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
//-------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------
|
||||||
// Main message procedure of the application
|
// Main message procedure of the application
|
||||||
//
|
//
|
||||||
|
@ -1763,6 +1799,10 @@ __DRUNKEN_ALIEN_FROM_MARS:
|
||||||
D3DCOLOR_ARGB(0xFF,0xFF,0xFF,0));
|
D3DCOLOR_ARGB(0xFF,0xFF,0xFF,0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (ID_TOOLS_SETANGLELIMIT == LOWORD(wParam))
|
||||||
|
{
|
||||||
|
DialogBox(g_hInstance,MAKEINTRESOURCE(IDD_DIALOGSMOOTH),g_hDlg,&SMMessageProc);
|
||||||
|
}
|
||||||
else if (ID_VIEWER_CLEARHISTORY == LOWORD(wParam))
|
else if (ID_VIEWER_CLEARHISTORY == LOWORD(wParam))
|
||||||
{
|
{
|
||||||
ClearHistory();
|
ClearHistory();
|
||||||
|
|
|
@ -92,7 +92,7 @@ public:
|
||||||
|
|
||||||
|
|
||||||
bool g_bWasFlipped = false;
|
bool g_bWasFlipped = false;
|
||||||
|
float g_smoothAngle = 80.f;
|
||||||
|
|
||||||
//-------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------
|
||||||
// Flip all normal vectors
|
// Flip all normal vectors
|
||||||
|
@ -103,8 +103,7 @@ void AssetHelper::FlipNormalsInt()
|
||||||
for (unsigned int i = 0; i < this->pcScene->mNumMeshes;++i)
|
for (unsigned int i = 0; i < this->pcScene->mNumMeshes;++i)
|
||||||
{
|
{
|
||||||
aiMesh* pcMesh = this->pcScene->mMeshes[i];
|
aiMesh* pcMesh = this->pcScene->mMeshes[i];
|
||||||
for (unsigned int a = 0; a < pcMesh->mNumVertices;++a)
|
for (unsigned int a = 0; a < pcMesh->mNumVertices;++a){
|
||||||
{
|
|
||||||
pcMesh->mNormals[a] *= -1.0f;
|
pcMesh->mNormals[a] *= -1.0f;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -126,24 +125,22 @@ void AssetHelper::FlipNormals()
|
||||||
//-------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------
|
||||||
void AssetHelper::SetNormalSet(unsigned int iSet)
|
void AssetHelper::SetNormalSet(unsigned int iSet)
|
||||||
{
|
{
|
||||||
if (this->iNormalSet == iSet)return;
|
|
||||||
|
|
||||||
// we need to build an unique set of vertices for this ...
|
// we need to build an unique set of vertices for this ...
|
||||||
{
|
{
|
||||||
MyMakeVerboseFormatProcess* pcProcess = new MyMakeVerboseFormatProcess();
|
MyMakeVerboseFormatProcess* pcProcess = new MyMakeVerboseFormatProcess();
|
||||||
pcProcess->Execute(this->pcScene);
|
pcProcess->Execute(pcScene);
|
||||||
delete pcProcess;
|
delete pcProcess;
|
||||||
|
|
||||||
for (unsigned int i = 0; i < this->pcScene->mNumMeshes;++i)
|
for (unsigned int i = 0; i < pcScene->mNumMeshes;++i)
|
||||||
{
|
{
|
||||||
if (!this->apcMeshes[i]->pvOriginalNormals)
|
if (!apcMeshes[i]->pvOriginalNormals)
|
||||||
{
|
{
|
||||||
this->apcMeshes[i]->pvOriginalNormals = new aiVector3D[this->pcScene->mMeshes[i]->mNumVertices];
|
apcMeshes[i]->pvOriginalNormals = new aiVector3D[pcScene->mMeshes[i]->mNumVertices];
|
||||||
memcpy( this->apcMeshes[i]->pvOriginalNormals,this->pcScene->mMeshes[i]->mNormals,
|
memcpy( apcMeshes[i]->pvOriginalNormals,pcScene->mMeshes[i]->mNormals,
|
||||||
this->pcScene->mMeshes[i]->mNumVertices * sizeof(aiVector3D));
|
pcScene->mMeshes[i]->mNumVertices * sizeof(aiVector3D));
|
||||||
}
|
}
|
||||||
delete[] this->pcScene->mMeshes[i]->mNormals;
|
delete[] pcScene->mMeshes[i]->mNormals;
|
||||||
this->pcScene->mMeshes[i]->mNormals = NULL;
|
pcScene->mMeshes[i]->mNormals = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -152,49 +149,49 @@ void AssetHelper::SetNormalSet(unsigned int iSet)
|
||||||
if (HARD == iSet)
|
if (HARD == iSet)
|
||||||
{
|
{
|
||||||
MyGenFaceNormalsProcess* pcProcess = new MyGenFaceNormalsProcess();
|
MyGenFaceNormalsProcess* pcProcess = new MyGenFaceNormalsProcess();
|
||||||
pcProcess->Execute(this->pcScene);
|
pcProcess->Execute(pcScene);
|
||||||
//FlipNormalsInt();
|
FlipNormalsInt();
|
||||||
delete pcProcess;
|
delete pcProcess;
|
||||||
}
|
}
|
||||||
else if (SMOOTH == iSet)
|
else if (SMOOTH == iSet)
|
||||||
{
|
{
|
||||||
MyGenVertexNormalsProcess* pcProcess = new MyGenVertexNormalsProcess();
|
MyGenVertexNormalsProcess* pcProcess = new MyGenVertexNormalsProcess();
|
||||||
pcProcess->SetMaxSmoothAngle(1.5f);
|
pcProcess->SetMaxSmoothAngle((float)AI_DEG_TO_RAD(g_smoothAngle));
|
||||||
pcProcess->Execute(this->pcScene);
|
pcProcess->Execute(pcScene);
|
||||||
//FlipNormalsInt();
|
FlipNormalsInt();
|
||||||
delete pcProcess;
|
delete pcProcess;
|
||||||
}
|
}
|
||||||
else if (ORIGINAL == iSet)
|
else if (ORIGINAL == iSet)
|
||||||
{
|
{
|
||||||
for (unsigned int i = 0; i < this->pcScene->mNumMeshes;++i)
|
for (unsigned int i = 0; i < pcScene->mNumMeshes;++i)
|
||||||
{
|
{
|
||||||
if (this->apcMeshes[i]->pvOriginalNormals)
|
if (apcMeshes[i]->pvOriginalNormals)
|
||||||
{
|
{
|
||||||
delete[] this->pcScene->mMeshes[i]->mNormals;
|
delete[] pcScene->mMeshes[i]->mNormals;
|
||||||
this->pcScene->mMeshes[i]->mNormals = this->apcMeshes[i]->pvOriginalNormals;
|
pcScene->mMeshes[i]->mNormals = apcMeshes[i]->pvOriginalNormals;
|
||||||
this->apcMeshes[i]->pvOriginalNormals = NULL;
|
apcMeshes[i]->pvOriginalNormals = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// recalculate tangents and bitangents
|
// recalculate tangents and bitangents
|
||||||
Assimp::BaseProcess* pcProcess = new MyCalcTangentsProcess();
|
Assimp::BaseProcess* pcProcess = new MyCalcTangentsProcess();
|
||||||
pcProcess->Execute(this->pcScene);
|
pcProcess->Execute(pcScene);
|
||||||
delete pcProcess;
|
delete pcProcess;
|
||||||
|
|
||||||
// join the mesh vertices again
|
// join the mesh vertices again
|
||||||
pcProcess = new MyJoinVerticesProcess();
|
pcProcess = new MyJoinVerticesProcess();
|
||||||
pcProcess->Execute(this->pcScene);
|
pcProcess->Execute(pcScene);
|
||||||
delete pcProcess;
|
delete pcProcess;
|
||||||
|
|
||||||
this->iNormalSet = iSet;
|
iNormalSet = iSet;
|
||||||
|
|
||||||
if (g_bWasFlipped)
|
if (g_bWasFlipped)
|
||||||
{
|
{
|
||||||
// invert all normal vectors
|
// invert all normal vectors
|
||||||
for (unsigned int i = 0; i < this->pcScene->mNumMeshes;++i)
|
for (unsigned int i = 0; i < pcScene->mNumMeshes;++i)
|
||||||
{
|
{
|
||||||
aiMesh* pcMesh = this->pcScene->mMeshes[i];
|
aiMesh* pcMesh = pcScene->mMeshes[i];
|
||||||
for (unsigned int a = 0; a < pcMesh->mNumVertices;++a)
|
for (unsigned int a = 0; a < pcMesh->mNumVertices;++a)
|
||||||
{
|
{
|
||||||
pcMesh->mNormals[a] *= -1.0f;
|
pcMesh->mNormals[a] *= -1.0f;
|
||||||
|
|
Binary file not shown.
|
@ -272,6 +272,7 @@ enum EClickPos
|
||||||
extern bool g_bPlay /*= false*/;
|
extern bool g_bPlay /*= false*/;
|
||||||
|
|
||||||
extern double g_dCurrent;
|
extern double g_dCurrent;
|
||||||
|
extern float g_smoothAngle /*= 90.f*/;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // !! AV_MAIN_H_INCLUDED
|
#endif // !! AV_MAIN_H_INCLUDED
|
|
@ -156,6 +156,20 @@ BEGIN
|
||||||
CONTROL "",IDC_EDIT1,"RichEdit20A",ES_MULTILINE | ES_AUTOVSCROLL | ES_READONLY | ES_NUMBER | WS_VSCROLL | WS_TABSTOP,3,4,358,174,WS_EX_STATICEDGE
|
CONTROL "",IDC_EDIT1,"RichEdit20A",ES_MULTILINE | ES_AUTOVSCROLL | ES_READONLY | ES_NUMBER | WS_VSCROLL | WS_TABSTOP,3,4,358,174,WS_EX_STATICEDGE
|
||||||
END
|
END
|
||||||
|
|
||||||
|
IDD_DIALOGSMOOTH DIALOGEX 0, 0, 253, 86
|
||||||
|
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||||
|
CAPTION "Set smooth limit "
|
||||||
|
FONT 8, "MS Shell Dlg", 400, 0, 0x1
|
||||||
|
BEGIN
|
||||||
|
DEFPUSHBUTTON "OK",IDOK,195,53,50,14
|
||||||
|
PUSHBUTTON "Cancel",IDCANCEL,143,53,50,14
|
||||||
|
EDITTEXT IDC_EDITSM,107,7,139,14,ES_AUTOHSCROLL | ES_NUMBER
|
||||||
|
LTEXT "Angle limit (in degrees):",IDC_STATIC,13,10,76,8
|
||||||
|
LTEXT "The angle limit defines the maximum angle that may be between two adjacent face normals that they're smoothed together.",IDC_STATIC,13,27,231,19
|
||||||
|
LTEXT "NOTE: use 'Smooth normals' to update the normals to the new settings",IDC_STATIC,12,75,230,8
|
||||||
|
CONTROL "",IDC_STATIC,"Static",SS_ETCHEDHORZ,7,73,239,1
|
||||||
|
END
|
||||||
|
|
||||||
|
|
||||||
#ifdef APSTUDIO_INVOKED
|
#ifdef APSTUDIO_INVOKED
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -259,6 +273,14 @@ BEGIN
|
||||||
TOPMARGIN, 14
|
TOPMARGIN, 14
|
||||||
BOTTOMMARGIN, 175
|
BOTTOMMARGIN, 175
|
||||||
END
|
END
|
||||||
|
|
||||||
|
IDD_DIALOGSMOOTH, DIALOG
|
||||||
|
BEGIN
|
||||||
|
LEFTMARGIN, 7
|
||||||
|
RIGHTMARGIN, 246
|
||||||
|
TOPMARGIN, 7
|
||||||
|
BOTTOMMARGIN, 79
|
||||||
|
END
|
||||||
END
|
END
|
||||||
#endif // APSTUDIO_INVOKED
|
#endif // APSTUDIO_INVOKED
|
||||||
|
|
||||||
|
@ -310,9 +332,10 @@ BEGIN
|
||||||
MENUITEM "Clear log", ID_TOOLS_CLEARLOG
|
MENUITEM "Clear log", ID_TOOLS_CLEARLOG
|
||||||
MENUITEM SEPARATOR
|
MENUITEM SEPARATOR
|
||||||
MENUITEM "Original normals", ID_TOOLS_ORIGINALNORMALS, CHECKED
|
MENUITEM "Original normals", ID_TOOLS_ORIGINALNORMALS, CHECKED
|
||||||
MENUITEM "Smooth normals", ID_TOOLS_SMOOTHNORMALS
|
|
||||||
MENUITEM "Hard normals", ID_TOOLS_HARDNORMALS
|
MENUITEM "Hard normals", ID_TOOLS_HARDNORMALS
|
||||||
|
MENUITEM "Smooth normals", ID_TOOLS_SMOOTHNORMALS
|
||||||
MENUITEM SEPARATOR
|
MENUITEM SEPARATOR
|
||||||
|
MENUITEM "Set angle limit ...", ID_TOOLS_SETANGLELIMIT
|
||||||
MENUITEM "Flip normals", ID_TOOLS_FLIPNORMALS
|
MENUITEM "Flip normals", ID_TOOLS_FLIPNORMALS
|
||||||
MENUITEM SEPARATOR
|
MENUITEM SEPARATOR
|
||||||
MENUITEM "Stereo view", ID_TOOLS_STEREOVIEW
|
MENUITEM "Stereo view", ID_TOOLS_STEREOVIEW
|
||||||
|
|
|
@ -40,6 +40,7 @@
|
||||||
#define IDB_BTXI 155
|
#define IDB_BTXI 155
|
||||||
#define IDR_TXPOPUP 156
|
#define IDR_TXPOPUP 156
|
||||||
#define IDR_MATPOPUP 157
|
#define IDR_MATPOPUP 157
|
||||||
|
#define IDD_DIALOGSMOOTH 159
|
||||||
#define IDC_CHECK1 1000
|
#define IDC_CHECK1 1000
|
||||||
#define IDC_TOGGLEMS 1000
|
#define IDC_TOGGLEMS 1000
|
||||||
#define IDC_CHECK2 1001
|
#define IDC_CHECK2 1001
|
||||||
|
@ -104,6 +105,7 @@
|
||||||
#define IDC_PLAY 1053
|
#define IDC_PLAY 1053
|
||||||
#define IDC_SHOWSKELETON 1054
|
#define IDC_SHOWSKELETON 1054
|
||||||
#define IDC_BFCULL 1055
|
#define IDC_BFCULL 1055
|
||||||
|
#define IDC_EDITSM 1056
|
||||||
#define ID_VIEWER_OPEN 32771
|
#define ID_VIEWER_OPEN 32771
|
||||||
#define ID_VIEWER_CLOSETHIS 32772
|
#define ID_VIEWER_CLOSETHIS 32772
|
||||||
#define ID_VIEWER_CLOSEASSET 32773
|
#define ID_VIEWER_CLOSEASSET 32773
|
||||||
|
@ -164,6 +166,27 @@
|
||||||
#define ID_VERTEXCACHELOCALITY_FINDBEST 32828
|
#define ID_VERTEXCACHELOCALITY_FINDBEST 32828
|
||||||
#define ID_OPTIMIZE_SCENEGRAPH 32829
|
#define ID_OPTIMIZE_SCENEGRAPH 32829
|
||||||
#define ID_SCENEGRAPH_SMALLESTPOSSIBLEGRAPH 32830
|
#define ID_SCENEGRAPH_SMALLESTPOSSIBLEGRAPH 32830
|
||||||
|
#define ID_SMOOTHNORMALS_5 32831
|
||||||
|
#define ID_SMOOTHNORMALS_6 32832
|
||||||
|
#define ID_SMOOTHNORMALS_MAXANGLE60 32833
|
||||||
|
#define ID_SMOOTHNORMALS_MAXANGLE90 32834
|
||||||
|
#define ID_SMOOTHNORMALS_MAXANGLE120 32835
|
||||||
|
#define ID_SMOOTHNORMALS_NOLIMIT 32836
|
||||||
|
#define ID_SMOOTHNORMALS_30 32837
|
||||||
|
#define ID_SMOOTHNORMALS_40 32838
|
||||||
|
#define ID_SMOOTHNORMALS_60 32839
|
||||||
|
#define ID_SMOOTHNORMALS_90 32840
|
||||||
|
#define ID_SMOOTHNORMALS_120 32841
|
||||||
|
#define ID_Menu32842 32842
|
||||||
|
#define ID_SMOOTHANGLE_30 32843
|
||||||
|
#define ID_SMOOTHANGLE_40 32844
|
||||||
|
#define ID_SMOOTHANGLE_50 32845
|
||||||
|
#define ID_SMOOTHANGLE_60 32846
|
||||||
|
#define ID_SMOOTHANGLE_70 32847
|
||||||
|
#define ID_SMOOTHANGLE_90 32848
|
||||||
|
#define ID_SMOOTHANGLE_120 32849
|
||||||
|
#define ID_SMOOTHANGLE_NONE 32850
|
||||||
|
#define ID_TOOLS_SETANGLELIMIT 32851
|
||||||
#define IDC_STATIC -1
|
#define IDC_STATIC -1
|
||||||
|
|
||||||
// Next default values for new objects
|
// Next default values for new objects
|
||||||
|
@ -171,9 +194,9 @@
|
||||||
#ifdef APSTUDIO_INVOKED
|
#ifdef APSTUDIO_INVOKED
|
||||||
#ifndef APSTUDIO_READONLY_SYMBOLS
|
#ifndef APSTUDIO_READONLY_SYMBOLS
|
||||||
#define _APS_NO_MFC 1
|
#define _APS_NO_MFC 1
|
||||||
#define _APS_NEXT_RESOURCE_VALUE 159
|
#define _APS_NEXT_RESOURCE_VALUE 160
|
||||||
#define _APS_NEXT_COMMAND_VALUE 32831
|
#define _APS_NEXT_COMMAND_VALUE 32852
|
||||||
#define _APS_NEXT_CONTROL_VALUE 1056
|
#define _APS_NEXT_CONTROL_VALUE 1057
|
||||||
#define _APS_NEXT_SYMED_VALUE 110
|
#define _APS_NEXT_SYMED_VALUE 110
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue