Esempio n. 1
0
void Chain::draw() {
    Bone *current = this->root;
    int depth = 0;
    //Matrix4f transform;
    glPushMatrix();
    while (current != NULL) {
        glMultMatrixf(current->getTransformationMatrix().data());
        current->draw(BONE_RADIUS, BONE_FACES);
        //transform = current->getTransformationMatrix();
        current = current->getChild(0);
    }
    glPopMatrix();
}
Esempio n. 2
0
/**
 * Draws the skeleton.
 * \param mode  bitmask of RENDER_WIREFRAME, RENDER_FEEDBACK or RENDER_OUTPUT,
 *              determines how the primitives are drawn.
 * \param active active state
 **/
void Skeleton::draw(int mode, int active)
{
    unsigned hit = 0;
    SelectItem *selected = NULL;

    if (selector->getPickLayer()
        && selector->getPickLayer()->getSkeleton() == this) {
        hit = selector->getHitCount();
        selected = selector->getSelected();
    }

    // select objects from the selection buffer
    pJoint = NULL;
    pBone = NULL;
    for (unsigned int i = 0; i < hit; i++) {
        if (selected->type == Selection::SELECT_JOINT &&
            ((ui->settings.mode == ANIMATA_MODE_CREATE_JOINT) ||
             (ui->settings.mode == ANIMATA_MODE_SKELETON_SELECT) ||
             (ui->settings.mode == ANIMATA_MODE_SKELETON_DELETE) ||
             (ui->settings.mode == ANIMATA_MODE_CREATE_BONE))) {
            /* joints are prefered to bones if they overlap */
            pJoint = (*joints)[selected->name];
            pBone = NULL;
            break;
        }
        else if (selected->type == Selection::SELECT_BONE &&
                 (ui->settings.mode != ANIMATA_MODE_CREATE_BONE)) {
            pBone = (*bones)[selected->name];
        }

        selected++;
    }

    if ((mode & RENDER_WIREFRAME)
        && ((!(mode & RENDER_OUTPUT)
             && ui->settings.display_elements & DISPLAY_EDITOR_BONE)
            || ((mode & RENDER_OUTPUT)
                && ui->settings.display_elements & DISPLAY_OUTPUT_BONE)))
    {
        glLoadName(Selection::SELECT_BONE);    /* type of primitive */
        glPushName(0);                        /* id of primitive */

        for (unsigned i = 0; i < bones->size(); i++) {
            Bone *bone = (*bones)[i];

            glLoadName(i);

            if (mode & RENDER_OUTPUT)
                bone->draw(false);
            else
                bone->draw(bone == pBone, active);
        }

        glPopName();
    }

    if (mode & RENDER_FEEDBACK) {
        for (unsigned i = 0; i < joints->size(); i++) {
            Joint *joint = (*joints)[i];

            glPassThrough(i);
            glBegin(GL_POINTS);
                glVertex2f(joint->position.x, joint->position.y);
            glEnd();
        }
    }
    else if ((mode & RENDER_WIREFRAME) &&
             ((!(mode & RENDER_OUTPUT)
               && ui->settings.display_elements & DISPLAY_EDITOR_JOINT) ||
             ((mode & RENDER_OUTPUT)
              && ui->settings.display_elements & DISPLAY_OUTPUT_JOINT)))
    {
        glLoadName(Selection::SELECT_JOINT);    /* type of primitive */
        glPushName(0);                            /* id of primitive */

        for (unsigned i = 0; i < joints->size(); i++) {
            Joint *joint = (*joints)[i];

            glLoadName(i);

            if (mode & RENDER_OUTPUT)
                joint->draw(false);
            else
                joint->draw(joint == pJoint, active);
        }

        glPopName();
    }
}