예제 #1
0
void runTests(bool write,BinaryDataHandler &pMem)
{
    runTest  (write,pMem, std::string("Hallo") );
    runTest1 (write,pMem, Time(222.22) );
    runTest  (write,pMem, Color3f(1.1,2.2,3.3) );
    runTest  (write,pMem, Color4f(1.1,2.2,3.3,4.4) );
    runTest  (write,pMem, Color3ub(1,2,3) );
    runTest  (write,pMem, Color4ub(1,2,3,4) );
    runTest  (write,pMem, DynamicVolume(DynamicVolume::BOX_VOLUME) );
    runTest  (write,pMem, DynamicVolume(DynamicVolume::SPHERE_VOLUME) );
    runTest1 (write,pMem, BitVector(0xabcd) );
    runTest  (write,pMem, Plane(Vec3f(1.0,0),0.222) );
    runTest  (write,pMem, Matrix(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16) );
    runTest  (write,pMem, Quaternion(Vec3f(1,2,3),22) );
    runTest2<bool>(write,pMem, true );
    runTest  (write,pMem, Int8(-22) );
    runTest  (write,pMem, UInt8(11) );
    runTest  (write,pMem, Int16(-10233) );
    runTest  (write,pMem, UInt16(20233) );
    runTest  (write,pMem, Int32(-222320233) );
    runTest  (write,pMem, UInt32(522320233) );
    runTest<Int64>  (write,pMem, Int64(-522323334) );
    runTest  (write,pMem, UInt64(44523423) );
    runTest  (write,pMem, Real32(22.333224) );
    runTest  (write,pMem, Real64(52.334534533224) );
    runTest  (write,pMem, Vec2f(1.1,2.2) );
    runTest  (write,pMem, Vec3f(1.1,2.2,3.3) );
    runTest  (write,pMem, Vec4f(1.1,2.2,3.3,4.4) );
    runTest  (write,pMem, Pnt2f(1.1,2.2) );
    runTest  (write,pMem, Pnt2d(1.1,2.2) );
    runTest  (write,pMem, Pnt3f(1.1,2.2,3.3) );
    runTest  (write,pMem, Pnt3d(1.1,2.2,3.3) );
    runTest  (write,pMem, Pnt4f(1.1,2.2,3.3,4.4) );
    runTest  (write,pMem, Pnt4d(1.1,2.2,3.3,4.4) );
}
예제 #2
0
파일: Color.cpp 프로젝트: irigi/pioneer
const Color4f Color4f::GRAY   = Color4f(0.5f,0.5f,0.5f,1.f);
const Color4f Color4f::STEELBLUE = Color4f(0.27f, 0.51f, 0.71f, 1.f);
const Color4f Color4f::BLANK = Color4f(0.0f, 0.0f, 0.0f, 0.0f);

const Color4ub Color::BLACK   = Color(0, 0, 0, 255);
const Color4ub Color::WHITE   = Color(255, 255, 255, 255);
const Color4ub Color::RED     = Color(255, 0, 0, 255);
const Color4ub Color::GREEN   = Color(0, 255, 0, 255);
const Color4ub Color::BLUE    = Color(0, 0, 255, 255);
const Color4ub Color::YELLOW  = Color(255, 255, 0, 255);
const Color4ub Color::GRAY    = Color(128,128,128,255);
const Color4ub Color::STEELBLUE = Color(68, 130, 181, 255);
const Color4ub Color::BLANK = Color(0, 0, 0, 0);
const Color4ub Color::PINK	= Color(252, 15, 192, 255); // debug pink

const Color3ub Color3ub::BLACK   = Color3ub(0, 0, 0);
const Color3ub Color3ub::WHITE   = Color3ub(255, 255, 255);
const Color3ub Color3ub::RED     = Color3ub(255, 0, 0);
const Color3ub Color3ub::GREEN   = Color3ub(0, 255, 0);
const Color3ub Color3ub::BLUE    = Color3ub(0, 0, 255);
const Color3ub Color3ub::YELLOW  = Color3ub(255, 255, 0);
const Color3ub Color3ub::STEELBLUE = Color3ub(68, 130, 181);
const Color3ub Color3ub::BLANK = Color3ub(0, 0, 0);

float Color4f::GetLuminance() const
{
	return (0.299f * r) + (0.587f * g) + (0.114f * b);
}

void Color4f::ToLuaTable(lua_State *l)
{
예제 #3
0
파일: Color.cpp 프로젝트: starmoth/starmoth
const Color4f Color4f::WHITE  = Color4f(1.0f,1.0f,1.0f,1.0f);
const Color4f Color4f::RED    = Color4f(1.0f,0.0f,0.0f,1.0f);
const Color4f Color4f::GREEN  = Color4f(0.0f,1.0f,0.0f,1.0f);
const Color4f Color4f::BLUE   = Color4f(0.0f,0.0f,1.0f,1.0f);
const Color4f Color4f::YELLOW = Color4f(1.0f,1.0f,0.0f,1.0f);
const Color4f Color4f::GRAY   = Color4f(0.5f,0.5f,0.5f,1.f);

const Color4ub Color::BLACK   = Color(0, 0, 0, 255);
const Color4ub Color::WHITE   = Color(255, 255, 255, 255);
const Color4ub Color::RED     = Color(255, 0, 0, 255);
const Color4ub Color::GREEN   = Color(0, 255, 0, 255);
const Color4ub Color::BLUE    = Color(0, 0, 255, 255);
const Color4ub Color::YELLOW  = Color(255, 255, 0, 255);
const Color4ub Color::GRAY    = Color(128,128,128,255);

const Color3ub Color3ub::BLACK   = Color3ub(0, 0, 0);
const Color3ub Color3ub::WHITE   = Color3ub(255, 255, 255);
const Color3ub Color3ub::RED     = Color3ub(255, 0, 0);
const Color3ub Color3ub::GREEN   = Color3ub(0, 255, 0);
const Color3ub Color3ub::BLUE    = Color3ub(0, 0, 255);
const Color3ub Color3ub::YELLOW  = Color3ub(255, 255, 0);

float Color4f::GetLuminance() const
{
	return (0.299f * r) + (0.587f * g) + (0.114f * b);
}

Uint8 Color4ub::GetLuminance() const
{
	// these weights are those used for the JPEG luma channel
	return (r*299 + g*587 + b*114) / 1000;
예제 #4
0
//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
bool VertexColoring::onInitialize()
{
    ref<ModelBasicList> myModel = new ModelBasicList;

    // Create the fixed function effect
    {
        m_fixedFuncEffect = new Effect;

        ref<RenderStateMaterial_FF> mat = new RenderStateMaterial_FF(Color3::BLUE);
        mat->enableColorMaterial(true);
        m_fixedFuncEffect->setRenderState(mat.p());

        ref<RenderStateLighting_FF> lighting = new RenderStateLighting_FF;
        m_fixedFuncEffect->setRenderState(lighting.p());
    }

    // Create effect with shader program
    {
        m_shaderEffect = new Effect;

        ShaderProgramGenerator gen("PerVertexColor", ShaderSourceProvider::instance());
        gen.addVertexCode(ShaderSourceRepository::vs_Standard);
        gen.addFragmentCode(ShaderSourceRepository::src_VaryingColorGlobalAlpha);
        gen.addFragmentCode(ShaderSourceRepository::light_SimpleHeadlight);
        gen.addFragmentCode(ShaderSourceRepository::fs_Standard);
        m_shaderProg = gen.generate();
        m_shaderProg->setDefaultUniform(new cvf::UniformFloat("u_alpha", 1.0f));

        m_shaderEffect->setShaderProgram(m_shaderProg.p());
    }


    ref<Effect> effectToUse = m_useShaders ? m_shaderEffect : m_fixedFuncEffect;

    // Lower left: "Normal" geometry
    {
        GeometryBuilderDrawableGeo builder;
        GeometryUtils::createBox(Vec3f(0,0,0), 2.0, 2.0, 2.0, &builder);
        ref<DrawableGeo> geo = builder.drawableGeo();
        geo->computeNormals();

        ref<Part> part = new Part;
        part->setDrawable(geo.p());
        part->setEffect(effectToUse.p());

        myModel->addPart(part.p());
    }

    // Lower right: Geometry with per vertex colors 
    // Results in one color per face of the cube
    {
        GeometryBuilderDrawableGeo builder;
        GeometryUtils::createBox(Vec3f(3,0,0), 2.0, 2.0, 2.0, &builder);
        ref<DrawableGeo> geo = builder.drawableGeo();
        geo->computeNormals();

        const Color3ub colorTable[] = 
        {
            Color3ub(Color3::ORANGE),
            Color3ub(Color3::FOREST_GREEN),
            Color3ub(Color3::SKY_BLUE),
            Color3ub(Color3::ORCHID),
            Color3ub(Color3::BROWN),
            Color3ub(Color3::DARK_RED)
        };
        const int colorTableSize = sizeof(colorTable)/sizeof(Color3ub);

        size_t vertexCount = geo->vertexCount();
        ref<Color3ubArray> colorArray = new Color3ubArray;
        colorArray->resize(vertexCount);
        colorArray->setAll(Color3::WHITE);

        size_t i;
        for (i = 0; i < vertexCount; i++)
        {
            Color3ub c = colorTable[(i/4) % colorTableSize];
            colorArray->set(i, c);
        }
        geo->setColorArray(colorArray.p());

        ref<Part> part = new Part;
        part->setDrawable(geo.p());
        part->setEffect(effectToUse.p());

        myModel->addPart(part.p());
    }

    // Upper right: Geometry with per vertex colors (using ScalarToColorMapper)
    {
        BoxGenerator gen;
        gen.setMinMax(Vec3d(2,-1,2), Vec3d(4, 1, 4));
        gen.setSubdivisions(10, 10, 10);

        GeometryBuilderDrawableGeo builder;
        gen.generate(&builder);
        ref<DrawableGeo> geo = builder.drawableGeo();
        geo->computeNormals();

        cvf::Color3ubArray colors;
        colors.reserve(4);
        colors.add(Color3::BLUE);
        colors.add(Color3::CYAN);
        colors.add(Color3::YELLOW);
        colors.add(Color3::RED);

        ScalarMapperUniformLevels mapper;
        mapper.setColors(colors);
        mapper.setRange(0, 3);

        size_t vertexCount = geo->vertexCount();
        ref<Color3ubArray> colorArray = new Color3ubArray;
        colorArray->resize(vertexCount);
        colorArray->setAll(Color3::WHITE);

        size_t i;
        for (i = 0; i < vertexCount; i++)
        {
            Vec3f v = geo->vertexArray()->get(i);
            float dist = v.pointDistance(Vec3f(2, -1, 2));
            Color3ub c = mapper.mapToColor(dist);
            colorArray->set(i, c);
        }

        geo->setColorArray(colorArray.p());

        ref<Part> part = new Part;
        part->setDrawable(geo.p());
        part->setEffect(effectToUse.p());

        myModel->addPart(part.p());
    }

    // Upper left: Geometry without normals
    {
        GeometryBuilderDrawableGeo builder;
        GeometryUtils::createBox(Vec3f(0,0,3), 2.0, 2.0, 2.0, &builder);
        ref<DrawableGeo> geo = builder.drawableGeo();
        geo->setNormalArray(NULL);

        ref<Part> part = new Part;
        part->setDrawable(geo.p());
        part->setEffect(effectToUse.p());

        myModel->addPart(part.p());
    }

    

    myModel->updateBoundingBoxesRecursive();

    m_renderSequence->firstRendering()->scene()->addModel(myModel.p());
    m_renderSequence->firstRendering()->addOverlayItem(new OverlayAxisCross(m_camera.p(), new FixedAtlasFont(FixedAtlasFont::STANDARD)));

    BoundingBox bb = m_renderSequence->boundingBox();
    if (bb.isValid())
    {
        m_camera->fitView(bb, Vec3d::Y_AXIS, Vec3d::Z_AXIS);
    }

    addEdgesRendering();
       
    return true;
}