• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ ViewportPtr类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中ViewportPtr的典型用法代码示例。如果您正苦于以下问题:C++ ViewportPtr类的具体用法?C++ ViewportPtr怎么用?C++ ViewportPtr使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了ViewportPtr类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: createDepthTarget

	RenderTextureTargetPtr createDepthTarget(const CameraPtr& camera, int width, int height)
	{
		ImageTextureConfig config = ImageTextureConfig::createDefault();
		config.width = width;
		config.height = height;
		config.textureAddressMode = TextureAddressMode_Clamp;
		config.format = PixelFormat_DepthComponent24;

		TexturePtr texture(new Texture(config));

		RenderTextureTargetPtr target;

		{
			RenderTextureTargetConfig config;
			config.texture = texture;
			config.attachment = FrameBufferAttachment_Depth;
			config.techniqueCategory = TechniqueCategory_DepthRtt;
			target.reset(new RenderTextureTarget(config));

			{
				ViewportPtr viewport = target->addDefaultViewport(m_camera);
				viewport->setBackgroundColor(glm::vec4(1,1,1,1));
			}

			m_window->addRenderTarget(target);
		}
		return target;
	}
开发者ID:fohr,项目名称:Graphtane,代码行数:28,代码来源:Main.cpp


示例2: display

// redraw the window
void display(void)
{
    mgr->getNavigator()->updateCameraTransformation();

    mgr->getWindow()->activate();
    mgr->getWindow()->frameInit();

    raction->setWindow(getCPtr(mgr->getWindow()));

    ViewportPtr viewport = mgr->getWindow()->getPort(0);

    glClear(GL_ACCUM_BUFFER_BIT);

    for (int i=0; i < JITTERSIZE[activeJitter]; i++) {
        beginEditCP(cameraDecorator);
            cameraDecorator->setOffset(
                (JITTER[activeJitter][i].x() - 0.5) * jitterRadius,
                (JITTER[activeJitter][i].y() - 0.5) * jitterRadius);
        endEditCP(cameraDecorator);

        viewport->render(raction);
    
        glAccum(GL_ACCUM, 1.0f / float(JITTERSIZE[activeJitter]));
        glAccum(GL_RETURN, float(JITTERSIZE[activeJitter]) / float(i + 1));
    }

    glAccum(GL_RETURN, 1.0f);

    mgr->getWindow()->swap();
    mgr->getWindow()->frameExit();
}
开发者ID:mlimper,项目名称:OpenSG1x,代码行数:32,代码来源:32OffsetCameraDecoAntialiasing.cpp


示例3: setCamera

	void setCamera(CameraPtr c)
	{
		_camera = c;
		ViewportPtr vp = _win->getPort(0);
		beginEditCP(vp);
			vp->setCamera(_camera);
		endEditCP(vp);

	}
开发者ID:Himbeertoni,项目名称:OpenSGToolbox,代码行数:9,代码来源:01RubberBandCamera.cpp


示例4: Apply

void StudyPropertiesDlg::Apply()
{
	// set properties based on state of controls in General page
	m_studyLayer->SetName(m_txtLayerName->GetValue().c_str());
	m_studyLayer->SetDescription(m_txtLayerDescription->GetValue().c_str());
	m_studyLayer->SetAuthours(m_txtAuthours->GetValue().c_str());

	// set properties based on state of controls in Projection page
	StudyControllerPtr studyController = m_studyLayer->GetStudyController();
	studyController->SetDatum(m_cboDatum->GetValue().wc_str());
	studyController->SetProjection(m_cboProjection->GetValue().wc_str());

	ViewportPtr viewport = App::Inst().GetViewport();

	// set properties based on state of controls in Symbology page
	viewport->SetBackgroundColour( Colour( m_colourBackground->GetColour() ) );

	if(m_cboTerrainResolution->GetValue() == _T("256"))
		viewport->SetMaxTerrainResolution(256);
	else if(m_cboTerrainResolution->GetValue() == _T("512"))
		viewport->SetMaxTerrainResolution(512);
	else if(m_cboTerrainResolution->GetValue() == _T("1024"))
		viewport->SetMaxTerrainResolution(1024);
	else if(m_cboTerrainResolution->GetValue() == _T("2048"))
		viewport->SetMaxTerrainResolution(2048);
	else if(m_cboTerrainResolution->GetValue() == _T("4096"))
		viewport->SetMaxTerrainResolution(4096);
	else if(m_cboTerrainResolution->GetValue() == _T("8196"))
		viewport->SetMaxTerrainResolution(8196);

	App::Inst().SetSaveStatus( SESSION_NOT_SAVED );
	viewport->Refresh( false );
	App::Inst().GetLayerTreeController()->SetName(m_studyLayer, m_studyLayer->GetName());
}
开发者ID:beiko-lab,项目名称:gengis,代码行数:34,代码来源:StudyPropertiesDlg.cpp


示例5: on_enableCheckBox_toggled

void SkyBackgroundPluginForm::on_enableCheckBox_toggled( bool checked )
{
	vrOSGWidget *gl = vrOSGWidget::getMGLW(-1);
	ViewportPtr vredViewport = gl->getViewport();
	beginEditCP(vredViewport);
	if (checked && skyBackground != NullFC)
		vredViewport->setBackground(skyBackground);
	else if (oldBackground != NullFC)
		vredViewport->setBackground(oldBackground);
	endEditCP(vredViewport);

	enableCheckBox->setChecked(checked); // for scripting
}
开发者ID:ufz-vislab,项目名称:vislab,代码行数:13,代码来源:SkyBackgroundPluginForm.cpp


示例6: getNode

ViewportPtr
Canvas::getViewportAt(const unsigned int theX, const unsigned int theY) const {
    int myViewportCount = getNode().childNodesLength(VIEWPORT_NODE_NAME);
    for (int i = myViewportCount-1; i >= 0; --i) {
        dom::NodePtr myViewportNode = getNode().childNode(VIEWPORT_NODE_NAME,i);
        ViewportPtr myViewport = myViewportNode->getFacade<Viewport>();
        int myTop = 0;
        int myLeft = 0;
        unsigned int myWidth = 0;
        unsigned int myHeight = 0;
        if (myViewport->getTop(myTop) && myViewport->getHeight(myHeight) && 
            myViewport->getWidth(myWidth) && myViewport->getLeft(myLeft) && 
            myTop <= static_cast<int>(theY) &&
            myHeight + myTop >= theY &&
            myLeft <= static_cast<int>(theX) &&
            myLeft + myWidth >= theX)
        {
            return myViewport;
        }
    }
    return ViewportPtr(0);
}
开发者ID:artcom,项目名称:y60,代码行数:22,代码来源:Canvas.cpp


示例7: beginEditCP

void OpenSGWidget::initializeGL()
{
    pwin->init();

    // create a gradient background.
    GradientBackgroundPtr gback = GradientBackground::create();
    beginEditCP(gback, GradientBackground::LineFieldMask);
        gback->clearLines();
        gback->addLine(Color3f(0.7, 0.7, 0.8), 0);
        gback->addLine(Color3f(0.0, 0.1, 0.3), 1);
    endEditCP(gback, GradientBackground::LineFieldMask);

    beginEditCP(pwin);
        for(int i=0;i<pwin->getPort().size();++i)
        {
            ViewportPtr vp = pwin->getPort()[i];
            beginEditCP(vp);
                vp->setBackground(gback);
            endEditCP(vp);
        }
    endEditCP(pwin);

    _initialized = true;
}
开发者ID:mlimper,项目名称:OpenSG1x,代码行数:24,代码来源:testPassiveMTQT4.cpp


示例8: SkyBackgroundPluginFormBase

SkyBackgroundPluginForm::SkyBackgroundPluginForm( QWidget* parent /*= 0*/, const char* name /*= 0*/, WFlags fl /*= 0*/ )
	: SkyBackgroundPluginFormBase(parent, name, fl)
{

	settings.setPath("UFZ", "VRED-SkyBackgroundPlugin");

	skyDir = QDir(settings.readEntry("presetDir", "D:/Data/SkyBackgrounds"));
	presetDirLineEdit->setText(skyDir.absPath());

	presetDirs[0] = QDir("NiceDay");
	//presetDirs[1] = QDir("NiceDay/1024");
	//presetDirs[2] = QDir("NiceDay/512");

	skyBackground = NullFC;
	vrOSGWidget *gl = vrOSGWidget::getMGLW(-1);
	ViewportPtr vredViewport = gl->getViewport();
	oldBackground = vredViewport->getBackground();

	for (int i = 0; i < 6; i++)
	{
		images[i] = Image::create();

		textures[i] = TextureChunk::create();
		beginEditCP(textures[i]);
		textures[i]->setMinFilter( GL_LINEAR );
		textures[i]->setMagFilter( GL_LINEAR );
		textures[i]->setWrapS    ( GL_CLAMP_TO_EDGE );	// other clamping causes black seams on the edges
		textures[i]->setWrapT    ( GL_CLAMP_TO_EDGE );	// of the sky cube because of gl_linear filtering
		textures[i]->setWrapR    ( GL_CLAMP_TO_EDGE );
		textures[i]->setEnvMode  ( GL_REPLACE );
		endEditCP(textures[i]);
	}

	LightDistanceExSlider->setRange(1, 10000);
	LightDistanceExSlider->setValue(1000);
}
开发者ID:ufz-vislab,项目名称:vislab,代码行数:36,代码来源:SkyBackgroundPluginForm.cpp


示例9: main


//.........这里部分代码省略.........
    Restart1 = TutorialDialog->addDialog("Restart", 0.0, NullFC, false, RestartEnd1);
    End1 = TutorialDialog->addDialog("End", 0.0, NullFC, false, RestartEnd1);
    Restart2 = TutorialDialog->addDialog("Restart", 0.0, NullFC, false, RestartEnd2);
    End2 = TutorialDialog->addDialog("End", 0.0, NullFC, false, RestartEnd2);
    Restart3 = TutorialDialog->addDialog("Restart", 0.0, NullFC, false, RestartEnd3);
    End3 = TutorialDialog->addDialog("End", 0.0, NullFC, false, RestartEnd3);
    Restart4 = TutorialDialog->addDialog("Restart", 0.0, NullFC, false, RestartEnd4);
    End4 = TutorialDialog->addDialog("End", 0.0, NullFC, false, RestartEnd4);

    TutorialDialogListener TheTutorialDialogListener;
    rootDialog->addDialogListener(&TheTutorialDialogListener);
    RootDialogChildA->addDialogListener(&TheTutorialDialogListener);
    RootDialogChildB->addDialogListener(&TheTutorialDialogListener);
    ADialogChildA->addDialogListener(&TheTutorialDialogListener);
    ADialogChildB->addDialogListener(&TheTutorialDialogListener);
    BDialogChildA->addDialogListener(&TheTutorialDialogListener);
    BDialogChildB->addDialogListener(&TheTutorialDialogListener);
    Restart1->addDialogListener(&TheTutorialDialogListener);
    End1->addDialogListener(&TheTutorialDialogListener);
    Restart2->addDialogListener(&TheTutorialDialogListener);
    End2->addDialogListener(&TheTutorialDialogListener);
    Restart3->addDialogListener(&TheTutorialDialogListener);
    End3->addDialogListener(&TheTutorialDialogListener);
    Restart4->addDialogListener(&TheTutorialDialogListener);
    End4->addDialogListener(&TheTutorialDialogListener);

    SelectableDialogChildA->addDialogListener(&TheTutorialDialogListener);
    SelectableDialogChildB->addDialogListener(&TheTutorialDialogListener);
    RestartEnd1->addDialogListener(&TheTutorialDialogListener);
    RestartEnd2->addDialogListener(&TheTutorialDialogListener);
    RestartEnd3->addDialogListener(&TheTutorialDialogListener);
    RestartEnd4->addDialogListener(&TheTutorialDialogListener);
    
    LayoutPtr MainInternalWindowLayout = osg::FlowLayout::create();
    
    // Create The Main InternalWindow
    // Create Background to be used with the Main InternalWindow
    MainInternalWindowBackground = osg::ColorLayer::create();
    MainInternalWindow = osg::InternalWindow::create();
    beginEditCP(MainInternalWindowBackground, ColorLayer::ColorFieldMask);
        MainInternalWindowBackground->setColor(Color4f(1.0,1.0,1.0,0.5));
    endEditCP(MainInternalWindowBackground, ColorLayer::ColorFieldMask);
	beginEditCP(MainInternalWindow, InternalWindow::ChildrenFieldMask | InternalWindow::LayoutFieldMask | InternalWindow::BackgroundsFieldMask | InternalWindow::AlignmentInDrawingSurfaceFieldMask | InternalWindow::ScalingInDrawingSurfaceFieldMask | InternalWindow::DrawTitlebarFieldMask | InternalWindow::ResizableFieldMask);
       MainInternalWindow->setLayout(MainInternalWindowLayout);
       MainInternalWindow->setBackgrounds(MainInternalWindowBackground);
	   MainInternalWindow->setAlignmentInDrawingSurface(Vec2f(0.5f,0.5f));
	   MainInternalWindow->setScalingInDrawingSurface(Vec2f(0.5f,0.5f));
	   MainInternalWindow->setDrawTitlebar(false);
	   MainInternalWindow->setResizable(false);
    endEditCP(MainInternalWindow, InternalWindow::ChildrenFieldMask | InternalWindow::LayoutFieldMask | InternalWindow::BackgroundsFieldMask | InternalWindow::AlignmentInDrawingSurfaceFieldMask | InternalWindow::ScalingInDrawingSurfaceFieldMask | InternalWindow::DrawTitlebarFieldMask | InternalWindow::ResizableFieldMask);

    beginEditCP(TutorialDialogInterface, DialogInterface::ComponentGeneratorFieldMask | DialogInterface::ParentContainerFieldMask | DialogInterface::SourceDialogHierarchyFieldMask);
        TutorialDialogInterface->setComponentGenerator(TutorialDialogGenerator);
        TutorialDialogInterface->setParentContainer(MainInternalWindow);
        TutorialDialogInterface->setSourceDialogHierarchy(TutorialDialog);
    endEditCP(TutorialDialogInterface, DialogInterface::ComponentGeneratorFieldMask | DialogInterface::ParentContainerFieldMask | DialogInterface::SourceDialogHierarchyFieldMask);

    // Create the Drawing Surface
    UIDrawingSurfacePtr TutorialDrawingSurface = UIDrawingSurface::create();
    beginEditCP(TutorialDrawingSurface, UIDrawingSurface::GraphicsFieldMask | UIDrawingSurface::EventProducerFieldMask);
        TutorialDrawingSurface->setGraphics(TutorialGraphics);
        TutorialDrawingSurface->setEventProducer(TutorialWindowEventProducer);
    endEditCP(TutorialDrawingSurface, UIDrawingSurface::GraphicsFieldMask | UIDrawingSurface::EventProducerFieldMask);
    
	TutorialDrawingSurface->openWindow(MainInternalWindow);
	
	// Create the UI Foreground Object
    UIForegroundPtr TutorialUIForeground = osg::UIForeground::create();

    beginEditCP(TutorialUIForeground, UIForeground::DrawingSurfaceFieldMask);
        TutorialUIForeground->setDrawingSurface(TutorialDrawingSurface);
    endEditCP(TutorialUIForeground, UIForeground::DrawingSurfaceFieldMask);

    mgr->setRoot(scene);

    // Add the UI Foreground Object to the Scene
    ViewportPtr TutorialViewport = mgr->getWindow()->getPort(0);
    beginEditCP(TutorialViewport, Viewport::ForegroundsFieldMask);
        TutorialViewport->getForegrounds().push_back(TutorialUIForeground);
    beginEditCP(TutorialViewport, Viewport::ForegroundsFieldMask);

    // Show the whole Scene
    mgr->showAll();
    SoundManager::the()->setCamera(mgr->getCamera());

    TutorialDialog->start();

    Vec2f WinSize(TutorialWindowEventProducer->getDesktopSize() * 0.85f);
    Pnt2f WinPos((TutorialWindowEventProducer->getDesktopSize() - WinSize) *0.5);
    TutorialWindowEventProducer->openWindow(WinPos,
            WinSize,
            "07DialogTypeTwo");

    //Enter main Loop
    TutorialWindowEventProducer->mainLoop();

    osgExit();

    return 0;
}
开发者ID:Himbeertoni,项目名称:OpenSGToolbox,代码行数:101,代码来源:07DialogTypeTwo.cpp


示例10: main


//.........这里部分代码省略.........
    root->addChild(dlight);
    endEditCP(root);

    // Load the file
    NodePtr     fileRoot = Node::create();

    //  OSGActivateColMatPtr colMat = OSGActivateColMat::create();
    GroupPtr    gr = Group::create();

    beginEditCP(fileRoot);

    //  fileRoot->setCore(colMat);
    fileRoot->setCore(gr);
    endEditCP(fileRoot);

    beginEditCP(dlight);
    dlight->addChild(fileRoot);
    endEditCP(dlight);

    //   for(UInt32 numFiles = 1; numFiles < argc; numFiles++)
    //    {
    //       file = SceneFileHandler::the().read(argv[1]);
    file = loader.getRootNode();
    beginEditCP(fileRoot);
    fileRoot->addChild(file);
    fileRoot->invalidateVolume();
    endEditCP(fileRoot);

    //    }
    dlight->updateVolume();

    Vec3f   min, max;
    dlight->getVolume().getBounds(min, max);

    std::cout << "Volume: from " << min << " to " << max << std::endl;

    //std::cerr << "Tree: " << std::endl;
    //root->dump();
    // Camera
    PerspectiveCameraPtr    cam = PerspectiveCamera::create();

    cam->setBeacon(b1n);
    cam->setFov(deg2rad(60));
    cam->setNear(1.);
    cam->setFar(100000.);

    // Background
    GradientBackgroundPtr   bkgnd = GradientBackground::create();

    bkgnd->addLine(Color3f(0, 0, 0), 0);
    bkgnd->addLine(Color3f(.5, .5, 0), 0.5);
    bkgnd->addLine(Color3f(.7, .7, 1), 0.5);
    bkgnd->addLine(Color3f(0, 0, 1), 1);

    // Viewport
    ViewportPtr vp = Viewport::create();
    vp->setCamera(cam);
    vp->setBackground(bkgnd);
    vp->setRoot(root);
    vp->setSize(0, 0, 1, 1);

    // Window
    std::cout << "GLUT winid: " << winid << std::endl;

    GLUTWindowPtr   gwin;

    GLint           glvp[4];
    glGetIntegerv(GL_VIEWPORT, glvp);

    gwin = GLUTWindow::create();
    gwin->setId(winid);
    gwin->setSize(glvp[2], glvp[3]);

    win = gwin;

    win->addPort(vp);

    // Actions
    dact = DrawAction::create();
    ract = RenderAction::create();

    // tball
    /*
	Vec3f pos(min[0] + 0.5 * (max[0] - min[0]),
              min[1] + 0.5 * (max[1] - min[1]),
              max[2] + 1.5 * (max[2] - min[2]));
*/
    Vec3f   pos(0, 0, max[2] + 1.5 * (max[2] - min[2]));

    tball.setMode(Trackball::OSGObject);
    tball.setStartPosition(pos, true);
    tball.setSum(true);
    tball.setTranslationMode(Trackball::OSGFree);
    tball.setTranslationScale(10000.);

    // run...
    glutMainLoop();

    return 0;
}
开发者ID:mlimper,项目名称:OpenSG1x,代码行数:101,代码来源:testBINLoader.cpp


示例11: it


//.........这里部分代码省略.........
					endEditCP(textures[0]);
					vrLog::info("Sky Background: Left/West image loaded.");
					imageLoaded[5] = true;
				}
				endEditCP(images[0]);
			}

			++it;
		}

		skyBackground = SkyBackground::create();
		beginEditCP(skyBackground);
		if (!zUp)
		{
			skyBackground->setFrontTexture(textures[5]);
			skyBackground->setBackTexture(textures[4]);
			skyBackground->setBottomTexture(textures[3]);
			skyBackground->setTopTexture(textures[2]);
			skyBackground->setRightTexture(textures[1]);
			skyBackground->setLeftTexture(textures[0]);
		}
		else
		{
			skyBackground->setFrontTexture(textures[3]);
			skyBackground->setBackTexture(textures[2]);
			skyBackground->setBottomTexture(textures[4]);
			skyBackground->setTopTexture(textures[5]);
			skyBackground->setRightTexture(textures[1]);
			skyBackground->setLeftTexture(textures[0]);
		}
		endEditCP(skyBackground);

		vrOSGWidget *gl = vrOSGWidget::getMGLW(-1);
		ViewportPtr vredViewport = gl->getViewport();
		//oldBackground = vredViewport->getBackground();
		beginEditCP(vredViewport);
		vredViewport->setBackground(skyBackground);
		endEditCP(vredViewport);

		directoryLineEdit->setText(dir.absPath());

		// read light settings
		if (SetLightingCheckBox->isChecked())
		{
			string lightName = LightNameLineEdit->text().ascii();
			if (!QFile::exists(dir.absPath() + "/LightSettings.xml"))
				vrLog::warning("Light Settings not found.");
			else
			{
				QFile* file = new QFile(dir.absPath() + "/LightSettings.xml");
				if (file->open(IO_ReadOnly))
				{
					LightSettingsHandler handler;
					QXmlSimpleReader reader;
					reader.setContentHandler(&handler);
					reader.setErrorHandler(&handler);
					QXmlInputSource source(file);
					reader.parse(source);
					file->close();
					handler.direction.normalize();

					vector<NodePtr> lights;
					vrLights::getLights(lights);
					bool lightSet = false;
					for (vector<NodePtr>::const_iterator it = lights.begin();
						it != lights.end(); ++it)
开发者ID:ufz-vislab,项目名称:vislab,代码行数:67,代码来源:SkyBackgroundPluginForm.cpp


示例12: Vector4

VOID Editor::Run()
{
	// check the window rect
	RECT wnd_rc; ::GetClientRect(mWnd, &wnd_rc);
	I32 wnd_width = wnd_rc.right-wnd_rc.left;
	I32 wnd_height = wnd_rc.bottom-wnd_rc.top;
	if(wnd_width<=0||wnd_height<=0) return;

	// get the frame time
	static U32 system_time = Timer::instance().time();
	U32 current_time = Timer::instance().time();
	U32 frame_time = current_time - system_time;
	if(frame_time == 0) return;
	system_time = current_time;

	if(mGraphPtr==NULL) return;

	// reset the render context
	mGraphPtr->Reset();

	// get the window rect	
	Vector4 rect = Vector4(wnd_rc.left, wnd_rc.top, wnd_rc.right, wnd_rc.bottom);

	// set the viewport
	mGraphPtr->viewport(rect);
	ViewportPtr viewport = GNEW(Viewport(rect[0],rect[1],rect[2],rect[3])); CHECK(viewport);
	mGraphPtr->draw(static_cast<Operation*>(viewport.Ptr()));

	// set the scissor
	ScissorPtr scissor = GNEW(Scissor(rect[0],rect[1],rect[2],rect[3]));
	mGraphPtr->draw(static_cast<Operation*>(scissor.Ptr()));

	// clear the target and the zbuffer
	ClearPtr clear = GNEW(Clear(Clear::CT_COLOR|Clear::CT_DEPTH,Vector4(0.5,0.5,0.5,1.0),1.0f)); CHECK(clear);
	mGraphPtr->draw(static_cast<Operation*>(clear.Ptr()));

	// make the projection and the view
	F32 left	= -P2U(wnd_width/2)*mScale;
	F32 right	= P2U(wnd_width/2)*mScale;
	F32 bottom	= -P2U(wnd_height/2)*mScale;
	F32 top		= P2U(wnd_height/2)*mScale;
	F32 znear	= -512.0;
	F32 zfar	= 512.0;
	mGraphPtr->projection(Matrix::makeOrtho(left,right,bottom,top,znear,zfar));
	mGraphPtr->view(Matrix::makeTranslate(-mEye));

	// draw the map
	if(mMapPtr)
	{
		// update the map
		Vector3 start(rect[0], rect[1], 0);
		mGraphPtr->unproject(start, start);
		Vector3 end(rect[2], rect[3], 0);
		mGraphPtr->unproject(end, end);
		mMapPtr->Update(Vector4(start[0], start[1], end[0], end[1]));

		// draw the map
		mMapPtr->Draw(mGraphPtr.Ptr());

		// draw the reference line
		if(mDrawGrid)
		{
			mMapPtr->DrawReferenceLine(mGraphPtr.Ptr());
		}		
	}	

	// draw the brush
	if(mBrushPtr) mBrushPtr->Draw(mGraphPtr.Ptr());

	// swap the graph buffer
	mGraphPtr->swap();

	// swap buffers
	eglSwapBuffers(mDisplay, mSurface);
}
开发者ID:sundoom,项目名称:glow,代码行数:75,代码来源:Editor.cpp


示例13: main

int main(int argc, char **argv)
{
    osgInit(argc,argv);

    // GLUT init
    glutInit(&argc, argv);
    glutInitDisplayMode(GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE);
    
    int id=glutCreateWindow("OpenSG");
    
    glutReshapeFunc(reshape);
    glutDisplayFunc(display);
    glutIdleFunc(display);
    glutMouseFunc(mouse);
    glutMotionFunc(motion);
    glutKeyboardFunc(keyboard);

    GLUTWindowPtr gwin=GLUTWindow::create();
    gwin->setId(id);
    gwin->init();

    // create the scene
//    NodePtr scene = makeTorus(.5, 2, 16, 16);
    NodePtr scene = Node::create();
    beginEditCP(scene);
    scene->setCore(Group::create());
    endEditCP(scene);

    // create the SimpleSceneManager helper
    mgr = new SimpleSceneManager;

    // tell the manager what to manage
    mgr->setWindow(gwin );
    mgr->setRoot  (scene);
    
    DisplayFilterForegroundPtr fg = DisplayFilterForeground::create();

    beginEditCP(fg);
    // add filter
    endEditCP(fg);

    // take the viewport
    ViewportPtr vp = gwin->getPort(0);

    beginEditCP(vp);
    vp->editMFForegrounds()->push_back(fg);    
    endEditCP  (vp);

    colorFilterPtr = ColorDisplayFilter::create();
    distortionFilterPtr = DistortionDisplayFilter::create();
    resolutionFilterPtr = ResolutionDisplayFilter::create();

    beginEditCP(colorFilterPtr);
    beginEditCP(resolutionFilterPtr);
    beginEditCP(distortionFilterPtr);
    beginEditCP(fg);
    colorFilterPtr->setMatrix(osg::Matrix(0,0,1,0,
                                          1,0,0,0,
                                          0,1,0,0,
                                          0,0,0,1));
    resolutionFilterPtr->setDownScale(0.25);

    distortionFilterPtr->setColumns(2);
    distortionFilterPtr->setRows(2);
    distortionFilterPtr->editMFPositions()->push_back(Vec2f(0,.5));
    distortionFilterPtr->editMFPositions()->push_back(Vec2f(.5,0));
    distortionFilterPtr->editMFPositions()->push_back(Vec2f(.5,1));
    distortionFilterPtr->editMFPositions()->push_back(Vec2f(1,.5));
    
    fg->editMFFilter()->push_back(colorFilterPtr);
    fg->editMFFilter()->push_back(resolutionFilterPtr);
    fg->editMFFilter()->push_back(distortionFilterPtr);

    endEditCP(distortionFilterPtr);
    endEditCP(colorFilterPtr);
    endEditCP(resolutionFilterPtr);
    endEditCP(fg);

    for(UInt32 a=1 ; a<argc ;a++)
    {
        NodePtr file = SceneFileHandler::the().read(argv[a],0);
        if(file != NullFC)
            scene->addChild(file);
        else
            std::cerr << "Couldn't load file, ignoring " << argv[a] << std::endl;
    }
	if ( scene->getNChildren() == 0 )
	{
        scene->addChild(makeTorus( .5, 2, 16, 16 ));
//        scene->addChild(makeBox(.6,.6,.6,5,5,5));
    }

    // show the whole scene
    mgr->showAll();
    
    // GLUT main loop
    glutMainLoop();

    return 0;
}
开发者ID:mlimper,项目名称:OpenSG1x,代码行数:100,代码来源:testDisplayFilter.cpp


示例14: main

// Initialize GLUT & OpenSG and set up the scene
int main(int argc, char **argv)
{
    // OSG init
    glutInit(&argc, argv);
    osgInit(argc, argv);

    std::string fontfile("testfont.ttf");
    std::string testtext("Test Text");
    UInt32 drawmode;
    
    if(argc > 1)
        testtext = argv[1];
    if(argc > 2)
        fontfile = argv[2];
    if(argc < 4 || sscanf(argv[3], "%d", &drawmode) != 1 )
        drawmode = FTGLFont::Outline;
        
    // GLUT 
    int winid = setupGLUT(&argc, argv);
    GLUTWindowPtr gwin= GLUTWindow::create();
    gwin->setId(winid);
    gwin->init();
   
    
    // Create the Cubes node

    NodePtr scene = makeCoredNode<Group>();

    beginEditCP(scene);
    
    scene->addChild( makeBox(200,200,200, 1,1,1) );
//    scene->addChild( SceneFileHandler::the().read("tie.wrl") );
    endEditCP(scene);


    // Create the text
    
    FTGLFontPtr font = FTGLFont::create();
    
    beginEditCP(font);
    font->setName(fontfile);
    font->setDrawType(drawmode);
    font->setSize(40);
    font->setRes(72);
    font->setDepth(20);
    endEditCP(font);

    FTGLTextPtr text;
    NodePtr tnode = makeCoredNode<FTGLText>(&text);
    
    beginEditCP(text);
    text->setFont(font);
    text->setText(testtext);
    text->setPosition(Pnt3f(0,300,0));
    text->setMaterial(getDefaultMaterial());      
    endEditCP(text);
    

    beginEditCP(scene);
    scene->addChild(tnode);
    endEditCP(scene);
    
    
    // create the SimpleSceneManager helper
    mgr = new SimpleSceneManager;

    // tell the manager what to manage
    mgr->setWindow(gwin );
    mgr->setRoot  (scene);

    // show the whole scene
    mgr->showAll();
        
    // copy to second window 
    int winid2 = setupGLUT(&argc, argv);
    gwin2= GLUTWindow::create();
    gwin2->setId(winid2);
    gwin2->init();
    
    ViewportPtr ovp = gwin->getPort()[0];
    
    ViewportPtr vp = Viewport::create();
    
    beginEditCP(vp);
    vp->setLeft(0);
    vp->setRight(400);
    vp->setBottom(0);
    vp->setTop(400);
    vp->setCamera(ovp->getCamera());
    vp->setRoot(ovp->getRoot());
    vp->setBackground(ovp->getBackground());
    vp->setParent(gwin2);
    endEditCP(vp);
    
    beginEditCP(gwin2);
    gwin2->getPort().push_back(vp);
    endEditCP(gwin2);
    
    // GLUT main loop
//.........这里部分代码省略.........
开发者ID:mlimper,项目名称:OpenSG1x,代码行数:101,代码来源:testFTGLText.cpp


示例15: setHServers

void MultiDisplayWindow::serverRender(WindowPtr         serverWindow,
                                      UInt32            id,
                                      DrawActionBase *action )
{
    TileCameraDecoratorPtr deco;
    ViewportPtr serverPort;
    ViewportPtr clientPort;
    StereoBufferViewportPtr clientStereoPort;
    UInt32 sv,cv;
    Int32 l,r,t,b;
    Int32 cleft,cright,ctop,cbottom;

    // sync, otherwise viewports will be out of date

    if(!getHServers())
    {
        setHServers(getServers().size());
    }
    if(!getVServers())
    {
        setVServers(1);
    }

    UInt32 row   =id/getHServers();
    UInt32 column=id%getHServers();

    // calculate width and height from local width and height
    UInt32 width  = serverWindow->getWidth() ;
    UInt32 height = serverWindow->getHeight();

    if(getWidth()==0)
    {
        setWidth( width*getHServers() );
    }
    if(getHeight()==0)
    {
        setHeight( height*getVServers() );
    }

    Int32 left   = column * width  - column * getXOverlap();
    Int32 bottom = row    * height - row    * getYOverlap();
    Int32 right  = left   + width  - 1;
    Int32 top    = bottom + height - 1;
    Real64 scaleCWidth  =
        ((width - getXOverlap()) * (getHServers() - 1) + width) /
        (float)getWidth();
    Real64 scaleCHeight =
        ((height - getYOverlap())* (getVServers() - 1) + height)/
        (float)getHeight();

    bool   isVirtualPort = false;

    // duplicate viewports
    for(cv = 0, sv = 0; cv < getPort().size(); ++cv)
    {
        clientPort = getPort()[cv];

#if 0
        isVirtualPort = clientPort->getType().isDerivedFrom(FBOViewport::getClassType());

        if(isVirtualPort)
        {
            // TODO -- seems wrong to render this on all servers, though rendering
            // then transmitting the texture doesn't seem like a good idea either.
            if(serverWindow->getPort().size() <= sv)
            {
                serverPort = ViewportPtr::dcast(clientPort->shallowCopy());
                beginEditCP(serverWindow);
                serverWindow->addPort(serverPort);
                endEditCP(serverWindow);
            }
            else
            {
                serverPort = serverWindow->getPort()[sv];
                if(serverWindow->getPort()[sv]->getType() !=
                        clientPort->getType())
                {
                    // there is a viewport with the wrong type
                    subRefCP(serverWindow->getPort()[sv]);
                    serverPort = ViewportPtr::dcast(clientPort->shallowCopy());
                    beginEditCP(serverWindow);
                    {
                        serverWindow->getPort()[sv] = serverPort;
                    }
                    endEditCP(serverWindow);
                }
            }
            // update changed viewport fields
            updateViewport(serverPort,clientPort);
        }
        else
#endif
        {
            clientStereoPort =
                dynamic_cast<StereoBufferViewportPtr>(clientPort);

            cleft   = (Int32)(clientPort->getPixelLeft()      * scaleCWidth)   ;
            cbottom = (Int32)(clientPort->getPixelBottom()    * scaleCHeight)  ;
            cright  = (Int32)((clientPort->getPixelRight()+1) * scaleCWidth) -1;
            ctop    = (Int32)((clientPort->getPixelTop()+1)   * scaleCHeight)-1;
//.........这里部分代码省略.........
开发者ID:rdgoetz,项目名称:OpenSGDevMaster_Toolbox,代码行数:101,代码来源:OSGMultiDisplayWindow.cpp


示例16: main

int main(int argc, char **argv)
{
    osgInit(argc,argv);

    // GLUT init
    glutInit(&argc, argv);
    
    bool stereobuffer = false;
    bool amberblue = false;
    if(argc >= 2 && !strcmp(argv[1],"-s"))
    {
        stereobuffer = true;
        --argc, ++argv;
    }
    if(argc >= 2 && !strcmp(argv[1],"-a"))
    {
        amberblue = true;
        --argc, ++argv;
    }
    
    
    glutInitDisplayMode(GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE |
                        (stereobuffer?GLUT_STEREO:0) );
    
    glutCreateWindow("OpenSG");
    
    glutReshapeFunc(reshape);
    glutDisplayFunc(display);
    glutIdleFunc(display);
    glutMouseFunc(mouse);
    glutMotionFunc(motion);
    glutKeyboardFunc(keyboard);

    PassiveWindowPtr pwin=PassiveWindow::create();
    pwin->init();

    // create the scene
    NodePtr scene;
    
    if(argc > 1)
    {
        scene = SceneFileHandler::the().read(argv[1]);
    }
    else
    {
        scene = makeBox(2,2,2, 1,1,1);
    }

    // create the SimpleSceneManager helper
    mgr = new SimpleSceneManager;

    // create the window and initial camera/viewport
    mgr->setWindow(pwin );
    // tell the manager what to manage
    mgr->setRoot  (scene);
    
    // now create the second vp for stereo
    ViewportPtr vp = pwin->getPort(0);
    
    PerspectiveCameraPtr cam = PerspectiveCameraPtr::dcast(vp->getCamera());
    beginEditCP(cam);
    cam->setFov(deg2rad(90));
    cam->setAspect(1);
    endEditCP  (cam);

    Navigator *nav = mgr->getNavigator();
    nav->setAt(Pnt3f(0,0,0));
    nav->setDistance(1.5);
    
    mgr->showAll();
    
    // create the decorators and the second viewport
    ViewportPtr vpleft,vpright;
       
    decoleft = ShearedStereoCameraDecorator::create();
    decoright = ShearedStereoCameraDecorator::create();
    
    beginEditCP(decoleft);
    decoleft->setEyeSeparation(ed);
    decoleft->setZeroParallaxDistance(zpp);
    decoleft->setLeftEye(true);  
    decoleft->setDecoratee(cam);  
    endEditCP  (decoleft);
    
    beginEditCP(decoright);
    decoright->setEyeSeparation(ed);
    decoright->setZeroParallaxDistance(zpp);
    decoright->setLeftEye(false);  
    decoright->setDecoratee(cam);  
    endEditCP  (decoright);

    if(amberblue)
    {
        ColorBufferViewportPtr svpleft = ColorBufferViewport::create();
        ColorBufferViewportPtr svpright = ColorBufferViewport::create();
 
        beginEditCP(svpleft);
        svpleft->setLeft(0);
        svpleft->setRight(1);
        svpleft->setBottom(0);
//.........这里部分代码省略.........
开发者ID:mlimper,项目名称:OpenSG1x,代码行数:101,代码来源:testStereoDecorator.cpp


示例17: beginEditCP

void ApplicationBuilder::attachApplication(void)
{
	Inherited::attachApplication();

	beginEditCP(ApplicationBuilderPtr(this) , ApplicationBuilder::EditingProjectFieldMask);
		setEditingProject(MainApplication::the()->getProject());
	endEditCP(ApplicationBuilderPtr(this) , ApplicationBuilder::EditingProjectFieldMask);

	
	//Camera Beacon
	Matrix TransformMatrix;
	TransformPtr CameraBeaconTransform = Transform::create();
	beginEditCP(CameraBeaconTransform, Transform::MatrixFieldMask);
		CameraBeaconTransform->setMatrix(TransformMatrix);
	endEditCP(CameraBeaconTransform, Transform::MatrixFieldMask);

	NodePtr CameraBeaconNode = Node::create();
	beginEditCP(CameraBeaconNode, Node::CoreFieldMask);
		CameraBeaconNode->setCore(CameraBeaconTransform);
	endEditCP(CameraBeaconNode, Node::CoreFieldMask);

    // Make Main Scene Node empty
    NodePtr DefaultRootNode = osg::Node::create();
    beginEditCP(DefaultRootNode, Node::CoreFieldMask | Node::ChildrenFieldMask);
        DefaultRootNode->setCore(osg::Group::create());
        DefaultRootNode->addChild(CameraBeaconNode);
    endEditCP(DefaultRootNode, Node::CoreFieldMask | Node::ChildrenFieldMask);
	
	//Camera
	PerspectiveCameraPtr DefaultCamera = PerspectiveCamera::create();
	beginEditCP(DefaultCamera);
		DefaultCamera->setBeacon(CameraBeaconNode);
		DefaultCamera->setFov   (deg2rad(60.f));
		DefaultCamera->setNear  (0.1f);
		DefaultCamera->setFar   (10000.f);
	endEditCP(DefaultCamera);

	//Background
	SolidBackgroundPtr DefaultBackground = SolidBackground::create();
	beginEditCP(DefaultBackground, SolidBackground::ColorFieldMask);
		DefaultBackground->setColor(Color3f(0.0f,0.0f,0.0f));
	endEditCP(DefaultBackground, SolidBackground::ColorFieldMask);

	//Icon Manager
	_IconManager = DefaultIconManager::create();
	
	//User Interface
	ForegroundPtr UserInterfaceForeground = createInterface();
    beginEditCP(_TheBuilderInterface->getDrawingSurface(), UIDrawingSurface::EventProducerFieldMask);
        _TheBuilderInterface->getDrawingSurface()->setEventProducer(MainApplication::the()->getMainWindowEventProducer());
    endEditCP(_TheBuilderInterface->getDrawingSurface(), UIDrawingSurface::EventProducerFieldMask);

	//Viewport
	if(MainApplication::the()->getMainWindowEventProducer()->getWindow() != NullFC && MainApplication::the()->getMainWindowEventProducer()->getWindow()->getPort().size() == 0)
	{
		ViewportPtr DefaultViewport = Viewport::create();
		beginEditCP(DefaultViewport);
			DefaultViewport->setCamera                  (DefaultCamera);
			DefaultViewport->setRoot                    (DefaultRootNode);
			DefaultViewport->setSize                    (0.0f,0.0f, 1.0f,1.0f);
			DefaultViewport->setBackground              (DefaultBackground);
			DefaultViewport->getForegrounds().push_back    (UserInterfaceForeground);
		endEditCP(DefaultViewport);

		beginEditCP(MainApplication::the()->getMainWindowEventProducer()->getWindow(), Window::PortFieldMask);
			MainApplication::the()->getMainWindowEventProducer()->getWindow()->addPort(DefaultViewport);
		endEditCP(MainApplication::the()->getMainWindowEventProducer()->getWindow(), Window::PortFieldMask);
	}
}
开发者ID:Langkamp,项目名称:KabalaEngine,代码行数:69,代码来源:KEApplicationBuilder.cpp


示例18: updateViewport

/*! update all changed viewport field from the client port
 */
void MultiDisplayWindow::updateViewport(ViewportPtr &serverPort,
                                        ViewportPtr &clientPort)
{
    bool equal, found;

    // Compare the pointers.
    if(serverPort == clientPort)
        return;
    if(serverPort == NullFC || clientPort == NullFC)
        return;
    if(serverPort->getType() != serverPort->getType())
        return;

    const FieldContainerType &type = serverPort->getType();
    UInt32 fcount = osgMin(serverPort->getType().getNumFieldDescs(),
                           clientPort->getType().getNumFieldDescs());

    BitVector ffilter = RemoteAspect::getFieldFilter(type.getId());

    for(UInt32 i = 1; i <= fcount; ++i)
    {
        const FieldDescription* fdesc = type.getFieldDescription(i);
        // ignore attachments
        if(strcmp(fdesc->getCName(), "parent") == 0 ||
           strcmp(fdesc->getCName(), "camera") == 0)
            continue;

        BitVector mask = fdesc->getFieldMask();

        // don't update filtered fields
        if(ffilter & mask)
            continue;

        Field *dst_field = serverPort->getField(i);
        Field *src_field = clientPort->getField(i);

        const FieldType &dst_ftype = dst_field->getType();
        const FieldType &src_ftype = src_field->getType();

        if(dst_ftype != src_ftype)
            continue;

        equal = true;
        found = false;

        if(strstr(dst_ftype.getCName(), "Ptr") == NULL)
        {
            // This is very slow with multi fields!!!!
            std::string av, bv;
            dst_field->getValueByStr(av);
            src_field->getValueByStr(bv);
            if(av != bv)
                equal = false;
        }
        else
        {
            if(dst_field->getCardinality() == FieldType::SINGLE_FIELD)
            {
                if((static_cast<SFFieldContainerPtr *>(dst_field)->getValue() !=
                    static_cast<SFFieldContainerPtr *>(src_field)->getValue()))
                    equal = false;
            }
            else if(dst_field->getCardinality() == FieldType::MULTI_FIELD)
            {
                UInt32 j, cn = static_cast<MFFieldContainerPtr*>(src_field)->size(),
                          sn = static_cast<MFFieldContainerPtr*>(src_field)->size();

                if (strcmp(fdesc->getCName(), "foregrounds") == 0)
                {
                    MFForegroundPtr sFgndBag;
                    MFForegroundPtr::const_iterator sFgndIt, cFgndIt;
                    DisplayFilterForegroundPtr filterFgnd = NullFC;

                    sFgndIt = serverPort->getMFForegrounds()->begin();
                    cFgndIt = clientPort->getMFForegrounds()->begin();

                    while (sFgndIt != serverPort->getMFForegrounds()->end())
                    {
                        filterFgnd = DisplayFilterForegroundPtr::dcast(*sFgndIt);

                        if (filterFgnd != NullFC &&
                           !filterFgnd->getServer().empty())
                            found = true;   // loaded filters found
                        else
                            sFgndBag.push_back(*sFgndIt);

                        ++sFgndIt;
                    }

                    if (sFgndBag.size() !=
                            clientPort->getMFForegrounds()->size())
                    {
                        equal = false;
                    }
                    else
                    {
                        sFgndIt = sFgndBag.begin();

//.........这里部分代码省略.........
开发者ID:mlimper,项目名称:OpenSG1x,代码行数:101,代码来源:OSGMultiDisplayWindow.cpp


示例19: main

该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ ViewportRecPtr类代码示例发布时间:2022-05-31
下一篇:
C++ Viewport类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap