2008-05-09 17:24:28 +00:00
|
|
|
/*
|
|
|
|
---------------------------------------------------------------------------
|
2012-02-03 03:38:30 +00:00
|
|
|
Open Asset Import Library (assimp)
|
2008-05-09 17:24:28 +00:00
|
|
|
---------------------------------------------------------------------------
|
|
|
|
|
2012-02-03 03:38:30 +00:00
|
|
|
Copyright (c) 2006-2012, assimp team
|
2008-05-09 17:24:28 +00:00
|
|
|
|
|
|
|
All rights reserved.
|
|
|
|
|
|
|
|
Redistribution and use of this software in source and binary forms,
|
|
|
|
with or without modification, are permitted provided that the following
|
|
|
|
conditions are met:
|
|
|
|
|
|
|
|
* Redistributions of source code must retain the above
|
2008-05-13 23:26:52 +00:00
|
|
|
copyright notice, this list of conditions and the
|
|
|
|
following disclaimer.
|
2008-05-09 17:24:28 +00:00
|
|
|
|
|
|
|
* Redistributions in binary form must reproduce the above
|
2008-05-13 23:26:52 +00:00
|
|
|
copyright notice, this list of conditions and the
|
|
|
|
following disclaimer in the documentation and/or other
|
|
|
|
materials provided with the distribution.
|
2008-05-09 17:24:28 +00:00
|
|
|
|
2012-02-03 03:38:30 +00:00
|
|
|
* Neither the name of the assimp team, nor the names of its
|
2008-05-13 23:26:52 +00:00
|
|
|
contributors may be used to endorse or promote products
|
|
|
|
derived from this software without specific prior
|
2012-02-03 03:38:30 +00:00
|
|
|
written permission of the assimp team.
|
2008-05-09 17:24:28 +00:00
|
|
|
|
|
|
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
|
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
|
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
|
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
|
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
|
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
|
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
|
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
---------------------------------------------------------------------------
|
2008-05-05 12:36:31 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "assimp_view.h"
|
|
|
|
|
|
|
|
namespace AssimpView {
|
|
|
|
|
2015-04-17 18:02:55 +00:00
|
|
|
extern std::string g_szSkyboxShader;
|
2008-05-05 12:36:31 +00:00
|
|
|
|
|
|
|
// From: U3D build 1256 (src\kernel\graphic\scenegraph\SkyBox.cpp)
|
|
|
|
// ------------------------------------------------------------------------------
|
|
|
|
/** \brief Vertex structure for the skybox
|
2008-05-13 23:26:52 +00:00
|
|
|
*/
|
2008-05-05 12:36:31 +00:00
|
|
|
// ------------------------------------------------------------------------------
|
|
|
|
struct SkyBoxVertex
|
2008-05-13 23:26:52 +00:00
|
|
|
{
|
|
|
|
float x,y,z;
|
|
|
|
float u,v,w;
|
|
|
|
};
|
2008-05-05 12:36:31 +00:00
|
|
|
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------
|
|
|
|
/** \brief Vertices for the skybox
|
2008-05-13 23:26:52 +00:00
|
|
|
*/
|
2008-05-05 12:36:31 +00:00
|
|
|
// ------------------------------------------------------------------------------
|
|
|
|
SkyBoxVertex g_cubeVertices_indexed[] =
|
2008-05-13 23:26:52 +00:00
|
|
|
{
|
2008-05-05 12:36:31 +00:00
|
|
|
{ -1.0f, 1.0f, -1.0f, -1.0f,1.0f,-1.0f }, // 0
|
|
|
|
{ 1.0f, 1.0f, -1.0f, 1.0f,1.0f,-1.0f }, // 1
|
|
|
|
{ -1.0f, -1.0f, -1.0f, -1.0f,-1.0f,-1.0f }, // 2
|
|
|
|
{ 1.0f,-1.0f,-1.0f, 1.0f,-1.0f,-1.0f }, // 3
|
|
|
|
{-1.0f, 1.0f, 1.0f, -1.0f,1.0f,1.0f }, // 4
|
|
|
|
{-1.0f,-1.0f, 1.0f, -1.0f,-1.0f,1.0f }, // 5
|
|
|
|
{ 1.0f, 1.0f, 1.0f, 1.0f,1.0f,1.0f }, // 6
|
|
|
|
{ 1.0f,-1.0f, 1.0f, 1.0f,-1.0f,1.0f } // 7
|
2008-05-13 23:26:52 +00:00
|
|
|
};
|
2008-05-05 12:36:31 +00:00
|
|
|
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------
|
|
|
|
/** \brief Indices for the skybox
|
2008-05-13 23:26:52 +00:00
|
|
|
*/
|
2008-05-05 12:36:31 +00:00
|
|
|
// ------------------------------------------------------------------------------
|
|
|
|
unsigned short g_cubeIndices[] =
|
2008-05-13 23:26:52 +00:00
|
|
|
{
|
2008-05-05 12:36:31 +00:00
|
|
|
0, 1, 2, 3, 2, 1,4, 5, 6,
|
|
|
|
7, 6, 5, 4, 6, 0, 1, 6, 0,
|
|
|
|
5, 2, 7,3, 2, 7, 1, 6, 3,
|
|
|
|
7, 3, 6, 0, 2, 4, 5, 4, 2,
|
2008-05-13 23:26:52 +00:00
|
|
|
};
|
2008-05-05 12:36:31 +00:00
|
|
|
|
|
|
|
CBackgroundPainter CBackgroundPainter::s_cInstance;
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------------
|
|
|
|
void CBackgroundPainter::SetColor (D3DCOLOR p_clrNew)
|
2008-05-13 23:26:52 +00:00
|
|
|
{
|
2009-02-11 20:56:05 +00:00
|
|
|
if (TEXTURE_CUBE == eMode)
|
|
|
|
RemoveSBDeps();
|
2008-05-05 12:36:31 +00:00
|
|
|
|
2009-02-11 20:56:05 +00:00
|
|
|
clrColor = p_clrNew;
|
|
|
|
eMode = SIMPLE_COLOR;
|
2008-05-05 12:36:31 +00:00
|
|
|
|
2009-02-11 20:56:05 +00:00
|
|
|
if (pcTexture)
|
2008-05-13 23:26:52 +00:00
|
|
|
{
|
2009-02-11 20:56:05 +00:00
|
|
|
pcTexture->Release();
|
|
|
|
pcTexture = NULL;
|
2008-05-05 12:36:31 +00:00
|
|
|
}
|
2008-05-13 23:26:52 +00:00
|
|
|
}
|
2008-05-05 12:36:31 +00:00
|
|
|
//-------------------------------------------------------------------------------
|
|
|
|
void CBackgroundPainter::RemoveSBDeps()
|
2008-05-13 23:26:52 +00:00
|
|
|
{
|
2009-02-11 20:56:05 +00:00
|
|
|
MODE e = eMode;
|
|
|
|
eMode = SIMPLE_COLOR;
|
2008-05-05 12:36:31 +00:00
|
|
|
if (g_pcAsset && g_pcAsset->pcScene)
|
2008-05-13 23:26:52 +00:00
|
|
|
{
|
2008-05-05 12:36:31 +00:00
|
|
|
for (unsigned int i = 0; i < g_pcAsset->pcScene->mNumMeshes;++i)
|
2008-05-13 23:26:52 +00:00
|
|
|
{
|
2008-05-05 12:36:31 +00:00
|
|
|
if (aiShadingMode_Gouraud != g_pcAsset->apcMeshes[i]->eShadingMode)
|
2008-05-13 23:26:52 +00:00
|
|
|
{
|
|
|
|
CMaterialManager::Instance().DeleteMaterial(g_pcAsset->apcMeshes[i]);
|
|
|
|
CMaterialManager::Instance().CreateMaterial(
|
|
|
|
g_pcAsset->apcMeshes[i],g_pcAsset->pcScene->mMeshes[i]);
|
2008-05-05 12:36:31 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2009-02-11 20:56:05 +00:00
|
|
|
eMode = e;
|
2008-05-13 23:26:52 +00:00
|
|
|
}
|
2008-05-05 12:36:31 +00:00
|
|
|
//-------------------------------------------------------------------------------
|
|
|
|
void CBackgroundPainter::ResetSB()
|
2008-05-13 23:26:52 +00:00
|
|
|
{
|
2009-02-11 20:56:05 +00:00
|
|
|
mMatrix = aiMatrix4x4();
|
2008-05-13 23:26:52 +00:00
|
|
|
}
|
2008-05-05 12:36:31 +00:00
|
|
|
//-------------------------------------------------------------------------------
|
|
|
|
void CBackgroundPainter::SetCubeMapBG (const char* p_szPath)
|
2008-05-13 23:26:52 +00:00
|
|
|
{
|
2008-05-05 12:36:31 +00:00
|
|
|
bool bHad = false;
|
2009-02-11 20:56:05 +00:00
|
|
|
if (pcTexture)
|
2008-05-13 23:26:52 +00:00
|
|
|
{
|
2009-02-11 20:56:05 +00:00
|
|
|
pcTexture->Release();
|
|
|
|
pcTexture = NULL;
|
|
|
|
if(TEXTURE_CUBE ==eMode)bHad = true;
|
2008-05-13 23:26:52 +00:00
|
|
|
}
|
2008-05-05 12:36:31 +00:00
|
|
|
|
2009-02-11 20:56:05 +00:00
|
|
|
eMode = TEXTURE_CUBE;
|
2008-05-05 12:36:31 +00:00
|
|
|
|
2009-02-11 20:56:05 +00:00
|
|
|
szPath = std::string( p_szPath );
|
2008-05-05 12:36:31 +00:00
|
|
|
|
|
|
|
// ARRRGHH... ugly. TODO: Rewrite this!
|
|
|
|
aiString sz;
|
2009-02-11 20:56:05 +00:00
|
|
|
sz.Set(szPath);
|
2008-05-13 23:26:52 +00:00
|
|
|
CMaterialManager::Instance().FindValidPath(&sz);
|
2009-02-11 20:56:05 +00:00
|
|
|
szPath = std::string( sz.data );
|
2008-05-05 12:36:31 +00:00
|
|
|
|
|
|
|
// now recreate all native resources
|
2009-02-11 20:56:05 +00:00
|
|
|
RecreateNativeResource();
|
2008-05-05 12:36:31 +00:00
|
|
|
|
|
|
|
if (SIMPLE_COLOR != this->eMode)
|
2008-05-13 23:26:52 +00:00
|
|
|
{
|
2008-05-05 12:36:31 +00:00
|
|
|
// this influences all material with specular components
|
|
|
|
if (!bHad)
|
2008-05-13 23:26:52 +00:00
|
|
|
{
|
2008-05-05 12:36:31 +00:00
|
|
|
if (g_pcAsset && g_pcAsset->pcScene)
|
2008-05-13 23:26:52 +00:00
|
|
|
{
|
2008-05-05 12:36:31 +00:00
|
|
|
for (unsigned int i = 0; i < g_pcAsset->pcScene->mNumMeshes;++i)
|
2008-05-13 23:26:52 +00:00
|
|
|
{
|
2008-05-05 12:36:31 +00:00
|
|
|
if (aiShadingMode_Phong == g_pcAsset->apcMeshes[i]->eShadingMode)
|
2008-05-13 23:26:52 +00:00
|
|
|
{
|
|
|
|
CMaterialManager::Instance().DeleteMaterial(g_pcAsset->apcMeshes[i]);
|
|
|
|
CMaterialManager::Instance().CreateMaterial(
|
|
|
|
g_pcAsset->apcMeshes[i],g_pcAsset->pcScene->mMeshes[i]);
|
2008-05-05 12:36:31 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2008-05-13 23:26:52 +00:00
|
|
|
}
|
2008-05-05 12:36:31 +00:00
|
|
|
else
|
2008-05-13 23:26:52 +00:00
|
|
|
{
|
2008-05-05 12:36:31 +00:00
|
|
|
if (g_pcAsset && g_pcAsset->pcScene)
|
2008-05-13 23:26:52 +00:00
|
|
|
{
|
2008-05-05 12:36:31 +00:00
|
|
|
for (unsigned int i = 0; i < g_pcAsset->pcScene->mNumMeshes;++i)
|
2008-05-13 23:26:52 +00:00
|
|
|
{
|
2008-05-05 12:36:31 +00:00
|
|
|
if (aiShadingMode_Phong == g_pcAsset->apcMeshes[i]->eShadingMode)
|
2008-05-13 23:26:52 +00:00
|
|
|
{
|
2008-05-05 12:36:31 +00:00
|
|
|
g_pcAsset->apcMeshes[i]->piEffect->SetTexture(
|
|
|
|
"lw_tex_envmap",CBackgroundPainter::Instance().GetTexture());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2008-05-13 23:26:52 +00:00
|
|
|
}
|
2008-05-05 12:36:31 +00:00
|
|
|
//-------------------------------------------------------------------------------
|
|
|
|
void CBackgroundPainter::RotateSB(const aiMatrix4x4* pm)
|
2008-05-13 23:26:52 +00:00
|
|
|
{
|
2009-02-11 20:56:05 +00:00
|
|
|
this->mMatrix = mMatrix * (*pm);
|
2008-05-13 23:26:52 +00:00
|
|
|
}
|
2008-05-05 12:36:31 +00:00
|
|
|
//-------------------------------------------------------------------------------
|
|
|
|
void CBackgroundPainter::SetTextureBG (const char* p_szPath)
|
2008-05-13 23:26:52 +00:00
|
|
|
{
|
2008-05-05 12:36:31 +00:00
|
|
|
if (TEXTURE_CUBE == this->eMode)this->RemoveSBDeps();
|
|
|
|
|
2009-02-11 20:56:05 +00:00
|
|
|
if (pcTexture)
|
2008-05-13 23:26:52 +00:00
|
|
|
{
|
2009-02-11 20:56:05 +00:00
|
|
|
pcTexture->Release();
|
|
|
|
pcTexture = NULL;
|
2008-05-13 23:26:52 +00:00
|
|
|
}
|
|
|
|
|
2009-02-11 20:56:05 +00:00
|
|
|
eMode = TEXTURE_2D;
|
|
|
|
szPath = std::string( p_szPath );
|
2008-05-05 12:36:31 +00:00
|
|
|
|
|
|
|
// ARRRGHH... ugly. TODO: Rewrite this!
|
|
|
|
aiString sz;
|
2009-02-11 20:56:05 +00:00
|
|
|
sz.Set(szPath);
|
2008-05-13 23:26:52 +00:00
|
|
|
CMaterialManager::Instance().FindValidPath(&sz);
|
2009-02-11 20:56:05 +00:00
|
|
|
szPath = std::string( sz.data );
|
2008-05-05 12:36:31 +00:00
|
|
|
|
|
|
|
// now recreate all native resources
|
2009-02-11 20:56:05 +00:00
|
|
|
RecreateNativeResource();
|
2008-05-13 23:26:52 +00:00
|
|
|
}
|
2008-05-05 12:36:31 +00:00
|
|
|
//-------------------------------------------------------------------------------
|
|
|
|
void CBackgroundPainter::OnPreRender()
|
2008-05-13 23:26:52 +00:00
|
|
|
{
|
2009-02-11 20:56:05 +00:00
|
|
|
if (SIMPLE_COLOR != eMode)
|
2008-05-13 23:26:52 +00:00
|
|
|
{
|
2008-05-05 12:36:31 +00:00
|
|
|
// clear the z-buffer only (in wireframe mode we must also clear
|
|
|
|
// the color buffer )
|
|
|
|
if (g_sOptions.eDrawMode == RenderOptions::WIREFRAME)
|
2008-05-13 23:26:52 +00:00
|
|
|
{
|
2008-05-05 12:36:31 +00:00
|
|
|
g_piDevice->Clear(0,NULL,D3DCLEAR_ZBUFFER | D3DCLEAR_TARGET,
|
|
|
|
D3DCOLOR_ARGB(0xff,100,100,100),1.0f,0);
|
2008-05-13 23:26:52 +00:00
|
|
|
}
|
2008-05-05 12:36:31 +00:00
|
|
|
else
|
2008-05-13 23:26:52 +00:00
|
|
|
{
|
2008-05-05 12:36:31 +00:00
|
|
|
g_piDevice->Clear(0,NULL,D3DCLEAR_ZBUFFER,0,1.0f,0);
|
2008-05-13 23:26:52 +00:00
|
|
|
}
|
2008-05-05 12:36:31 +00:00
|
|
|
|
2009-02-11 20:56:05 +00:00
|
|
|
if (TEXTURE_2D == eMode)
|
2008-05-13 23:26:52 +00:00
|
|
|
{
|
2008-05-05 12:36:31 +00:00
|
|
|
RECT sRect;
|
|
|
|
GetWindowRect(GetDlgItem(g_hDlg,IDC_RT),&sRect);
|
|
|
|
sRect.right -= sRect.left;
|
|
|
|
sRect.bottom -= sRect.top;
|
|
|
|
|
|
|
|
struct SVertex
|
2008-05-13 23:26:52 +00:00
|
|
|
{
|
2008-05-05 12:36:31 +00:00
|
|
|
float x,y,z,w,u,v;
|
2008-05-13 23:26:52 +00:00
|
|
|
};
|
2008-05-05 12:36:31 +00:00
|
|
|
|
|
|
|
UINT dw;
|
|
|
|
this->piSkyBoxEffect->Begin(&dw,0);
|
|
|
|
this->piSkyBoxEffect->BeginPass(0);
|
|
|
|
|
|
|
|
SVertex as[4];
|
|
|
|
as[1].x = 0.0f;
|
|
|
|
as[1].y = 0.0f;
|
|
|
|
as[1].z = 0.2f;
|
|
|
|
as[1].w = 1.0f;
|
|
|
|
as[1].u = 0.0f;
|
|
|
|
as[1].v = 0.0f;
|
|
|
|
|
|
|
|
as[3].x = (float)sRect.right;
|
|
|
|
as[3].y = 0.0f;
|
|
|
|
as[3].z = 0.2f;
|
|
|
|
as[3].w = 1.0f;
|
|
|
|
as[3].u = 1.0f;
|
|
|
|
as[3].v = 0.0f;
|
|
|
|
|
|
|
|
as[0].x = 0.0f;
|
|
|
|
as[0].y = (float)sRect.bottom;
|
|
|
|
as[0].z = 0.2f;
|
|
|
|
as[0].w = 1.0f;
|
|
|
|
as[0].u = 0.0f;
|
|
|
|
as[0].v = 1.0f;
|
|
|
|
|
|
|
|
as[2].x = (float)sRect.right;
|
|
|
|
as[2].y = (float)sRect.bottom;
|
|
|
|
as[2].z = 0.2f;
|
|
|
|
as[2].w = 1.0f;
|
|
|
|
as[2].u = 1.0f;
|
|
|
|
as[2].v = 1.0f;
|
|
|
|
|
|
|
|
as[0].x -= 0.5f;as[1].x -= 0.5f;as[2].x -= 0.5f;as[3].x -= 0.5f;
|
|
|
|
as[0].y -= 0.5f;as[1].y -= 0.5f;as[2].y -= 0.5f;as[3].y -= 0.5f;
|
|
|
|
|
|
|
|
DWORD dw2;g_piDevice->GetFVF(&dw2);
|
|
|
|
g_piDevice->SetFVF(D3DFVF_XYZRHW | D3DFVF_TEX1);
|
|
|
|
|
|
|
|
g_piDevice->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP,2,
|
|
|
|
&as,sizeof(SVertex));
|
|
|
|
|
2009-02-11 20:56:05 +00:00
|
|
|
piSkyBoxEffect->EndPass();
|
|
|
|
piSkyBoxEffect->End();
|
2008-05-05 12:36:31 +00:00
|
|
|
|
|
|
|
g_piDevice->SetFVF(dw2);
|
|
|
|
}
|
2008-05-13 23:26:52 +00:00
|
|
|
return;
|
|
|
|
}
|
2008-05-05 12:36:31 +00:00
|
|
|
// clear both the render target and the z-buffer
|
|
|
|
g_piDevice->Clear(0,NULL,D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER,
|
2009-02-11 20:56:05 +00:00
|
|
|
clrColor,1.0f,0);
|
2008-05-13 23:26:52 +00:00
|
|
|
}
|
2008-05-05 12:36:31 +00:00
|
|
|
//-------------------------------------------------------------------------------
|
|
|
|
void CBackgroundPainter::OnPostRender()
|
2008-05-13 23:26:52 +00:00
|
|
|
{
|
2009-02-11 20:56:05 +00:00
|
|
|
if (TEXTURE_CUBE == eMode)
|
2008-05-13 23:26:52 +00:00
|
|
|
{
|
2008-05-05 12:36:31 +00:00
|
|
|
aiMatrix4x4 pcProj;
|
|
|
|
GetProjectionMatrix(pcProj);
|
|
|
|
|
|
|
|
aiMatrix4x4 pcCam;
|
|
|
|
aiVector3D vPos = GetCameraMatrix(pcCam);
|
|
|
|
|
|
|
|
aiMatrix4x4 aiMe;
|
2008-05-13 23:26:52 +00:00
|
|
|
aiMe[3][0] = vPos.x;
|
2008-05-05 12:36:31 +00:00
|
|
|
aiMe[3][1] = vPos.y;
|
|
|
|
aiMe[3][2] = vPos.z;
|
2009-02-11 20:56:05 +00:00
|
|
|
aiMe = mMatrix * aiMe;
|
2008-05-05 12:36:31 +00:00
|
|
|
|
|
|
|
pcProj = (aiMe * pcCam) * pcProj;
|
|
|
|
|
2009-02-11 20:56:05 +00:00
|
|
|
piSkyBoxEffect->SetMatrix("WorldViewProjection",
|
2008-05-05 12:36:31 +00:00
|
|
|
(const D3DXMATRIX*)&pcProj);
|
|
|
|
|
|
|
|
UINT dwPasses;
|
2009-02-11 20:56:05 +00:00
|
|
|
piSkyBoxEffect->Begin(&dwPasses,0);
|
|
|
|
piSkyBoxEffect->BeginPass(0);
|
2008-05-05 12:36:31 +00:00
|
|
|
|
|
|
|
DWORD dw2;
|
|
|
|
g_piDevice->GetFVF(&dw2);
|
|
|
|
g_piDevice->SetFVF(D3DFVF_XYZ | D3DFVF_TEX1 | D3DFVF_TEXCOORDSIZE3(0));
|
|
|
|
|
|
|
|
g_piDevice->DrawIndexedPrimitiveUP(
|
|
|
|
D3DPT_TRIANGLELIST,0,8,12,g_cubeIndices,D3DFMT_INDEX16,
|
|
|
|
g_cubeVertices_indexed,sizeof(SkyBoxVertex));
|
|
|
|
|
|
|
|
g_piDevice->SetFVF(dw2);
|
|
|
|
|
2009-02-11 20:56:05 +00:00
|
|
|
piSkyBoxEffect->EndPass();
|
|
|
|
piSkyBoxEffect->End();
|
2008-05-05 12:36:31 +00:00
|
|
|
}
|
2008-05-13 23:26:52 +00:00
|
|
|
}
|
2008-05-05 12:36:31 +00:00
|
|
|
//-------------------------------------------------------------------------------
|
|
|
|
void CBackgroundPainter::ReleaseNativeResource()
|
2008-05-13 23:26:52 +00:00
|
|
|
{
|
2009-02-11 20:56:05 +00:00
|
|
|
if ( piSkyBoxEffect)
|
2008-05-13 23:26:52 +00:00
|
|
|
{
|
2009-02-11 20:56:05 +00:00
|
|
|
piSkyBoxEffect->Release();
|
|
|
|
piSkyBoxEffect = NULL;
|
2008-05-13 23:26:52 +00:00
|
|
|
}
|
2009-02-11 20:56:05 +00:00
|
|
|
if (pcTexture)
|
2008-05-13 23:26:52 +00:00
|
|
|
{
|
2009-02-11 20:56:05 +00:00
|
|
|
pcTexture->Release();
|
|
|
|
pcTexture = NULL;
|
2008-05-05 12:36:31 +00:00
|
|
|
}
|
2008-05-13 23:26:52 +00:00
|
|
|
}
|
2008-05-05 12:36:31 +00:00
|
|
|
//-------------------------------------------------------------------------------
|
|
|
|
void CBackgroundPainter::RecreateNativeResource()
|
2008-05-13 23:26:52 +00:00
|
|
|
{
|
2009-02-11 20:56:05 +00:00
|
|
|
if (SIMPLE_COLOR == eMode)return;
|
|
|
|
if (TEXTURE_CUBE == eMode)
|
2008-05-13 23:26:52 +00:00
|
|
|
{
|
2008-05-05 12:36:31 +00:00
|
|
|
|
|
|
|
// many skyboxes are 16bit FP format which isn't supported
|
|
|
|
// with bilinear filtering on older cards
|
|
|
|
D3DFORMAT eFmt = D3DFMT_UNKNOWN;
|
|
|
|
if(FAILED(g_piD3D->CheckDeviceFormat(0,D3DDEVTYPE_HAL,
|
|
|
|
D3DFMT_X8R8G8B8,D3DUSAGE_QUERY_FILTER,D3DRTYPE_CUBETEXTURE,D3DFMT_A16B16G16R16F)))
|
|
|
|
{
|
|
|
|
eFmt = D3DFMT_A8R8G8B8;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (FAILED(D3DXCreateCubeTextureFromFileEx(
|
|
|
|
g_piDevice,
|
2009-02-11 20:56:05 +00:00
|
|
|
szPath.c_str(),
|
2008-05-05 12:36:31 +00:00
|
|
|
D3DX_DEFAULT,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
eFmt,
|
|
|
|
D3DPOOL_MANAGED,
|
|
|
|
D3DX_DEFAULT,
|
|
|
|
D3DX_DEFAULT,
|
|
|
|
0,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
2009-02-11 20:56:05 +00:00
|
|
|
(IDirect3DCubeTexture9**)&pcTexture)))
|
2008-05-13 23:26:52 +00:00
|
|
|
{
|
2009-02-11 20:56:05 +00:00
|
|
|
const char* szEnd = strrchr(szPath.c_str(),'\\');
|
|
|
|
if (!szEnd)szEnd = strrchr(szPath.c_str(),'/');
|
|
|
|
if (!szEnd)szEnd = szPath.c_str()-1;
|
2008-05-05 12:36:31 +00:00
|
|
|
|
|
|
|
char szTemp[1024];
|
|
|
|
sprintf(szTemp,"[ERROR] Unable to load background cubemap %s",szEnd+1);
|
2008-05-13 23:26:52 +00:00
|
|
|
|
2008-05-05 12:36:31 +00:00
|
|
|
CLogDisplay::Instance().AddEntry(szTemp,
|
|
|
|
D3DCOLOR_ARGB(0xFF,0xFF,0,0));
|
|
|
|
|
2009-02-11 20:56:05 +00:00
|
|
|
eMode = SIMPLE_COLOR;
|
2008-05-05 12:36:31 +00:00
|
|
|
return;
|
2008-05-13 23:26:52 +00:00
|
|
|
}
|
2008-05-05 12:36:31 +00:00
|
|
|
else CLogDisplay::Instance().AddEntry("[OK] The skybox has been imported successfully",
|
|
|
|
D3DCOLOR_ARGB(0xFF,0,0xFF,0));
|
2008-05-13 23:26:52 +00:00
|
|
|
}
|
2008-05-05 12:36:31 +00:00
|
|
|
else
|
2008-05-13 23:26:52 +00:00
|
|
|
{
|
2008-05-05 12:36:31 +00:00
|
|
|
if (FAILED(D3DXCreateTextureFromFileEx(
|
|
|
|
g_piDevice,
|
2009-02-11 20:56:05 +00:00
|
|
|
szPath.c_str(),
|
2008-05-05 12:36:31 +00:00
|
|
|
D3DX_DEFAULT,
|
|
|
|
D3DX_DEFAULT,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
D3DFMT_A8R8G8B8,
|
|
|
|
D3DPOOL_MANAGED,
|
|
|
|
D3DX_DEFAULT,
|
|
|
|
D3DX_DEFAULT,
|
|
|
|
0,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
2009-02-11 20:56:05 +00:00
|
|
|
(IDirect3DTexture9**)&pcTexture)))
|
2008-05-13 23:26:52 +00:00
|
|
|
{
|
2009-02-11 20:56:05 +00:00
|
|
|
const char* szEnd = strrchr(szPath.c_str(),'\\');
|
|
|
|
if (!szEnd)szEnd = strrchr(szPath.c_str(),'/');
|
|
|
|
if (!szEnd)szEnd = szPath.c_str()-1;
|
2008-05-05 12:36:31 +00:00
|
|
|
|
|
|
|
char szTemp[1024];
|
|
|
|
sprintf(szTemp,"[ERROR] Unable to load background texture %s",szEnd+1);
|
2008-05-13 23:26:52 +00:00
|
|
|
|
2008-05-05 12:36:31 +00:00
|
|
|
CLogDisplay::Instance().AddEntry(szTemp,
|
|
|
|
D3DCOLOR_ARGB(0xFF,0xFF,0,0));
|
|
|
|
|
2009-02-11 20:56:05 +00:00
|
|
|
eMode = SIMPLE_COLOR;
|
2008-05-05 12:36:31 +00:00
|
|
|
return;
|
2008-05-13 23:26:52 +00:00
|
|
|
}
|
2008-05-05 12:36:31 +00:00
|
|
|
else CLogDisplay::Instance().AddEntry("[OK] The background texture has been imported successfully",
|
|
|
|
D3DCOLOR_ARGB(0xFF,0,0xFF,0));
|
2008-05-13 23:26:52 +00:00
|
|
|
}
|
2008-05-05 12:36:31 +00:00
|
|
|
if (!piSkyBoxEffect)
|
2008-05-13 23:26:52 +00:00
|
|
|
{
|
2009-02-11 22:24:17 +00:00
|
|
|
ID3DXBuffer* piBuffer = NULL;
|
2008-05-05 12:36:31 +00:00
|
|
|
if(FAILED( D3DXCreateEffect(
|
|
|
|
g_piDevice,
|
|
|
|
g_szSkyboxShader.c_str(),
|
|
|
|
(UINT)g_szSkyboxShader.length(),
|
|
|
|
NULL,
|
|
|
|
NULL,
|
General
- Added format auto-detection to most loaders
- Simplified BaseImporter::CanRead() with some utility methods
- improved fast_atof -> no overruns anymore. Fuck you, irrlicht.
- added assimp_cmd tool to allow command line model processing. Mainly adebugging tool for internal purposes, but others might find it useful, too.
- vc8/vc9: revision number is now written to DLL version header
- mkutil: some batch scripts to simplify tagging & building of release versions
- some API cleanup
- fixing some doxygen markup (+now explicit use of @file <filename>)
- Icon for assimp_view and assimp_cmd
3DS
- Normal vectors are not anymore inverted in some cases
- Improved pivot handling
- Improved handling of x-flipped meshes
Collada
- fixed a minor bug (visual_scene element)
LWS
- WIP implementation. No animations yet, some bugs and crashes.
- Animation system remains disabled, WIP code
- many test files for LWS, but most of them test the anim support, which is, read above, currently disabled.
STL
- fixing a log warning which appears for every model
- added binary&ascii test spider, exported from truespace
MD3
- Cleaning up output tags for automatically joined player models.
IRR
- Fixing coordinate system issues.
- Instance handling improved.
- Some of the reported crashes not yet fixed.
PretransformVertices
- Numerous performance improvements.
- Added config option to preserve the hierarchy during the step.
RemoveRedundantMaterials
- Added config option to specify a list of materials which are kept in every case.
UNREAL
- Added support for the old unreal data format (*.a,*.d,*.uc)
- tested only with exports from Milkshape
- more Unreal stuff to come soon
git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@356 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
2009-03-05 22:32:13 +00:00
|
|
|
AI_SHADER_COMPILE_FLAGS,
|
2008-05-05 12:36:31 +00:00
|
|
|
NULL,
|
2009-02-11 22:24:17 +00:00
|
|
|
&piSkyBoxEffect,&piBuffer)))
|
2008-05-13 23:26:52 +00:00
|
|
|
{
|
2009-02-11 22:24:17 +00:00
|
|
|
// failed to compile the shader
|
|
|
|
if( piBuffer) {
|
|
|
|
MessageBox(g_hDlg,(LPCSTR)piBuffer->GetBufferPointer(),"HLSL",MB_OK);
|
|
|
|
piBuffer->Release();
|
|
|
|
}
|
|
|
|
|
2008-05-05 12:36:31 +00:00
|
|
|
CLogDisplay::Instance().AddEntry("[ERROR] Unable to compile skybox shader",
|
|
|
|
D3DCOLOR_ARGB(0xFF,0xFF,0,0));
|
2009-02-11 22:24:17 +00:00
|
|
|
eMode = SIMPLE_COLOR;
|
2008-05-05 12:36:31 +00:00
|
|
|
return ;
|
|
|
|
}
|
2008-05-13 23:26:52 +00:00
|
|
|
}
|
2008-05-05 12:36:31 +00:00
|
|
|
// commit the correct textures to the shader
|
2009-02-11 20:56:05 +00:00
|
|
|
if (TEXTURE_CUBE == eMode)
|
2008-05-13 23:26:52 +00:00
|
|
|
{
|
2009-02-11 20:56:05 +00:00
|
|
|
piSkyBoxEffect->SetTexture("lw_tex_envmap",pcTexture);
|
|
|
|
piSkyBoxEffect->SetTechnique("RenderSkyBox");
|
2008-05-13 23:26:52 +00:00
|
|
|
}
|
2009-02-11 20:56:05 +00:00
|
|
|
else if (TEXTURE_2D == eMode)
|
2008-05-13 23:26:52 +00:00
|
|
|
{
|
2009-02-11 20:56:05 +00:00
|
|
|
piSkyBoxEffect->SetTexture("TEXTURE_2D",pcTexture);
|
|
|
|
piSkyBoxEffect->SetTechnique("RenderImage2D");
|
2008-05-05 12:36:31 +00:00
|
|
|
}
|
2008-05-13 23:26:52 +00:00
|
|
|
}
|
2008-05-05 12:36:31 +00:00
|
|
|
};
|