Origin Code :
Code: Select all
//! renders the node.
void CShadowVolumeSceneNode::render()
{
// Skip some code
...
if ( DebugDataVisible & scene::EDS_MESH_WIRE_OVERLAY )
{
// Skip some code
...
// IdentityMatrix ?
driver->setTransform(video::ETS_WORLD, core::IdentityMatrix);
// 1: Never draw the lines because of indices
// 2: drawVertexPrimitiveList will invoke pID3DDevice->SetRenderState(D3DRS_STENCILENABLE, FALSE) in setRenderStates3DMode(),
// but there is no SetRenderState(D3DRS_STENCILENABLE, true) between ShadowNodeList[i]->render() and drawStencilShadow(true,ShadowColor, ShadowColor in drawAll of SceneManager.
for (u32 i=0; i<ShadowVolumesUsed; ++i)
driver->drawVertexPrimitiveList(ShadowVolumes[i].vertices,
ShadowVolumes[i].count,0,0,video::EVT_STANDARD,scene::EPT_LINES);
}
}
Code: Select all
//! renders the node.
void CShadowVolumeSceneNode::render()
{
video::IVideoDriver* driver = SceneManager->getVideoDriver();
if (!ShadowVolumesUsed || !driver)
return;
// Draw debug data first
if ( DebugDataVisible & scene::EDS_MESH_WIRE_OVERLAY )
{
video::SMaterial mat;
mat.Lighting = false;
mat.ZWriteEnable = false;
mat.MaterialType = video::EMT_TRANSPARENT_ADD_COLOR;
driver->setMaterial(mat);
driver->setTransform(video::ETS_WORLD, Parent->getAbsoluteTransformation());//core::IdentityMatrix);
u32 primitiveCount = 0;
core::array<video::S3DVertex> vb;
core::array<u32> ib;
for(u32 i=0; i<ShadowVolumesUsed; ++i)
{
primitiveCount = ShadowVolumes[i].count/3;
if(primitiveCount == 0)
{
continue ;
}
vb.reallocate(ShadowVolumes[i].count);
ib.reallocate(ShadowVolumes[i].count);
vb.set_used(0);
ib.set_used(0);
const core::vector3df* pVb = ShadowVolumes[i].vertices;
core::triangle3df tri;
for(u32 j=0; j<primitiveCount; ++j)
{
tri.set(pVb[0], pVb[1], pVb[2]);
vb.push_back(video::S3DVertex(pVb[0], tri.getNormal(), 0xff005500, core::vector2df(0.0f, 0.0f)));
vb.push_back(video::S3DVertex(pVb[1], tri.getNormal(), 0xff005500, core::vector2df(0.0f, 0.0f)));
vb.push_back(video::S3DVertex(pVb[2], tri.getNormal(), 0xff005500, core::vector2df(0.0f, 0.0f)));
ib.push_back(3*j);
ib.push_back(3*j+1);
ib.push_back(3*j+2);
pVb += 3;
}
driver->drawVertexPrimitiveList
(
vb.const_pointer(),
vb.size(),
ib.const_pointer(),
ib.size()/3,
video::EVT_STANDARD,
scene::EPT_TRIANGLES,
video::EIT_32BIT
);
}
}
driver->setTransform(video::ETS_WORLD, Parent->getAbsoluteTransformation());
for (u32 i=0; i<ShadowVolumesUsed; ++i)
driver->drawStencilShadowVolume(ShadowVolumes[i].vertices,
ShadowVolumes[i].count, UseZFailMethod);
}
Code: Select all
// Why there is no Particles[i].vector ?
AbsoluteTransformation.rotateVect(Particles[i].startVector);
rotateVect() will make a difference between Particles.vector and Particles.startVector, But they should have the same meaning for affector, I'm not sure if
it's a problem.