Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - theodor

Pages: [1] 2
1
Graphics / Re: SFML Window + Irrlicht rendering animation problems
« on: April 10, 2013, 12:41:23 pm »
I'll look at the source code, hopefully I am knowledgeable enough to somehow integrate it with Irrlicht without changing the sfml code I already have.

The reason why I am so stubborn is because I like those wrappers(thin or not), which hide the hideous code from me and in turn simplify everything. So for me, it would be ideal to be able to use SFML for 2D and Irrlicht for 3D.

Theo

2
Graphics / Re: SFML Window + Irrlicht rendering animation problems
« on: April 09, 2013, 02:28:41 pm »
No worries, mate.

If I can't get help, I suppose I'll have to do some more searching and experimenting. I will perhaps have to see what SDL has to offer even though I dislike it.

Thank you.

Cheers,
Theo

3
Graphics / Re: SFML Window + Irrlicht rendering animation problems
« on: April 08, 2013, 10:49:13 am »
bump

4
Graphics / Re: SFML Window + Irrlicht rendering animation problems
« on: March 30, 2013, 11:13:43 am »
Looks like I don't even have to explain myself. People know why :)

Will I get an explanation why my code doesn't work as intended, or should I just scrap everything I wrote with sfml and try to rewrite everything using irrlicht?

I really like sfml so I do not want to abandon it.

5
Graphics / Re: SFML Window + Irrlicht rendering animation problems
« on: March 28, 2013, 09:58:28 am »
bump

6
Graphics / SFML Window + Irrlicht rendering animation problems
« on: March 22, 2013, 12:29:52 pm »
Hey,

Here I am, once again in my journey to combine 2D and 3D api's.

The following is the minimal code I use to draw an animated model in the SFML window:
Code: [Select]
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Graphics.hpp>
#include <irrlicht.h>

//#include <GL/glu.h>
#include <iostream>
#include <math.h>
#define M_PI           3.14159265358979323846

////////////////////////////////////////////////////////////
/// Entry point of application
///
/// \return Application exit code
///
////////////////////////////////////////////////////////////

using namespace irr;
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;

int main()
{
    // Create the main rendering window
    sf::ContextSettings settings;
    settings.depthBits = 16;
    settings.stencilBits = 8;
    settings.antialiasingLevel = 8;
    settings.majorVersion = 3;
    settings.minorVersion = 0;

    sf::RenderWindow App(sf::VideoMode(800, 600), "OpenGL", sf::Style::Default, settings);

    IrrlichtDevice* device;
    SIrrlichtCreationParameters Parameters;
    Parameters.DriverType = video::EDT_OPENGL;
    Parameters.Bits = 16;
    Parameters.Fullscreen = false;
    Parameters.Stencilbuffer = true;
    Parameters.Vsync = true;
    Parameters.AntiAlias = true;
    Parameters.HighPrecisionFPU = false;
    Parameters.WindowId = App.getSystemHandle();
    device = createDeviceEx(Parameters);

    IVideoDriver* driver = device->getVideoDriver();
ISceneManager* smgr = device->getSceneManager();
IGUIEnvironment* guienv = device->getGUIEnvironment();

IAnimatedMesh* mesh = smgr->getMesh("sydney.md2");
if (!mesh)
{
device->drop();
return 1;
}
IAnimatedMeshSceneNode* node = smgr->addAnimatedMeshSceneNode( mesh );

if (node)
{
node->setMaterialFlag(EMF_LIGHTING, false);
node->setMD2Animation(scene::EMAT_STAND);
node->setMaterialTexture( 0, driver->getTexture("sydney.bmp") );
}

    smgr->addCameraSceneNode(0, vector3df(0,30,-60), vector3df(0,5,0));
    //App.setVerticalSyncEnabled(true);

    bool running = true;
    while (running == true)
    {
        // Process events
        sf::Event Event;

        while (App.pollEvent(Event))
        {
            // Close window : exit
            if (Event.type == sf::Event::Closed)
            {
                running = false;
            }
            else if ((Event.type == sf::Event::KeyPressed) && (Event.key.code == sf::Keyboard::Escape))
            {
                running = false;
            }
            else if (Event.type == sf::Event::Resized)
            {
                // adjust the viewport when the window is resized
                //glViewport(0, 0, Event.size.width, Event.size.height);
            }

        }

          driver->beginScene(true, true, SColor(255,0,0,255));
          //App.display();
       smgr->drawAll();
      guienv->drawAll();
    driver->endScene();
    }
    device->drop();
    return EXIT_SUCCESS;
}

The result is just a non-moving model.
This irrlicht example (hello world), works fine(removed comments to save space):

Code: [Select]
#include <irrlicht.h>

using namespace irr;

using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;

#ifdef _IRR_WINDOWS_
#pragma comment(lib, "Irrlicht.lib")
#pragma comment(linker, "/subsystem:windows /ENTRY:mainCRTStartup")
#endif


/*
This is the main method. We can now use main() on every platform.
*/
int main()
{
IrrlichtDevice *device =
createDevice( video::EDT_OPENGL, dimension2d<u32>(640, 480), 16,
false, false, false, 0);

if (!device)
return 1;

device->setWindowCaption(L"Hello World! - Irrlicht Engine Demo");

IVideoDriver* driver = device->getVideoDriver();
ISceneManager* smgr = device->getSceneManager();
IGUIEnvironment* guienv = device->getGUIEnvironment();

guienv->addStaticText(L"Hello World! This is the Irrlicht Software renderer!",
rect<s32>(10,10,260,22), true);

IAnimatedMesh* mesh = smgr->getMesh("../../media/sydney.md2");
if (!mesh)
{
device->drop();
return 1;
}
IAnimatedMeshSceneNode* node = smgr->addAnimatedMeshSceneNode( mesh );

if (node)
{
node->setMaterialFlag(EMF_LIGHTING, false);
node->setMD2Animation(scene::EMAT_STAND);
node->setMaterialTexture( 0, driver->getTexture("../../media/sydney.bmp") );
}

smgr->addCameraSceneNode(0, vector3df(0,30,-40), vector3df(0,5,0));

while(device->run())
{

driver->beginScene(true, true, SColor(255,100,101,140));

smgr->drawAll();
guienv->drawAll();

driver->endScene();
}

device->drop();

return 0;
}

So the problem is that the model doesn't animate.

If I use raw opengl and draw a rotating cube in the SFML and Irrlicht combination, the cube shows, but completely black and missing one side (square) [yes it, rotates fine]

My program with the raw opengl rotating cube in the background and sfml animated sprites worked fine without irrlicht. Just using irrlicht with sfml window(without 3D rendering on it's part) resulted in sprites not showing and the cube missing one side and being black.

That is just extra information and is subject to a further topic though.

I simplified everything and right now I would like feedback on why the mesh isn't animating in the sfml window. What am I missing? (Probably some fundamental knowledge)

Cheers,
Theo


7
Graphics / Re: OpenGL object position and rotation not changing realtime
« on: August 09, 2012, 11:06:00 pm »
Alright, thank you very much!

8
Graphics / Re: OpenGL object position and rotation not changing realtime
« on: August 09, 2012, 08:49:56 pm »
I think I will just wait for a release. As far as I remember, one would have to go through lots of hassle to compile the code (download a couple of programs). Will I suffer some significant performance loss just setting the matrixmode right now myself? If it is indeed that bad, then I will consider compiling the code myself.

9
Graphics / Re: OpenGL object position and rotation not changing realtime
« on: August 08, 2012, 04:08:31 pm »
Oh, I actually saw that report, but it was before I ran into my own bug so I didn't even realize that.
And thank you.

10
Graphics / Re: OpenGL object position and rotation not changing realtime
« on: August 08, 2012, 03:54:10 pm »
So when the bug is fixed, I will no longer have to set the matrixmode myself anymore?
That is great. Please do tell me when the bug is fixed and how I can get the fix, or if it's something I can do, then some instructions would be nice.

It's interesting that nobody except me has stumbled upon this yet. My project, which I started a very long time ago with a friend is a 2.5D rpg which is featuring one main character. It was initially going to be just 2D, so I've gone through SDL and allegro, but it just wasn't what I needed. Right now I'm also stuck with object collision junk variables in directX 9, so I haven't even gotten to the part to implement 2D.

Right now I pretty much have the perfect environment for 2D, all I need now is to integrate opengl rendering and for starters import some 3D models and set the camera. So 2D character(s) and 3D world, that is my plan.. Hopefully I will successfully do this and in turn, promote your SFML api.

It will however take a long time, but hopefully not so long for finally getting something to show. I'm the only one programming the game. My friend is the one making the sprites. So yeah, it'll take a while.

11
Graphics / Re: OpenGL object position and rotation not changing realtime
« on: August 08, 2012, 03:23:28 pm »
As funny as it is... Just one small thing made the difference, nothing else. Doesn't even make sense though.

If I put this code anywhere in the running loop: glMatrixMode(GL_MODELVIEW);
It will work. Even though I had already set it in the initialization. It seems like this "matrix mode", gets
reset every time I draw using sfml. So programs that don't loop and only draw once, will render correctly.

I suppose this can be considered a bug? Or at least something very much worth mentioning in tutorials that pop and push glstates does not take care of the matrixmode.

Excuse me if what I said is partially nonsense, but that comes from the fact that I really do not understand what a matrixmode in opengl is. I just use it when it is necessary and it seems like it is necessary every time both opengl and sfml drawing/rendering is used.


Now I will have to... OH WAIT THANK GOD!!! Phew, I have the ... do I... hmm.. No, sadly. I do not have the full source code here anymore. Now I'll have to rewrite most of my code because code::blocks decided he would keep my code in the minimalistic version even though I undid all of the changes and saved before closing it yesterday... Oh well,  at least I still have my sprite clipper :)

12
Graphics / Re: OpenGL object position and rotation not changing realtime
« on: August 08, 2012, 02:39:46 pm »
Anybody? Why is the sfml drawing conflicting when the pop and push functions were made specifically to avoid that?

13
bool DoOnce = true;
if (DoOnce == true)
{
      DoIt();
      DoOnce = false;
}

It would probably disappear too quickly if I just clear the sceen there so..
if (ElapsedTime.asSeconds == 0.5f)
{
      clearscreen();
}

Something like that... I'm sure you are drawing other objects to the screen as well, in that case you need to figure out how to implement what I wrote above yourself.

14
Graphics / Re: OpenGL object position and rotation not changing realtime
« on: August 07, 2012, 12:48:46 pm »
After two hours, I managed to trim it down and isolate the problem while keeping the code testable.

The cube rotates fine after removing this:
           App.pushGLStates();

                 App.draw(idleUp);

             App.popGLStates();
 
If I only remove the push and pop state functions, then the cube doesn't show up.

Full complete... minimal... working code:
 
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Graphics.hpp>
#include <GL/glew.h>
#include <SFML/OpenGL.hpp>

#include <GL/glu.h>
#define M_PI           3.14159265358979323846

////////////////////////////////////////////////////////////
/// Entry point of application
///
/// \return Application exit code
///
////////////////////////////////////////////////////////////

void NextSprite(sf::Sprite &Sprite, int SpriteSizeY, int rectHorizontal, int rectVertical);

int InitGL()                                                                            // All Setup For OpenGL Goes Here
{
        glShadeModel(GL_SMOOTH);                                                        // Enable Smooth Shading
        glClearColor(0.0f, 0.0f, 220.0f, 0.5f);                         // Black Background
        glClearDepth(1.0f);                                                                     // Depth Buffer Setup
        glEnable(GL_DEPTH_TEST);                                                        // Enables Depth Testing
        glDepthFunc(GL_LEQUAL);                                                         // The Type Of Depth Testing To Do
        glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);      // Really Nice Perspective Calculations
        return true;                                                                            // Initialization Went OK
}

void ResizeGLScene(int width, int height)               // Resize And Initialize The GL Window
{
        if (height==0)                                                                          // Prevent A Divide By Zero By
        {
                height=1;                                                                               // Making Height Equal One
        }

        glViewport(0,0,width,height);                                           // Reset The Current Viewport

        glMatrixMode(GL_PROJECTION);                                            // Select The Projection Matrix
        glLoadIdentity();                                                                       // Reset The Projection Matrix

        // Calculate The Aspect Ratio Of The Window
        gluPerspective(45.0f,(GLfloat)width/(GLfloat)height,0.1f,1000.0f);


        glMatrixMode(GL_MODELVIEW);                                                     // Select The Modelview Matrix
        glLoadIdentity();                                                                       // Reset The Modelview Matrix
}

int main()
{

    // Create the main rendering window
    sf::ContextSettings settings;
    settings.depthBits = 32;
    settings.stencilBits = 8;
    settings.antialiasingLevel = 8;
    settings.majorVersion = 3;
    settings.minorVersion = 0;

    sf::RenderWindow App(sf::VideoMode(800, 600), "OpenGL", sf::Style::Default, settings);
    App.setVerticalSyncEnabled(true);
    ResizeGLScene(App.getSize().x, App.getSize().y);
    InitGL();
    // Load the sprite image from a file

    sf::Texture IdleUp;

    if (!IdleUp.loadFromFile("idleUp.png"))
    {
        return EXIT_FAILURE;
    }

    sf::Sprite idleUp(IdleUp);
    idleUp.setPosition(50, 100);


    bool running = true;
    while (running == true)
    {
        // Process events
        sf::Event Event;

        while (App.pollEvent(Event))
        {
            // Close window : exit
            if (Event.type == sf::Event::Closed)
            {
                running = false;
            }
            else if ((Event.type == sf::Event::KeyPressed) && (Event.key.code == sf::Keyboard::Escape))
            {
                running = false;
            }
            else if (Event.type == sf::Event::Resized)
            {
                // adjust the viewport when the window is resized
                glViewport(0, 0, Event.size.width, Event.size.height);
            }

        }


        // Clear screen
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
          static float angle = 0.0f;
         //DrawGLScene();
           glLoadIdentity();                                                                    // Reset The Current Modelview Matrix
                 glTranslatef(0.0f,0.0f, -260.0f);
                  glRotatef(angle, 0.0f, 1.0f, 1.0f);                                   // Move Left 1.5 Units And Into The Screen 6.0
               glBegin(GL_QUADS);

            glVertex3f(-50.f, -50.f, -50.f);
            glVertex3f(-50.f,  50.f, -50.f);
            glVertex3f( 50.f,  50.f, -50.f);
            glVertex3f( 50.f, -50.f, -50.f);

            glVertex3f(-50.f, -50.f, 50.f);
            glVertex3f(-50.f,  50.f, 50.f);
            glVertex3f( 50.f,  50.f, 50.f);
            glVertex3f( 50.f, -50.f, 50.f);

            glVertex3f(-50.f, -50.f, -50.f);
            glVertex3f(-50.f,  50.f, -50.f);
            glVertex3f(-50.f,  50.f,  50.f);
            glVertex3f(-50.f, -50.f,  50.f);

            glVertex3f(50.f, -50.f, -50.f);
            glVertex3f(50.f,  50.f, -50.f);
            glVertex3f(50.f,  50.f,  50.f);
            glVertex3f(50.f, -50.f,  50.f);

            glVertex3f(-50.f, -50.f,  50.f);
            glVertex3f(-50.f, -50.f, -50.f);
            glVertex3f( 50.f, -50.f, -50.f);
            glVertex3f( 50.f, -50.f,  50.f);

            glVertex3f(-50.f, 50.f,  50.f);
            glVertex3f(-50.f, 50.f, -50.f);
            glVertex3f( 50.f, 50.f, -50.f);
            glVertex3f( 50.f, 50.f,  50.f);
                glEnd();
                angle += 0.5f;




             App.pushGLStates();

                 App.draw(idleUp);

             App.popGLStates();



        // Display window contents on screen
        App.display();
    }

    return EXIT_SUCCESS;
}

15
SFML projects / Re: [sf3d] a project for 3D rendering
« on: August 07, 2012, 01:23:11 am »
I would really appreciate if somebody would make this work for sfml 2.0

Pages: [1] 2
anything