Example #1
0
    void Renderer::Draw ( const SceneNode* node )
    {
        // Set the lights for this node.
        for ( int i = 0; i < node->LightCount (); i++ )
        {
            ApplyLighting ( node->GetLight ( i ) );
        }

        // Execute pre-drawing effects setup.
        for ( int i = 0; i < node->EffectCount (); i++ )
        {
            SetupEffect ( node->GetEffect ( i ) );
        }
        
        // Draw any mesh associated with this node.
        if ( node->IsDerived ( Mesh::GetRTTI () ) )
        {
            Mesh* mesh = (Mesh*) node;
            Draw ( mesh );
        }
        
        // Draw this node's children (if the child is a SceneNode).
        for ( int i = 0; i < node->ChildCount (); i++ )
        {
            if ( node->GetChild ( i )->IsDerived ( SceneNode::GetRTTI () ) )
            {
                SceneNode* child = (SceneNode*) node->GetChild ( i );
                Draw ( child );
            }
        }
    }
Example #2
0
//
// PERFORM LIGHTING ON AN ARRAY OF VERTICES
//
void DxLight::Manager::Light(VertexL *dstV, Plane *srcP, Vector *srcV, Vector *srcN, Color *srcC, UVPair *srcUV, U32 &countV, U16 *dstI, U16 *srcI, U32 &countI)
{
	ASSERT(srcV);
	ASSERT(dstV);
	ASSERT(countV < MAXVERTS);

	// set up the material values
	SetMaterialValues();
	
	ASSERT(countV > 0 && (material_diffuse.r + material_diffuse.g + material_diffuse.b + material_diffuse.a) > 0.0f);
	
	// if the polygons are two-sided...
	if (BucketMan::GetPrimitiveFlags() & RS_2SIDED)
	{
		// combine the components without back-face culling
		Combine(dstV, srcP, srcV, srcN, srcC, srcUV, countV, dstI, srcI, countI);
	}
	else
	{
		// combine the components with back-face culling
		BackCull(dstV, srcP, srcV, srcN, srcC, srcUV, countV, dstI, srcI, countI);
	}
	
	// if there are any vertices left...
	if (countV)
	{
		// calculate lighting for the vertices
		CalculateLighting(dstV, countV);

		// apply lighting to the vertices
		ApplyLighting(dstV, countV);
	}
}