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


C++ ISceneManager::getActiveCamera方法代码示例

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


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

示例1: OnEvent

bool Hud::OnEvent(const SEvent& event)
{
	if (!_showMinimap)
		return false;

	ISceneManager* scene;
	IVideoDriver* video;

	switch (Game::ToGameEvent(event)) {
	
	case EGE_ADDITIONAL_RENDER_STARTING:
		scene = _game->getDevice()->getSceneManager();
		video = _game->getDevice()->getVideoDriver();

		_previousCamera = scene->getActiveCamera();
		scene->setActiveCamera(_minimapCamera);
		video->setRenderTarget(_minimapTexture);

		show(false);
		break;

	case EGE_ADDITIONAL_RENDER_FINISHED:
		scene = _game->getDevice()->getSceneManager();
		video = _game->getDevice()->getVideoDriver();

		scene->setActiveCamera(_previousCamera);
		video->setRenderTarget(NULL);

		show(true);
		break;

	}

	return false;
}
开发者ID:titarenko,项目名称:Pathman,代码行数:35,代码来源:Hud.cpp

示例2: selectObject

// selectObject
// detect list objs at rect
void CDocument::selectObject( int x, int y, int w, int h, bool isControlHold )
{
	IView *pView = getIView();
	ISceneManager *smgr = pView->getSceneMgr();	
	
	ICameraSceneNode *camera = smgr->getActiveCamera();

	// if no camera
	if (  camera == NULL )
		return;

	const SViewFrustum* viewFrustum = camera->getViewFrustum();
	ISceneCollisionManager *collMan = smgr->getSceneCollisionManager();

	int screenX = -1, screenY = -1;
		
	ArrayZoneIter iZone = m_zones.begin(), iEnd = m_zones.end();
	while ( iZone != iEnd )
	{
		ArrayGameObject* listObj = (*iZone)->getChilds();
		ArrayGameObjectIter iObj = listObj->begin(), objEnd = listObj->end();
		ISceneNode *pNode = NULL;

		while ( iObj != objEnd )
		{
			CGameObject *pGameObj = (CGameObject*)(*iObj);
			
			pNode = pGameObj->getSceneNode();
			
			if ( pNode != NULL && pGameObj->isVisible() )
			{
				core::vector3df center = pGameObj->getPosition();

				// check object is in frustum
				if ( viewFrustum->getBoundingBox().isPointInside( center ) )
				{					
					if ( pView->getScreenCoordinatesFrom3DPosition( center, &screenX, &screenY ) )
					{
						if ( x <= screenX && screenX <= x + w && y <= screenY && screenY <= y + h )
						{
							
							if ( isControlHold == false || pGameObj->getObjectState() == CGameObject::Normal )
								m_selectObjects.push_back( pGameObj );							

						}	// inselect
					}	// getScreenCoordinatesFrom3DPosition			
				} // frustum
			}

			iObj++;
		}

		iZone++;
	}

}
开发者ID:codeman001,项目名称:gsleveleditor,代码行数:58,代码来源:CDocument.cpp

示例3: isActive

    bool isActive() 
    {
        ISceneManager* smgr = irrDevice->getSceneManager();
        if (smgr->getActiveCamera() == m_camNode)
        {
            return true;
        }

        return false;
    }
开发者ID:xiaofeme,项目名称:tt,代码行数:10,代码来源:cirr3dengine.hpp

示例4: getIView

CGameCamera::CGameCamera()
{
	m_targetObject = NULL;
	m_objectType = CGameObject::CameraObject;

#ifdef GSEDITOR
	m_cameraMesh = NULL;
#endif

	ISceneManager *smgr = getIView()->getSceneMgr();

	// save old camera
	ICameraSceneNode *oldCam = smgr->getActiveCamera();

	// create new camera
	m_camera = smgr->addCameraSceneNode();		
	m_camera->setFOV( core::degToRad(60.0f) );
	m_camera->setFarValue( 8000.0f );
	m_camera->grab();	
	
	core::vector3df	pos(0,0,0);
	setPosition( pos );

	core::vector3df target(1,0,0);
	setTarget( target );

#ifdef GSEDITOR	
	CColladaMeshComponent *comp = new CColladaMeshComponent( this );
	comp->loadFromFile( getIView()->getPath("data/editor/camera.dae") );
	addComponent( comp );
	setLighting( false );

	m_cameraMesh = m_node;	
	m_cameraMesh->setVisible( true );	

	ITriangleSelector *selector = smgr->createTriangleSelectorFromBoundingBox( m_cameraMesh );
	m_cameraMesh->setTriangleSelector(selector);
	selector->drop();
#endif

	// set camera node
	m_node = m_camera;

	// restore camera
	smgr->setActiveCamera( oldCam );
		
	m_animator = NULL;

#ifndef GSGAMEPLAY
	setEditorCamera();
#else
	setFreeCamera();
#endif
}
开发者ID:codeman001,项目名称:gsleveleditor,代码行数:54,代码来源:CGameCamera.cpp

示例5: update

void CDR::update(NBEditor* editor, bool drag, rect<s32> offset)
{
	if (!editor->state->project) {
		return;
	}

	if (!editor->state->settings->getBool("always_show_position_handle") &&
			(editor->state->keys[KEY_LSHIFT] == EKS_UP) ==
			(type == CDR_XY || type == CDR_XZ || type == CDR_ZY)) {
		return;
	}

	Node* node = editor->state->project->GetCurrentNode();

	if (!node) {
		return;
	}

	NodeBox *box = node->GetCurrentNodeBox();

	if (!box) {
		return;
	}

	ISceneManager * smgr = editor->state->device->getSceneManager();

	if (drag) {
		// get mouse position
		position2di target = editor->state->mouse_position;
		target -= offset.UpperLeftCorner;

		// Get the ray
		line3d<irr::f32> ray = smgr->getSceneCollisionManager()
				->getRayFromScreenCoordinates(target, smgr->getActiveCamera());

		// Contains the output values
		vector3df wpos = vector3df(0, 0, 0); // The collision position

		// Not used, but required for function
		#if IRRLICHT_VERSION_MAJOR == 1 && IRRLICHT_VERSION_MINOR < 8
			const ISceneNode* tmpNode;
		#else
			ISceneNode* tmpNode;
		#endif
		triangle3df tmpTri;

		// Execute ray
		smgr->getSceneCollisionManager()->getCollisionPoint(ray,
				editor->state->plane_tri, wpos, tmpTri, tmpNode);

		// Snapping
		wpos -= vector3df(node->position.X, node->position.Y, node->position.Z);
		if (window == VIEW_XZ)
			wpos.Z -= 0.1;

		if (editor->state->settings->getBool("snapping")) {
			wpos.X = floor((wpos.X + 0.5) * 16 + 0.5) / 16 - 0.5;
			wpos.Y = floor((wpos.Y + 0.5) * 16 + 0.5) / 16 - 0.5;
			wpos.Z = floor((wpos.Z + 0.5) * 16 + 0.5) / 16 - 0.5;
		}

		// Do node limiting
		if (editor->state->settings->getBool("limiting")) {
			// X Axis
			if (wpos.X < -0.5) {
				wpos.X = -0.5;
			} else if (wpos.X > 0.5) {
				wpos.X = 0.5;
			}

			// Y Axis
			if (wpos.Y < -0.5) {
				wpos.Y = -0.5;
			} else if (wpos.Y > 0.5) {
				wpos.Y = 0.5;
			}

			// Z Axis
			if (wpos.Z < -0.5) {
				wpos.Z = -0.5;
			} else if (wpos.Z > 0.5) {
				wpos.Z = 0.5;
			}
		}

		// Call required function
		if (type < CDR_XZ) {
			box->resizeNodeBoxFace(editor->state, type, wpos,
				editor->state->keys[KEY_LCONTROL] == EKS_DOWN);
		} else {
			box->moveNodeBox(editor->state, type, wpos);
		}
		node->remesh();

		editor->triggerCDRmoved();
	}

	vector3df pos = box->GetCenter();

	switch (type) {
//.........这里部分代码省略.........
开发者ID:stormchaser3000,项目名称:NodeBoxEditor,代码行数:101,代码来源:NBEditor.cpp

示例6: main


//.........这里部分代码省略.........
	for(int i = 0; i < MAX_OBJECTS; i++){
		objects[i] = smgr->addCubeSceneNode(2);
		objects[i]->setMaterialFlag(EMF_LIGHTING, false);
		objects[i]->setPosition( vector3df( (rand() % 30) - 5, (rand() % 30) - 5, rand() % 80) );
	}

	//device->setInputReceivingSceneManager(smgr);
	
	//použivane pro 
	vector3df tempRot; 
	irr::core::quaternion tempQ;
	irr::core::matrix4 tempM;

	float round = 0;

    while(device->run())
    {
		round += 0.01;
        driver->beginScene(true, true, SColor(255,100,101,140));
		
		for(int i = 0; i < MAX_OBJECTS; i++){
			vector3df tmpPos = objects[i]->getPosition();
			if(tmpPos.Z > pos.Z) continue;
			
			objects[i]->setPosition( vector3df( (rand() % 30) - 15, (rand() % 30) - 15, rand() % 80 + pos.Z) );
		}
		
	#ifndef OCCULUS
			tempM.setRotationDegrees(vector3df(sin(round*0.5)*360-180, sin(round)*360-180, cos(round*0.8)*360-180));
			
			// transform forward vector of camera
			irr::core::vector3df frv = irr::core::vector3df (0.0f, 0.0f, 1.0f);
			tempM.transformVect(frv);
    
			// transform upvector of camera
		    irr::core::vector3df upv = irr::core::vector3df (0.0f, 1.0f, 0.0f);
			tempM.transformVect(upv);

		    camera->setUpVector(upv); //set up vector of camera
			camera->setTarget(frv); //set target of camera (look at point) (thx Zeuss for correcting it)

	#endif

		
		if(pSensor){
			Quatf quaternion = FusionResult.GetOrientation();

		   ICameraSceneNode* camera = smgr->getActiveCamera();
   
		   tempQ.set(-quaternion.z,quaternion.y,-quaternion.x, quaternion.w);
		   tempQ.normalize();
		   tempQ.toEuler(tempRot);
    
		   
			tempM.setRotationDegrees(tempRot);

			// transform forward vector of camera
			irr::core::vector3df frv = irr::core::vector3df (0.0f, 0.0f, 1.0f);
			tempM.transformVect(frv);
    
			// transform upvector of camera
		    irr::core::vector3df upv = irr::core::vector3df (0.0f, 1.0f, 0.0f);
			tempM.transformVect(upv);

		    camera->setUpVector(upv); //set up vector of camera
			camera->setTarget(frv); //set target of camera (look at point) (thx Zeuss for correcting it)

			// update absolute position
			camera->updateAbsolutePosition();



			float yaw, pitch, roll;
			quaternion.GetEulerAngles<Axis_Y, Axis_X, Axis_Z>(&yaw, &pitch, &roll);
			camera->getParent()->setRotation( vector3df(RadToDegree(pitch),RadToDegree(yaw),RadToDegree(roll)));
			//camera->setRotation( vector3df(RadToDegree(-pitch),RadToDegree(-yaw),RadToDegree(roll)));
			//camera->setProjectionMatrix(ToMatrix(quaternion));
			cout << " Yaw: " << RadToDegree(yaw) << 
				", Pitch: " << RadToDegree(pitch) << 
				", Roll: " << RadToDegree(roll) << endl;
		
			if (_kbhit()) exit(0);
		}

		#ifdef OCCULUS
			renderer.drawAll(smgr); 
		#else
			smgr->drawAll();
		#endif

        guienv->drawAll();

        driver->endScene();
    }


    device->drop();
	Clear();
    return 0;
}
开发者ID:Tezar,项目名称:tunnel,代码行数:101,代码来源:main.cpp

示例7: animateNode

	void CSceneNodeAnimatorCameraFPS::animateNode(ISceneNode* node, UINT32 timeMs)
	{
		if (!node || node->getType() != ESNT_CAMERA)
			return;

		ICameraSceneNode* camera = static_cast<ICameraSceneNode*>(node);

		if (firstUpdate)
		{
			camera->updateAbsolutePosition();
			if (CursorControl)
			{
				CursorControl->setPosition(0.5f, 0.5f);
				CursorPos = CenterCursor = CursorControl->getRelativePosition();
			}

			LastAnimationTime = timeMs;

			firstUpdate = false;
		}

		// If the camera isn't the active camera, and receiving input, then don't process it.
		if (!camera->isInputReceiverEnabled())
		{
			firstInput = true;
			return;
		}

		if (firstInput)
		{
			allKeysUp();
			firstInput = false;
		}

		ISceneManager * smgr = camera->getSceneManager();
		if (smgr && smgr->getActiveCamera() != camera)
			return;

		// get time
		FLOAT32 timeDiff = (FLOAT32)(timeMs - LastAnimationTime);
		LastAnimationTime = timeMs;

		// update position
		Vector3 pos = camera->getPosition();

		// Update rotation
		Vector3 target = (camera->getTarget() - camera->getAbsolutePosition());
		Vector3 relativeRotation = target.getHorizontalAngle();

		if (CursorControl)
		{
			if (CursorPos != CenterCursor)
			{
				relativeRotation.y -= (0.5f - CursorPos.x) * RotateSpeed;
				relativeRotation.x -= (0.5f - CursorPos.y) * RotateSpeed * MouseYDirection;

				// X < MaxVerticalAngle or X > 360-MaxVerticalAngle

				if (relativeRotation.x > MaxVerticalAngle * 2 &&
					relativeRotation.x < 360.0f - MaxVerticalAngle)
				{
					relativeRotation.x = 360.0f - MaxVerticalAngle;
				}
				else
					if (relativeRotation.x > MaxVerticalAngle &&
						relativeRotation.x < 360.0f - MaxVerticalAngle)
					{
						relativeRotation.x = MaxVerticalAngle;
					}

				// Do the fix as normal, special case below
				// reset cursor position to the centre of the window.
				CursorControl->setPosition(0.5f, 0.5f);
				CenterCursor = CursorControl->getRelativePosition();

				// needed to avoid problems when the event receiver is disabled
				CursorPos = CenterCursor;
			}

			// Special case, mouse is whipped outside of window before it can update.
			IVideoDriver* driver = smgr->getVideoDriver();
			Vector2 mousepos(UINT32(CursorControl->getPosition().x), UINT32(CursorControl->getPosition().y));
			rect<UINT32> screenRect(0, 0, driver->getScreenSize().Width, driver->getScreenSize().Height);

			// Only if we are moving outside quickly.
			bool reset = !screenRect.isPointInside(mousepos);

			if (reset)
			{
				// Force a reset.
				CursorControl->setPosition(0.5f, 0.5f);
				CenterCursor = CursorControl->getRelativePosition();
				CursorPos = CenterCursor;
			}
		}

		// set target

		target.set(0, 0, Math::_max<Real>(1.f, pos.length()));
		Vector3 movedir = target;
//.........这里部分代码省略.........
开发者ID:zxycode007,项目名称:Sapphire,代码行数:101,代码来源:SapphireCSceneNodeAnimatorCameraFPS.cpp


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