Gyazo:
Code:
# Shadow System for isHeight Objects
## Overview
isHeight objects (bridges, platforms) receive shadows but do not cast shadows.
## Changes
### 1. ThingInstance.h
**File:** `/src/EterGrnLib/ThingInstance.h`
Add after `bool HaveBlendThing();`:
```cpp
bool HaveBlendThing();
bool IsHeightObject();
```
---
### 2. ThingInstance.cpp
**File:** `/src/EterGrnLib/ThingInstance.cpp`
Add after HaveBlendThing() method:
```cpp
bool CGraphicThingInstance::HaveBlendThing()
{
for (int i = 0; i < m_LODControllerVector.size(); i++)
{
if (m_LODControllerVector->HaveBlendThing())
return true;
}
return false;
}
bool CGraphicThingInstance::IsHeightObject()
{
return (m_pHeightAttributeInstance && m_pHeightAttributeInstance->IsHeightData());
}
```
---
### 3. Area.cpp
**File:** src/GameLib/Area.cpp`
In Refresh() method:
```cpp
if (pObjectInstance->isShadowFlag)
{
bool isHeightOnly = (pObjectInstance->pAttributeInstance &&
pObjectInstance->pAttributeInstance->IsHeightData());
if (!isHeightOnly)
{
m_ShadowThingCloneInstaceVector.push_back(pObjectInstance->pThingInstance);
}
}
```
---
### 4. MapOutdoorRender.cpp
**File:** GameLib/MapOutdoorRender.cpp`
Struct definition:
```cpp
struct CMapOutdoor_FOpaqueThingInstanceRenderWithShadow
{
LPDIRECT3DTEXTURE9 m_lpShadowTexture;
CMapOutdoor_FOpaqueThingInstanceRenderWithShadow(LPDIRECT3DTEXTURE9 lpShadowTex)
: m_lpShadowTexture(lpShadowTex) {}
inline void operator () (CGraphicThingInstance * pkThingInst)
{
if (pkThingInst->IsHeightObject())
{
STATEMANAGER.SetTexture(1, m_lpShadowTexture);
STATEMANAGER.SetTextureStageState(1, D3DTSS_COLORARG1, D3DTA_TEXTURE);
STATEMANAGER.SetTextureStageState(1, D3DTSS_COLORARG2, D3DTA_CURRENT);
STATEMANAGER.SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_MODULATE);
pkThingInst->RenderWithShadowTexture();
}
else
{
STATEMANAGER.SetTexture(1, NULL);
STATEMANAGER.SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_DISABLE);
pkThingInst->Render();
}
}
};
```
Function call:
```cpp
std::for_each(s_kVct_pkOpaqueThingInstSort.begin(),
s_kVct_pkOpaqueThingInstSort.end(),
CMapOutdoor_FOpaqueThingInstanceRenderWithShadow(m_lpCharacterShadowMapTexture));
```
---
### 5. AttributeInstance (if IsHeightData() is missing)
**File:** `client source 26.11/src/GameLib/AttributeInstance.cpp`
```cpp
bool CAttributeInstance::IsHeightData() const
{
if (!m_pAttributeData)
return false;
return m_pAttributeData->IsHeightData();
}
```
---
## Behavior
**Shadow Receiving:**
- isHeight objects: Receive shadows
- Normal buildings: Do not receive shadows
**Shadow Casting:**
- isHeight objects: Do not cast shadows
- Normal buildings: Cast shadows
---
## Overview
isHeight objects (bridges, platforms) receive shadows but do not cast shadows.
## Changes
### 1. ThingInstance.h
**File:** `/src/EterGrnLib/ThingInstance.h`
Add after `bool HaveBlendThing();`:
```cpp
bool HaveBlendThing();
bool IsHeightObject();
```
---
### 2. ThingInstance.cpp
**File:** `/src/EterGrnLib/ThingInstance.cpp`
Add after HaveBlendThing() method:
```cpp
bool CGraphicThingInstance::HaveBlendThing()
{
for (int i = 0; i < m_LODControllerVector.size(); i++)
{
if (m_LODControllerVector->HaveBlendThing())
return true;
}
return false;
}
bool CGraphicThingInstance::IsHeightObject()
{
return (m_pHeightAttributeInstance && m_pHeightAttributeInstance->IsHeightData());
}
```
---
### 3. Area.cpp
**File:** src/GameLib/Area.cpp`
In Refresh() method:
```cpp
if (pObjectInstance->isShadowFlag)
{
bool isHeightOnly = (pObjectInstance->pAttributeInstance &&
pObjectInstance->pAttributeInstance->IsHeightData());
if (!isHeightOnly)
{
m_ShadowThingCloneInstaceVector.push_back(pObjectInstance->pThingInstance);
}
}
```
---
### 4. MapOutdoorRender.cpp
**File:** GameLib/MapOutdoorRender.cpp`
Struct definition:
```cpp
struct CMapOutdoor_FOpaqueThingInstanceRenderWithShadow
{
LPDIRECT3DTEXTURE9 m_lpShadowTexture;
CMapOutdoor_FOpaqueThingInstanceRenderWithShadow(LPDIRECT3DTEXTURE9 lpShadowTex)
: m_lpShadowTexture(lpShadowTex) {}
inline void operator () (CGraphicThingInstance * pkThingInst)
{
if (pkThingInst->IsHeightObject())
{
STATEMANAGER.SetTexture(1, m_lpShadowTexture);
STATEMANAGER.SetTextureStageState(1, D3DTSS_COLORARG1, D3DTA_TEXTURE);
STATEMANAGER.SetTextureStageState(1, D3DTSS_COLORARG2, D3DTA_CURRENT);
STATEMANAGER.SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_MODULATE);
pkThingInst->RenderWithShadowTexture();
}
else
{
STATEMANAGER.SetTexture(1, NULL);
STATEMANAGER.SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_DISABLE);
pkThingInst->Render();
}
}
};
```
Function call:
```cpp
std::for_each(s_kVct_pkOpaqueThingInstSort.begin(),
s_kVct_pkOpaqueThingInstSort.end(),
CMapOutdoor_FOpaqueThingInstanceRenderWithShadow(m_lpCharacterShadowMapTexture));
```
---
### 5. AttributeInstance (if IsHeightData() is missing)
**File:** `client source 26.11/src/GameLib/AttributeInstance.cpp`
```cpp
bool CAttributeInstance::IsHeightData() const
{
if (!m_pAttributeData)
return false;
return m_pAttributeData->IsHeightData();
}
```
---
## Behavior
**Shadow Receiving:**
- isHeight objects: Receive shadows
- Normal buildings: Do not receive shadows
**Shadow Casting:**
- isHeight objects: Do not cast shadows
- Normal buildings: Cast shadows
---
