Commit b03d2f4b authored by Byurrrer's avatar Byurrrer

полная переделка либы статической геометрии, поправил рендер полупрозрачности, правка мелких багов

parent 8306303d
......@@ -25,7 +25,8 @@ half4 main(VSO_PP IN):COLOR0
half fLayer = NormalDecodeLayer(vNormal.xyz);
//цвет приводим к sRGB
half4 vColor = pow(tex2D(g_sColor,IN.vTexUV), 2.2);
half4 vColor = tex2D(g_sColor,IN.vTexUV);
vColor.rgb = pow(vColor.rgb, 2.2);
half4 vParameters = tex2D(g_sParameters,IN.vTexUV);
half4 vAmbient = tex2D(g_sAmbient,IN.vTexUV);
......@@ -54,5 +55,5 @@ half4 main(VSO_PP IN):COLOR0
vColor.rgb /= (fAdaptedLum + vColor.rgb);
//приводим цвет к линейному пространству
return pow(vColor, 1.0/2.2);
return half4(pow(vColor.rgb, 1.0/2.2), vColor.a);
}
\ No newline at end of file
......@@ -71,10 +71,10 @@ PSO_UnionAlpha main(VSO_PP IN):COLOR0
aIdLayer[2] = int(NormalDecodeLayer(aNormal[2].xyz) * LAYERS_COUNT_MAX);
aIdLayer[3] = int(NormalDecodeLayer(aNormal[3].xyz) * LAYERS_COUNT_MAX);
aIsTransparency[0] = aNormal[0].w >= MTLTYPE_LAYER_TRANSPARENT_UNLIT ? 1 : 0;
aIsTransparency[1] = aNormal[1].w >= MTLTYPE_LAYER_TRANSPARENT_UNLIT ? 1 : 0;
aIsTransparency[2] = aNormal[2].w >= MTLTYPE_LAYER_TRANSPARENT_UNLIT ? 1 : 0;
aIsTransparency[3] = aNormal[3].w >= MTLTYPE_LAYER_TRANSPARENT_UNLIT ? 1 : 0;
aIsTransparency[0] = (aNormal[0].w >= MTLTYPE_LAYER_TRANSPARENT_UNLIT) ? 1 : 0;
aIsTransparency[1] = (aNormal[1].w >= MTLTYPE_LAYER_TRANSPARENT_UNLIT) ? 1 : 0;
aIsTransparency[2] = (aNormal[2].w >= MTLTYPE_LAYER_TRANSPARENT_UNLIT) ? 1 : 0;
aIsTransparency[3] = (aNormal[3].w >= MTLTYPE_LAYER_TRANSPARENT_UNLIT) ? 1 : 0;
//в случае если у нас нет ппрозрачных слоев то возвращаем текущий цвет
[branch] if((aIsTransparency[0] == 0 && aIsTransparency[1] == 0 && aIsTransparency[2] == 0 && aIsTransparency[3] == 0))
......@@ -124,7 +124,7 @@ PSO_UnionAlpha main(VSO_PP IN):COLOR0
{
fAlpha2 = aColor[aSort2[2]].a;
vCountColor = aColor[aSort2[2]] * fAlpha2 + vCountColor * (1.f - fAlpha2);
vCountColor.a = max(fAlpha2,fAlpha);
vCountColor.a = max(fAlpha2,fAlpha) * 1.1;
fAlpha = vCountColor.a;
g_aExistsIDs[1] = aIdLayer[aSort2[2]];
}
......@@ -133,7 +133,7 @@ PSO_UnionAlpha main(VSO_PP IN):COLOR0
{
fAlpha2 = aColor[aSort2[1]].a;
vCountColor = aColor[aSort2[1]] * fAlpha2 + vCountColor.rgba * (1.f - fAlpha2);
vCountColor.a = max(fAlpha2,fAlpha);
vCountColor.a = max(fAlpha2,fAlpha) * 1.1;
fAlpha = vCountColor.a;
g_aExistsIDs[2] = aIdLayer[aSort2[1]];
}
......@@ -142,7 +142,7 @@ PSO_UnionAlpha main(VSO_PP IN):COLOR0
{
fAlpha2 = aColor[aSort2[0]].a;
vCountColor = aColor[aSort2[0]] * fAlpha2 + vCountColor * (1.f - fAlpha2);
vCountColor.a = max(fAlpha2,fAlpha);
vCountColor.a = max(fAlpha2,fAlpha) * 1.1;
}
OUT.vColor = vCountColor;
......@@ -150,8 +150,8 @@ PSO_UnionAlpha main(VSO_PP IN):COLOR0
OUT.vDepth1 = aDepth[aSort2[0]];
//если есть хотя бы один не прозрачный материал
[branch] if(!aIsTransparency[0] || !aIsTransparency[1] || !aIsTransparency[2] || !aIsTransparency[3])
OUT.vColor.a = 1;
/*[branch] if((!aIsTransparency[0] && aDepth[0] > 0.0) || (!aIsTransparency[1] && aDepth[1] > 0.0) || (!aIsTransparency[2] && aDepth[2] > 0.0) || (!aIsTransparency[3] && aDepth[3] > 0.0))
OUT.vColor.a = 1;*/
//если хотя бы один слой полупрозрачный
[branch] if(aIsTransparency[0] || aIsTransparency[1] || aIsTransparency[2] || aIsTransparency[3])
......
......@@ -12,10 +12,7 @@
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\..\..\source\common\string.cpp" />
<ClCompile Include="..\..\..\source\geom\static_geom.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\..\source\geom\models.cpp" />
<ClCompile Include="..\..\..\source\geom\sxgeom.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</ExcludedFromBuild>
......@@ -24,7 +21,7 @@
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\..\source\common\string.h" />
<ClInclude Include="..\..\..\source\geom\static_geom.h" />
<ClInclude Include="..\..\..\source\geom\models.h" />
<ClInclude Include="..\..\..\source\geom\sxgeom.h" />
</ItemGroup>
<PropertyGroup Label="Globals">
......
......@@ -2,15 +2,15 @@
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<ClCompile Include="..\..\..\source\geom\sxgeom_dll.cpp" />
<ClCompile Include="..\..\..\source\geom\static_geom.cpp">
<Filter>Source</Filter>
</ClCompile>
<ClCompile Include="..\..\..\source\geom\sxgeom.cpp">
<Filter>Source</Filter>
</ClCompile>
<ClCompile Include="..\..\..\source\common\string.cpp">
<Filter>Source</Filter>
</ClCompile>
<ClCompile Include="..\..\..\source\geom\models.cpp">
<Filter>Source</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<Filter Include="Source">
......@@ -21,14 +21,14 @@
</Filter>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\..\source\geom\static_geom.h">
<Filter>Header</Filter>
</ClInclude>
<ClInclude Include="..\..\..\source\geom\sxgeom.h">
<Filter>Header</Filter>
</ClInclude>
<ClInclude Include="..\..\..\source\common\string.h">
<Filter>Header</Filter>
</ClInclude>
<ClInclude Include="..\..\..\source\geom\models.h">
<Filter>Header</Filter>
</ClInclude>
</ItemGroup>
</Project>
\ No newline at end of file
......@@ -72,14 +72,45 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLin
SSCore_SndInstancePlay2d(tmpidsnd);
//SSCore_SndInstancePlay2d(tmpidsnd);*/
SLevel_AmbientSndPlay();
SLevel_WeatherSndPlay();
//SGeom_ModelsAddModel("tt.dse", "tt.dse", 0, false);
/*SGeom_ModelsAddModel("stalker_atp.dse", "stalker_atp.dse", "stalker_atp.dse", "stalker_atp.dse", true);
SGeom_ModelsMsetScale(0, &float3(0.1, 0.1, 0.1));
SGeom_ModelsMsetRotation(0, &float3(0, 1, 0));
SGeom_ModelsMsetPosition(0, &float3(10, -11, 10));
ID idModel = SGeom_ModelsCopy(0);
SGeom_ModelsMsetScale(idModel, &float3(0.1, 0.1, 0.1));
SGeom_ModelsMsetRotation(idModel, &float3(0, 1, 0));
SGeom_ModelsMsetPosition(idModel, &float3(50, 11, 50));
//SGeom_ModelsReComBound(0);
ID idGlobal = SLight_CreatePoint(
&float3(60, 60, 0),
0,
&float3(1, 1, 1),
true,
true);
//SGeom_ModelsDelModel(0);
SXPhysics_LoadGeom();
//SXGame_OnLevelLoad("stalker_atp");
Core_0ConsoleExecCmd("ent_load_level \"%s\" \"%s\"", "D:\\project\\engine\\build\\gamesource\\levels\\stalker_atp\\stalker_atp.ent", "stalker_atp");
SLevel_Save("new_test");
SLight_SetEnable(idGlobal, true);
//SLevel_Load("new_test", false);*/
SGCore_ShaderAllLoad();
SGCore_LoadTexAllLoad();
SetWindowPos(SGCore_GetHWND(), HWND_TOP, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE);
SLevel_AmbientSndPlay();
SLevel_WeatherSndPlay();
int result = SkyXEngine_CycleMain();
SkyXEngine_Kill();
return result;
......
......@@ -63,7 +63,7 @@ void CHUDcontroller::loadMap(const char *szName)
{
// /hud/levels/stalker_atp.png
float3 vMin, vMax;
SGeom_ModelsGetMinMax(&vMin, &vMax);
SGeom_GetMinMax(&vMin, &vMax);
m_vLevelMin = vMin;
m_vLevelMax = vMax;
......
......@@ -586,69 +586,227 @@ void CreateBoundingBoxMesh(const float3* min, const float3* max, ID3DXMesh** bbm
//##########################################################################
float4x4* CSXTransObject::calcWorld()
CTransObject::CTransObject()
{
m_mWorld = SMMatrixScaling(m_vScale) * /*Rotation.GetMatrix()*/SMMatrixRotationX(m_vRotation.x) * SMMatrixRotationY(m_vRotation.y) * SMMatrixRotationZ(m_vRotation.z) * SMMatrixTranslation(m_vPosition);
m_vPosition = float3(0, 0, 0);
m_vRotation = float3(0, 0, 0);
m_vScale = float3(1, 1, 1);
}
const float4x4* CTransObject::calcWorld()
{
m_mWorld = SMMatrixScaling(m_vScale) * SMMatrixRotationX(m_vRotation.x) * SMMatrixRotationY(m_vRotation.y) * SMMatrixRotationZ(m_vRotation.z) * SMMatrixTranslation(m_vPosition);
return &m_mWorld;
}
void CTransObject::setPosition(const float3 *pPos)
{
if (pPos)
m_vPosition = *pPos;
}
void CTransObject::setRotation(const float3 *pRot)
{
if (pRot)
m_vRotation = *pRot;
}
void CTransObject::setScale(const float3 *pScale)
{
if (pScale)
m_vScale = *pScale;
}
const float3* CTransObject::getPosition(float3 *pPos)
{
if (pPos)
*pPos = m_vPosition;
return &m_vPosition;
}
const float3* CTransObject::getRotation(float3 *pRot)
{
if (pRot)
*pRot = m_vRotation;
return &m_vRotation;
}
const float3* CTransObject::getScale(float3 *pScale)
{
if (pScale)
*pScale = m_vScale;
return &m_vScale;
}
//##########################################################################
void CSXBound::calcBound(IDirect3DVertexBuffer9* vertex_buffer, DWORD count_vert, DWORD bytepervert)
void CBound::calcBound(IDirect3DVertexBuffer9 *pVertexBuffer, int iCountVertex, int iBytePerVertex)
{
BYTE *V = 0;
HRESULT hr = 0;
BYTE *pVertex = 0;
calcWorld();
if (vertex_buffer && SUCCEEDED(vertex_buffer->Lock(0, 0, (void **)&V, 0)))
if (pVertexBuffer && SUCCEEDED(pVertexBuffer->Lock(0, 0, (void **)&pVertex, 0)))
{
float3_t tmppos = *(float3_t*)((char*)(V)+bytepervert * 0);
m_vMax = tmppos;
m_vMin = tmppos;
float3_t vPos = *(float3_t*)((char*)(pVertex)+iBytePerVertex * 0);
m_vMaxOrigin = vPos;
m_vMinOrigin = vPos;
for (DWORD i = 0; i<count_vert; i++)
for (int i = 0; i<iCountVertex; ++i)
{
float3_t pos = *(float3_t*)((char*)(V)+bytepervert * i);
vPos = *(float3_t*)((char*)(pVertex)+iBytePerVertex * i);
if (vPos.x > m_vMaxOrigin.x)
m_vMaxOrigin.x = vPos.x;
if (vPos.y > m_vMaxOrigin.y)
m_vMaxOrigin.y = vPos.y;
if (pos.x > m_vMax.x)
m_vMax.x = pos.x;
if (vPos.z > m_vMaxOrigin.z)
m_vMaxOrigin.z = vPos.z;
if (pos.y > m_vMax.y)
m_vMax.y = pos.y;
if (pos.z > m_vMax.z)
m_vMax.z = pos.z;
if (vPos.x < m_vMinOrigin.x)
m_vMinOrigin.x = vPos.x;
if (vPos.y < m_vMinOrigin.y)
m_vMinOrigin.y = vPos.y;
if (pos.x < m_vMin.x)
m_vMin.x = pos.x;
if (vPos.z < m_vMinOrigin.z)
m_vMinOrigin.z = vPos.z;
if (pos.y < m_vMin.y)
m_vMin.y = pos.y;
vPos = SMVector3Transform(vPos, m_mWorld);
if (pos.z < m_vMin.z)
m_vMin.z = pos.z;
if (vPos.x > m_vMaxTransform.x)
m_vMaxTransform.x = vPos.x;
if (vPos.y > m_vMaxTransform.y)
m_vMaxTransform.y = vPos.y;
if (vPos.z > m_vMaxTransform.z)
m_vMaxTransform.z = vPos.z;
if (vPos.x < m_vMinTransform.x)
m_vMinTransform.x = vPos.x;
if (vPos.y < m_vMinTransform.y)
m_vMinTransform.y = vPos.y;
if (vPos.z < m_vMinTransform.z)
m_vMinTransform.z = vPos.z;
}
vertex_buffer->Unlock();
pVertexBuffer->Unlock();
}
m_vCenter = (m_vMin + m_vMax) * 0.5f;
m_fRadius = SMVector3Length(m_vCenter - m_vMax);
m_vCenterOrigin = (m_vMinOrigin + m_vMaxOrigin) * 0.5f;
m_fRadiusOrigin = SMVector3Length(m_vCenterOrigin - m_vMaxOrigin);
m_vCenterTransform = (m_vMinTransform + m_vMaxTransform) * 0.5f;
m_fRadiusTransform = SMVector3Length(m_vCenterTransform - m_vMaxTransform);
}
float4x4* CSXBound::calcWorldAndTrans()
void CBound::calcBoundIndex(IDirect3DVertexBuffer9 *pVertexBuffer, uint32_t **ppArrIndex, uint32_t *pCountIndex, int iCountSubset, int iBytePerVertex)
{
if (!ppArrIndex || pCountIndex || iCountSubset <= 0)
return;
BYTE *pVertex = 0;
calcWorld();
m_vMax = SMVector3Transform(m_vMax, m_mWorld);
m_vMin = SMVector3Transform(m_vMin, m_mWorld);
if (pVertexBuffer && SUCCEEDED(pVertexBuffer->Lock(0, 0, (void **)&pVertex, 0)))
{
float3_t vPos = *(float3_t*)((BYTE*)(pVertex)+iBytePerVertex * ppArrIndex[0][0]);
m_vMaxOrigin = vPos;
m_vMinOrigin = vPos;
for (int i = 0; i<iCountSubset; ++i)
{
for (int k = 0; k<pCountIndex[i]; ++k)
{
vPos = *(float3_t*)((BYTE*)(pVertex)+iBytePerVertex * ppArrIndex[i][k]);
if (vPos.x > m_vMaxOrigin.x)
m_vMaxOrigin.x = vPos.x;
if (vPos.y > m_vMaxOrigin.y)
m_vMaxOrigin.y = vPos.y;
if (vPos.z > m_vMaxOrigin.z)
m_vMaxOrigin.z = vPos.z;
if (vPos.x < m_vMinOrigin.x)
m_vMinOrigin.x = vPos.x;
if (vPos.y < m_vMinOrigin.y)
m_vMinOrigin.y = vPos.y;
if (vPos.z < m_vMinOrigin.z)
m_vMinOrigin.z = vPos.z;
vPos = SMVector3Transform(vPos, m_mWorld);
if (vPos.x > m_vMaxTransform.x)
m_vMaxTransform.x = vPos.x;
if (vPos.y > m_vMaxTransform.y)
m_vMaxTransform.y = vPos.y;
if (vPos.z > m_vMaxTransform.z)
m_vMaxTransform.z = vPos.z;
if (vPos.x < m_vMinTransform.x)
m_vMinTransform.x = vPos.x;
if (vPos.y < m_vMinTransform.y)
m_vMinTransform.y = vPos.y;
if (vPos.z < m_vMinTransform.z)
m_vMinTransform.z = vPos.z;
}
}
pVertexBuffer->Unlock();
}
m_vCenterOrigin = (m_vMinOrigin + m_vMaxOrigin) * 0.5f;
m_fRadiusOrigin = SMVector3Length(m_vCenterOrigin - m_vMaxOrigin);
m_vCenterTransform = (m_vMinTransform + m_vMaxTransform) * 0.5f;
m_fRadiusTransform = SMVector3Length(m_vCenterTransform - m_vMaxTransform);
}
m_vCenter = (m_vMin + m_vMax) * 0.5f;
/*float4x4* CBound::calcWorldAndTrans()
{
calcWorld();
m_vMaxTransform = SMVector3Transform(m_vMaxOrigin, m_mWorld);
m_vMinTransform = SMVector3Transform(m_vMinOrigin, m_mWorld);
m_fRadius = SMVector3Length(m_vCenter - m_vMax);
m_vCenterTransform = (m_vMinOrigin + m_vMaxOrigin) * 0.5f;
m_fRadiusTransform = SMVector3Length(m_vCenterOrigin - m_vMaxOrigin);
return &m_mWorld;
}*/
void CBound::resetTransform()
{
m_vMinTransform = m_vMinOrigin;
m_vMaxTransform = m_vMaxOrigin;
m_vCenterTransform = m_vCenterOrigin;
m_fRadiusTransform = m_fRadiusOrigin;
}
void CSXBound::getPosBBScreen(SXPosBBScreen *res, float3* campos, float3* sizemapdepth, float4x4* mat)
/*void CBound::getPosBBScreen(SXPosBBScreen *res, float3* campos, float3* sizemapdepth, float4x4* mat)
{
float3 max,min;
max = m_vMax;
......@@ -825,54 +983,68 @@ void CSXBound::getPosBBScreen(SXPosBBScreen *res, float3* campos, float3* sizema
res->IsVisible = true;
/*if(campos->x > Min.x && campos->y > Min.y && campos->z > Min.z && campos->x < Max.x && campos->y < Max.y && campos->z < Max.z)
res->IsIn = true;*/
}
//if(campos->x > Min.x && campos->y > Min.y && campos->z > Min.z && campos->x < Max.x && campos->y < Max.y && campos->z < Max.z)
//res->IsIn = true;
}*/
void CSXBound::setMinMax(const float3* min, const float3* max)
void CBound::setMinMax(const float3* min, const float3* max)
{
m_vMin = *min;
m_vMax = *max;
m_vMinOrigin = *min;
m_vMaxOrigin = *max;
/*float3 vec = (Max - Min) * 0.5f;
Radius = sqrt(vec.x * vec.x + vec.y * vec.y + vec.x * vec.z);*/
m_vCenter = (m_vMin + m_vMax) * 0.5f;
m_fRadius = SMVector3Length(m_vCenter - m_vMax);
m_vCenterOrigin = (m_vMinOrigin + m_vMaxOrigin) * 0.5f;
m_fRadiusOrigin = SMVector3Length(m_vCenterOrigin - m_vMaxOrigin);
m_vMinTransform = m_vMinOrigin;
m_vMaxTransform = m_vMaxOrigin;
m_vCenterTransform = m_vCenterOrigin;
m_fRadiusTransform = m_fRadiusOrigin;
};
void CSXBound::getMinMax(float3* min, float3* max) const
void CBound::getMinMax(float3* min, float3* max) const
{
*min = m_vMin; *max = m_vMax;
*min = m_vMinTransform; *max = m_vMaxTransform;
};
void CSXBound::setSphere(const float3* center, float radius)
void CBound::setSphere(const float3* center, float radius)
{
m_vCenter = *center;
m_fRadius = radius;
m_vCenterOrigin = *center;
m_fRadiusOrigin = radius;
m_vMinOrigin = m_vCenterOrigin - float3(m_fRadiusOrigin, m_fRadiusOrigin, m_fRadiusOrigin);
m_vMaxOrigin = m_vCenterOrigin + float3(m_fRadiusOrigin, m_fRadiusOrigin, m_fRadiusOrigin);
m_vMinTransform = m_vMinOrigin;
m_vMaxTransform = m_vMaxOrigin;
m_vMin = m_vCenter - float3(m_fRadius, m_fRadius, m_fRadius);
m_vMax = m_vCenter + float3(m_fRadius, m_fRadius, m_fRadius);
m_vCenterTransform = m_vCenterOrigin;
m_fRadiusTransform = m_fRadiusOrigin;
};
void CSXBound::getSphere(float3* center, float* radius) const
void CBound::getSphere(float3* center, float* radius) const
{
*center = m_vCenter;
*radius = m_fRadius;
*center = m_vCenterTransform;
*radius = m_fRadiusTransform;
};
bool CSXBound::isPointInSphere(const float3* point) const
bool CBound::isPointInSphere(const float3* point) const
{
float distsqr = SMVector3Dot(m_vCenter - *point);
if (distsqr <= m_fRadius*m_fRadius)
float distsqr = SMVector3Dot(m_vCenterTransform - *point);
if (distsqr <= m_fRadiusTransform*m_fRadiusTransform)
return true;
else
return false;
}
bool CSXBound::isPointInBox(const float3* point) const
bool CBound::isPointInBox(const float3* point) const
{
if (point->x >= m_vMin.x && point->y >= m_vMin.y && point->z >= m_vMin.z && point->x <= m_vMax.x && point->y <= m_vMax.y && point->z <= m_vMax.z)
if (point->x >= m_vMinTransform.x && point->y >= m_vMinTransform.y && point->z >= m_vMinTransform.z && point->x <= m_vMaxTransform.x && point->y <= m_vMaxTransform.y && point->z <= m_vMaxTransform.z)
return true;
else
return false;
......
......@@ -37,16 +37,32 @@ void CreateBoundingBoxMesh(const float3* min, const float3* max, ID3DXMesh** bbm
//
// // CalculateWorld
struct CSXTransObject : public virtual ISXTransObject
class CTransObject : public virtual ITransObject
{
CSXTransObject(){};
~CSXTransObject(){};
public:
CTransObject();
~CTransObject(){};
void Release(){ mem_del(this); };
SX_ALIGNED_OP_MEM
float4x4* calcWorld();
const float4x4* calcWorld();
void setPosition(const float3 *pPos);
void setRotation(const float3 *pRot);
void setScale(const float3 *pScale);
const float3* getPosition(float3 *pPos = 0);
const float3* getRotation(float3 *pRot = 0);
const float3* getScale(float3 *pScale = 0);
protected:
float3 m_vPosition; //!<
float3 m_vRotation; //!<
float3 m_vScale; //!<
float4x4 m_mWorld; //!<
};
#define TRANSFORM_COORD_SCREEN2(point,sizemapdepth)\
......@@ -62,22 +78,25 @@ struct CSXTransObject : public virtual ISXTransObject
// CalculateBound
//SetMinMax, GetMinMax CalculateWorldAndTrans
// Bound Object CalculateWorldAndTrans
class CSXBound : public CSXTransObject, public virtual ISXBound
class CBound : public CTransObject, public virtual ISXBound
{
public:
CSXBound(){};
~CSXBound(){};
CBound() :CTransObject(){};
~CBound(){};
void Release(){ mem_del(this); };
SX_ALIGNED_OP_MEM
void calcBound(IDirect3DVertexBuffer9* vertex_buffer, DWORD count_vert, DWORD bytepervert);
void calcBound(IDirect3DVertexBuffer9 *pVertexBuffer, int iCountVertex, int iBytePerVertex);
void calcBoundIndex(IDirect3DVertexBuffer9 *pVertexBuffer, uint32_t **ppArrIndex, uint32_t *pCountIndex, int iCountSubset, int iBytePerVertex);
//
float4x4* calcWorldAndTrans();
//float4x4* calcWorldAndTrans();
void resetTransform();
void getPosBBScreen(SXPosBBScreen *res, float3* campos, float3* sizemapdepth, float4x4* mat);
//void getPosBBScreen(SXPosBBScreen *res, float3* campos, float3* sizemapdepth, float4x4* mat);
void setMinMax(const float3* min, const float3* max);
void getMinMax(float3* min, float3* max) const;
......@@ -89,11 +108,17 @@ public:
bool isPointInBox(const float3* point) const;
protected:
float3 m_vMin;
float3 m_vMax;
float3 m_vMinTransform;
float3 m_vMaxTransform;
float3 m_vCenterTransform;
float m_fRadiusTransform;
float3 m_vMinOrigin;
float3 m_vMaxOrigin;
float3 m_vCenter;
float m_fRadius;
float3 m_vCenterOrigin;
float m_fRadiusOrigin;
};
#endif
\ No newline at end of file
......@@ -41,56 +41,54 @@ struct DataStaticModel : public ISXDataStaticModel
ISXDataStaticModel* getCopy()
{
ISXDataStaticModel* nm = new DataStaticModel();
nm->m_ppTextures = new char*[m_uiSubsetCount];
for (DWORD i = 0; i < m_uiSubsetCount; i++)
{
nm->m_ppTextures[i] = new char[strlen(m_ppTextures[i]) + 1];
sprintf(nm->m_ppTextures[i], "%s", m_ppTextures[i]);
}
nm->m_uiSubsetCount = m_uiSubsetCount;
nm->m_pStartIndex = new UINT[m_uiSubsetCount];
memcpy(nm->m_pStartIndex, m_pStartIndex, sizeof(UINT)*m_uiSubsetCount);
nm->m_pIndexCount = new UINT[m_uiSubsetCount];
memcpy(nm->m_pIndexCount, m_pIndexCount, sizeof(UINT)*m_uiSubsetCount);
nm->m_pStartVertex = new UINT[m_uiSubsetCount];
memcpy(nm->m_pStartVertex, m_pStartVertex, sizeof(UINT)*m_uiSubsetCount);
nm->m_pVertexCount = new UINT[m_uiSubsetCount];
memcpy(nm->m_pVertexCount, m_pVertexCount, sizeof(UINT)*m_uiSubsetCount);
DWORD tmpvert = 0;
DWORD tmpind = 0;
for (DWORD i = 0; i < m_uiSubsetCount; i++)
ISXDataStaticModel *pModelCopy = new DataStaticModel();
// !!!!!!!!!!!!!
pModelCopy->m_uiAllVertexCount = m_uiAllVertexCount;
pModelCopy->m_uiAllIndexCount = m_uiAllIndexCount;
pModelCopy->m_vBBMax = m_vBBMax;
pModelCopy->m_vBBMin = m_vBBMin;
pModelCopy->m_vBSphere = m_vBSphere;
pModelCopy->m_ppTextures = new char*[m_uiSubsetCount];