本文整理汇总了C++中ogre::Camera::setAutoAspectRatio方法的典型用法代码示例。如果您正苦于以下问题:C++ Camera::setAutoAspectRatio方法的具体用法?C++ Camera::setAutoAspectRatio怎么用?C++ Camera::setAutoAspectRatio使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ogre::Camera
的用法示例。
在下文中一共展示了Camera::setAutoAspectRatio方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setupScene
static void setupScene()
{
LOGI("------->setupScene()");
Ogre::ConfigFile cf;
cf.load(openAPKFile("resources.cfg"));
Ogre::ConfigFile::SectionIterator seci = cf.getSectionIterator();
while (seci.hasMoreElements())
{
Ogre::String sec, type, arch;
sec = seci.peekNextKey();
Ogre::ConfigFile::SettingsMultiMap* settings = seci.getNext();
Ogre::ConfigFile::SettingsMultiMap::iterator i;
for (i = settings->begin(); i != settings->end(); i++)
{
type = i->first;
arch = i->second;
Ogre::ResourceGroupManager::getSingleton().addResourceLocation(arch, type, sec);
}
}
Ogre::ResourceGroupManager::getSingletonPtr()->initialiseResourceGroup(
Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
gSceneMgr = gRoot->createSceneManager(Ogre::ST_GENERIC);
Ogre::Camera* camera = gSceneMgr->createCamera("MyCam");
Ogre::Entity* pEntity = gSceneMgr->createEntity("SinbadInstance", "Sinbad.mesh");
Ogre::SceneNode* pNode = gSceneMgr->getRootSceneNode()->createChildSceneNode();
pNode->attachObject(pEntity);
Ogre::Light* pDirLight = gSceneMgr->createLight();
pDirLight->setDirection(Ogre::Vector3(0, -1, 0));
pDirLight->setType(Ogre::Light::LT_DIRECTIONAL);
pNode->attachObject(pDirLight);
camera->setNearClipDistance(1.0f);
camera->setFarClipDistance(100000.0f);
camera->setPosition(0, 0, 20.0f);
camera->lookAt(0, 0, 0);
camera->setAutoAspectRatio(true);
Ogre::Viewport* vp = gRenderWnd->addViewport(camera);
vp->setBackgroundColour(Ogre::ColourValue(1, 0, 0));
LOGI("<-------setupScene()");
}
示例2:
void
OgreCameraSystem::update(int) {
for (EntityId entityId : m_impl->m_entities.removedEntities()) {
Ogre::Camera* camera = m_impl->m_cameras[entityId];
if (camera) {
Ogre::SceneNode* sceneNode = camera->getParentSceneNode();
sceneNode->detachObject(camera);
m_impl->m_sceneManager->destroyCamera(camera);
}
m_impl->m_cameras.erase(entityId);
}
for (auto& value : m_impl->m_entities.addedEntities()) {
EntityId entityId = value.first;
OgreSceneNodeComponent* sceneNodeComponent = std::get<0>(value.second);
OgreCameraComponent* cameraComponent = std::get<1>(value.second);
Ogre::Camera* camera = m_impl->m_sceneManager->createCamera(
cameraComponent->name()
);
camera->setAutoAspectRatio(true);
cameraComponent->m_camera = camera;
m_impl->m_cameras[entityId] = camera;
sceneNodeComponent->m_sceneNode->attachObject(camera);
}
m_impl->m_entities.clearChanges();
for (auto& value : m_impl->m_entities) {
OgreCameraComponent* cameraComponent = std::get<1>(value.second);
auto& properties = cameraComponent->m_properties;
if (properties.hasChanges()) {
Ogre::Camera* camera = cameraComponent->m_camera;
// Update camera
camera->setPolygonMode(properties.polygonMode);
camera->setFOVy(properties.fovY);
camera->setNearClipDistance(properties.nearClipDistance);
camera->setFarClipDistance(properties.farClipDistance);
// Untouch
properties.untouch();
}
}
}
示例3: setCurrentScene
void TestApp::setCurrentScene(SceneBase* scene) {
mInputHandler->setScene(scene);
// Setup the renderer window (i.e. add a camera/viewport to it)
Ogre::Camera* camera = scene->getCamera();
if (!mViewport) {
mViewport = mRenderWindow->addViewport(camera);
}
mViewport->setCamera(camera);
camera->setAspectRatio(((Ogre::Real)mViewport->getActualWidth())
/ ((Ogre::Real)mViewport->getActualHeight()));
camera->setAutoAspectRatio(true);
camera->setNearClipDistance(5.0f); // AB: default is 100
camera->moveRelative(Ogre::Vector3(0.0f, 0.0f, 200.0f));
mInputHandler->setCamera(camera);
Ogre::SceneManager* manager = scene->getSceneManager();
mGui->setSceneManager(manager);
mGui->setSceneId(SceneHandler::getSceneHandler()->getSceneId(scene));
mGui->setSceneDescription(scene->getSceneDescription());
mScene = scene;
mInputHandler->forceToggleCallbackActivation();
}
示例4: while
//.........这里部分代码省略.........
}
}
result = dynamic_cast<Ogre::MovableObject *>(entityCopy);
} else if (typeName == "Light") {
// clone light
Ogre::Light *light = dynamic_cast<Ogre::Light *>(movableObject);
Ogre::Light *lightCopy = sceneManager->createLight(name.toStdString());
lightCopy->setType(light->getType());
lightCopy->setDiffuseColour(light->getDiffuseColour());
lightCopy->setSpecularColour(light->getSpecularColour());
lightCopy->setAttenuation(light->getAttenuationRange(), light->getAttenuationConstant(), light->getAttenuationLinear(), light->getAttenuationQuadric());
lightCopy->setPosition(light->getPosition());
lightCopy->setDirection(light->getDirection());
if (lightCopy->getType() == Ogre::Light::LT_SPOTLIGHT)
lightCopy->setSpotlightRange(light->getSpotlightInnerAngle(), light->getSpotlightOuterAngle(), light->getSpotlightFalloff());
lightCopy->setPowerScale(light->getPowerScale());
lightCopy->setCastShadows(light->getCastShadows());
// create a new container for the cloned light
OgreContainer *lightCopyContainer = new OgreContainer(lightCopy);
lightCopy->setUserAny(Ogre::Any(lightCopyContainer));
if (!light->getUserAny().isEmpty()) {
OgreContainer *lightContainer = Ogre::any_cast<OgreContainer *>(light->getUserAny());
if (lightContainer)
QObject::connect(lightContainer, SIGNAL(sceneNodeUpdated()), lightCopyContainer, SLOT(updateLight()));
}
result = dynamic_cast<Ogre::MovableObject *>(lightCopy);
} else if (typeName == "Camera") {
// clone camera
Ogre::Camera *camera = dynamic_cast<Ogre::Camera *>(movableObject);
Ogre::Camera *cameraCopy = sceneManager->createCamera(name.toStdString());
//cameraCopy->setCustomParameter(0, camera->getCustomParameter(0));
cameraCopy->setAspectRatio(camera->getAspectRatio());
cameraCopy->setAutoAspectRatio(camera->getAutoAspectRatio());
//cameraCopy->setAutoTracking(...);
cameraCopy->setCastShadows(camera->getCastsShadows());
//cameraCopy->setCullingFrustum(camera->getCullingFrustum());
//cameraCopy->setCustomParameter(...);
//cameraCopy->setCustomProjectionMatrix(..);
//cameraCopy->setCustomViewMatrix(..);
//cameraCopy->setDebugDisplayEnabled(...);
//cameraCopy->setDefaultQueryFlags(...);
//cameraCopy->setDefaultVisibilityFlags(...);
cameraCopy->setDirection(camera->getDirection());
//cameraCopy->setFixedYawAxis(...);
cameraCopy->setFocalLength(camera->getFocalLength());
cameraCopy->setFOVy(camera->getFOVy());
//Ogre::Real left;
//Ogre::Real right;
//Ogre::Real top;
//Ogre::Real bottom;
//camera->getFrustumExtents(left, right, top, bottom);
//cameraCopy->setFrustumExtents(left, right, top, bottom);
//cameraCopy->setFrustumOffset(camera->getFrustumOffset());
//cameraCopy->setListener(camera->getListener());
cameraCopy->setLodBias(camera->getLodBias());
//cameraCopy->setLodCamera(camera->getLodCamera());
cameraCopy->setNearClipDistance(camera->getNearClipDistance());
cameraCopy->setFarClipDistance(camera->getFarClipDistance());
cameraCopy->setOrientation(camera->getOrientation());
//cameraCopy->setOrthoWindow(...);
//cameraCopy->setOrthoWindowHeight(...);
//cameraCopy->setOrthoWindowWidth(...);
cameraCopy->setPolygonMode(camera->getPolygonMode());
cameraCopy->setPolygonModeOverrideable(camera->getPolygonModeOverrideable());
示例5: camera_set_auto_aspect_ratio
void camera_set_auto_aspect_ratio(CoiHandle camera_handle, bool on)
{
Ogre::Camera* camera = reinterpret_cast<Ogre::Camera*>(camera_handle);
camera->setAutoAspectRatio(on);
}
示例6: camera_set_auto_aspect_ratio
void camera_set_auto_aspect_ratio(CameraHandle camera_handle, bool on)
{
Ogre::Camera* camera = static_cast<Ogre::Camera*>(camera_handle);
camera->setAutoAspectRatio(on);
}
示例7: initialise
bool initialise()
{
mRoot = new Ogre::Root(PLUGINS_CFG, OGRE_CFG, OGRE_LOG);
if (!mRoot->restoreConfig())
if (!mRoot->showConfigDialog())
return false;
initResources();
mWindow = mRoot->initialise(true, "CS Clone Editor v0.0");
Ogre::WindowEventUtilities::addWindowEventListener(mWindow, this);
mSceneMgr = mRoot->createSceneManager(Ogre::ST_GENERIC);
mSceneMgr->setAmbientLight(Ogre::ColourValue(0.7, 0.7, 0.7));
mCamera = mSceneMgr->createCamera("camera");
mWindow->addViewport(mCamera);
mCamera->setAutoAspectRatio(true);
mCamera->setNearClipDistance(0.1);
mCamera->setFarClipDistance(10000);
mCamera->setPosition(10, 10, 10);
// mCamera->lookAt(0, 0, 0);
mRoot->addFrameListener(this);
Ogre::ResourceGroupManager::getSingleton().initialiseAllResourceGroups();
//Initializing OIS
Ogre::LogManager::getSingletonPtr()->logMessage("*-*-* OIS Initialising");
OIS::ParamList pl;
size_t windowHnd = 0;
mWindow->getCustomAttribute("WINDOW", &windowHnd);
pl.insert(std::make_pair(std::string("WINDOW"), Ogre::StringConverter::toString(windowHnd)));
#if OGRE_DEBUG_MODE == 1
#if OGRE_PLATFORM == OGRE_PLATFORM_LINUX
#define NO_EXCLUSIVE_INPUT
#endif
#endif
#ifdef NO_EXCLUSIVE_INPUT
#if defined OIS_WIN32_PLATFORM
pl.insert(std::make_pair(std::string("w32_mouse"), std::string("DISCL_FOREGROUND" )));
pl.insert(std::make_pair(std::string("w32_mouse"), std::string("DISCL_NONEXCLUSIVE")));
pl.insert(std::make_pair(std::string("w32_keyboard"), std::string("DISCL_FOREGROUND")));
pl.insert(std::make_pair(std::string("w32_keyboard"), std::string("DISCL_NONEXCLUSIVE")));
#elif defined OIS_LINUX_PLATFORM
pl.insert(std::make_pair(std::string("x11_mouse_grab"), std::string("false")));
pl.insert(std::make_pair(std::string("x11_mouse_hide"), std::string("false")));
pl.insert(std::make_pair(std::string("x11_keyboard_grab"), std::string("false")));
pl.insert(std::make_pair(std::string("XAutoRepeatOn"), std::string("true")));
#endif
#endif
mInputManager = OIS::InputManager::createInputSystem(pl);
mKeyboard = static_cast<OIS::Keyboard*>(mInputManager->createInputObject(OIS::OISKeyboard, true));
mKeyboard->setEventCallback(this);
mMouse = static_cast<OIS::Mouse*>(mInputManager->createInputObject(OIS::OISMouse, true));
mMouse->setEventCallback(this);
windowResized(mWindow);
//Initialising GUI
Ogre::LogManager::getSingletonPtr()->logMessage("*-*-* MyGUI Initialising");
mGUI = new MyGUI::Gui;
mGUI->initialise(mWindow);
mGUI->load("editor.layout");
mMenuBar = mGUI->createWidget<MyGUI::MenuBar>("MenuBar",
MyGUI::IntCoord(0, 0, mGUI->getViewWidth(), 28),
MyGUI::ALIGN_TOP | MyGUI::ALIGN_HSTRETCH, "Overlapped");
mMenuBar->addItem("File");
mPopupMenuFile = mMenuBar->getItemMenu(0);
mPopupMenuFile->addItem("New");
mPopupMenuFile->addItem("Open ...");
mPopupMenuFile->addItem("Save");
mPopupMenuFile->addItem("Save as ...", false, true);
mPopupMenuFile->addItem("Settings", false, true);
mPopupMenuFile->addItem("Quit");
mMenuBar->addItem("Help");
mPopupMenuHelp = mMenuBar->getItemMenu(1);
mPopupMenuHelp->addItem("Help");
mPopupMenuHelp->addItem("About ...");
return (true);
}