Example #1
0
    STARTDECL(ph_renderparticles) (Value &particlescale)
    {
        CheckPhysics();
        if (!particlesystem) return Value();

        //DebugLog(1, (string("rendering particles: ") + inttoa(particlesystem->GetParticleCount())).c_str());
        auto verts = (float2 *)particlesystem->GetPositionBuffer();
        auto colors = (byte4 *)particlesystem->GetColorBuffer();
        auto scale = fabs(object2view[0].x());
        SetPointSprite(scale * particlesystem->GetRadius() * particlescale.fval);
        particlematerial->Set();
        RenderArray(PRIM_POINT, particlesystem->GetParticleCount(), "pC", sizeof(float2), verts, NULL, sizeof(byte4), colors);
        return Value();
    }
Example #2
0
void Mesh::Render(Shader *sh)
{
    if (prim == PRIM_POINT) SetPointSprite(pointsize);

    sh->Set();

    if (numbones && numframes)
    {
        int frame1 = (int)floor(curanim);
        int frame2 = frame1 + 1;
        float frameoffset = curanim - frame1;

        float3x4 *mat1 = &mats[(frame1 % numframes) * numbones],
                 *mat2 = &mats[(frame2 % numframes) * numbones];

        auto outframe = new float3x4[numbones];

        for(int i = 0; i < numbones; i++) outframe[i] = mix(mat1[i], mat2[i], frameoffset);

        sh->SetAnim(outframe, numbones);

        delete[] outframe;
    }

    geom->RenderSetup();

    if (surfs.size())
    {
        for (auto s : surfs) s->Render(sh);
    }
    else
    {
        glDrawArrays(GetPrimitive(prim), 0, geom->nverts);
    }
    geom->RenderDone();
}