Exemple #1
0
    /// Convert to another ell, then to geodetic coordinates.
    /// @return a reference to this.
    /// @throw GeometryException if input is NULL.
 Position asGeodetic(EllipsoidModel *ell)
    throw(GeometryException)
 {
    try { setEllipsoidModel(ell); }
    catch(GeometryException& ge) { GPSTK_RETHROW(ge); }
    transformTo(Geodetic);
    return *this;
 }
void rWeaponRaybeam::drawSolid() {

    if (drawWeapon) {
        GL::glPushAttrib(GL_ALL_ATTRIB_BITS);
        {
            GLS::glUseProgram_fglitcolor();

            GL::glPushMatrix();
            {
                transformTo();
                GL::glRotatef(-90, 1, 0, 0);

                // Scale
                float scale = weaponScale;
                GL::glScalef(scale, scale, scale);

                if (this->ready() == 0 && remainingAmmo != 0) {
                }

                GL::glColor4f(0.3, 0.2, 0.3, 1.0);
                GL::glPushMatrix();
                {
                    GL::glScalef(0.1, 0.14, 0.12);
                    Primitive::glCenterUnitBlock();
                }
                GL::glPopMatrix();

                GL::glColor4f(0.1, 0.1, 0.1, 1.0);
                GL::glPushMatrix();
                {
                    GL::glTranslatef(0.0, 0.7, 0);
                    GL::glScalef(0.03, 0.7, 0.03);
                    Primitive::glCenterUnitCylinder(7);
                    GL::glTranslatef(0.0, 1.0, 0);
                    GL::glScalef(2.0, 0.1, 2.0);
                    GL::glColor4f(0.4, 0.4, 0.4, 1.0);
                    Primitive::glCenterUnitCylinder(7);
                }
                GL::glPopMatrix();
            }
            GL::glPopMatrix();
        }
        GL::glPopAttrib();
    }
}
void rWeaponRaybeam::drawEffect() {

    if (timeFiring == 0) return;

    const float len = 10;

    struct appearance {
        float width, length;
        rgba icolor;
        rgba ocolor;
    } app[] = {
        {
            0.10, 8 * len,
            {0.3, 0.3, 0.3, 1},
            {0.3, 0.0, 0.0, 1},
        },
        {
            0.40, 8 * len,
            {0.5, 0.5, 0.5, 1},
            {0.3, 0.0, 0.0, 1},
        },
        {
            0.80, 8 * len,
            {0.9, 0.9, 0.9, 1},
            {0.3, 0.0, 0.0, 1},
        },
        {
            0.85, 8 * len,
            {1.0, 1.0, 1.0, 1},
            {0.4, 0.0, 0.0, 1},
        },
        {
            0.90, 8.2 * len,
            {1.0, 1.0, 1.0, 1},
            {0.7, 0.0, 0.0, 1},
        },
        {
            0.60, 8.4 * len,
            {0.9, 0.9, 0.9, 1},
            {0.3, 0.0, 0.0, 1},
        },
        {
            0.30, 8.5 * len,
            {0.7, 0.7, 0.7, 1},
            {0.3, 0.0, 0.0, 1},
        }
    };

    int lifeindex = (int) ((0.7 - timeFiring) * 10);
    int entries = (int) (sizeof (app) / sizeof (appearance) - 1);
    if (lifeindex > entries) lifeindex = sizeof (app) / sizeof (appearance) - 1;
    if (lifeindex < 0) lifeindex = 0;

    GL::glPushAttrib(GL_ALL_ATTRIB_BITS);
    {
        GLS::glUseProgram_fgaddcolor();

        GL::glPushMatrix();
        {
            transformTo();

            float m[16];
            GL::glGetFloatv(GL_MODELVIEW_MATRIX, m);
            float* mpnt = &m[12]; // Vector that points to the Mountpoint relative to the eye.
            //vector_print(mpnt);
            float* mfwd = &m[8]; // Mountpoint-Forward Vector relative to the eye.
            //vector_print(mfwd);

            float right[3];
            vector_cross(right, mpnt, mfwd);
            vector_norm(right, right);
            //vector_print(right);

            //if (mpnt[2] > 0 || mfwd[2] < 0) right[1] = -right[1]; // Correction
            //if (mpnt[1] > 0 || mfwd[1] < 0) right[1] = -right[1]; // Correction

            const float w = app[lifeindex].width;
            right[0] *= -w;
            right[1] *= -w;
            right[2] *= -w;
            GL::glBegin(GL_TRIANGLE_STRIP);
            GL::glColor4fv(app[lifeindex].ocolor);
            GL::glVertex3f(-right[0], -right[1], -right[2] - 2 * w);
            GL::glVertex3f(-right[0], -right[1], -right[2] - app[lifeindex].length);
            GL::glColor4fv(app[lifeindex].icolor);
            GL::glVertex3f(0, 0.0, 0);
            GL::glVertex3f(0, 0.0, -app[lifeindex].length);
            GL::glColor4fv(app[lifeindex].ocolor);
            GL::glVertex3f(+right[0], +right[1], +right[2] - 2 * w);
            GL::glVertex3f(+right[0], +right[1], +right[2] - app[lifeindex].length);
            GL::glEnd();

        }
        GL::glPopMatrix();
    }
    GL::glPopAttrib();
}
Exemple #4
0
    /// Convert to cartesian coordinates (does nothing if
    /// system == Cartesian already).
 Position asECEF()
    throw()
 { transformTo(Cartesian); return *this; }
Exemple #5
0
    /// Convert to geodetic coordinates (does nothing if
    /// system == Geodetic already).
 Position asGeodetic()
    throw()
 { transformTo(Geodetic); return *this; }