some noob questions

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Eventide
Posts: 23
Joined: Fri Jul 19, 2013 4:46 am

some noob questions

Post by Eventide »

Hi, i'm using CopperCube as a level editor, but when i test it in my own application it looks very different from when i test with CopperCube, is that some filter or what?

my game:
Image
coppercube:
Image

And, how can i detect what mesh the mouse is in? It's possible to assign name to a mesh and get the name by the position?

What program do you recommend for terrain editing? I saw that CopperCube have it but i can't found...

Thanks for the attention... =)~
chronologicaldot
Competition winner
Posts: 688
Joined: Mon Sep 10, 2012 8:51 am

Re: some noob questions

Post by chronologicaldot »

Um... First, CopperCube is completely different than irrlicht because it's written in Javascript, even though it was written by the same guy. I honestly have no idea what he did different, so I can't tell you there.

HOWEVER, I do believe the picture on the bottom has anti-aliasing. I believe irrlicht has that, although the material setting for it might be turned off by default. I'd have to check again... *sigh*

Incidentally, what renderer are you using? Don't use the default renderer ("Software1" as it's labeled) for irrlicht. It can't do very much, and it is progressively falling farther behind the others. I'm not sure if that's what your doing or not, but it may not support anti-aliasing.

... I could be wrong.

Sorry, I don't know of any terrain editor to recommend.
hendu
Posts: 2600
Joined: Sat Dec 18, 2010 12:53 pm

Re: some noob questions

Post by hendu »

Aniso is off in the lower picture, making it look that much worse (blurry).
Eventide
Posts: 23
Joined: Fri Jul 19, 2013 4:46 am

Re: some noob questions

Post by Eventide »

I searched for filters like antialising in the docs but didn't found, and never heard about aniso, where can i see the filters and how to activate them?
chronologicaldot wrote: what renderer are you using? Don't use the default renderer
No, i'm using OpenGL, i usually use directx because it's faster, but the DLL for win32 gcc don't support it and i'm not having performance issues yet(and by the FPS running on the demos i saw, i'll probably never have).
mongoose7
Posts: 1227
Joined: Wed Apr 06, 2011 12:13 pm

Re: some noob questions

Post by mongoose7 »

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?
Eventide
Posts: 23
Joined: Fri Jul 19, 2013 4:46 am

Re: some noob questions

Post by Eventide »

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;
}
 
Eventide
Posts: 23
Joined: Fri Jul 19, 2013 4:46 am

Re: some noob questions

Post by Eventide »

Already turned on/off Antialising and mipmaps, nothing changed...

Here is how i turned on antialising:

Code: Select all

 
irr::SIrrlichtCreationParameters params;
    params.DriverType=EDT_OPENGL;
    params.WindowSize=dimension2d<u32>(800, 600);
    params.Bits=32;
    params.Fullscreen=false;
    params.Stencilbuffer=true;
    params.Vsync=true;
    params.AntiAlias=true;
    params.EventReceiver=0;
 
    IrrlichtDevice *device = createDeviceEx(params);
 
mipmaps(turned on and off, nothing changed):

Code: Select all

driver->setTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS, true);
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: some noob questions

Post by CuteAlien »

The other filters are in the material-settings (TextureLayer settings in SMaterial). You can access them from the scenenode or per meshbuffer.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Eventide
Posts: 23
Joined: Fri Jul 19, 2013 4:46 am

Re: some noob questions

Post by Eventide »

i setted on anisotropic filter(various values), trillinear filter and LODBias(positive and negative values), nothing changed... :(
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: some noob questions

Post by CuteAlien »

Strange - you should really see a difference when switching filters... how does the code you used there look like?
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Eventide
Posts: 23
Joined: Fri Jul 19, 2013 4:46 am

Re: some noob questions

Post by Eventide »

CuteAlien wrote:Strange - you should really see a difference when switching filters... how does the code you used there look like?
The code to change filters:

Code: Select all

 
        node->getMaterial(node->getMaterialCount()).TextureLayer->AnisotropicFilter = 16;
        node->getMaterial(node->getMaterialCount()).TextureLayer->TrilinearFilter = true;
        node->getMaterial(node->getMaterialCount()).TextureLayer->LODBias = 256;
 
And the node is got here:

Code: Select all

 
core::array<ISceneNode*> nodes;
    mSceneManager->getSceneNodesFromType(scene::ESNT_ANY, nodes);
     for (u32 i=0; i < nodes.size(); ++i)
    {
        scene::ISceneNode * node = nodes[i];
 
mongoose7
Posts: 1227
Joined: Wed Apr 06, 2011 12:13 pm

Re: some noob questions

Post by mongoose7 »

It looks as if you are writing to the material after the last material, that is, into (outer) space! I think you need a 'for' loop:

for (i < node->getMaterialCount) node->getMaterial(i).TextureLayer->AnisotropicFilter = 16;, etc.
Eventide
Posts: 23
Joined: Fri Jul 19, 2013 4:46 am

Re: some noob questions

Post by Eventide »

Nothing changed... :|

Here is my code:

Code: Select all

 
for (u32 i = 0; i < node->getMaterialCount(); i++)
        {
            node->getMaterial(i).TextureLayer->AnisotropicFilter = 16;
            node->getMaterial(i).TextureLayer->TrilinearFilter = true;
            node->getMaterial(i).TextureLayer->LODBias = 64;
        }
 
hendu
Posts: 2600
Joined: Sat Dec 18, 2010 12:53 pm

Re: some noob questions

Post by hendu »

Does that even compile? Texturelayer is not a pointer.
zerochen
Posts: 273
Joined: Wed Jan 07, 2009 1:17 am
Location: Germany

Re: some noob questions

Post by zerochen »

it should work because Texturelayer is an array. so he accessed the first element.

node->getMaterial(i).TextureLayer[0].AnisotropicFilter = 16; should be better so other can see that is an array

do you have more than one texture? if so you have to loop through the other texturelayers
Post Reply