예제 #1
0
파일: slider.cpp 프로젝트: Aethyra/Client
void Slider::drawMarker(gcn::Graphics *graphics)
{
    if (isFocused())
        static_cast<Graphics*>(graphics)->drawImage(hGripHi, getMarkerPosition(),
                                                   (getHeight() -
                                                    hGripHi->getHeight()) / 2);
    else
        static_cast<Graphics*>(graphics)->drawImage(hGrip, getMarkerPosition(),
                                                   (getHeight() -
                                                    hGrip->getHeight()) / 2);
}
예제 #2
0
    void Slider::drawMarker(gcn::Graphics* graphics)
    {
        gcn::Color faceColor = getBaseColor();
        Color highlightColor, shadowColor;
        int alpha = getBaseColor().a;
        highlightColor = faceColor + 0x303030;
        highlightColor.a = alpha;
        shadowColor = faceColor - 0x303030;
        shadowColor.a = alpha;

        graphics->setColor(faceColor);

        if (getOrientation() == HORIZONTAL)
        {
            int v = getMarkerPosition();
            graphics->fillRectangle(gcn::Rectangle(v + 1, 1, getMarkerLength() - 2, getHeight() - 2));
            graphics->setColor(highlightColor);
            graphics->drawLine(v, 0, v + getMarkerLength() - 1,0);
            graphics->drawLine(v, 0, v, getHeight() - 1);
            graphics->setColor(shadowColor);
            graphics->drawLine(v + getMarkerLength() - 1, 1, v + getMarkerLength() - 1, getHeight() - 1);
            graphics->drawLine(v + 1, getHeight() - 1, v + getMarkerLength() - 1, getHeight() - 1);

            if (isFocused())
            {
                graphics->setColor(getForegroundColor());
                graphics->drawRectangle(Rectangle(v + 2, 2, getMarkerLength() - 4, getHeight() - 4));
            }
        }
        else
        {
            int v = (getHeight() - getMarkerLength()) - getMarkerPosition();
            graphics->fillRectangle(gcn::Rectangle(1, v + 1, getWidth() - 2, getMarkerLength() - 2));
            graphics->setColor(highlightColor);
            graphics->drawLine(0, v, 0, v + getMarkerLength() - 1);
            graphics->drawLine(0, v, getWidth() - 1, v);
            graphics->setColor(shadowColor);
            graphics->drawLine(1, v + getMarkerLength() - 1, getWidth() - 1, v + getMarkerLength() - 1);
            graphics->drawLine(getWidth() - 1, v + 1, getWidth() - 1, v + getMarkerLength() - 1);

            if (isFocused())
            {
                graphics->setColor(getForegroundColor());
                graphics->drawRectangle(Rectangle(2, v + 2, getWidth() - 4, getMarkerLength() - 4));
            }
        }
    }
예제 #3
0
파일: object.cpp 프로젝트: Fynjyfun/openmw
osg::ref_ptr<osg::Node> CSVRender::Object::makeRotateMarker (int axis)
{
    const float Pi = 3.14159265f;

    const float InnerRadius = std::max(MarkerShaftBaseLength, mBaseNode->getBound().radius());
    const float OuterRadius = InnerRadius + MarkerShaftWidth;

    const float SegmentDistance = 100.f;
    const size_t SegmentCount = std::min(64, std::max(24, (int)(OuterRadius * 2 * Pi / SegmentDistance)));
    const size_t VerticesPerSegment = 4;
    const size_t IndicesPerSegment = 24;

    const size_t VertexCount = SegmentCount * VerticesPerSegment;
    const size_t IndexCount = SegmentCount * IndicesPerSegment;

    const float Angle = 2 * Pi / SegmentCount;

    const unsigned short IndexPattern[IndicesPerSegment] =
    {
        0, 4, 5, 0, 5, 1,
        2, 6, 4, 2, 4, 0,
        3, 7, 6, 3, 6, 2,
        1, 5, 7, 1, 7, 3
    };


    osg::ref_ptr<osg::Geometry> geometry = new osg::Geometry();

    osg::ref_ptr<osg::Vec3Array> vertices = new osg::Vec3Array(VertexCount);
    osg::ref_ptr<osg::Vec4Array> colors = new osg::Vec4Array(1);
    osg::ref_ptr<osg::DrawElementsUShort> primitives = new osg::DrawElementsUShort(osg::PrimitiveSet::TRIANGLES,
        IndexCount);

    // prevent some depth collision issues from overlaps
    osg::Vec3f offset = getMarkerPosition(0, MarkerShaftWidth/4, 0, axis);

    for (size_t i = 0; i < SegmentCount; ++i)
    {
        size_t index = i * VerticesPerSegment;

        float innerX = InnerRadius * std::cos(i * Angle);
        float innerY = InnerRadius * std::sin(i * Angle);

        float outerX = OuterRadius * std::cos(i * Angle);
        float outerY = OuterRadius * std::sin(i * Angle);

        vertices->at(index++) = getMarkerPosition(innerX, innerY,  MarkerShaftWidth / 2, axis) + offset;
        vertices->at(index++) = getMarkerPosition(innerX, innerY, -MarkerShaftWidth / 2, axis) + offset;
        vertices->at(index++) = getMarkerPosition(outerX, outerY,  MarkerShaftWidth / 2, axis) + offset;
        vertices->at(index++) = getMarkerPosition(outerX, outerY, -MarkerShaftWidth / 2, axis) + offset;
    }

    colors->at(0) = osg::Vec4f (
        axis==0 ? 1.0f : 0.2f,
        axis==1 ? 1.0f : 0.2f,
        axis==2 ? 1.0f : 0.2f,
        mMarkerTransparency);

    for (size_t i = 0; i < SegmentCount; ++i)
    {
        size_t indices[IndicesPerSegment];
        for (size_t j = 0; j < IndicesPerSegment; ++j)
        {
            indices[j] = i * VerticesPerSegment + j;

            if (indices[j] >= VertexCount)
                indices[j] -= VertexCount;
        }

        size_t offset = i * IndicesPerSegment;
        for (size_t j = 0; j < IndicesPerSegment; ++j)
        {
            primitives->setElement(offset++, indices[IndexPattern[j]]);
        }
    }

    geometry->setVertexArray(vertices);
    geometry->setColorArray(colors, osg::Array::BIND_OVERALL);
    geometry->addPrimitiveSet(primitives);

    setupCommonMarkerState(geometry);

    osg::ref_ptr<osg::Geode> geode = new osg::Geode();
    geode->addDrawable (geometry);

    return geode;
}
예제 #4
0
size_t FileInputStream::getRemainingByteCount()
{
    return length - getMarkerPosition();
}
예제 #5
0
파일: object.cpp 프로젝트: Fynjyfun/openmw
osg::ref_ptr<osg::Node> CSVRender::Object::makeMoveOrScaleMarker (int axis)
{
    osg::ref_ptr<osg::Geometry> geometry (new osg::Geometry);

    float shaftLength = MarkerShaftBaseLength + mBaseNode->getBound().radius();

    // shaft
    osg::Vec3Array *vertices = new osg::Vec3Array;

    for (int i=0; i<2; ++i)
    {
        float length = i ? shaftLength : MarkerShaftWidth;

        vertices->push_back (getMarkerPosition (-MarkerShaftWidth/2, -MarkerShaftWidth/2, length, axis));
        vertices->push_back (getMarkerPosition (-MarkerShaftWidth/2, MarkerShaftWidth/2, length, axis));
        vertices->push_back (getMarkerPosition (MarkerShaftWidth/2, MarkerShaftWidth/2, length, axis));
        vertices->push_back (getMarkerPosition (MarkerShaftWidth/2, -MarkerShaftWidth/2, length, axis));
    }

    // head backside
    vertices->push_back (getMarkerPosition (-MarkerHeadWidth/2, -MarkerHeadWidth/2, shaftLength, axis));
    vertices->push_back (getMarkerPosition (-MarkerHeadWidth/2, MarkerHeadWidth/2, shaftLength, axis));
    vertices->push_back (getMarkerPosition (MarkerHeadWidth/2, MarkerHeadWidth/2, shaftLength, axis));
    vertices->push_back (getMarkerPosition (MarkerHeadWidth/2, -MarkerHeadWidth/2, shaftLength, axis));

    // head
    vertices->push_back (getMarkerPosition (0, 0, shaftLength+MarkerHeadLength, axis));

    geometry->setVertexArray (vertices);

    osg::DrawElementsUShort *primitives = new osg::DrawElementsUShort (osg::PrimitiveSet::TRIANGLES, 0);

    // shaft
    for (int i=0; i<4; ++i)
    {
        int i2 = i==3 ? 0 : i+1;
        primitives->push_back (i);
        primitives->push_back (4+i);
        primitives->push_back (i2);

        primitives->push_back (4+i);
        primitives->push_back (4+i2);
        primitives->push_back (i2);
    }

    // cap
    primitives->push_back (0);
    primitives->push_back (1);
    primitives->push_back (2);

    primitives->push_back (2);
    primitives->push_back (3);
    primitives->push_back (0);

    // head, backside
    primitives->push_back (0+8);
    primitives->push_back (1+8);
    primitives->push_back (2+8);

    primitives->push_back (2+8);
    primitives->push_back (3+8);
    primitives->push_back (0+8);

    for (int i=0; i<4; ++i)
    {
        primitives->push_back (12);
        primitives->push_back (8+(i==3 ? 0 : i+1));
        primitives->push_back (8+i);
    }

    geometry->addPrimitiveSet (primitives);

    osg::Vec4Array *colours = new osg::Vec4Array;

    for (int i=0; i<8; ++i)
        colours->push_back (osg::Vec4f (axis==0 ? 1.0f : 0.2f, axis==1 ? 1.0f : 0.2f,
            axis==2 ? 1.0f : 0.2f, mMarkerTransparency));

    for (int i=8; i<8+4+1; ++i)
        colours->push_back (osg::Vec4f (axis==0 ? 1.0f : 0.0f, axis==1 ? 1.0f : 0.0f,
            axis==2 ? 1.0f : 0.0f, mMarkerTransparency));

    geometry->setColorArray (colours, osg::Array::BIND_PER_VERTEX);

    setupCommonMarkerState(geometry);

    osg::ref_ptr<osg::Geode> geode (new osg::Geode);
    geode->addDrawable (geometry);

    return geode;
}