Skip to content
Snippets Groups Projects
Commit a249675e authored by D-AIRY's avatar D-AIRY
Browse files

Allow create resource model in runtime; some shadow fixes

parent 955951f6
No related branches found
No related tags found
No related merge requests found
......@@ -9,3 +9,5 @@ r_stats 1
hud_draw 0
hud_crosshair 0
hud_rangefinder 0
cl_mousesense 4.5
......@@ -38,7 +38,7 @@ CResourceManager::CResourceManager(IXCore *pCore):
}
bool CResourceManager::getModel(const char *szName, IXResourceModel **ppOut, bool bForceReload)
bool XMETHODCALLTYPE CResourceManager::getModel(const char *szName, IXResourceModel **ppOut, bool bForceReload)
{
const AssotiativeArray<String, IXResourceModel*>::Node *pNode1;
if(!bForceReload && m_mpModels.KeyExists(szName, &pNode1) && (*pNode1->Val))
......@@ -211,7 +211,7 @@ bool CResourceManager::getModel(const char *szName, IXResourceModel **ppOut, boo
assert(!"Should never get here!");
return(false);
}
bool CResourceManager::getModelStatic(const char *szName, IXResourceModelStatic **ppOut, bool bForceReload)
bool XMETHODCALLTYPE CResourceManager::getModelStatic(const char *szName, IXResourceModelStatic **ppOut, bool bForceReload)
{
IXResourceModel *pModel = NULL;
if(getModel(szName, &pModel, bForceReload))
......@@ -226,7 +226,7 @@ bool CResourceManager::getModelStatic(const char *szName, IXResourceModelStatic
*ppOut = NULL;
return(false);
}
bool CResourceManager::getModelAnimated(const char *szName, IXResourceModelAnimated **ppOut, bool bForceReload)
bool XMETHODCALLTYPE CResourceManager::getModelAnimated(const char *szName, IXResourceModelAnimated **ppOut, bool bForceReload)
{
IXResourceModel *pModel = NULL;
if(getModel(szName, &pModel, bForceReload))
......@@ -243,9 +243,12 @@ bool CResourceManager::getModelAnimated(const char *szName, IXResourceModelAnima
}
void CResourceManager::onResourceModelRelease(CResourceModel *pResource)
{
if(pResource->getFileName())
{
m_mpModels[pResource->getFileName()] = NULL;
}
}
UINT XMETHODCALLTYPE CResourceManager::getModelSupportedFormats()
{
......@@ -257,3 +260,20 @@ const XFormatName* XMETHODCALLTYPE CResourceManager::getModelSupportedFormat(UIN
return(&m_aModelExts[uIndex]);
}
IXResourceModelStatic* XMETHODCALLTYPE CResourceManager::newResourceModelStatic()
{
return(new CResourceModelStatic(this));
}
IXResourceModelAnimated* XMETHODCALLTYPE CResourceManager::newResourceModelAnimated()
{
return(new CResourceModelAnimated(this));
}
void XMETHODCALLTYPE CResourceManager::addModel(const char *szName, IXResourceModel *pModel)
{
CResourceModel *pResource = dynamic_cast<CResourceModel*>(pModel);
assert(pResource);
m_mpModels[szName] = pResource;
pResource->setFileName(m_mpModels.TmpNode->Key.c_str());
}
......@@ -21,6 +21,10 @@ public:
UINT XMETHODCALLTYPE getModelSupportedFormats() override;
const XFormatName* XMETHODCALLTYPE getModelSupportedFormat(UINT uIndex) override;
IXResourceModelStatic* XMETHODCALLTYPE newResourceModelStatic() override;
IXResourceModelAnimated* XMETHODCALLTYPE newResourceModelAnimated() override;
void XMETHODCALLTYPE addModel(const char *szName, IXResourceModel *pModel) override;
void onResourceModelRelease(CResourceModel *pResource);
protected:
......
......@@ -68,7 +68,7 @@ void CPropStatic::initPhysics()
UINT uShapesCount = m_pModel->getPhysboxCount();
float3 vSize = m_pModel->getLocalBoundMax() - m_pModel->getLocalBoundMin();
bool useTrimesh = m_useTrimeshPhysics && vSize.x > 1.0f && vSize.z > 1.0f && vSize.y > 1.8f;
bool useTrimesh = m_useTrimeshPhysics && (vSize.x > 1.0f || vSize.z > 1.0f || vSize.y > 1.8f) ;
if(uShapesCount || !useTrimesh)
{
......
......@@ -13,10 +13,10 @@ CLights::CLights()
const int *r_win_width = GET_PCVAR_INT("r_win_width");
const int *r_win_height = GET_PCVAR_INT("r_win_height");
#if 0
m_idShadowMap = SGCore_RTAdd(*r_win_width, *r_win_height, 1, GX_TEXFLAG_RENDERTARGET | GX_TEXFLAG_AUTORESIZE, GXFMT_R16F, "shadowmap");
m_idShadowMap2 = SGCore_RTAdd(*r_win_width, *r_win_height, 1, GX_TEXFLAG_RENDERTARGET | GX_TEXFLAG_AUTORESIZE, GXFMT_R16F, "shadowmap2");
#endif
m_idGlobalLight = -1;
m_isCastGlobalShadow = false;
}
......@@ -809,7 +809,10 @@ float CLights::getDistFor(ID id)
IGXTexture2D* CLights::getShadow2()
{
return(NULL);
#if 0
return SGCore_RTGetTexture((m_iHowShadow == 1 ? m_idShadowMap2 : m_idShadowMap));
#endif
}
#if 0
......@@ -1021,6 +1024,7 @@ void CLights::shadowGen2(ID id)
void CLights::shadowNull()
{
#if 0
IGXSurface *RenderSurf, *BackBuf;
RenderSurf = SGCore_RTGetTexture(m_idShadowMap)->getMipmap(0);
......@@ -1037,6 +1041,7 @@ void CLights::shadowNull()
mem_release_del(BackBuf);
m_iHowShadow = 0;
#endif
}
void CLights::setLightAngle(ID id, float angle, bool is_create)
......@@ -1433,6 +1438,7 @@ void CLights::lightCountUpdateNull(ID id)
void CLights::shadowSoft(bool randomsam, float size, bool isfirst)
{
#if 0
if (isfirst)
m_iHowShadow = 0;
......@@ -1503,6 +1509,7 @@ void CLights::shadowSoft(bool randomsam, float size, bool isfirst)
m_iHowShadow = 0;
else
m_iHowShadow = 1;
#endif
}
void CLights::set4Or3Splits(ID id, bool is4)
......
......@@ -424,6 +424,7 @@ void PSSM::flickering(float4x4 *matLVP,float size_x,float size_y)
void PSSM::genShadow(IGXTexture2D* shadowmap)
{
#if 0
static const int *r_win_width = GET_PCVAR_INT("r_win_width");
static const int *r_win_height = GET_PCVAR_INT("r_win_height");
......@@ -517,6 +518,7 @@ void PSSM::genShadow(IGXTexture2D* shadowmap)
{
light_data::pDXDevice->saveTextureToFile("C:\\1\\pssm.png", shadowmap);
}
#endif
}
void PSSM::genShadowAll(IGXTexture2D* shadowmap)
......@@ -754,6 +756,7 @@ void ShadowMapTech::end()
void ShadowMapTech::genShadow(IGXTexture2D* shadowmap)
{
#if 0
static const int *r_win_width = GET_PCVAR_INT("r_win_width");
static const int *r_win_height = GET_PCVAR_INT("r_win_height");
......@@ -840,6 +843,7 @@ void ShadowMapTech::genShadow(IGXTexture2D* shadowmap)
mem_release_del(RenderSurf);
mem_release_del(BackBuf);
#endif
}
//##########################################################################
......@@ -1112,6 +1116,7 @@ void ShadowMapCubeTech::end()
void ShadowMapCubeTech::genShadow(IGXTexture2D* shadowmap)
{
#if 0
static const int *r_win_width = GET_PCVAR_INT("r_win_width");
static const int *r_win_height = GET_PCVAR_INT("r_win_height");
......@@ -1188,6 +1193,7 @@ void ShadowMapCubeTech::genShadow(IGXTexture2D* shadowmap)
light_data::pDXDevice->setColorTarget(BackBuf);
mem_release_del(RenderSurf);
mem_release_del(BackBuf);
#endif
}
void ShadowMapCubeTech::setIDArr(long id, int split, long idarr)
......
......@@ -7,6 +7,7 @@ CShadowMap::CShadowMap()
CShadowMap::~CShadowMap()
{
mem_release(m_pCameraShaderDataVS);
mem_release(m_pShaderDataInjectVS);
mem_release(m_pShaderDataPS);
mem_release(m_pDepthMap);
......@@ -109,6 +110,7 @@ void CShadowMap::init(IGXContext *pContext, UINT uSize)
m_pShaderDataPS = m_pDevice->createConstantBuffer(sizeof(m_shaderData.ps));
m_pShaderDataInjectVS = m_pDevice->createConstantBuffer(sizeof(SMMATRIX));
m_pCameraShaderDataVS = m_pDevice->createConstantBuffer(sizeof(m_cameraShaderData.vs));
}
void CShadowMap::setLight(IXLight *pLight)
......@@ -131,6 +133,12 @@ void CShadowMap::process(IXRenderPipeline *pRenderPipeline)
Core_RMatrixSet(G_RI_MATRIX_VIEW, &m_mView);
Core_RMatrixSet(G_RI_MATRIX_PROJECTION, &m_mProj);
m_cameraShaderData.vs.mVP = SMMatrixTranspose(m_mView * m_mProj);
m_cameraShaderData.vs.vPosCam = vPos;
m_pCameraShaderDataVS->update(&m_cameraShaderData.vs);
m_pDevice->setVertexShaderConstant(m_pCameraShaderDataVS, SCR_CAMERA);
m_pDevice->setDepthStencilSurface(ms_pDepthStencilSurface);
m_pDevice->setBlendState(NULL);
......
......@@ -83,6 +83,18 @@ private:
} m_shaderData;
IGXConstantBuffer *m_pShaderDataPS = NULL;
IGXConstantBuffer *m_pShaderDataInjectVS = NULL;
struct
{
struct
{
//SMMATRIX mV;
SMMATRIX mVP;
float3 vPosCam;
} vs;
//float4 vNearFarLayers;
} m_cameraShaderData;
IGXConstantBuffer *m_pCameraShaderDataVS = NULL;
};
//##########################################################################
......
......@@ -104,8 +104,9 @@ public:
int x, y;
SSInput_GetMouseDelta(&x, &y);
static const float * sense = GET_PCVAR_FLOAT("cl_mousesense");
float dx = (float)x * *sense * 10.0f;
float dy = (float)y * *sense * 10.0f;
float fCoeff = SMToRadian(0.022) * *sense;
float dx = (float)x * fCoeff;
float dy = (float)y * fCoeff;
ICamera *pCamera = g_xConfig.m_pViewportCamera[XWP_TOP_LEFT];
if(g_is3DRotating)
......@@ -303,9 +304,15 @@ public:
{
m_pOldPipeline->endFrame();
g_pTopRightSwapChain->swapBuffers();
g_pBottomLeftSwapChain->swapBuffers();
g_pBottomRightSwapChain->swapBuffers();
HWND hWnds[] = {g_hTopRightWnd, g_hBottomLeftWnd, g_hBottomRightWnd};
IGXSwapChain *p2DSwapChains[] = {g_pTopRightSwapChain, g_pBottomLeftSwapChain, g_pBottomRightSwapChain};
for(int i = 0; i < 3; ++i)
{
if(IsWindowVisible(hWnds[i]))
{
p2DSwapChains[i]->swapBuffers();
}
}
}
void updateVisibility() override
{
......
......@@ -22,6 +22,10 @@ public:
virtual UINT XMETHODCALLTYPE getModelSupportedFormats() = 0;
virtual const XFormatName* XMETHODCALLTYPE getModelSupportedFormat(UINT uIndex) = 0;
virtual IXResourceModelStatic* XMETHODCALLTYPE newResourceModelStatic() = 0;
virtual IXResourceModelAnimated* XMETHODCALLTYPE newResourceModelAnimated() = 0;
virtual void XMETHODCALLTYPE addModel(const char *szName, IXResourceModel *pModel) = 0;
// void getModelInfo();
// void getTextureInfo();
// void getTexture();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment