Example #1
0
void Arrow3d::Render(ScreenBase const & screen, int zoomLevel, ref_ptr<dp::GpuProgramManager> mng)
{
    // Unbind current VAO, because glVertexAttributePointer and glEnableVertexAttribute can affect it.
    if (dp::GLExtensionsList::Instance().IsSupported(dp::GLExtensionsList::VertexArrayObject))
        GLFunctions::glBindVertexArray(0);

    if (!m_isInitialized)
    {
        Build();
        m_isInitialized = true;
    }

    // Render shadow.
    if (screen.isPerspective())
    {
        ref_ptr<dp::GpuProgram> shadowProgram = mng->GetProgram(gpu::ARROW_3D_SHADOW_PROGRAM);
        RenderArrow(screen, shadowProgram, dp::Color(60, 60, 60, 60), 0.05f, false /* hasNormals */);
    }

    // Render arrow.
    ref_ptr<dp::GpuProgram> arrowProgram = mng->GetProgram(gpu::ARROW_3D_PROGRAM);
    dp::Color const color = df::GetColorConstant(GetStyleReader().GetCurrentStyle(),
                            m_obsoletePosition ? df::Arrow3DObsolete : df::Arrow3D);
    RenderArrow(screen, arrowProgram, color, 0.0f, true /* hasNormals */);

    arrowProgram->Unbind();
    GLFunctions::glBindBuffer(0, gl_const::GLArrayBuffer);
}
Example #2
0
Group* startup()
{
	// we need the scene's state set to enable the light for the entire scene
	Group *scene = new Group();
	lightStateSet = scene->getOrCreateStateSet();
	lightStateSet->ref();
	
	// create VideoGeometry
	try {
		videoGeode = new VideoGeode();
		
		// stars / starfield
		Material *material = new Material();
		material->setEmission(Material::FRONT, Vec4(1.0f, 1.0f, 1.0f, 1.0f));
		material->setAmbient(Material::FRONT,  Vec4(1.0f, 1.0f, 1.0f, 1.0f));
		material->setShininess(Material::FRONT, 25.0f);
		// creating a video plane
		videoGeode->prepareMaterial(material);
      //videoPlane = videoGeode->createVideoPlane(1,1, true);
      videoPlane = videoGeode->createVideoPlane(2,2, true);
      videoPlane->setPosition(Vec3(0,0,0));
	} catch (char *e) {
		std::cerr << e;
	}
	
   scene->addChild(videoPlane);
	
	return scene;
}
Example #3
0
ref_ptr<ShaderInput> ShaderInput::copy(const ref_ptr<ShaderInput> &in, GLboolean copyData)
{
  ref_ptr<ShaderInput> cp = create(in->name(), in->dataType(), in->valsPerElement());
  cp->stride_ = in->stride_;
  cp->offset_ = in->offset_;
  cp->inputSize_ = in->inputSize_;
  cp->elementSize_ = in->elementSize_;
  cp->elementCount_ = in->elementCount_;
  cp->numVertices_ = in->numVertices_;
  cp->numInstances_ = in->numInstances_;
  cp->divisor_ = in->divisor_;
  cp->buffer_ = 0;
  cp->bufferStamp_ = 0;
  cp->normalize_ = in->normalize_;
  cp->isVertexAttribute_ = in->isVertexAttribute_;
  cp->isConstant_ = in->isConstant_;
  cp->transpose_ = in->transpose_;
  cp->stamp_ = in->stamp_;
  cp->forceArray_ = in->forceArray_;
  cp->data_ = new byte[cp->inputSize_];

  if(copyData && in->data_!=NULL) {
    std::memcpy(cp->data_, in->data_, cp->inputSize_);
  }
  // make data_ stack root
  cp->dataStack_.push(cp->data_);

  return cp;
}
Example #4
0
ModulatedMagneticFieldGrid::ModulatedMagneticFieldGrid(ref_ptr<VectorGrid> grid,
		ref_ptr<ScalarGrid> modGrid) {
	grid->setReflective(false);
	modGrid->setReflective(true);
	setGrid(grid);
	setModulationGrid(modGrid);
}
void replication_service_test_app::write_current_chkpt_file_test()
{
    cold_backup_context_ptr backup_context =
        new cold_backup_context(nullptr, request, concurrent_uploading_file_cnt);

    backup_context->start_check();
    backup_context->block_service = block_service.get();
    backup_context->backup_root = backup_root;
    backup_context->_status.store(cold_backup_status::ColdBackupUploading);
    // case1: create current_chkpt_file succeed, and write succeed
    {
        std::string value = "test write_current_chkpt_file";
        backup_context->write_current_chkpt_file(value);

        std::string result(current_chkpt_file->context.data(),
                           current_chkpt_file->context.length());
        ASSERT_TRUE(value == result);
        ASSERT_TRUE(backup_context->status() == cold_backup_status::ColdBackupCompleted);
        ASSERT_TRUE(backup_context->_progress.load() >= 1000);
    }
    ASSERT_TRUE(backup_context->get_count() == 1);
    ASSERT_TRUE(current_chkpt_file->get_count() == 1);
    ASSERT_TRUE(backup_metadata_file->get_count() == 1);
    ASSERT_TRUE(regular_file->get_count() == 1);
}
  RealSenseApp()  {
    PXCSession::ImplDesc desc1 = {};
    desc1.group = PXCSession::IMPL_GROUP_SENSOR;
    desc1.subgroup = PXCSession::IMPL_SUBGROUP_VIDEO_CAPTURE;
    //for (int m = 0;; m++) {
    //  PXCSession::ImplDesc desc2;
    //  if (session->QueryImpl(&desc1, m, &desc2)<PXC_STATUS_NO_ERROR) break;
    //  SAY("Module[%d]: %s\n", m, desc2.friendlyName);

    //  PXCCapture *capture;
    //  session->CreateImpl<PXCCapture>(&desc2, &capture);
    //  // print out all device information
    //  for (int d = 0;; d++) {
    //    PXCCapture::DeviceInfo dinfo;
    //    if (capture->QueryDeviceInfo(d, &dinfo)<PXC_STATUS_NO_ERROR) break;
    //    SAY("    Device[%d]: %s\n", d, dinfo.name);
    //    auto dd = sm->QueryCaptureManager()->QueryDevice();
    //  }
    //  capture->Release();
    //}
    // Select the color and depth streams
    auto status = sm->EnableStream(PXCCapture::STREAM_TYPE_COLOR, 640, 480, 60);
    status = sm->EnableStream(PXCCapture::STREAM_TYPE_DEPTH, 640, 480, 60);

    // Initialize and Stream Samples
    sm->Init();
  }
Example #7
0
void Arrow3d::RenderArrow(ScreenBase const & screen, ref_ptr<dp::GpuProgram> program,
                          dp::Color const & color, float dz, bool hasNormals)
{
    program->Bind();

    GLFunctions::glBindBuffer(m_bufferId, gl_const::GLArrayBuffer);
    uint32_t const attributePosition = program->GetAttributeLocation("a_pos");
    ASSERT_NOT_EQUAL(attributePosition, -1, ());
    GLFunctions::glEnableVertexAttribute(attributePosition);
    GLFunctions::glVertexAttributePointer(attributePosition, kComponentsInVertex,
                                          gl_const::GLFloatType, false, 0, 0);

    if (hasNormals)
    {
        GLFunctions::glBindBuffer(m_bufferNormalsId, gl_const::GLArrayBuffer);
        uint32_t const attributeNormal = program->GetAttributeLocation("a_normal");
        ASSERT_NOT_EQUAL(attributeNormal, -1, ());
        GLFunctions::glEnableVertexAttribute(attributeNormal);
        GLFunctions::glVertexAttributePointer(attributeNormal, 3, gl_const::GLFloatType, false, 0, 0);
    }

    dp::UniformValuesStorage uniforms;
    math::Matrix<float, 4, 4> const modelTransform = CalculateTransform(screen, dz);
    uniforms.SetMatrix4x4Value("u_transform", modelTransform.m_data);
    glsl::vec4 const c = glsl::ToVec4(color);
    uniforms.SetFloatValue("u_color", c.r, c.g, c.b, c.a);
    dp::ApplyState(m_state, program);
    dp::ApplyUniforms(uniforms, program);
    GLFunctions::glDrawArrays(gl_const::GLTriangles, 0, m_vertices.size() / kComponentsInVertex);
}
Example #8
0
void BezierCurveVisualizer::drawCurve(ref_ptr<MatrixTransform> master)
{
    Vec4 colorRed = Vec4(1.0, 0.0, 0.0, 1.0);
    double t;

    switch (computation)
    {
    case APROXIMATION:
    {
        std::vector<Vec3> points = controlPoints;
        Vec3 p1 = casteljauAproximation(controlPoints, 0.0);
        Vec3 p2 = casteljauAproximation(controlPoints, 0.005);
        drawLine(master, p1, p2, colorRed);
        for (t = 0.01; t <= 1.0; t += 0.005)
        {
            p1 = p2;
            p2 = casteljauAproximation(controlPoints, t);
            drawLine(master.get(), p1, p2, colorRed);
        }
        break;
    }
    case EXACT_COMPUTATION:
    {
        Vec3 p1 = computePointOnCurve(controlPoints, 0.0);
        Vec3 p2 = computePointOnCurve(controlPoints, 0.001);
        drawLine(master, p1, p2, colorRed);
        for (t = 0.002; t <= 1.0; t += 0.001)
        {
            p1 = p2;
            p2 = computePointOnCurve(controlPoints, t);
            drawLine(master.get(), p1, p2, colorRed);
        }
        break;
    }
    //takes just the first 4 points of controlPoints to compute the curve
    case CUBIC_APROXIMATION:
    {
        if (controlPoints.size() < 4)
        {
            if (cover->debugLevel(3))
                fprintf(stderr, "Nicht genügend Kontrollpunkte vorhanden, um eine kubische Bezierkurve zu erzeugen.\n");
        }
        else
        {
            Vec3 p1 = controlPoints[0];
            Vec3 p2 = controlPoints[1];
            Vec3 p3 = controlPoints[2];
            Vec3 p4 = controlPoints[3];

            cubicCasteljauAproximation(master, p1, p2, p3, p4, 4);
        }

        break;
    }
    default:
    {
    }
    }
}
Example #9
0
void Batcher::ChangeBuffer(ref_ptr<CallbacksWrapper> wrapper)
{
  GLState const & state = wrapper->GetState();
  FinalizeBucket(state);

  ref_ptr<RenderBucket> bucket = GetBucket(state);
  wrapper->SetVAO(bucket->GetBuffer());
}
Example #10
0
void StateNode::addFirstChild(const ref_ptr<StateNode> &child)
{
  if(child->parent_!=NULL) {
    child->parent_->removeChild(child.get());
  }
  childs_.push_front(child);
  child->set_parent( this );
}
Example #11
0
// associe un objet light a un objet lightsource
ref_ptr<LightSource> MyView::associeLightASource(ref_ptr<Light> light,ref_ptr<Camera> camera){
	ref_ptr<LightSource> source = new LightSource;
	source->setLight(light);
	if(light->getLightNum() == 0){
		source->setReferenceFrame(LightSource::ABSOLUTE_RF);
	}
	camera->addChild(source);	
	return source;
}
void replication_service_test_app::upload_checkpoint_to_remote_test()
{
    cold_backup_context_ptr backup_context =
        new cold_backup_context(nullptr, request, concurrent_uploading_file_cnt);

    backup_context->start_check();
    backup_context->block_service = block_service.get();
    backup_context->backup_root = backup_root;
    backup_context->_status.store(cold_backup_status::ColdBackupChecking);
    backup_context->_have_check_upload_status.store(false);
    backup_context->_upload_status.store(cold_backup_context::upload_status::UploadInvalid);
    backup_context->_status.store(cold_backup_status::ColdBackupUploading);
    // case1: create metadata_file fail
    {
        std::cout << "testing upload_checkpoint_to_remote, stop with create metadata fail..."
                  << std::endl;
        block_service->enable_create_file_fail = true;
        backup_context->upload_checkpoint_to_remote();
        ASSERT_TRUE(backup_context->status() == cold_backup_status::ColdBackupFailed);
        block_service->enable_create_file_fail = false;
    }
    backup_context->_status.store(cold_backup_status::ColdBackupUploading);
    // case2: create metadata succeed, and metadata is exist
    //  this case will stop when call read_backup_metadata with reason read file fail
    {
        std::cout << "testing upload_checkpoint_to_remote, stop with read metadata file fail..."
                  << std::endl;
        backup_context->_have_check_upload_status.store(false);
        backup_context->_upload_status.store(cold_backup_context::upload_status::UploadInvalid);
        std::string md5 = "test_md5";
        int64_t size = 10;
        backup_metadata_file->enable_read_fail = true;
        backup_metadata_file->file_exist(md5, size);
        backup_context->upload_checkpoint_to_remote();
        ASSERT_TRUE(backup_context->status() == cold_backup_status::ColdBackupFailed);
        backup_metadata_file->clear_file_exist();
        backup_metadata_file->enable_read_fail = false;
    }
    backup_context->_status.store(cold_backup_status::ColdBackupUploading);
    // case3: create metadata succeed, but metadata is not exist
    //  this case will stop after call write_metadata_file with write fail
    {
        std::cout << "testing upload_chekpoint_to_remote, stop with create metadata file fail..."
                  << std::endl;
        backup_context->_have_check_upload_status.store(false);
        backup_context->_upload_status.store(cold_backup_context::upload_status::UploadInvalid);
        backup_metadata_file->enable_write_fail = true;
        backup_context->upload_checkpoint_to_remote();
        ASSERT_TRUE(backup_context->status() == cold_backup_status::ColdBackupFailed);
        backup_metadata_file->enable_write_fail = false;
    }
    ASSERT_TRUE(backup_context->get_count() == 1);
    ASSERT_TRUE(current_chkpt_file->get_count() == 1);
    ASSERT_TRUE(backup_metadata_file->get_count() == 1);
    ASSERT_TRUE(regular_file->get_count() == 1);
}
Example #13
0
PhysicalProps::PhysicalProps(
    const ref_ptr<btMotionState> &motionState,
    const ref_ptr<btCollisionShape> &shape)
: constructInfo_(0,motionState.get(),shape.get()),
  shape_(shape),
  motionState_(motionState)
{
  constructInfo_.m_restitution = 0;
  constructInfo_.m_friction = 1.5;
}
  virtual void draw() {
    glClearColor(0, 1, 1, 1);
    glClear(GL_COLOR_BUFFER_BIT);

    if (sm->AcquireFrame(true) == PXC_STATUS_NO_ERROR) {
      PXCCapture::Sample *sample = sm->QuerySample();
      sample->color()->
      sm->ReleaseFrame();
    }
  }
Example #15
0
void Render(float curTime)
{
    // render
    device->Clear(true, true);

    static float lastTime = -2.0;
    switch(fractalType)
    {
    case JULIA:
        RenderJulia(animationTime += (curTime - lastTime) * animationSpeed * toggleAnimation);
        break;

    case TAILOR:
        RenderTailor(animationTime += (curTime - lastTime) * animationSpeed * toggleAnimation);
        break;

    default:
        assert(!"Fractal is not supported");
        break;
    }

    RenderCommon(curTime);
    lastTime = curTime;

    // here we can take screenshot
    if ( takeScreenShot )
    {
        if ( outputFile.empty() )
        {
            // get time
            static int screenNum = 0;

            ostringstream numSS;
            numSS << screenNum++;
            outputFile = string("screen_") + numSS.str()
        #ifdef SIMPLE_GL_USE_SDL_IMAGE
                       + ".bmp";
        #else // SIMPLE_GL_USE_DEVIL
                       + ".jpg";
        #endif // SIMPLE_GL_USE_SDL_IMAGE
        }

        // screenshot
        ref_ptr<Image> image( device->CreateImage() );
        //device->TakeScreenshot( image.get() );
        image->SaveToFile( outputFile.c_str() );
        outputFile.clear();

        takeScreenShot = false;
    }

#ifndef __ANDROID__
    device->SwapBuffers();
#endif
}
Example #16
0
Vector3f meanFieldVector(ref_ptr<VectorGrid> grid) {
	size_t Nx = grid->getNx();
	size_t Ny = grid->getNy();
	size_t Nz = grid->getNz();
	Vector3f mean(0.);
	for (int ix = 0; ix < Nx; ix++)
		for (int iy = 0; iy < Ny; iy++)
			for (int iz = 0; iz < Nz; iz++)
				mean += grid->get(ix, iy, iz);
	return mean / Nx / Ny / Nz;
}
Example #17
0
double meanFieldStrength(ref_ptr<VectorGrid> grid) {
	size_t Nx = grid->getNx();
	size_t Ny = grid->getNy();
	size_t Nz = grid->getNz();
	double mean = 0;
	for (int ix = 0; ix < Nx; ix++)
		for (int iy = 0; iy < Ny; iy++)
			for (int iz = 0; iz < Nz; iz++)
				mean += grid->get(ix, iy, iz).getR();
	return mean / Nx / Ny / Nz;
}
Example #18
0
void MyPositionController::AnimationStarted(ref_ptr<Animation> anim)
{
  if (m_isPendingAnimation && m_animCreator != nullptr && anim != nullptr &&
      (anim->GetType() == Animation::MapFollow ||
       anim->GetType() == Animation::MapLinear))
  {
    m_isPendingAnimation = false;
    double const kDoNotChangeDuration = -1.0;
    m_animCreator(anim->GetType() == Animation::MapFollow ? anim->GetDuration() : kDoNotChangeDuration);
  }
}
Example #19
0
double rmsFieldStrength(ref_ptr<VectorGrid> grid) {
	size_t Nx = grid->getNx();
	size_t Ny = grid->getNy();
	size_t Nz = grid->getNz();
	double sumB2 = 0;
	for (int ix = 0; ix < Nx; ix++)
		for (int iy = 0; iy < Ny; iy++)
			for (int iz = 0; iz < Nz; iz++)
				sumB2 += grid->get(ix, iy, iz).getR2();
	return std::sqrt(sumB2 / Nx / Ny / Nz);
}
Example #20
0
void AppState::updateNear()
{
    // Assume that the viewing frustum is symmetric.
    double fovy, aspectRatio, cNear, cFar;
    viewer->getCamera()->getProjectionMatrixAsPerspective(fovy, aspectRatio,
                                                          cNear, cFar);
    viewer->getCamera()->setProjectionMatrixAsPerspective(fovy, aspectRatio,
                                                          zNear, cFar);
    stringstream nearStream;
    nearStream << "near: " << zNear;
    zNearText->setText(nearStream.str());
    zNearText->update();
}
Example #21
0
ParaboloidCamera::ParaboloidCamera(
    const ref_ptr<Mesh> &mesh,
    const ref_ptr<Camera> &userCamera,
    GLboolean hasBackFace)
: OmniDirectionalCamera(hasBackFace,GL_FALSE),
  userCamera_(userCamera)
{
  GLuint numLayer = (hasBackFace ? 2 : 1);
  shaderDefine("RENDER_TARGET", hasBackFace ? "DUAL_PARABOLOID" : "PARABOLOID");
  shaderDefine("RENDER_LAYER", REGEN_STRING(numLayer));
  shaderDefine("USE_PARABOLOID_PROJECTION", "TRUE");
  updateFrustum(180.0f, 1.0f,
      userCamera_->near()->getVertex(0),
      userCamera_->far()->getVertex(0),
      GL_FALSE);

  // Set matrix array size
  view_->set_elementCount(numLayer);
  viewInv_->set_elementCount(numLayer);
  viewproj_->set_elementCount(numLayer);
  viewprojInv_->set_elementCount(numLayer);

  // Allocate matrices
  proj_->setUniformDataUntyped(NULL);
  projInv_->setUniformDataUntyped(NULL);
  view_->setUniformDataUntyped(NULL);
  viewInv_->setUniformDataUntyped(NULL);
  viewproj_->setUniformDataUntyped(NULL);
  viewprojInv_->setUniformDataUntyped(NULL);

  // Projection is calculated in shaders.
  proj_->setVertex(0, Mat4f::identity());
  projInv_->setVertex(0, Mat4f::identity());

  // Initialize directions.
  direction_->set_elementCount(numLayer);
  direction_->setUniformDataUntyped(NULL);
  direction_->setVertex(0, Vec3f(0.0,0.0, 1.0));
  if(hasBackFace_)
    direction_->setVertex(1, Vec3f(0.0,0.0,-1.0));

  modelMatrix_ = ref_ptr<ShaderInputMat4>::dynamicCast(mesh->findShaderInput("modelMatrix"));
  pos_ = ref_ptr<ShaderInput3f>::dynamicCast(mesh->positions());
  nor_ = ref_ptr<ShaderInput3f>::dynamicCast(mesh->normals());
  matrixStamp_ = 0;
  positionStamp_ = 0;
  normalStamp_ = 0;

  // initially update shadow maps
  update();
}
Example #22
0
// Create the parts of the local scene graph used to display the final
// results.
Switch* makeTexturesAndGeometry(int width, int height, Switch* sw)
{
    if (!sw)
        sw = new Switch;
    colorTexture = new Texture2D;
    colorTexture->setTextureSize(width, height);
    colorTexture->setInternalFormat(GL_RGBA);
    colorTexture->setFilter(Texture2D::MIN_FILTER, Texture2D::LINEAR);
    colorTexture->setFilter(Texture2D::MAG_FILTER, Texture2D::LINEAR);
    colorTexture->setWrap(Texture::WRAP_S, Texture::CLAMP_TO_EDGE);
    colorTexture->setWrap(Texture::WRAP_T, Texture::CLAMP_TO_EDGE);
    colorTexture->setBorderColor(Vec4(0, 0, 0, 0));

    depthTexture24 = makeDepthTexture(width, height, GL_DEPTH_COMPONENT24);
    if (depthTextureEnum)
        depthTexture = makeDepthTexture(width, height, depthTextureEnum);
    else
        depthTexture = depthTexture24;
    sw->removeChildren(0, sw->getNumChildren());
    sw->addChild(createTextureQuad(colorTexture.get()));
    sw->addChild(createTextureQuad(depthTexture.get()));
    sw->addChild(createTextureQuad(depthTexture24.get()));
    sw->setSingleChildOn(0);
    return sw;
}
void replication_service_test_app::write_backup_metadata_test()
{
    cold_backup_context_ptr backup_context =
        new cold_backup_context(nullptr, request, concurrent_uploading_file_cnt);

    backup_context->start_check();
    backup_context->block_service = block_service.get();
    backup_context->backup_root = backup_root;
    backup_context->_status.store(cold_backup_status::ColdBackupUploading);
    // case1: create backup_metadata file fail
    //  this case has been already tested

    // case2: create backup_metadata file succeed, but write file fail
    //  this case has been already tested

    // case3: create backup_metadata file succeed, and write file succeed
    {
        std::cout << "create backup_metadata_file succeed, and write file succeed..." << std::endl;
        std::string test_file1 = "test_file1";
        std::string test_file2 = "test_file2";
        backup_context->_metadata.checkpoint_decree = 100;

        file_meta f_meta;
        f_meta.name = test_file1;
        f_meta.md5 = "test_file1_md5";
        f_meta.size = 10;
        backup_context->_metadata.files.emplace_back(f_meta);
        f_meta.name = test_file2;
        f_meta.md5 = "test_file2_md5";
        f_meta.size = 11;
        backup_context->_metadata.files.emplace_back(f_meta);

        blob result =
            ::json::json_forwarder<cold_backup_metadata>::encode(backup_context->_metadata);
        std::string value(result.data(), result.length());
        current_chkpt_file->enable_write_fail = true;
        backup_context->write_backup_metadata();
        std::string value_write(backup_metadata_file->context.data(),
                                backup_metadata_file->context.length());
        ASSERT_TRUE(result.data() != backup_metadata_file->context.data());
        ASSERT_TRUE(value == value_write);
        ASSERT_TRUE(backup_context->status() == cold_backup_status::ColdBackupFailed);
        current_chkpt_file->enable_write_fail = false;
        backup_context->_metadata.files.clear();
    }
    ASSERT_TRUE(backup_context->get_count() == 1);
    ASSERT_TRUE(current_chkpt_file->get_count() == 1);
    ASSERT_TRUE(backup_metadata_file->get_count() == 1);
    ASSERT_TRUE(regular_file->get_count() == 1);
}
Example #24
0
void FlightPathVisualizer::loadUnlightedGeostate(ref_ptr<StateSet> state)
{
    ref_ptr<Material> mat = new Material;
    mat->setColorMode(Material::AMBIENT_AND_DIFFUSE);
    mat->setDiffuse(Material::FRONT_AND_BACK, Vec4(0.9f, 0.9f, 0.9f, 1.f));
    mat->setSpecular(Material::FRONT_AND_BACK, Vec4(0.9f, 0.9f, 0.9f, 1.f));
    mat->setAmbient(Material::FRONT_AND_BACK, Vec4(0.2f, 0.2f, 0.2f, 1.f));
    mat->setEmission(Material::FRONT_AND_BACK, Vec4(0.0f, 0.0f, 0.0f, 1.f));
    mat->setShininess(Material::FRONT_AND_BACK, 16.f);
    mat->setTransparency(Material::FRONT_AND_BACK, 1.f); // Noch Wert anpassen für Transparency

    state->setAttributeAndModes(mat, osg::StateAttribute::ON);
    state->setMode(GL_BLEND, osg::StateAttribute::ON);
    state->setRenderingHint(osg::StateSet::TRANSPARENT_BIN);
}
Example #25
0
void AppState::setStateFromConfig(const FboConfig& config)
{
    Camera* camera = viewer->getSlave(0)._camera.get();
    setAttachmentsFromConfig(camera, config);
    osgViewer::Renderer* renderer
        = dynamic_cast<osgViewer::Renderer*>(camera->getRenderer());
    if (renderer)
        renderer->setCameraRequiresSetUp(true);
    if (configText.valid())
    {
        configText->setText(validConfigs[currentConfig].name);
        configText->update();
    }
    updateDisplayedTexture();
}
Example #26
0
void ResizedCallback::resizedImplementation(GraphicsContext* gc, int x, int y,
                                            int width, int height)
{
    gc->resizedImplementation(x, y, width, height);
    makeTexturesAndGeometry(width, height, _appState->sw.get());
    _appState->setStateFromConfig(validConfigs[_appState
                                               ->currentConfig]);
    osgViewer::Viewer* viewer = _appState->viewer;
    Viewport* vp = viewer->getSlave(0)._camera->getViewport();
    if (vp)
    {
        double oldWidth = vp->width(), oldHeight = vp->height();
        double aspectRatioChange
            = (width / oldWidth) / (height / oldHeight);
        vp->setViewport(0, 0, width, height);
        if (aspectRatioChange != 1.0)
        {
            Camera* master = viewer->getCamera();
            switch (master->getProjectionResizePolicy())
            {
            case Camera::HORIZONTAL:
                master->getProjectionMatrix()
                    *= Matrix::scale(1.0/aspectRatioChange,1.0,1.0);
                break;
            case Camera::VERTICAL:
                master->getProjectionMatrix()
                    *= Matrix::scale(1.0, aspectRatioChange,1.0);
                break;
            default:
                break;
            }
        }
    }
}
Example #27
0
 void handleChildren(
     SceneParser *parser,
     SceneInputNode &input,
     const ref_ptr<StateNode> &newNode)
 {
   // Process node children
   const list< ref_ptr<SceneInputNode> > &childs = input.getChildren();
   for(list< ref_ptr<SceneInputNode> >::const_iterator
       it=childs.begin(); it!=childs.end(); ++it)
   {
     const ref_ptr<SceneInputNode> &x = *it;
     // First try node processor
     ref_ptr<NodeProcessor> nodeProcessor = parser->getNodeProcessor(x->getCategory());
     if(nodeProcessor.get()!=NULL) {
       nodeProcessor->processInput(parser, *x.get(), newNode);
       continue;
     }
     // Second try state processor
     ref_ptr<StateProcessor> stateProcessor = parser->getStateProcessor(x->getCategory());
     if(stateProcessor.get()!=NULL) {
       stateProcessor->processInput(parser, *x.get(), newNode->state());
       continue;
     }
     REGEN_WARN("No processor registered for '" << x->getDescription() << "'.");
   }
 }
Example #28
0
void BezierCurveVisualizer::drawLine(ref_ptr<MatrixTransform> master, Vec3 point1, Vec3 point2, Vec4 color, float linewidth)
{
    ref_ptr<Vec3Array> lineCoordList = new Vec3Array(2);
    lineCoordList.get()->at(0) = point1;
    lineCoordList.get()->at(1) = point2;

    ref_ptr<Vec4Array> lineColorList = new Vec4Array;
    lineColorList->push_back(color);

    ref_ptr<Geometry> lineGeoset = new Geometry;
    ref_ptr<StateSet> lineGeoset_state = lineGeoset->getOrCreateStateSet();
    lineGeoset->setVertexArray(lineCoordList);
    lineGeoset->setColorArray(lineColorList);
    lineGeoset->setColorBinding(Geometry::BIND_OVERALL);
    lineGeoset->addPrimitiveSet(new DrawArrays(PrimitiveSet::LINES, 0, 2));
    ref_ptr<LineWidth> lw = new LineWidth(linewidth);
    lineGeoset_state->setAttribute(lw);

    ref_ptr<Material> mtl = new Material;
    mtl->setColorMode(Material::AMBIENT_AND_DIFFUSE);
    mtl->setAmbient(Material::FRONT_AND_BACK, Vec4(0.2f, 0.2f, 0.2f, 1.f));
    mtl->setDiffuse(Material::FRONT_AND_BACK, Vec4(0.9f, 0.9f, 0.9f, 1.f));
    mtl->setSpecular(Material::FRONT_AND_BACK, Vec4(0.9f, 0.9f, 0.9f, 1.f));
    mtl->setEmission(Material::FRONT_AND_BACK, Vec4(0.0f, 0.0f, 0.0f, 1.f));
    mtl->setShininess(Material::FRONT_AND_BACK, 16.f);

    //	lineGeoState->setAttributeAndModes(material, osg::StateAttribute::ON);
    lineGeoset_state->setAttribute(mtl.get());

    ref_ptr<Geode> lineGeode = new Geode;
    lineGeode->addDrawable(lineGeoset);

    master->addChild(lineGeode);
}
Example #29
0
void Furniture::addPart(ref_ptr < AbstractObject > apAbstractObject) {
	addChild(apAbstractObject);

	string strCommand = apAbstractObject->getSQLCommand();

	m_arrSQLCommandLines.push_back(strCommand);
}
Example #30
0
void main_Model3D(ref_ptr<Group> pScene)	{
	ref_ptr<Model3D> pModel3D = new Model3D();

	pModel3D->setColor(Vec4(0.0, 1.0, 0.0, 1.0));
	pModel3D->setIsTargetPick(true);
	pScene->addChild(pModel3D);
}