当前位置: 首页>>代码示例>>C++>>正文


C++ WindowEventProducerRefPtr::editEventProducer方法代码示例

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


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

示例1: main

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

    // Set up Window
    TutorialWindow = createNativeWindow();
    TutorialWindow->initWindow();

    TutorialWindow->setDisplayCallback(display);
    TutorialWindow->setReshapeCallback(reshape);

    TutorialKeyListener TheKeyListener;
    TutorialWindow->addKeyListener(&TheKeyListener);
    TutorialMouseListener TheTutorialMouseListener;
    TutorialMouseMotionListener TheTutorialMouseMotionListener;
    TutorialWindow->addMouseListener(&TheTutorialMouseListener);
    TutorialWindow->addMouseMotionListener(&TheTutorialMouseMotionListener);
	TutorialUpdateListener TheTutorialUpdateListener;
    TutorialWindow->addUpdateListener(&TheTutorialUpdateListener);


    // Create the SimpleSceneManager helper
    mgr = new SimpleSceneManager;

	
    // Tell the Manager what to manage
    mgr->setWindow(TutorialWindow);

    //Make Main Scene Node
	NodeRefPtr scene = makeCoredNode<Group>();
    setName(scene, "scene");
    rootNode = Node::create();
    setName(rootNode, "rootNode");
    ComponentTransformRefPtr Trans;
    Trans = ComponentTransform::create();
    {
        rootNode->setCore(Trans);
 
        // add the torus as a child
        rootNode->addChild(scene);
    }

    //Make The Physics Characteristics Node
    PhysicsCharacteristicsDrawableUnrecPtr PhysDrawable = PhysicsCharacteristicsDrawable::create();
        PhysDrawable->setRoot(rootNode);

	PhysDrawableNode = Node::create();
    PhysDrawableNode->setCore(PhysDrawable);
    PhysDrawableNode->setTravMask(TypeTraits<UInt32>::getMin());

    rootNode->addChild(PhysDrawableNode);

    //Light Beacon
    NodeRefPtr TutorialLightBeacon = makeCoredNode<Transform>();

    //Light Node
    DirectionalLightRefPtr TutorialLight = DirectionalLight::create();
    TutorialLight->setDirection(0.0,0.0,-1.0);
    TutorialLight->setBeacon(TutorialLightBeacon);

    NodeRefPtr TutorialLightNode = Node::create();
    TutorialLightNode->setCore(TutorialLight);

    scene->addChild(TutorialLightNode);
    scene->addChild(TutorialLightBeacon);


    //Setup Physics Scene
    physicsWorld = PhysicsWorld::create();
        physicsWorld->setWorldContactSurfaceLayer(0.01);
        physicsWorld->setAutoDisableFlag(1);
        physicsWorld->setAutoDisableTime(0.75);
        physicsWorld->setWorldContactMaxCorrectingVel(1.0);
        //physicsWorld->setGravity(Vec3f(0.0, 0.0, -9.81));
        //physicsWorld->setCfm(0.001);
        //physicsWorld->setErp(0.2);

    hashSpace = PhysicsHashSpace::create();

    physHandler = PhysicsHandler::create();
        physHandler->setWorld(physicsWorld);
        physHandler->pushToSpaces(hashSpace);
        physHandler->setUpdateNode(rootNode);
    physHandler->attachUpdateProducer(TutorialWindow->editEventProducer());
    

        rootNode->addAttachment(physHandler);    
        rootNode->addAttachment(physicsWorld);
        rootNode->addAttachment(hashSpace);


	/************************************************************************/
	/* create spaces, geoms and bodys                                                                     */
	/************************************************************************/
    //create a group for our space
    GroupRefPtr spaceGroup;
	spaceGroupNode = makeCoredNode<Group>(&spaceGroup);
	//add Attachments to nodes...
//.........这里部分代码省略.........
开发者ID:Langkamp,项目名称:OpenSGToolbox,代码行数:101,代码来源:04ZeroGravityShip.cpp

示例2: main

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

    // Set up Window
    TutorialWindow = createNativeWindow();
    TutorialWindow->initWindow();

    TutorialWindow->setDisplayCallback(display);
    TutorialWindow->setReshapeCallback(reshape);

    TutorialKeyListener TheKeyListener;
    TutorialWindow->addKeyListener(&TheKeyListener);
    TutorialMouseListener TheTutorialMouseListener;
    TutorialMouseMotionListener TheTutorialMouseMotionListener;
    TutorialWindow->addMouseListener(&TheTutorialMouseListener);
    TutorialWindow->addMouseMotionListener(&TheTutorialMouseMotionListener);


    // Create the SimpleSceneManager helper
    mgr = new SimpleSceneManager;


    // Tell the Manager what to manage
    mgr->setWindow(TutorialWindow);

    //Make Base Geometry Node
    TriGeometryBase = makeTorus(0.5, 1.0, 24, 24);

    //Make Main Scene Node
    NodeRefPtr scene = makeCoredNode<Group>();
    setName(scene, "scene");
    rootNode = Node::create();
    setName(rootNode, "rootNode");
    ComponentTransformRefPtr Trans;
    Trans = ComponentTransform::create();
    rootNode->setCore(Trans);

    // add the torus as a child
    rootNode->addChild(scene);

    //Make The Physics Characteristics Node
    PhysicsCharacteristicsDrawableRefPtr PhysDrawable = PhysicsCharacteristicsDrawable::create();
    PhysDrawable->setRoot(rootNode);

    PhysDrawableNode = Node::create();
    PhysDrawableNode->setCore(PhysDrawable);
    PhysDrawableNode->setTravMask(TypeTraits<UInt32>::getMin());

    rootNode->addChild(PhysDrawableNode);


    //Setup Physics Scene
    physicsWorld = PhysicsWorld::create();
    physicsWorld->setWorldContactSurfaceLayer(0.005);
    physicsWorld->setAutoDisableFlag(1);
    physicsWorld->setAutoDisableTime(0.75);
    physicsWorld->setWorldContactMaxCorrectingVel(100.0);
    physicsWorld->setGravity(Vec3f(0.0, 0.0, -9.81));

    physicsSpace = PhysicsHashSpace::create();

    physHandler = PhysicsHandler::create();
    physHandler->setWorld(physicsWorld);
    physHandler->pushToSpaces(physicsSpace);
    physHandler->setUpdateNode(rootNode);

    physHandler->attachUpdateProducer(TutorialWindow->editEventProducer());


    /************************************************************************/
    /* create spaces, geoms and bodys                                       */
    /************************************************************************/
    //create a group for our space
    GroupRefPtr spaceGroup;
    spaceGroupNode = makeCoredNode<Group>(&spaceGroup);
    //create the ground plane
    GeometryRefPtr plane;
    NodeRefPtr planeNode = makeBox(30.0, 30.0, 1.0, 1, 1, 1);
    plane = dynamic_cast<Geometry*>(planeNode->getCore());
    //and its Material
    SimpleMaterialRefPtr plane_mat = SimpleMaterial::create();
    plane_mat->setAmbient(Color3f(0.7,0.7,0.7));
    plane_mat->setDiffuse(Color3f(0.9,0.6,1.0));

    plane->setMaterial(plane_mat);



    //create Physical Attachments
    PhysicsBoxGeomRefPtr planeGeom = PhysicsBoxGeom::create();
    planeGeom->setLengths(Vec3f(30.0, 30.0, 1.0));
    //add geoms to space for collision
    planeGeom->setSpace(physicsSpace);


    //add Attachments to nodes...
    spaceGroupNode->addAttachment(physicsSpace);
//.........这里部分代码省略.........
开发者ID:msteners,项目名称:OpenSGToolbox,代码行数:101,代码来源:01SimplePhysics.cpp


注:本文中的WindowEventProducerRefPtr::editEventProducer方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。