Ejemplo n.º 1
0
void
ColorAttributeList::SetFromNode(DataNode *parentNode)
{
    if(parentNode == 0)
        return;

    DataNode *searchNode = parentNode->GetNode("ColorAttributeList");
    if(searchNode == 0)
        return;

    DataNode *node;
    DataNode **children;
    // Clear all the ColorAttributes.
    ClearColors();

    // Go through all of the children and construct a new
    // ColorAttribute for each one of them.
    children = searchNode->GetChildren();
    if(children != 0)
    {
        for(int i = 0; i < searchNode->GetNumChildren(); ++i)
        {
            if(children[i]->GetKey() == std::string("ColorAttribute"))
            {
                ColorAttribute temp;
                temp.SetFromNode(children[i]);
                AddColors(temp);
            }
        }
    }

}
Ejemplo n.º 2
0
GLGraphicsScene::GLGraphicsScene(QWidget *parent) :
    QGLWidget(parent)
{
    setFormat(QGLFormat(QGL::DoubleBuffer | QGL::DepthBuffer));

    mRotateX = -21.0;
    mRotateY = -57.0;
    mRotateZ = 0.0;

    _mScaPlusKey = new QShortcut(QKeySequence(tr("=")), this);
    _mScaMinusKey = new QShortcut(QKeySequence(tr("-")), this);
    _mMoveLeftXKey = new QShortcut(QKeySequence(tr("A")), this);
    _mMoveRightXKey = new QShortcut(QKeySequence(tr("D")), this);
    _mMoveTopYKey = new QShortcut(QKeySequence(tr("W")), this);
    _mMoveButtomYKey = new QShortcut(QKeySequence(tr("S")), this);
    _mRotateAxisXKey = new QShortcut(QKeySequence(tr("X")), this);
    _mRotateAxisYKey = new QShortcut(QKeySequence(tr("Y")), this);
    _mRotateAxisZKey = new QShortcut(QKeySequence(tr("Z")), this);
    _mMoveLeftRotateXKey = new QShortcut(Qt::CTRL+Qt::Key_A, this);
    _mMoveRightRotateXKey = new QShortcut(Qt::CTRL+Qt::Key_D, this);
    _mMoveTopRotateYKey = new QShortcut(Qt::CTRL+Qt::Key_W, this);
    _mMoveButtomRotateYKey = new QShortcut(Qt::CTRL+Qt::Key_S, this);
    _mRotateXKey = new QShortcut(Qt::CTRL+Qt::Key_X, this);
    _mRotateYKey = new QShortcut(Qt::CTRL+Qt::Key_Y, this);
    _mRotateAxisXYKey = new QShortcut(Qt::SHIFT+Qt::Key_Q, this);

    mMoveX = 0.0f;
    mMoveZ = -10.0f;
    mSca = 1;

    connect(_mScaPlusKey, SIGNAL(activated()), this, SLOT(ScaPlusSlot()));
    connect(_mScaMinusKey, SIGNAL(activated()), this, SLOT(ScaMinusSlot()));
    connect(_mMoveLeftXKey, SIGNAL(activated()), this, SLOT(MoveLeftSlot()));
    connect(_mMoveRightXKey, SIGNAL(activated()), this, SLOT(MoveRightSlot()));
    connect(_mMoveTopYKey, SIGNAL(activated()), this, SLOT(MoveTopSlot()));
    connect(_mMoveButtomYKey, SIGNAL(activated()), this, SLOT(MoveButtomSlot()));
    connect(_mRotateAxisXKey, SIGNAL(activated()), this, SLOT(RotateCenterXSlot()));
    connect(_mRotateAxisYKey, SIGNAL(activated()), this, SLOT(RotateCenterYSlot()));
    connect(_mRotateAxisZKey, SIGNAL(activated()), this, SLOT(RotateCenterZSlot()));
    connect(_mMoveLeftRotateXKey, SIGNAL(activated()), this, SLOT(MoveLeftRotateXSlot()));
    connect(_mMoveRightRotateXKey, SIGNAL(activated()), this, SLOT(MoveRightRotateXSlot()));
    connect(_mMoveTopRotateYKey, SIGNAL(activated()), this, SLOT(MoveTopRotateYSlot()));
    connect(_mMoveButtomRotateYKey, SIGNAL(activated()), this, SLOT(MoveButtomRotateYSlot()));
    connect(_mRotateXKey, SIGNAL(activated()), this, SLOT(RotateXSlot()));
    connect(_mRotateYKey, SIGNAL(activated()), this, SLOT(RotateYSlot()));
    connect(_mRotateAxisXYKey, SIGNAL(activated()), this, SLOT(RotateCenterXYSlot()));

    colorA = new QColor(Qt::red);
    colorB = new QColor(Qt::green);
    colorC = new QColor(Qt::yellow);
    colorD = new QColor(Qt::magenta);
    colorE = new QColor(178, 34, 34);
    colorF = new QColor(255, 165, 0);

    AddColors();

    IsDrawCude = true;
}
Ejemplo n.º 3
0
// Helper function to gather all the colors
void AddColors(std::set<wxString> & colors, const ConfigGroup * group)
{
    const ConfigColor * color = dynamic_cast<const ConfigColor *>(group);
    if (color)
        colors.insert(color->Get().GetAsString());
    std::list<ConfigGroup *>::const_iterator it;
    for (it = group->m_children.begin(); it != group->m_children.end(); ++it)
        AddColors(colors, *it);
}
Ejemplo n.º 4
0
void ColorChoice::InitColors(ConfigManager * cfg)
{
    s_colors.clear();
    // Add the "Other..." item
    s_colors.push_back(wxNullColour, other_color);
    // Add colors from config
    if (cfg)
    {
        std::set<wxString> colors;
        AddColors(colors, &cfg->GetGroup());
        std::set<wxString>::iterator it;
        for (it = colors.begin(); it != colors.end(); ++it)
            s_colors.push_back(wxColour(*it));
    }
    UpdateCtrls();
}
Ejemplo n.º 5
0
int ThrowRayOnScene(Ray3D ray, const Scene *sc, Intersection *intersection) {
    float dist, far_dist = FLT_MAX;
    Intersection test;
    size_t i, l;
    for(i=0 ; i<sc->nbSpheres ; ++i) {
        if(!TestRaySphereIntersection(ray, sc->spheres[i], &test))
            continue;
        dist = SqrNorm(Vector(ray.origin, test.position));
        if(dist >= far_dist)
            continue;
        far_dist = dist;
        *intersection = test;
    }

    if(far_dist == FLT_MAX)
        return 0;

    Color3f lights_contrib = ColorRGB(0,0,0);
    for(l=0 ; l<sc->nbLights ; ++l) {
        const Light *light = &sc->lights[l];

        Vector3D lvec = Normalize(
            Vector(intersection->position, light->position)
        );
        const float strength = DotProduct(intersection->normal, lvec);
        if(strength <= 0.f)
            continue;
        lights_contrib = AddColors(
            lights_contrib,
            MultColors(
                intersection->color, 
                MultColors(
                    light->color,
                    ColorRGB(strength, strength, strength)
                )
            )
        );
    }
    intersection->color = lights_contrib;

    return 1;
}