rendering debug data of CShadowVolumeSceneNode

You discovered a bug in the engine, and you are sure that it is not a problem of your code? Just post it in here. Please read the bug posting guidelines first.
Post Reply
BuildItNow
Posts: 3
Joined: Sat Feb 25, 2012 12:18 pm

rendering debug data of CShadowVolumeSceneNode

Post by BuildItNow »

The problem is commented in the origin code. The version i have is 1.7.2.
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);
        }
}
 
What i have modified.

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);
}
 
Further more, I have make a post about ParticlesAreGlobal in CParticleSystemSceneNode in advanced help.

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.
Last edited by BuildItNow on Thu Mar 08, 2012 2:40 pm, edited 2 times in total.
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Re: rendering debug data of CShadowVolumeSceneNode

Post by hybrid »

Could you please add code tags so I can see where the actual code is and where your post comment is?!
BuildItNow
Posts: 3
Joined: Sat Feb 25, 2012 12:18 pm

Re: rendering debug data of CShadowVolumeSceneNode

Post by BuildItNow »

Sorry for the unclear post, the content has been modified.
Post Reply