Beispiel #1
0
void STKMeshSceneNode::drawSolidPass2(const GLMesh &mesh, ShadedMaterial type)
{
    switch (type)
    {
    case SM_SPHEREMAP:
        drawSphereMap(mesh, ModelViewProjectionMatrix, TransposeInverseModelView);
        break;
    case SM_SPLATTING:
        drawSplatting(mesh, ModelViewProjectionMatrix);
        break;
    case SM_ALPHA_REF_TEXTURE:
        drawObjectRefPass2(mesh, ModelViewProjectionMatrix, mesh.TextureMatrix);
        break;
    case SM_GRASS:
        drawGrassPass2(mesh, ModelViewProjectionMatrix, windDir);
        break;
    case SM_RIMLIT:
        drawObjectRimLimit(mesh, ModelViewProjectionMatrix, TransposeInverseModelView, core::matrix4::EM4CONST_IDENTITY);
        break;
    case SM_UNLIT:
        drawObjectUnlit(mesh, ModelViewProjectionMatrix);
        break;
    case SM_CAUSTICS:
    {
        const float time = irr_driver->getDevice()->getTimer()->getTime() / 1000.0f;
        const float speed = World::getWorld()->getTrack()->getCausticsSpeed();

        float strength = time;
        strength = fabsf(noise2d(strength / 10.0f)) * 0.006f + 0.001f;

        vector3df wind = irr_driver->getWind() * strength * speed;
        caustic_dir.X += wind.X;
        caustic_dir.Y += wind.Z;

        strength = time * 0.56f + sinf(time);
        strength = fabsf(noise2d(0.0, strength / 6.0f)) * 0.0095f + 0.001f;

        wind = irr_driver->getWind() * strength * speed;
        wind.rotateXZBy(cosf(time));
        caustic_dir2.X += wind.X;
        caustic_dir2.Y += wind.Z;
        drawCaustics(mesh, ModelViewProjectionMatrix, caustic_dir, caustic_dir2);
        break;
    }
    case SM_DETAILS:
        drawDetailledObjectPass2(mesh, ModelViewProjectionMatrix);
        break;
    case SM_UNTEXTURED:
        drawUntexturedObject(mesh, ModelViewProjectionMatrix);
        break;
    case SM_DEFAULT:
        drawObjectPass2(mesh, ModelViewProjectionMatrix, mesh.TextureMatrix);
        break;
    default:
        assert(0 && "Wrong shaded material");
        break;
    }
}
void STKMeshSceneNode::drawSolid(const GLMesh &mesh, video::E_MATERIAL_TYPE type)
{
    switch (irr_driver->getPhase())
    {
    case SOLID_NORMAL_AND_DEPTH_PASS:
    {
        windDir = getWind();

        computeMVP(ModelViewProjectionMatrix);
        computeTIMV(TransposeInverseModelView);

        if (type == irr_driver->getShader(ES_NORMAL_MAP))
            drawNormalPass(mesh, ModelViewProjectionMatrix, TransposeInverseModelView);
        else if (type == irr_driver->getShader(ES_OBJECTPASS_REF))
            drawObjectRefPass1(mesh, ModelViewProjectionMatrix, TransposeInverseModelView, TextureMatrix);
        else if (type == irr_driver->getShader(ES_GRASS) || type == irr_driver->getShader(ES_GRASS_REF))
            drawGrassPass1(mesh, ModelViewProjectionMatrix, TransposeInverseModelView, windDir);
        else
            drawObjectPass1(mesh, ModelViewProjectionMatrix, TransposeInverseModelView);
        break;
    }
    case SOLID_LIT_PASS:
    {
        if (type == irr_driver->getShader(ES_SPHERE_MAP))
            drawSphereMap(mesh, ModelViewProjectionMatrix, TransposeInverseModelView);
        else if (type == irr_driver->getShader(ES_SPLATTING))
            drawSplatting(mesh, ModelViewProjectionMatrix);
        else if (type == irr_driver->getShader(ES_OBJECTPASS_REF))
            drawObjectRefPass2(mesh, ModelViewProjectionMatrix, TextureMatrix);
        else if (type == irr_driver->getShader(ES_GRASS) || type == irr_driver->getShader(ES_GRASS_REF))
            drawGrassPass2(mesh, ModelViewProjectionMatrix, windDir);
        else if (type == irr_driver->getShader(ES_OBJECTPASS_RIMLIT))
            drawObjectRimLimit(mesh, ModelViewProjectionMatrix, TransposeInverseModelView, TextureMatrix);
        else if (type == irr_driver->getShader(ES_OBJECT_UNLIT))
            drawObjectUnlit(mesh, ModelViewProjectionMatrix);
        else if (mesh.textures[1] && type != irr_driver->getShader(ES_NORMAL_MAP))
            drawDetailledObjectPass2(mesh, ModelViewProjectionMatrix);
        else if (!mesh.textures[0])
            drawUntexturedObject(mesh, ModelViewProjectionMatrix);
        else
            drawObjectPass2(mesh, ModelViewProjectionMatrix, TextureMatrix);
        break;
    }
    default:
    {
        assert(0 && "wrong pass");
    }
    }
}