I'm a beginner with OGRE 3D and I am currently playing around to learn the API/see if it fits my needs. So far, I have managed to export a custom blender model and load it in Ogre. I did set an autotool environment from zero since I did not manage to make the example application work (compilations/executions issues, with libogre1.9 from repo or with custom libogre build)
I am currently facing an issue with the basic tutorial 2 : if a add the plane in the scene, the program show an exception at render :
The code I use is pretty similar to the one presented in the site tutorial. Here it is (disclaimer : the code is clearly not properly organized for an application, I am using these files as sandboxes) :OgreApp: /build/ogre-1.9-mqY1wq/ogre-1.9-1.9.0+dfsg1/OgreMain/include/OgreSharedPtr.h:253: T* Ogre::SharedPtr<T>::operator->() const [with T = Ogre::Material]: Assertion `pRep' failed.
[1] 15909 abort (core dumped) ./OgreApp
Base.cpp
Code: Select all
#include "Base.h"
#include "OgreEntity.h"
#include "OgreRenderWindow.h"
#include <OIS/OIS.h>
#include <OgreFrameListener.h>
#include <OgreMeshManager.h>
#include <cmath>
#include <OgrePlane.h>
using namespace std;
Base::Base(void):m_root(NULL), m_window(NULL), m_scene(NULL), m_entity(NULL),m_mainNode(NULL), m_rs(NULL), m_light(NULL), m_camera(NULL), m_vp(NULL)
{
m_root = new Ogre::Root("plugins.cfg", "ogre.cfg", "Ogre.log");
if(m_root->restoreConfig() == false)
{
if(m_root->showConfigDialog())
{
m_window = m_root->initialise(true);
}
else
{
cout<<"Error : cannot set render settings"<<endl;
return;
}
}
else
{
m_window = m_root->initialise(true);
}
m_scene = m_root->createSceneManager(Ogre::ST_GENERIC);
Ogre::ResourceGroupManager::getSingleton().addResourceLocation("../data", "FileSystem");
Ogre::ResourceGroupManager::getSingleton().initialiseAllResourceGroups();
//Floor
Ogre::Plane plane(Ogre::Vector3::UNIT_Y, 0);
Ogre::MeshManager::getSingleton().createPlane(
"ground",
Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
plane,
500, 500, 10,10,
true,
1, 5, 5,
Ogre::Vector3::UNIT_Z);
Ogre::Entity* groundEntity = m_scene->createEntity("ground");
groundEntity->setCastShadows(false);
m_scene->getRootSceneNode()->createChildSceneNode()->attachObject(groundEntity);
m_entity = m_scene->createEntity("MyEntity", "Cube.mesh");
cout<<"Ogre mesh loaded"<<endl;
m_mainNode = m_scene->getRootSceneNode()->createChildSceneNode();
m_entity->setCastShadows(true);
m_mainNode->attachObject(m_entity);
m_camera = m_scene->createCamera("Main camera");
if(m_camera == NULL)
{
cout << "Error creating camera"<<endl;
return;
}
m_camera->setPosition(Ogre::Vector3(3, 8, 8));
m_camera->lookAt(Ogre::Vector3(0, 0, 0));
m_camera->setNearClipDistance(5);
m_vp = m_window->addViewport(m_camera);
m_scene->setAmbientLight(Ogre::ColourValue(0.5, 0.5, 0.8));
m_light = m_scene->createLight("MainLight");
m_light->setPosition(20, 80, 50);
m_vp->setBackgroundColour(Ogre::ColourValue(0.1, 0.2, 0.1));
m_root->startRendering();
}
Code: Select all
#include <iostream>
#include "Base.h"
using namespace std;
int main()
{
Base* base = new Base();
return 0;
}
Code: Select all
PluginFolder=/usr/lib/x86_64-linux-gnu/OGRE-1.9.0
Plugin=RenderSystem_GL
If I let all the code except the line attaching the "ground" plane to the scene, the app runs perfectly. I also tried to add another mesh in the scene (loading the same mesh in another entity and attaching it to a new node) and it worked.
Maybe I am missing some initialisation with the MeshManager, but the only init function I have seen in the API reference seems to be internal and, as a consequence, not be called from the user code...
Is there anyone knowing anything about this issue ?