Commit d5da2742 authored by Byurrrer's avatar Byurrrer

внедрил новый формат вершин для статической геометрии, исправил баг когда при...

внедрил новый формат вершин для статической геометрии, исправил баг когда при сохранении статики происходила запись в массив пп моделей, а моделей там не было
parent c7f221b3
......@@ -17,7 +17,10 @@ See the license in LICENSE
#ifndef __MODEL_FILE_H
#define __MODEL_FILE_H
#define SX_MODEL_VERSION_OLD 6 /*!< Старая версия файла модели (для совместимости) */
/*! Старая версия формата
\todo убрать поддержку старой версии формата моделей
*/
#define SX_MODEL_VERSION_OLD 6
#define SX_MODEL_VERSION 7 /*!< Актуальная версия файла модели */
#define SX_MODEL_MAGICK 30510779525321540 /*!< Магическая константа для определения файла */
......
This diff is collapsed.
......@@ -68,12 +68,12 @@ struct DataStaticModel : public ISXDataStaticModel
pModelCopy->m_pVertexCount = new UINT[m_uiSubsetCount];
memcpy(pModelCopy->m_pVertexCount, m_pVertexCount, sizeof(UINT)*m_uiSubsetCount);
g_pDXDevice->CreateVertexBuffer(sizeof(vertex_static)* m_uiAllVertexCount, NULL, NULL, D3DPOOL_MANAGED, &pModelCopy->m_pVertexBuffer, 0);
g_pDXDevice->CreateVertexBuffer(sizeof(vertex_static_ex)* m_uiAllVertexCount, NULL, NULL, D3DPOOL_MANAGED, &pModelCopy->m_pVertexBuffer, 0);
BYTE *pDestData, *pSrcData;
pModelCopy->m_pVertexBuffer->Lock(0, 0, (void**)&pDestData, 0);
m_pVertexBuffer->Lock(0, 0, (void**)&pSrcData, 0);
memcpy(pDestData, pSrcData, sizeof(vertex_static)* m_uiAllVertexCount);
memcpy(pDestData, pSrcData, sizeof(vertex_static_ex)* m_uiAllVertexCount);
pModelCopy->m_pVertexBuffer->Unlock();
m_pVertexBuffer->Unlock();
......
......@@ -114,6 +114,8 @@ void GCoreInit(HWND hWnd, int iWidth, int iHeight, bool isWindowed, DWORD dwFlag
{ 0, 0, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0 },
{ 0, 12, D3DDECLTYPE_FLOAT2, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD, 0 },
{ 0, 20, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_NORMAL, 0 },
{ 0, 32, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TANGENT, 0 },
{ 0, 44, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_BINORMAL, 0 },
D3DDECL_END()
};
......
......@@ -761,8 +761,8 @@ SX_LIB_API bool SGCore_DSE_IsAnimation(const char *szPath);
//! загрузить статическую модель, data инициализируется внутри
SX_LIB_API void SGCore_StaticModelLoad(const char *szFile, ISXDataStaticModel **ppData);
//! сохранить статическую модель
SX_LIB_API void SGCore_StaticModelSave(const char *szFile, ISXDataStaticModel **pData);
// сохранить статическую модель
//SX_LIB_API void SGCore_StaticModelSave(const char *szFile, ISXDataStaticModel **pData);
//! возвращает декларацию вершин статической модели
SX_LIB_API IDirect3DVertexDeclaration9* SGCore_StaticModelGetDecl();
......@@ -794,21 +794,13 @@ struct ITransObject : public IBaseObject
virtual const float3* getPosition(float3 *pPos=0) = 0;
virtual const float3* getRotation(float3 *pRot = 0) = 0;
virtual const float3* getScale(float3 *pScale = 0) = 0;
/*
protected:
float3 m_vPosition; //!< позиция
float3 m_vRotation; //!< повороты
float3 m_vScale; //!< масштабирование
float4x4 m_mWorld; //!< мировая матрица на основе поворотов масштабирования и позиции
*/
};
//! создать ITransObject
SX_LIB_API ITransObject* SGCore_CrTransObject();
//! структура описывающая ограничивающий квадрат (а точнее параллелепипед) в пространстве экрана
struct SXPosBBScreen
/*struct SXPosBBScreen
{
float x; //!< позиция по оси x в пространстве экрана
float y; //!< позиция по оси y в пространстве экрана
......@@ -817,7 +809,7 @@ struct SXPosBBScreen
float maxdepth; //!< конец объекта глубина 0-1
float mindepth; //!< начало объект глубина 0-1
bool IsVisible; //!< виден ли квадрат наблюдателю
};
};*/
struct CBoundBox
{
......
This diff is collapsed.
......@@ -473,7 +473,7 @@ protected:
//**********************************************************************
//!
ID createTransparencyModel(ID idTex, const char *szTex, const vertex_static *pArrVertex, int iCountVertex, const UINT *pArrIndex, int iCountIndex);
ID createTransparencyModel(ID idTex, const char *szTex, const vertex_static_ex *pArrVertex, int iCountVertex, const UINT *pArrIndex, int iCountIndex);
//!
Array<CTransparencyModel*> m_aTransparency;
......
......@@ -195,7 +195,7 @@ void CGreen::preSegmentation(CModel *pGreen, const float3 *pLevelMin, const floa
//просчет ограничивающего бокса модели
pGreen->m_pSplitsTree->m_pBoundVolumeSys = SGCore_CrBound();
SGCore_FCompBoundBox(pGreen->m_aLods[0]->m_pModel->m_pVertexBuffer, &(pGreen->m_pSplitsTree->m_pBoundVolumeSys), pGreen->m_aLods[0]->m_pModel->m_uiAllVertexCount, sizeof(vertex_static));
SGCore_FCompBoundBox(pGreen->m_aLods[0]->m_pModel->m_pVertexBuffer, &(pGreen->m_pSplitsTree->m_pBoundVolumeSys), pGreen->m_aLods[0]->m_pModel->m_uiAllVertexCount, sizeof(vertex_static_ex));
pGreen->m_pSplitsTree->m_pBoundVolumeSys->getMinMax(&vMin, &vMax);
pGreen->m_vMax = vMax * (1.f + GREEN_GEN_RAND_SCALE);
......@@ -775,7 +775,7 @@ void CGreen::render2(DWORD timeDelta, const float3 *pViewPos, ID idGreen, int iL
CGreen::m_pDXDevice->SetStreamSourceFreq(1, (D3DSTREAMSOURCE_INSTANCEDATA | 1));
CGreen::m_pDXDevice->SetStreamSource(1, m_pTransVertBuf, 0, sizeof(CGreenDataVertex));
CGreen::m_pDXDevice->SetStreamSource(0, m_aGreens[idGreen]->m_aLods[iLod]->m_pModel->m_pVertexBuffer, 0, sizeof(vertex_static));
CGreen::m_pDXDevice->SetStreamSource(0, m_aGreens[idGreen]->m_aLods[iLod]->m_pModel->m_pVertexBuffer, 0, sizeof(vertex_static_ex));
CGreen::m_pDXDevice->SetIndices(m_aGreens[idGreen]->m_aLods[iLod]->m_pModel->m_pIndexBuffer);
CGreen::m_pDXDevice->SetVertexDeclaration(m_pVertexDeclarationGreen);
......@@ -1012,7 +1012,7 @@ ID CGreen::generate(const char *szName,
}
ISXBound *pBound = SGCore_CrBound();
SGCore_FCompBoundBox(pGreen->m_aLods[0]->m_pModel->m_pVertexBuffer, &pBound, pGreen->m_aLods[0]->m_pModel->m_uiAllVertexCount, sizeof(vertex_static));
SGCore_FCompBoundBox(pGreen->m_aLods[0]->m_pModel->m_pVertexBuffer, &pBound, pGreen->m_aLods[0]->m_pModel->m_uiAllVertexCount, sizeof(vertex_static_ex));
float3 vGreenMax, vGreenMin;
pBound->getMinMax(&vGreenMin, &vGreenMax);
......@@ -2111,7 +2111,7 @@ void CGreen::setGreenNav2(CModel *pGreen, const char *szPathName)
//pGreen->m_pPhysMesh->m_pArrVertex = new float3_t[pStatiModel->m_uiAllVertexCount];
pGreen->m_pPhysMesh->m_aVertex.resize(pStatiModel->m_uiAllVertexCount);
vertex_static *pVert;
vertex_static_ex *pVert;
pStatiModel->m_pVertexBuffer->Lock(0, 0, (void **)&pVert, 0);
for (int i = 0; i < pStatiModel->m_uiAllVertexCount; ++i)
{
......@@ -2159,7 +2159,7 @@ void CGreen::initGreenDataLod0(CModel *pGreen)
//pGreen->m_pDataLod0->m_pArrVertex = new float3_t[pGreen->m_aLods[0]->m_pModel->m_uiAllVertexCount];
pGreen->m_pDataLod0->m_aVertex.resize(pGreen->m_aLods[0]->m_pModel->m_uiAllVertexCount);
vertex_static *pVert;
vertex_static_ex *pVert;
pGreen->m_aLods[0]->m_pModel->m_pVertexBuffer->Lock(0, 0, (void **)&pVert, 0);
for (int i = 0; i < pGreen->m_aLods[0]->m_pModel->m_uiAllVertexCount; ++i)
{
......
......@@ -98,7 +98,7 @@ void CSimulationModel::add(const char *szPath)
sprintf(szFullPath, "%s.dds", pStaticModel->m_ppTextures[0]);
m_idMtrl = SGCore_MtlLoad(szFullPath, MTL_TYPE_GEOM);
vertex_static* pData;
vertex_static_ex* pData;
pStaticModel->m_pVertexBuffer->Lock(0, 0, (void**)&pData, 0);
float3_t tmppos = pData[pStaticModel->m_pStartVertex[0]].Pos;
......@@ -223,7 +223,7 @@ void CSimulationModel::render(DWORD timeDelta)
void CSimulationModel::renderStatic(DWORD timeDelta)
{
gdata::pDXDevice->SetStreamSource(0, m_aModels[m_iCurrRenderModel]->m_pModel->m_pVertexBuffer, 0, sizeof(vertex_static));
gdata::pDXDevice->SetStreamSource(0, m_aModels[m_iCurrRenderModel]->m_pModel->m_pVertexBuffer, 0, sizeof(vertex_static_ex));
gdata::pDXDevice->SetIndices(m_aModels[m_iCurrRenderModel]->m_pModel->m_pIndexBuffer);
gdata::pDXDevice->SetVertexDeclaration(m_pVertexDeclarationStatic);
......@@ -239,7 +239,7 @@ void CSimulationModel::renderGreen(DWORD timeDelta)
gdata::pDXDevice->SetStreamSourceFreq(1, (D3DSTREAMSOURCE_INSTANCEDATA | 1));
gdata::pDXDevice->SetStreamSource(1, m_pTransVertBufGreen, 0, sizeof(CGreenDataVertex));
gdata::pDXDevice->SetStreamSource(0, m_aModels[m_iCurrRenderModel]->m_pModel->m_pVertexBuffer, 0, sizeof(vertex_static));
gdata::pDXDevice->SetStreamSource(0, m_aModels[m_iCurrRenderModel]->m_pModel->m_pVertexBuffer, 0, sizeof(vertex_static_ex));
gdata::pDXDevice->SetIndices(m_aModels[m_iCurrRenderModel]->m_pModel->m_pIndexBuffer);
gdata::pDXDevice->SetVertexDeclaration(m_pVertexDeclarationGreen);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment