mirror of
https://github.com/glest/glest-source.git
synced 2025-08-16 21:33:59 +02:00
Fixed errors in G3D spec and documentation
This commit is contained in:
@@ -16,20 +16,20 @@ copy /y ..\shared\glestkeys.ini bin\vs2015\glestkeys.ini
|
||||
copy /y ..\shared\glestkeys.ini bin\vs2017\glestkeys.ini
|
||||
|
||||
|
||||
copy /y vs2015-32\g3d_viewerWin32\Release\g3d_viewer.exe bin\vs2015\g3d_viewer-32.exe
|
||||
copy /y vs2017-32\g3d_viewerWin32\Release\g3d_viewer.exe bin\vs2017\g3d_viewer-32.exe
|
||||
copy /y vs2015-32\g3d_viewer\Release\g3d_viewer.exe bin\vs2015\g3d_viewer-32.exe
|
||||
copy /y vs2017-32\g3d_viewer\Release\g3d_viewer.exe bin\vs2017\g3d_viewer-32.exe
|
||||
|
||||
copy /y vs2015-32\map_editorWin32\Release\map_editor.exe bin\vs2015\map_editor-32.exe
|
||||
copy /y vs2017-32\map_editorWin32\Release\map_editor.exe bin\vs2017\map_editor-32.exe
|
||||
copy /y vs2015-32\map_editor\Release\map_editor.exe bin\vs2015\map_editor-32.exe
|
||||
copy /y vs2017-32\map_editor\Release\map_editor.exe bin\vs2017\map_editor-32.exe
|
||||
|
||||
copy /y vs2015-32\zetaglest\zetaglest.exe bin\vs2015\zetaglest-32.exe
|
||||
copy /y vs2017-32\zetaglest\zetaglest.exe bin\vs2017\zetaglest-32.exe
|
||||
|
||||
copy /y vs2015-64\g3d_viewerx64\Release\g3d_viewer.exe bin\vs2015\g3d_viewer-64.exe
|
||||
copy /y vs2017-64\g3d_viewerx64\Release\g3d_viewer.exe bin\vs2017\g3d_viewer-64.exe
|
||||
copy /y vs2015-64\g3d_viewer\Release\g3d_viewer.exe bin\vs2015\g3d_viewer-64.exe
|
||||
copy /y vs2017-64\g3d_viewer\Release\g3d_viewer.exe bin\vs2017\g3d_viewer-64.exe
|
||||
|
||||
copy /y vs2015-64\map_editorx64\Release\map_editor.exe bin\vs2015\map_editor-64.exe
|
||||
copy /y vs2017-64\map_editorx64\Release\map_editor.exe bin\vs2017\map_editor-64.exe
|
||||
copy /y vs2015-64\map_editor\Release\map_editor.exe bin\vs2015\map_editor-64.exe
|
||||
copy /y vs2017-64\map_editor\Release\map_editor.exe bin\vs2017\map_editor-64.exe
|
||||
|
||||
copy /y vs2015-64\zetaglest\zetaglest.exe bin\vs2015\zetaglest-64.exe
|
||||
copy /y vs2017-64\zetaglest\zetaglest.exe bin\vs2017\zetaglest-64.exe
|
@@ -82,7 +82,7 @@
|
||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)\$(TargetName)$(Platform)_obj\$(Configuration)\</IntDir>
|
||||
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</LinkIncremental>
|
||||
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</LinkIncremental>
|
||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)\$(TargetName)$(Platform)\$(Configuration)\</OutDir>
|
||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)\$(TargetName)\</OutDir>
|
||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release_WITHOUT_STREFLOP|Win32'">$(SolutionDir)\$(TargetName)$(Platform)\$(Configuration)\</OutDir>
|
||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)\$(TargetName)$(Platform)_obj\$(Configuration)\</IntDir>
|
||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release_WITHOUT_STREFLOP|Win32'">$(SolutionDir)\$(TargetName)$(Platform)_obj\$(Configuration)\</IntDir>
|
||||
|
@@ -140,7 +140,7 @@
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<TargetName>libzetaglest</TargetName>
|
||||
<OutDir>$(SolutionDir)\$(TargetName)$(Platform)\$(Configuration)\</OutDir>
|
||||
<OutDir>$(SolutionDir)\$(TargetName)\</OutDir>
|
||||
<IntDir>$(SolutionDir)\$(TargetName)$(Platform)_obj\$(Configuration)\</IntDir>
|
||||
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
|
||||
</PropertyGroup>
|
||||
|
@@ -83,7 +83,7 @@
|
||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)\$(TargetName)$(Platform)_obj\$(Configuration)\</IntDir>
|
||||
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</LinkIncremental>
|
||||
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</LinkIncremental>
|
||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)\$(TargetName)$(Platform)\$(Configuration)\</OutDir>
|
||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)\$(TargetName)\</OutDir>
|
||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release_WITHOUT_STREFLOP|Win32'">$(SolutionDir)\$(TargetName)$(Platform)\$(Configuration)\</OutDir>
|
||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)\$(TargetName)$(Platform)_obj\$(Configuration)\</IntDir>
|
||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release_WITHOUT_STREFLOP|Win32'">$(SolutionDir)\$(TargetName)$(Platform)_obj\$(Configuration)\</IntDir>
|
||||
|
@@ -101,7 +101,7 @@
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<IntDir>$(SolutionDir)\$(TargetName)$(Platform)_obj\$(Configuration)\</IntDir>
|
||||
<OutDir>$(SolutionDir)\$(TargetName)$(Platform)\$(Configuration)\</OutDir>
|
||||
<OutDir>$(SolutionDir)\$(TargetName)\</OutDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release_WITHOUT_STREFLOP|x64'">
|
||||
<IntDir>$(SolutionDir)\$(TargetName)$(Platform)_obj\$(Configuration)\</IntDir>
|
||||
|
@@ -113,7 +113,7 @@
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<TargetName>libzetaglest</TargetName>
|
||||
<OutDir>$(SolutionDir)\$(TargetName)$(Platform)\$(Configuration)\</OutDir>
|
||||
<OutDir>$(SolutionDir)\$(TargetName)\</OutDir>
|
||||
<IntDir>$(SolutionDir)\$(TargetName)$(Platform)_obj\$(Configuration)\</IntDir>
|
||||
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
|
||||
</PropertyGroup>
|
||||
|
@@ -98,7 +98,7 @@
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<IntDir>$(SolutionDir)\$(TargetName)$(Platform)_obj\$(Configuration)\</IntDir>
|
||||
<OutDir>$(SolutionDir)\$(TargetName)$(Platform)\$(Configuration)\</OutDir>
|
||||
<OutDir>$(SolutionDir)\$(TargetName)\</OutDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release_WITHOUT_STREFLOP|x64'">
|
||||
<IntDir>$(SolutionDir)\$(TargetName)$(Platform)_obj\$(Configuration)\</IntDir>
|
||||
|
@@ -82,7 +82,7 @@
|
||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)\$(TargetName)$(Platform)_obj\$(Configuration)\</IntDir>
|
||||
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</LinkIncremental>
|
||||
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</LinkIncremental>
|
||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)\$(TargetName)$(Platform)\$(Configuration)\</OutDir>
|
||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)\$(TargetName)\</OutDir>
|
||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release_WITHOUT_STREFLOP|Win32'">$(SolutionDir)\$(TargetName)$(Platform)\$(Configuration)\</OutDir>
|
||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)\$(TargetName)$(Platform)_obj\$(Configuration)\</IntDir>
|
||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release_WITHOUT_STREFLOP|Win32'">$(SolutionDir)\$(TargetName)$(Platform)_obj\$(Configuration)\</IntDir>
|
||||
|
@@ -140,7 +140,7 @@
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<TargetName>libzetaglest</TargetName>
|
||||
<OutDir>$(SolutionDir)\$(TargetName)$(Platform)\$(Configuration)\</OutDir>
|
||||
<OutDir>$(SolutionDir)\$(TargetName)\</OutDir>
|
||||
<IntDir>$(SolutionDir)\$(TargetName)$(Platform)_obj\$(Configuration)\</IntDir>
|
||||
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
|
||||
</PropertyGroup>
|
||||
|
@@ -83,7 +83,7 @@
|
||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)\$(TargetName)$(Platform)_obj\$(Configuration)\</IntDir>
|
||||
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</LinkIncremental>
|
||||
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</LinkIncremental>
|
||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)\$(TargetName)$(Platform)\$(Configuration)\</OutDir>
|
||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)\$(TargetName)\</OutDir>
|
||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release_WITHOUT_STREFLOP|Win32'">$(SolutionDir)\$(TargetName)$(Platform)\$(Configuration)\</OutDir>
|
||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)\$(TargetName)$(Platform)_obj\$(Configuration)\</IntDir>
|
||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release_WITHOUT_STREFLOP|Win32'">$(SolutionDir)\$(TargetName)$(Platform)_obj\$(Configuration)\</IntDir>
|
||||
|
@@ -101,7 +101,7 @@
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<IntDir>$(SolutionDir)\$(TargetName)$(Platform)_obj\$(Configuration)\</IntDir>
|
||||
<OutDir>$(SolutionDir)\$(TargetName)$(Platform)\$(Configuration)\</OutDir>
|
||||
<OutDir>$(SolutionDir)\$(TargetName)\</OutDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release_WITHOUT_STREFLOP|x64'">
|
||||
<IntDir>$(SolutionDir)\$(TargetName)$(Platform)_obj\$(Configuration)\</IntDir>
|
||||
|
@@ -113,7 +113,7 @@
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<TargetName>libzetaglest</TargetName>
|
||||
<OutDir>$(SolutionDir)\$(TargetName)$(Platform)\$(Configuration)\</OutDir>
|
||||
<OutDir>$(SolutionDir)\$(TargetName)\</OutDir>
|
||||
<IntDir>$(SolutionDir)\$(TargetName)$(Platform)_obj\$(Configuration)\</IntDir>
|
||||
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
|
||||
</PropertyGroup>
|
||||
|
@@ -98,7 +98,7 @@
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<IntDir>$(SolutionDir)\$(TargetName)$(Platform)_obj\$(Configuration)\</IntDir>
|
||||
<OutDir>$(SolutionDir)\$(TargetName)$(Platform)\$(Configuration)\</OutDir>
|
||||
<OutDir>$(SolutionDir)\$(TargetName)\</OutDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release_WITHOUT_STREFLOP|x64'">
|
||||
<IntDir>$(SolutionDir)\$(TargetName)$(Platform)_obj\$(Configuration)\</IntDir>
|
||||
|
@@ -46,9 +46,9 @@ namespace Shared {
|
||||
class Mesh {
|
||||
private:
|
||||
//mesh data
|
||||
Texture2D * textures[meshTextureCount];
|
||||
bool texturesOwned[meshTextureCount];
|
||||
string texturePaths[meshTextureCount];
|
||||
Texture2D * textures[MESH_TEXTURE_COUNT];
|
||||
bool texturesOwned[MESH_TEXTURE_COUNT];
|
||||
string texturePaths[MESH_TEXTURE_COUNT];
|
||||
|
||||
string name;
|
||||
//vertex data counts
|
||||
@@ -61,7 +61,6 @@ namespace Shared {
|
||||
Vec3f *vertices;
|
||||
Vec3f *normals;
|
||||
Vec2f *texCoords;
|
||||
Vec3f *tangents;
|
||||
uint32 *indices;
|
||||
|
||||
//material data
|
||||
@@ -143,9 +142,6 @@ namespace Shared {
|
||||
const Vec2f *getTexCoords() const {
|
||||
return texCoords;
|
||||
}
|
||||
const Vec3f *getTangents() const {
|
||||
return tangents;
|
||||
}
|
||||
const uint32 *getIndices() const {
|
||||
return indices;
|
||||
}
|
||||
@@ -227,7 +223,7 @@ namespace Shared {
|
||||
|
||||
private:
|
||||
string findAlternateTexture(vector<string> conversionList, string textureFile);
|
||||
void computeTangents();
|
||||
//void computeTangents();
|
||||
|
||||
};
|
||||
|
||||
|
@@ -22,7 +22,6 @@ using Shared::Platform::float32;
|
||||
|
||||
namespace Shared {
|
||||
namespace Graphics {
|
||||
|
||||
#pragma pack(push, 1)
|
||||
|
||||
struct FileHeader {
|
||||
@@ -48,17 +47,15 @@ namespace Shared {
|
||||
mpfGlow = 8
|
||||
};
|
||||
|
||||
enum MeshTexture {
|
||||
mtDiffuse,
|
||||
mtSpecular,
|
||||
mtNormal,
|
||||
mtReflection,
|
||||
mtColorMask,
|
||||
static const int MESH_TEXTURE_COUNT = 3;
|
||||
|
||||
meshTextureCount
|
||||
enum MeshTexture {
|
||||
mtDiffuse = 1,
|
||||
mtSpecular = 2,
|
||||
mtNormal = 4
|
||||
};
|
||||
|
||||
const int meshTextureChannelCount[] = { -1, 1, 3, 1, 1 };
|
||||
const int meshTextureChannelCount[] = { 4, 1, 3 };
|
||||
|
||||
const uint32 meshNameSize = 64;
|
||||
const uint32 mapPathSize = 64;
|
||||
|
@@ -297,7 +297,7 @@ namespace Shared {
|
||||
}
|
||||
|
||||
//texture state
|
||||
const Texture2DGl *texture = static_cast<const Texture2DGl*>(mesh->getTexture(mtDiffuse));
|
||||
const Texture2DGl *texture = static_cast<const Texture2DGl*>(mesh->getTexture(0));
|
||||
if (texture != NULL && renderTextures) {
|
||||
if (lastTexture != texture->getHandle()) {
|
||||
//assert(glIsTexture(texture->getHandle()));
|
||||
@@ -351,7 +351,7 @@ namespace Shared {
|
||||
assertGl();
|
||||
|
||||
//tex coords
|
||||
if (renderTextures && mesh->getTexture(mtDiffuse) != NULL) {
|
||||
if (renderTextures && mesh->getTexture(0) != NULL) {
|
||||
if (duplicateTexCoords) {
|
||||
glActiveTexture(GL_TEXTURE0 + secondaryTexCoordUnit);
|
||||
|
||||
@@ -392,7 +392,7 @@ namespace Shared {
|
||||
assertGl();
|
||||
|
||||
//tex coords
|
||||
if (renderTextures && mesh->getTexture(mtDiffuse) != NULL) {
|
||||
if (renderTextures && mesh->getTexture(0) != NULL) {
|
||||
if (duplicateTexCoords) {
|
||||
glActiveTexture(GL_TEXTURE0 + secondaryTexCoordUnit);
|
||||
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
|
@@ -214,11 +214,10 @@ namespace Shared {
|
||||
vertices = NULL;
|
||||
normals = NULL;
|
||||
texCoords = NULL;
|
||||
tangents = NULL;
|
||||
indices = NULL;
|
||||
interpolationData = NULL;
|
||||
|
||||
for (int i = 0; i < meshTextureCount; ++i) {
|
||||
for (int i = 0; i < MESH_TEXTURE_COUNT; ++i) {
|
||||
textures[i] = NULL;
|
||||
texturesOwned[i] = false;
|
||||
}
|
||||
@@ -283,15 +282,13 @@ namespace Shared {
|
||||
normals = NULL;
|
||||
delete[] texCoords;
|
||||
texCoords = NULL;
|
||||
delete[] tangents;
|
||||
tangents = NULL;
|
||||
delete[] indices;
|
||||
indices = NULL;
|
||||
|
||||
cleanupInterpolationData();
|
||||
|
||||
if (textureManager != NULL) {
|
||||
for (int i = 0; i < meshTextureCount; ++i) {
|
||||
for (int i = 0; i < MESH_TEXTURE_COUNT; ++i) {
|
||||
if (texturesOwned[i] == true && textures[i] != NULL) {
|
||||
//printf("Deleting Texture [%s] i = %d\n",textures[i]->getPath().c_str(),i);
|
||||
textureManager->endTexture(textures[i]);
|
||||
@@ -457,17 +454,17 @@ namespace Shared {
|
||||
|
||||
//texture
|
||||
if (meshHeader.hasTexture && textureManager != NULL) {
|
||||
texturePaths[mtDiffuse] = toLower(reinterpret_cast<char*>(meshHeader.texName));
|
||||
texturePaths[0] = toLower(reinterpret_cast<char*>(meshHeader.texName));
|
||||
string texPath = dir;
|
||||
if (texPath != "") {
|
||||
endPathWithSlash(texPath);
|
||||
}
|
||||
texPath += texturePaths[mtDiffuse];
|
||||
texPath += texturePaths[0];
|
||||
|
||||
if (SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d] v2 model texture [%s] meshIndex = %d modelFile [%s]\n", extractFileFromDirectoryPath(__FILE__).c_str(), __FUNCTION__, __LINE__, texPath.c_str(), meshIndex, modelFile.c_str());
|
||||
|
||||
textures[mtDiffuse] = dynamic_cast<Texture2D*>(textureManager->getTexture(texPath));
|
||||
if (textures[mtDiffuse] == NULL) {
|
||||
textures[0] = dynamic_cast<Texture2D*>(textureManager->getTexture(texPath));
|
||||
if (textures[0] == NULL) {
|
||||
if (fileExists(texPath) == false) {
|
||||
vector<string> conversionList;
|
||||
conversionList.push_back("png");
|
||||
@@ -479,15 +476,15 @@ namespace Shared {
|
||||
if (fileExists(texPath) == true) {
|
||||
if (SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d] v2 model texture [%s] meshIndex = %d modelFile [%s]\n", extractFileFromDirectoryPath(__FILE__).c_str(), __FUNCTION__, __LINE__, texPath.c_str(), meshIndex, modelFile.c_str());
|
||||
|
||||
textures[mtDiffuse] = textureManager->newTexture2D();
|
||||
textures[mtDiffuse]->load(texPath);
|
||||
textures[0] = textureManager->newTexture2D();
|
||||
textures[0]->load(texPath);
|
||||
if (loadedFileList) {
|
||||
(*loadedFileList)[texPath].push_back(make_pair(sourceLoader, sourceLoader));
|
||||
}
|
||||
texturesOwned[mtDiffuse] = true;
|
||||
textures[mtDiffuse]->init(textureManager->getTextureFilter(), textureManager->getMaxAnisotropy());
|
||||
texturesOwned[0] = true;
|
||||
textures[0]->init(textureManager->getTextureFilter(), textureManager->getMaxAnisotropy());
|
||||
if (deletePixMapAfterLoad == true) {
|
||||
textures[mtDiffuse]->deletePixels();
|
||||
textures[0]->deletePixels();
|
||||
}
|
||||
} else {
|
||||
SystemFlags::OutputDebug(SystemFlags::debugError, "In [%s::%s Line: %d] Error v2 model is missing texture [%s] meshIndex = %d modelFile [%s]\n", extractFileFromDirectoryPath(__FILE__).c_str(), __FUNCTION__, __LINE__, texPath.c_str(), meshIndex, modelFile.c_str());
|
||||
@@ -512,7 +509,7 @@ namespace Shared {
|
||||
}
|
||||
fromEndianVecArray<Vec3f>(normals, frameCount*vertexCount);
|
||||
|
||||
if (textureFlags & (1 << mtDiffuse)) {
|
||||
if ((textureFlags & mtDiffuse) == mtDiffuse) {
|
||||
readBytes = fread(texCoords, sizeof(Vec2f)*vertexCount, 1, f);
|
||||
if (readBytes != 1 && vertexCount != 0) {
|
||||
char szBuf[8096] = "";
|
||||
@@ -598,18 +595,18 @@ namespace Shared {
|
||||
|
||||
//texture
|
||||
if ((meshHeader.properties & mp3NoTexture) != mp3NoTexture && textureManager != NULL) {
|
||||
texturePaths[mtDiffuse] = toLower(reinterpret_cast<char*>(meshHeader.texName));
|
||||
texturePaths[0] = toLower(reinterpret_cast<char*>(meshHeader.texName));
|
||||
|
||||
string texPath = dir;
|
||||
if (texPath != "") {
|
||||
endPathWithSlash(texPath);
|
||||
}
|
||||
texPath += texturePaths[mtDiffuse];
|
||||
texPath += texturePaths[0];
|
||||
|
||||
if (SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d] v3 model texture [%s] meshIndex = %d modelFile [%s]\n", extractFileFromDirectoryPath(__FILE__).c_str(), __FUNCTION__, __LINE__, texPath.c_str(), meshIndex, modelFile.c_str());
|
||||
|
||||
textures[mtDiffuse] = dynamic_cast<Texture2D*>(textureManager->getTexture(texPath));
|
||||
if (textures[mtDiffuse] == NULL) {
|
||||
textures[0] = dynamic_cast<Texture2D*>(textureManager->getTexture(texPath));
|
||||
if (textures[0] == NULL) {
|
||||
if (fileExists(texPath) == false) {
|
||||
vector<string> conversionList;
|
||||
conversionList.push_back("png");
|
||||
@@ -622,16 +619,16 @@ namespace Shared {
|
||||
if (fileExists(texPath) == true) {
|
||||
if (SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d] v3 model texture [%s] meshIndex = %d modelFile [%s]\n", extractFileFromDirectoryPath(__FILE__).c_str(), __FUNCTION__, __LINE__, texPath.c_str(), meshIndex, modelFile.c_str());
|
||||
|
||||
textures[mtDiffuse] = textureManager->newTexture2D();
|
||||
textures[mtDiffuse]->load(texPath);
|
||||
textures[0] = textureManager->newTexture2D();
|
||||
textures[0]->load(texPath);
|
||||
if (loadedFileList) {
|
||||
(*loadedFileList)[texPath].push_back(make_pair(sourceLoader, sourceLoader));
|
||||
}
|
||||
|
||||
texturesOwned[mtDiffuse] = true;
|
||||
textures[mtDiffuse]->init(textureManager->getTextureFilter(), textureManager->getMaxAnisotropy());
|
||||
texturesOwned[0] = true;
|
||||
textures[0]->init(textureManager->getTextureFilter(), textureManager->getMaxAnisotropy());
|
||||
if (deletePixMapAfterLoad == true) {
|
||||
textures[mtDiffuse]->deletePixels();
|
||||
textures[0]->deletePixels();
|
||||
}
|
||||
} else {
|
||||
SystemFlags::OutputDebug(SystemFlags::debugError, "In [%s::%s Line: %d] Error v3 model is missing texture [%s] meshHeader.properties = %d meshIndex = %d modelFile [%s]\n", extractFileFromDirectoryPath(__FILE__).c_str(), __FUNCTION__, __LINE__, texPath.c_str(), meshHeader.properties, meshIndex, modelFile.c_str());
|
||||
@@ -656,7 +653,7 @@ namespace Shared {
|
||||
}
|
||||
fromEndianVecArray<Vec3f>(normals, frameCount*vertexCount);
|
||||
|
||||
if (textureFlags & (1 << mtDiffuse)) {
|
||||
if ((textureFlags & mtDiffuse) == mtDiffuse) {
|
||||
for (unsigned int i = 0; i < meshHeader.texCoordFrameCount; ++i) {
|
||||
readBytes = fread(texCoords, sizeof(Vec2f)*vertexCount, 1, f);
|
||||
if (readBytes != 1 && vertexCount != 0) {
|
||||
@@ -800,7 +797,7 @@ namespace Shared {
|
||||
|
||||
//maps
|
||||
uint32 flag = 1;
|
||||
for (int i = 0; i < meshTextureCount; ++i) {
|
||||
for (int i = 0; i < MESH_TEXTURE_COUNT; ++i) {
|
||||
if (meshHeader.textures & flag) {
|
||||
uint8 cMapPath[mapPathSize + 1];
|
||||
memset(&cMapPath[0], 0, mapPathSize + 1);
|
||||
@@ -826,8 +823,7 @@ namespace Shared {
|
||||
}
|
||||
mapFullPath += mapPath;
|
||||
if (textureManager) {
|
||||
textures[i] = loadMeshTexture(meshIndex, i, textureManager, mapFullPath,
|
||||
meshTextureChannelCount[i], texturesOwned[i],
|
||||
textures[i] = loadMeshTexture(meshIndex, i, textureManager, mapFullPath, meshTextureChannelCount[i], texturesOwned[i],
|
||||
deletePixMapAfterLoad, loadedFileList, sourceLoader, modelFile);
|
||||
}
|
||||
}
|
||||
@@ -869,9 +865,9 @@ namespace Shared {
|
||||
Shared::PlatformByteOrder::fromEndianTypeArray<uint32>(indices, indexCount);
|
||||
|
||||
//tangents
|
||||
if (textures[mtNormal] != NULL) {
|
||||
/*if (textures[mtNormal] != NULL) {
|
||||
computeTangents();
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
void Mesh::save(int meshIndex, const string &dir, FILE *f, TextureManager *textureManager,
|
||||
@@ -909,11 +905,11 @@ namespace Shared {
|
||||
meshHeader.textures = textureFlags;
|
||||
fwrite(&meshHeader, sizeof(MeshHeader), 1, f);
|
||||
|
||||
if (SystemFlags::VERBOSE_MODE_ENABLED) printf("Save, this = %p, Found meshTextureCount = %d, meshHeader.textures = %d meshIndex = %d\n", this, meshTextureCount, meshHeader.textures, meshIndex);
|
||||
if (SystemFlags::VERBOSE_MODE_ENABLED) printf("Save, this = %p, Found meshTextureCount = %d, meshHeader.textures = %d meshIndex = %d\n", this, MESH_TEXTURE_COUNT, meshHeader.textures, meshIndex);
|
||||
|
||||
//maps
|
||||
uint32 flag = 1;
|
||||
for (int i = 0; i < meshTextureCount; ++i) {
|
||||
for (int i = 0; i < MESH_TEXTURE_COUNT; ++i) {
|
||||
if ((meshHeader.textures & flag)) {
|
||||
uint8 cMapPath[mapPathSize];
|
||||
memset(&cMapPath[0], 0, mapPathSize);
|
||||
@@ -1019,7 +1015,7 @@ namespace Shared {
|
||||
fwrite(indices, sizeof(uint32)*indexCount, 1, f);
|
||||
}
|
||||
|
||||
void Mesh::computeTangents() {
|
||||
/*void Mesh::computeTangents() {
|
||||
delete[] tangents;
|
||||
try {
|
||||
tangents = new Vec3f[vertexCount];
|
||||
@@ -1058,14 +1054,12 @@ namespace Shared {
|
||||
}
|
||||
|
||||
for (unsigned int i = 0; i < vertexCount; ++i) {
|
||||
/*Vec3f binormal= normals[i].cross(tangents[i]);
|
||||
tangents[i]+= binormal.cross(normals[i]);*/
|
||||
tangents[i].normalize();
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
void Mesh::deletePixels() {
|
||||
for (int i = 0; i < meshTextureCount; ++i) {
|
||||
for (int i = 0; i < MESH_TEXTURE_COUNT; ++i) {
|
||||
if (textures[i] != NULL) {
|
||||
textures[i]->deletePixels();
|
||||
}
|
||||
@@ -1446,7 +1440,7 @@ namespace Shared {
|
||||
void Mesh::copyInto(Mesh *dest, bool ignoreInterpolationData,
|
||||
bool destinationOwnsTextures) {
|
||||
|
||||
for (int index = 0; index < meshTextureCount; ++index) {
|
||||
for (int index = 0; index < MESH_TEXTURE_COUNT; ++index) {
|
||||
dest->textures[index] = this->textures[index];
|
||||
dest->texturesOwned[index] = this->texturesOwned[index];
|
||||
dest->texturePaths[index] = this->texturePaths[index];
|
||||
@@ -1491,15 +1485,6 @@ namespace Shared {
|
||||
memcpy(&dest->texCoords[0], &this->texCoords[0], this->vertexCount * sizeof(Vec2f));
|
||||
}
|
||||
|
||||
if (dest->tangents != NULL) {
|
||||
delete[] dest->tangents;
|
||||
dest->tangents = NULL;
|
||||
}
|
||||
if (this->tangents != NULL) {
|
||||
dest->tangents = new Vec3f[this->vertexCount];
|
||||
memcpy(&dest->tangents[0], &this->tangents[0], this->vertexCount * sizeof(Vec3f));
|
||||
}
|
||||
|
||||
if (dest->indices != NULL) {
|
||||
delete[] dest->indices;
|
||||
dest->indices = NULL;
|
||||
|
@@ -75,28 +75,32 @@
|
||||
#vertexCount: number of vertices in each frame
|
||||
#indexCount: number of indices in this mesh (the number of triangles is indexCount/3)
|
||||
#diffuseColor: RGB diffuse color
|
||||
#specularColor: RGB specular color (currently unused)
|
||||
#specularPower: specular power (currently unused)
|
||||
#specularColor: RGB specular color
|
||||
#specularPower: specular power
|
||||
##properties: property flags
|
||||
#Code:
|
||||
#enum MeshPropertyFlag{
|
||||
# mpfCustomColor= 1,
|
||||
# mpfTwoSided= 2,
|
||||
# mpfNoSelect= 4
|
||||
# mpfNoSelect= 4,
|
||||
# mpfGlow= 8
|
||||
#};
|
||||
#mpfTwoSided: meshes in this mesh are rendered by both sides, if this flag is not present only "counter clockwise" faces are rendered
|
||||
#The last 8 bits of properties are used for teamcolor transparency, where 0 is opaque, and 255 is fully transparent team color. The value is inverted for compatibility with megaglest
|
||||
#mpfTwoSided: meshes in this mesh are rendered by both sides, if this flag is not present only "counter clockwise" faces are rendered (culling)
|
||||
#mpfCustomColor: alpha in this model is replaced by a custom color, usually the player color
|
||||
#mpfNoSelect: whether the model is selectable
|
||||
#mpfGlow: whether the model has a glow effect
|
||||
#textures: texture flags
|
||||
#Code:
|
||||
#enum MeshTexture{
|
||||
# diffuse = 1,
|
||||
# specular = 2,
|
||||
# normal = 4
|
||||
# mtDiffuse = 1,
|
||||
# mtSpecular = 2,
|
||||
# mtNormal = 4
|
||||
#};
|
||||
#================================
|
||||
#4. TEXTURE NAMES
|
||||
#================================
|
||||
#A list of uint8[64] texture name values. One for each texture in the mesh. If there are no textures in the mesh no texture names are present.
|
||||
#A list of (max 3) uint8[64] texture name values. One for each corresponding texture flag in the mesh. If there are no textures in the mesh, no texture names are present.
|
||||
#================================
|
||||
#5. MESH DATA
|
||||
#================================
|
||||
@@ -179,7 +183,7 @@ class G3DMeshHeaderv3: #Read Meshheader
|
||||
temp = fileID.read(struct.calcsize(self.binary_format))
|
||||
data = struct.unpack(self.binary_format,temp)
|
||||
self.framecount = data[0] #Framecount = Number of Animationsteps
|
||||
self.normalframecount= data[1] #Number of Normal Frames actualli equal to Framecount
|
||||
self.normalframecount= data[1] #Number of Normal Frames actually equal to Framecount
|
||||
self.texturecoordframecount= data[2]#Number of Frames of Texturecoordinates seems everytime to be 1
|
||||
self.colorframecount= data[3] #Number of Frames of Colors seems everytime to be 1
|
||||
self.vertexcount= data[4] #Number of Vertices in each Frame
|
||||
@@ -227,8 +231,8 @@ class G3DMeshHeaderv4: #Read Meshheader
|
||||
self.istwosided = bool(self.properties & 2)
|
||||
self.noselect = bool(self.properties & 4)
|
||||
self.glow = bool(self.properties & 8)
|
||||
# Get last 8 bits for teamcolor transparency.
|
||||
# The value is inverted for compatibility with megaglest.
|
||||
# Get last 8 bits for teamcolor transparency
|
||||
# The value is inverted for compatibility with megaglest
|
||||
self.teamcoloralpha = 255 - (self.properties >> 24)
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user