コード例 #1
0
ファイル: MouseCursor.cpp プロジェクト: Skylion007/RifTop
MouseCursor::MouseCursor(Ogre::SceneManager *sceneMgr, 
					     Ogre::SceneNode* rotationNode,
						 Ogre::SceneNode* orientationNode)
	:m_Sensitivity(0.00175f),
	m_RotationNode(rotationNode)
{
	m_Cursor = orientationNode->createChildSceneNode("bodyNode");
	Ogre::SceneNode* child= m_Cursor->createChildSceneNode("iconNode");
	Ogre::Entity *cursorEntity = sceneMgr->createEntity("Cursor", "Cursor.mesh");

	Ogre::MaterialPtr material = Ogre::MaterialManager::getSingleton().getByName("Cursor");
	cursorEntity->setMaterial(material);
	child->attachObject(cursorEntity);

	child->yaw(Ogre::Radian(3*Ogre::Math::PI/2));
	child->roll(Ogre::Radian(-Ogre::Math::PI/2));
	m_Cursor->setPosition(Ogre::Vector3(0,0,-1.9f));
	child->setScale(.1f,.1f,.1f);
	
}
コード例 #2
0
bool np::HubConstructionComponent::addToConstruction( np::NeuroPlayer* player, double amount)
{
    std::list<np::HubConstructionSlot>::iterator iterator;

    iterator = slots.begin();
    while ( iterator != slots.end())
    {
        np::HubConstructionSlot& slot = *iterator;

        if ( slot.player == player)
        {
            slot.amount += amount;

            np::GraphicComponent* graphic = slot.proxyHub->getComponent<np::GraphicComponent>();

            Ogre::Entity* entity = graphic->entities.front();
            Ogre::MaterialPtr material = entity->getSubEntity(0)->getMaterial();
            material->getTechnique(0)->getPass(0)->getTextureUnitState(0)->setAlphaOperation(
                Ogre::LBX_SOURCE1,
                Ogre::LBS_MANUAL,
                Ogre::LBS_CURRENT,
                ( slot.amount / 60.0) * 0.6);
            entity->setMaterial( material);

            if ( slot.amount >= 60.0)
            {
                return true;
            }

            return false;
        }

        iterator++;
    }

    return false;
}
コード例 #3
0
ObjectEditHandler::ObjectEditHandler(SceneDoc *Owner)
{
	mOwner = Owner;
	mMode = OEM_NONE;
	mAxisMode = AM_NONE;
	mTarget = NULL;
	mObjectEditNode = mOwner->getSceneManager()->getRootSceneNode()->createChildSceneNode();
	mRayQuery = mOwner->getSceneManager()->createRayQuery(Ogre::Ray());

	mMaterials[0] = Ogre::MaterialManager::getSingletonPtr()->getByName("Editor/RedMat");
	mMaterials[1] = Ogre::MaterialManager::getSingletonPtr()->getByName("Editor/GreenMat");
	mMaterials[2] = Ogre::MaterialManager::getSingletonPtr()->getByName("Editor/BlueMat");
	mMaterials[3] = Ogre::MaterialManager::getSingletonPtr()->getByName("Editor/ObjectIndicatorWhiteMat");
	mMaterials[4] = Ogre::MaterialManager::getSingletonPtr()->getByName("Editor/ObjectIndicatorYellowMat");

	//////////////////////////////////////////////////
	// 碰撞检测
	//////////////////////////////////////////////////

	mCollisionManager = new OgreOpcode::CollisionManager(Owner->getSceneManager());
	mCollisionManager->addCollClass("Object");
	mCollisionManager->addCollType("Object", "Object", OgreOpcode::COLLTYPE_IGNORE);
	mCollisionContext = mCollisionManager->createContext("SceneObject");

	Ogre::MovableObjectFactory* Factory = 
		Ogre::Root::getSingleton().getMovableObjectFactory(Ogre::EntityFactory::FACTORY_TYPE_NAME);
	Ogre::NameValuePairList Params;

	//////////////////////////////////////////////////
	// 平移放缩指示器
	//////////////////////////////////////////////////

	mIndicatorContext = mCollisionManager->createContext("TransScale");

	mTransScaleNode = mObjectEditNode->createChildSceneNode("TransScaleIndicator");
	mTransScaleNode->setScale(200.0f, 200.0f, 200.0f);

	// x
	Ogre::SceneNode *SubNode = mTransScaleNode->createChildSceneNode();
	SubNode->roll(Ogre::Degree(-90.0f));

	Ogre::Entity *Entity = Owner->getSceneManager()->createEntity("TransScaleXLine", "MoveArrowLineVisible.mesh");
	//Entity->setQueryFlags(0); // 参与查询
	Entity->setCastShadows(false);
	Entity->setMaterial(mMaterials[0]);
	Entity->setRenderQueueGroup(Ogre::RENDER_QUEUE_8);
	SubNode->attachObject(Entity);
	mTransformEntities[AM_TRANS_SCALE_X] = Entity;

	Entity = Owner->getSceneManager()->createEntity("TransScaleXCone", "MoveArrowConeVisible.mesh");
	Entity->setQueryFlags(0);
	Entity->setCastShadows(false);
	Entity->setMaterial(mMaterials[0]);
	Entity->setRenderQueueGroup(Ogre::RENDER_QUEUE_8);
	SubNode->attachObject(Entity);

	Params["mesh"] = "MoveArrowCollision.mesh";
	Entity = (Ogre::Entity*)Factory->createInstance("TransScaleXCol", Owner->getSceneManager(), &Params);
	Entity->setQueryFlags(0);
	Entity->setCastShadows(false);

	Entity->setVisible(false);
	SubNode->attachObject(Entity);

	OgreOpcode::CollisionObject *CollisionObject = 
		AddCollisionEntity(mIndicatorContext, Entity);
	mCollisionObjectToAxisMode[CollisionObject] = AM_TRANS_SCALE_X;

	// y
	SubNode = mTransScaleNode;

	Entity = Owner->getSceneManager()->createEntity("TransScaleYLine", "MoveArrowLineVisible.mesh");
	//Entity->setQueryFlags(0);
	Entity->setCastShadows(false);
	Entity->setMaterial(mMaterials[1]);
	Entity->setRenderQueueGroup(Ogre::RENDER_QUEUE_8);
	SubNode->attachObject(Entity);
	mTransformEntities[AM_TRANS_SCALE_Y] = Entity;

	Entity = Owner->getSceneManager()->createEntity("TransScaleYCone", "MoveArrowConeVisible.mesh");
	Entity->setQueryFlags(0);
	Entity->setCastShadows(false);
	Entity->setMaterial(mMaterials[1]);
	Entity->setRenderQueueGroup(Ogre::RENDER_QUEUE_8);
	SubNode->attachObject(Entity);

	Params["mesh"] = "MoveArrowCollision.mesh";
	Entity = (Ogre::Entity*)Factory->createInstance("TransScaleYCol", Owner->getSceneManager(), &Params);
	Entity->setQueryFlags(0);
	Entity->setCastShadows(false);

	Entity->setVisible(false);
	SubNode->attachObject(Entity);

	CollisionObject = AddCollisionEntity(mIndicatorContext, Entity);
	mCollisionObjectToAxisMode[CollisionObject] = AM_TRANS_SCALE_Y;

	// z
	SubNode = mTransScaleNode->createChildSceneNode();
	SubNode->pitch(Ogre::Degree(90));

	Entity = Owner->getSceneManager()->createEntity("TransScaleZLine", "MoveArrowLineVisible.mesh");
	//Entity->setQueryFlags(0);
	Entity->setCastShadows(false);
	Entity->setMaterial(mMaterials[2]);
	Entity->setRenderQueueGroup(Ogre::RENDER_QUEUE_8);
	SubNode->attachObject(Entity);
	mTransformEntities[AM_TRANS_SCALE_Z] = Entity;

	Entity = Owner->getSceneManager()->createEntity("TransScaleZCone", "MoveArrowConeVisible.mesh");
	Entity->setQueryFlags(0);
	Entity->setCastShadows(false);
	Entity->setMaterial(mMaterials[2]);
	Entity->setRenderQueueGroup(Ogre::RENDER_QUEUE_8);
	SubNode->attachObject(Entity);

	Params["mesh"] = "MoveArrowCollision.mesh";
	Entity = (Ogre::Entity*)Factory->createInstance("TransScaleZCol", Owner->getSceneManager(), &Params);
	Entity->setQueryFlags(0);
	Entity->setCastShadows(false);

	Entity->setVisible(false);
	SubNode->attachObject(Entity);

	CollisionObject = AddCollisionEntity(mIndicatorContext, Entity);
	mCollisionObjectToAxisMode[CollisionObject] = AM_TRANS_SCALE_Z;

	// box
	SubNode = mTransScaleNode;

	Params["mesh"] = "Box1m.mesh";
	Entity =(Ogre::Entity*)Factory->createInstance("TransScaleAll", Owner->getSceneManager(), &Params);
	//Entity->setQueryFlags(0);
	Entity->setCastShadows(false);
	Entity->setMaterial(mMaterials[3]);
	Entity->setRenderQueueGroup(Ogre::RENDER_QUEUE_8);
	SubNode->attachObject(Entity);
	mTransformEntities[AM_TRANS_SCALE_ALL] = Entity;

	CollisionObject = AddCollisionEntity(mIndicatorContext, Entity);
	mCollisionObjectToAxisMode[CollisionObject] = AM_TRANS_SCALE_ALL;

	mIndicatorContext->reset();
	mObjectEditNode->removeChild(mTransScaleNode);

	//////////////////////////////////////////////////
	// 旋转指示器
	//////////////////////////////////////////////////

	mIndicatorContext = mCollisionManager->createContext("Rotate");

	mRotateNode = mObjectEditNode->createChildSceneNode("RotateIndicator");
	mRotateNode->setScale(200.0f, 200.0f, 200.0f);

	// x
	SubNode = mRotateNode->createChildSceneNode();
	SubNode->roll(Ogre::Degree(90));

	Entity = Owner->getSceneManager()->createEntity("RotateX", "RotationRingVisible.mesh");
	//Entity->setQueryFlags(0);
	Entity->setCastShadows(false);
	Entity->setMaterial(mMaterials[0]);
	Entity->setRenderQueueGroup(Ogre::RENDER_QUEUE_8);
	SubNode->attachObject(Entity);
	mTransformEntities[AM_ROTATE_X] = Entity;

	Params["mesh"] = "RotationRingCollision.mesh";
	Entity =(Ogre::Entity*)Factory->createInstance("RotateXCol", Owner->getSceneManager(), &Params);
	Entity->setQueryFlags(0);
	Entity->setCastShadows(false);

	Entity->setVisible(false);
	SubNode->attachObject(Entity);

	CollisionObject = AddCollisionEntity(mIndicatorContext, Entity);
	mCollisionObjectToAxisMode[CollisionObject] = AM_ROTATE_X;

	// y
	SubNode = mRotateNode;
	Entity = Owner->getSceneManager()->createEntity("RotateY", "RotationRingVisible.mesh");
	//Entity->setQueryFlags(0);
	Entity->setCastShadows(false);
	Entity->setMaterial(mMaterials[1]);
	Entity->setRenderQueueGroup(Ogre::RENDER_QUEUE_8);
	SubNode->attachObject(Entity);
	mTransformEntities[AM_ROTATE_Y] = Entity;

	Params["mesh"] = "RotationRingCollision.mesh";
	Entity =(Ogre::Entity*)Factory->createInstance("RotateYCol", Owner->getSceneManager(), &Params);
	Entity->setQueryFlags(0);
	Entity->setCastShadows(false);

	Entity->setVisible(false);
	SubNode->attachObject(Entity);
	
	CollisionObject = AddCollisionEntity(mIndicatorContext, Entity);
	mCollisionObjectToAxisMode[CollisionObject] = AM_ROTATE_Y;

	// z
	SubNode = mRotateNode->createChildSceneNode();
	SubNode->pitch(Ogre::Degree(90.0f));

	Entity = Owner->getSceneManager()->createEntity("RotateZ", "RotationRingVisible.mesh");
	//Entity->setQueryFlags(0);
	Entity->setCastShadows(false);
	Entity->setMaterial(mMaterials[2]);
	Entity->setRenderQueueGroup(Ogre::RENDER_QUEUE_8);
	SubNode->attachObject(Entity);
	mTransformEntities[AM_ROTATE_Z] = Entity;

	Params["mesh"] = "RotationRingCollision.mesh";
	Entity =(Ogre::Entity*)Factory->createInstance("RotateZCol", Owner->getSceneManager(), &Params);
	Entity->setQueryFlags(0);
	Entity->setCastShadows(false);

	Entity->setVisible(false);
	SubNode->attachObject(Entity);

	CollisionObject = AddCollisionEntity(mIndicatorContext, Entity);
	mCollisionObjectToAxisMode[CollisionObject] = AM_ROTATE_Z;

	mIndicatorContext->reset();
	mObjectEditNode->removeChild(mRotateNode);
}
コード例 #4
0
int main(int argc, char *argv[])
{
    CefMainArgs args(argc, argv);

    {
        int result = CefExecuteProcess(args, nullptr);
        // checkout CefApp, derive it and set it as second parameter, for more control on
        // command args and resources.
        if (result >= 0) // child proccess has endend, so exit.
        {
            return result;
        }
        if (result == -1)
        {
            // we are here in the father proccess.
        }
    }

    {
        CefSettings settings;

        // checkout detailed settings options http://magpcss.org/ceforum/apidocs/projects/%28default%29/_cef_settings_t.html
        // nearly all the settings can be set via args too.
        // settings.multi_threaded_message_loop = true; // not supported, except windows
        // CefString(&settings.browser_subprocess_path).FromASCII("sub_proccess path, by default uses and starts this executeable as child");
        // CefString(&settings.cache_path).FromASCII("");
        // CefString(&settings.log_file).FromASCII("");
        // settings.log_severity = LOGSEVERITY_DEFAULT;
        // CefString(&settings.resources_dir_path).FromASCII("");
        // CefString(&settings.locales_dir_path).FromASCII("");

        bool result = CefInitialize(args, settings, nullptr);
        // CefInitialize creates a sub-proccess and executes the same executeable, as calling CefInitialize, if not set different in settings.browser_subprocess_path
        // if you create an extra program just for the childproccess you only have to call CefExecuteProcess(...) in it.
        if (!result)
        {
            // handle error
            return -1;
        }
    }

    Ogre::Root* renderSystem(nullptr);
    Ogre::SceneManager* renderScene(nullptr);
    Ogre::TexturePtr renderTexture;
    Ogre::SceneNode *renderNode;

    // renderer
    {
        // initalise Ogre3d
        renderSystem = new Ogre::Root();
        if (!renderSystem->restoreConfig())
        {
            renderSystem->showConfigDialog();
        }
        renderSystem->initialise(true);

        renderScene = renderSystem->createSceneManager(Ogre::ST_GENERIC);

        Ogre::Camera* camera(renderScene->createCamera("camera"));
        camera->setAutoAspectRatio(true);
        camera->setNearClipDistance(0.1);
        camera->setFarClipDistance(100.);
        renderSystem->getAutoCreatedWindow()->addViewport(camera);
        camera->getViewport()->setBackgroundColour(Ogre::ColourValue::White);

        // create mesh, texture, material, node and entity
        renderTexture = Ogre::TextureManager::getSingleton().createManual(
                    "texture",
                    Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
                    Ogre::TEX_TYPE_2D, 1024, 768, 0, Ogre::PF_A8R8G8B8, Ogre::TU_DYNAMIC_WRITE_ONLY);

        Ogre::MaterialPtr material = Ogre::MaterialManager::getSingletonPtr()->create("material", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
        material->getTechnique(0)->getPass(0)->setCullingMode(Ogre::CULL_NONE); // print both sides of the polygones
        material->getTechnique(0)->getPass(0)->createTextureUnitState("texture");

        Ogre::MeshPtr mesh = Ogre::MeshManager::getSingletonPtr()->createPlane("mesh", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
                                                                                                     Ogre::Plane(Ogre::Vector3::UNIT_Z, 0), 3, 2);

        Ogre::Entity* entity = renderScene->createEntity(mesh);
        entity->setMaterial(material);

        renderNode = renderScene->getRootSceneNode()->createChildSceneNode("node", Ogre::Vector3(0., 0., -3.));

        renderNode->attachObject(entity);
    }


    RenderHandler* renderHandler;
    {
        renderHandler = new RenderHandler(renderTexture, renderNode);

        renderSystem->addFrameListener(renderHandler);
    }

    // create browser-window
    CefRefPtr<CefBrowser> browser;
    CefRefPtr<BrowserClient> browserClient;
    {
        CefWindowInfo window_info;
        CefBrowserSettings browserSettings;

        // in linux set a gtk widget, in windows a hwnd. If not available set nullptr - may cause some render errors, in context-menu and plugins.
        window_info.SetAsOffScreen(nullptr);

        browserClient = new BrowserClient(renderHandler);

        browser = CefBrowserHost::CreateBrowserSync(window_info, browserClient.get(), "http://deanm.github.io/pre3d/monster.html", browserSettings);

        // inject user-input by calling
        // browser->GetHost()->SendKeyEvent(...);
        // browser->GetHost()->SendMouseMoveEvent(...);
        // browser->GetHost()->SendMouseClickEvent(...);
        // browser->GetHost()->SendMouseWheelEvent(...);
    }

    // start rendering and calling method RenderHandler::frameStarted
    {
        renderSystem->startRendering();
    }

    {
        browser = nullptr;
        browserClient = nullptr;
        CefShutdown();

        renderScene->destroyAllMovableObjects();
        delete renderScene;
        delete renderSystem;
        delete renderHandler;
    }

    return 0;
}