1 #include "..\include\raMain.h" 7 "raEffects\\MyEngine.fx",
"RenderScene",
10 "raEffects\\ParticleEffect.fx",
"RenderParticle",
11 leafTextureFile), false, 2.0f, 0, 0)
21 m_nHeightSegs = height;
24 m_nMaxBranches = (int) pow((
float)m_nChildren, m_nLevels + 1) - 1;
27 m_nVertices = m_nMaxBranches * m_nSlices * m_nHeightSegs;
28 m_nIndices = m_nMaxBranches * 6 * m_nSlices * (m_nHeightSegs - 1);
30 m_pTransform = pTransform;
35 "raEffects\\ParticleEffect.fx",
"RenderParticle", leafTexturefilename), false, 2.0f, 0, 0)
45 m_nHeightSegs = height;
48 m_nMaxBranches = (int) pow((
float)m_nChildren, m_nLevels + 1) - 1;
51 m_nVertices = m_nMaxBranches * m_nSlices * m_nHeightSegs;
52 m_nIndices = m_nMaxBranches * 6 * m_nSlices * (m_nHeightSegs - 1);
54 m_pTransform = pTransform;
60 RERROR(
"Bei raEntity Create");
63 if(!m_ParticleSystem.
Create())
65 RERROR(
"Beim erstellen des ParticleSystems");
104 raVector3 position(0, m_l0 * (m_nHeightSegs-1), 0);
106 D3DXVec3Transform((D3DXVECTOR4*)&t, (D3DXVECTOR3*)&position, (D3DXMATRIX*)pParentMatrix);
110 m_r1 = m_rRatio * m_r0;
112 for(
int y = 0; y < m_nHeightSegs; y++)
114 for(
int phi = 0; phi < m_nSlices; phi++)
117 float phi0 = 2 *
PI * phi / (m_nSlices-1);
120 (
float) r0 * sin(phi0),
122 (
float) r0 * cos(phi0));
129 D3DXVec3TransformCoord((D3DXVECTOR3*)&vertices[n].position, (D3DXVECTOR3*)&position,
130 (D3DXMATRIX*)pParentMatrix);
132 D3DXVec3TransformNormal((D3DXVECTOR3*)&vertices[n].normal, (D3DXVECTOR3*)&normal,
133 (D3DXMATRIX*)pParentMatrix);
135 vertices[n].
texcoord.
x = phi / (m_nSlices - 1.0f);
136 vertices[n].
texcoord.
y = y / (m_nHeightSegs - 1.0f);
145 D3DXMatrixTranslation((D3DXMATRIX*)&mtrans, 0, m_l0 * (m_nHeightSegs-1), 0);
149 float pitch =
PI / 4.0f;
150 float yaw = 2.0f *
PI / nChildren;
156 D3DXMatrixScaling((D3DXMATRIX*)&m0, m_rRatio, m_lRatio, m_rRatio);
158 for(
int child = 0; child < nChildren; child++)
165 m4 = m3 * (*pParentMatrix);
167 n = AddBranchVerts(vertices, n, &m4, level - 1);
169 m_nBranches += nChildren;
179 for(
int branch= 0; branch < m_nBranches; branch++)
181 int offs = branch * m_nSlices * m_nHeightSegs;
182 for(
int y = 0; y < m_nHeightSegs - 1; y++)
185 for(
int phi = 0; phi < m_nSlices; phi++)
189 (phi + 1) % m_nSlices;
191 m_pIndices[
m_nIndices + 3] = offs + (y + 1) * m_nSlices + phi;
192 m_pIndices[
m_nIndices + 4] = offs + y * m_nSlices +
193 (phi + 1) % m_nSlices;
194 m_pIndices[
m_nIndices + 5] = offs + (y + 1) * m_nSlices +
195 (phi + 1) % m_nSlices; ;
213 const raLight* pLight, LPCSTR techniqueName)
216 pView, pProj, pLight, techniqueName);
217 m_ParticleSystem.
Render(drawOrder,
218 pView, pProj, pLight, techniqueName);
raTree(raSmartPointer< raDirectX > dx, LPCSTR barkTextureFile, LPCSTR leafTextureFile, int height, int nSlices=8, float r0=1.0f, raMatrix *pTransform=NULL)
raMatrix raMatrixIdentity()
virtual void SetupEffectVariables(const raMatrix &pView, const raMatrix &pProj, const raLight *pLight)
VERTEXPOSITIONNORMALTEXTURED * m_pVertices
virtual void SetupVertices()
virtual bool Render(UINT drawOrder, const raMatrix &pView, const raMatrix &pProj, const raLight *pLight, LPCSTR techniqueName="")
void AddParticle(float x=0, float y=0, float z=0, float vx=0, float vy=0, float vz=0)
RAPI raMatrix raMatrixRotationY(const float f)
SDKMESH_SUBSET * m_pSubsets
RAPI raMatrix raMatrixRotationZ(const float f)
virtual void SetupIndices()
virtual bool Render(UINT drawOrder, const raMatrix &pView, const raMatrix &pProj, const raLight *pLight, LPCSTR techniqueName="")
void RAPI ROK(raString x)
RAPI int raGetRandInt(int min, int max)
virtual void SetupEffectVariables(const raMatrix &pView, const raMatrix &pProj, const raLight *pLight)
RAPI float raGetRandFloat(float min, float max)
void RAPI RERROR(raString x)