Example #1
0
        /*
        ================
        R_AliasTransformAndProjectFinalVerts
        ================
        */
        static void R_AliasTransformAndProjectFinalVerts(draw.finalvert_t[] pfv, model.stvert_t[] pstverts)
        {
            int			        i, temp;
            double		        lightcos;
            double[]            plightnormal;
            double              zi;
            model.trivertx_t	pverts;

            for (i=0 ; i<r_anumverts ; i++)
            {
                draw.finalvert_t    fv = pfv[i];
                model.stvert_t stverts = pstverts[i];
                pverts = r_apverts[i];

                // transform and project
                zi = 1.0 / (mathlib.DotProduct(pverts.v, aliastransform[2]) +
                        aliastransform[2][3]);

            // x, y, and z are scaled down by 1/2**31 in the transform, so 1/z is
            // scaled up by 1/2**31, and the scaling cancels out for x and y in the
            // projection
                fv.v[5] = (int)zi;

                fv.v[0] = (int)(((mathlib.DotProduct(pverts.v, aliastransform[0]) +
                        aliastransform[0][3]) * zi) + aliasxcenter);
                fv.v[1] = (int)(((mathlib.DotProduct(pverts.v, aliastransform[1]) +
                        aliastransform[1][3]) * zi) + aliasycenter);

                fv.v[2] = stverts.s;
                fv.v[3] = stverts.t;
                fv.flags = stverts.onseam;

            // lighting
                plightnormal = r_avertexnormals[pverts.lightnormalindex];
                lightcos = mathlib.DotProduct(plightnormal, r_plightvec);
                temp = r_ambientlight;

                if (lightcos < 0)
                {
                    temp += (int)(r_shadelight * lightcos);

                // clamp; because we limited the minimum ambient and shading light, we
                // don't have to clamp low light, just bright
                    if (temp < 0)
                        temp = 0;
                }

                fv.v[4] = temp;
            }
        }
Example #2
0
        /*
        ================
        R_AliasTransformFinalVert
        ================
        */
        static void R_AliasTransformFinalVert(draw.finalvert_t fv, auxvert_t av,
            model.trivertx_t pverts, model.stvert_t pstverts)
        {
            int		    temp;
            double      lightcos;
            double[]    plightnormal;

            av.fv[0] = mathlib.DotProduct(pverts.v, aliastransform[0]) +
                    aliastransform[0][3];
            av.fv[1] = mathlib.DotProduct(pverts.v, aliastransform[1]) +
                    aliastransform[1][3];
            av.fv[2] = mathlib.DotProduct(pverts.v, aliastransform[2]) +
                    aliastransform[2][3];

            fv.v[2] = pstverts.s;
            fv.v[3] = pstverts.t;

            fv.flags = pstverts.onseam;

            // lighting
            plightnormal = r_avertexnormals[pverts.lightnormalindex];
            lightcos = mathlib.DotProduct(plightnormal, r_plightvec);
            temp = r_ambientlight;

            if (lightcos < 0)
            {
                temp += (int)(r_shadelight * lightcos);

            // clamp; because we limited the minimum ambient and shading light, we
            // don't have to clamp low light, just bright
                if (temp < 0)
                    temp = 0;
            }

            fv.v[4] = temp;
        }
Example #3
0
        /*
        ================
        R_AliasProjectFinalVert
        ================
        */
        static void R_AliasProjectFinalVert(draw.finalvert_t fv, auxvert_t av)
        {
            double	zi;

            // project points
            zi = 1.0 / av.fv[2];

            fv.v[5] = (int)(zi * ziscale);

            fv.v[0] = (int)((av.fv[0] * aliasxscale * zi) + aliasxcenter);
            fv.v[1] = (int)((av.fv[1] * aliasyscale * zi) + aliasycenter);
        }