Beispiel #1
0
void GCL::RenderComponent::PostInit()
{
    //must find the mesh component and hook it up with us
    if (!mParentActor->HasComponent("MeshComponent"))
        return;
    Component *meshComponent = mParentActor->GetComponent("MeshComponent");
    MeshComponent *tempMeshComponent = static_cast<MeshComponent*>(meshComponent);

    if (!tempMeshComponent->HasMesh())
        return;

    Mesh &mesh = tempMeshComponent->GetMesh();
    switch ((size_t)mesh.GetVertexType())
    {
    case ePOSITION:
        mObj = new RenderObject(mesh.GetMaterial(),
                                (const VertexP*)mesh.GetVertexData(0),
                                mesh.GetVertexCount(0));
        break;
    case ePOSITION|eNORMAL:
        mObj = new RenderObject(mesh.GetMaterial(),
                                (const VertexPN*)mesh.GetVertexData(0),
                                mesh.GetVertexCount(0));
        break;
    case ePOSITION|eNORMAL|eTEXTURE_COORD:
        mObj = new RenderObject(mesh.GetMaterial(),
                                (const VertexPNT*)mesh.GetVertexData(0),
                                mesh.GetVertexCount(0));
        break;
    default:
        GCLAssert(false);
    }
}