mongoose7 wrote:There is a lot of noise in the first example but not the second. Could it simply be that mipmaps are not in use, that is, bilinear filtering is off in the first example?
If off is the default, yes, how can i on/off filters? I found some types of filters in the docs, but not a function to activate it... Here is my code:
statemanager.cpp:
Code: Select all
#include "statemanager.h"
using namespace irr;
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;
void StateManager::setupSceneManager(IrrlichtDevice* dr)
{
mSceneManager = dr->getSceneManager();
mSceneManager->loadScene("data/maps/dungeons/dg1.irr");
mCamera = mSceneManager->addCameraSceneNodeFPS(0, 50.f, 0.1f);
setupCollision();
}
void StateManager::setupCollision()
{
IMetaTriangleSelector* meta = mSceneManager->createMetaTriangleSelector();
core::array<ISceneNode*> nodes;
mSceneManager->getSceneNodesFromType(scene::ESNT_ANY, nodes);
mSceneManager->getSceneNodesFromType(scene::ESNT_ANY, nodes);
for (u32 i=0; i < nodes.size(); ++i)
{
scene::ISceneNode * node = nodes[i];
scene::ITriangleSelector * selector = 0;
switch(node->getType())
{
case scene::ESNT_CUBE:
case scene::ESNT_ANIMATED_MESH:
// Because the selector won't animate with the mesh,
// and is only being used for camera collision, we'll just use an approximate
// bounding box instead of ((scene::IAnimatedMeshSceneNode*)node)->getMesh(0)
selector = mSceneManager->createTriangleSelectorFromBoundingBox(node);
break;
case scene::ESNT_MESH:
case scene::ESNT_SPHERE: // Derived from IMeshSceneNode
selector = mSceneManager->createTriangleSelector(((scene::IMeshSceneNode*)node)->getMesh(), node);
break;
case scene::ESNT_TERRAIN:
selector = mSceneManager->createTerrainTriangleSelector((scene::ITerrainSceneNode*)node);
break;
case scene::ESNT_OCTREE:
selector = mSceneManager->createOctreeTriangleSelector(((scene::IMeshSceneNode*)node)->getMesh(), node);
break;
default:
// Don't create a selector for this node type
break;
}
if(selector)
{
// Add it to the meta selector, which will take a reference to it
meta->addTriangleSelector(selector);
// And drop my reference to it, so that the meta selector owns it.
selector->drop();
}
}
ISceneNodeAnimator* anim = mSceneManager->createCollisionResponseAnimator(
meta, mCamera, core::vector3df(5,5,5),
core::vector3df(0,0,0));
meta->drop(); // I'm done with the meta selector now
mCamera->addAnimator(anim);
anim->drop(); // I'm done with the animator now
mCamera->setPosition(core::vector3df(0.f, 20.f, 0.f));
ISceneNode * cube = mSceneManager->getSceneNodeFromType(ESNT_CUBE);
if(cube)
mCamera->setTarget(cube->getAbsolutePosition());
}
void StateManager::drawScene()
{
mSceneManager->drawAll();
}
void StateManager::changeScene(const char* path, core::vector3df frompos)
{ //to-do: criar sistema de portas/portais e derivados para saber qual é a nova posição da camera a partir da posição antiga
mSceneManager->clear();
mSceneManager->loadScene(path);
setupCollision();
}
statemanager.h:
Code: Select all
#ifndef STATEMANAGER_HEADERFILE
# define STATEMANAGER_HEADERFILE
# include <irrlicht.h>
using namespace irr;
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;
class StateManager
{
private:
StateManager(){}
const char* mPath;
ISceneManager* mSceneManager;
ICameraSceneNode* mCamera;
void setupSceneManager(IrrlichtDevice* device);
void setupCollision();
public:
static StateManager* getInstance(IrrlichtDevice* device)
{
static StateManager* inst;
if(inst)
return inst;
inst = new StateManager();
inst->setupSceneManager(device);
return inst;
}
void changeScene(const char* path, core::vector3df frompos);
void drawScene();
};
#endif
main.cpp:
Code: Select all
#include <irrlicht.h>
#include "statemanager.h"
using namespace irr;
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;
int main()
{
IrrlichtDevice *device =
createDevice( video::EDT_OPENGL, dimension2d<u32>(640, 480), 32,
false, false, false, 0);
if (!device)
return 1;
device->setWindowCaption(L"Dimension Door");
IVideoDriver* driver = device->getVideoDriver();
StateManager* state_manager = StateManager::getInstance(device);
while(device->run())
{
driver->beginScene(true, true, SColor(255,100,101,140));
state_manager->drawScene();
driver->endScene();
}
device->drop();
return 0;
}