SFML community forums

General => SFML projects => Topic started by: Lokk on August 20, 2010, 02:06:40 pm

Title: [sf3d] a project for 3D rendering
Post by: Lokk on August 20, 2010, 02:06:40 pm
Hi all,

I just let you know that I am working on a 3D engine project, based on the SFML 2.0 library.

Here are some features :


sf3d often changes, there are a lot of improvements to do.
If someone is interested to contribute to the project, doors are open.

The official site is here : sf3d google code (http://code.google.com/p/sf3d/) with some images and svn sources.

For example, a simple OBJ importer with sf3d library
The  cube file (http://www.mediafire.com/?qag5og2ut70qply).
Code: [Select]
#include <SFML/Graphics.hpp>
#include <sf3d.hpp>

int main(int ac, char **av)
{
    sf::RenderWindow win(sf::VideoMode(800, 600), "sf3d - SFML 3D rendering");
    win.SetFramerateLimit(60);

    sf3d::Init();

    sf3d::Renderer& renderer = sf3d::Renderer::GetSingleton();
    renderer.Init(win);

    sf3d::FpsCamera cam;
    cam.SetPosition(sf::Vector3f(0, 0, -4));

    sf3d::OBJMeshLoader loader;
    sf3d::MeshNode node(loader.Load("cube.obj"));

    sf3d::Scene scene;
    scene.SetCamera(&cam);
    scene.Add(&node);

    sf3d::Light light;
    light.SetPosition(sf::Vector3f(15, 15, 15));
    scene.AddLight(&light);

    renderer.SetScene(&scene);

    while (win.IsOpened())
    {
        sf::Event event;
        while (win.GetEvent(event))
        {
            if (event.Type == sf::Event::Closed || (event.Type == sf::Event::KeyPressed && event.Key.Code == sf::Key::Escape))
                win.Close();

            if (event.Type == sf::Event::Resized)
                renderer.Resize();
        }

        win.Clear();

        renderer.Display();

        win.Display();
    }
    return 0;
}
Title: [sf3d] a project for 3D rendering
Post by: Jallen on August 20, 2010, 07:42:12 pm
The sample code looks cool, but I don't understand why you would piggy back on SFML when you could use something much more minimalistic with identical results.
Title: [sf3d] a project for 3D rendering
Post by: tonkosi on April 07, 2011, 05:11:43 pm
Can I somewhere download sf3d?  :D  :?:
Title: [sf3d] a project for 3D rendering
Post by: Lokk on April 07, 2011, 10:06:11 pm
Yeah, you can checkout the repository to get the source code using SVN :
Code: [Select]
svn checkout http://sf3d.googlecode.com/svn/trunk/ sf3d-read-only
Title: [sf3d] a project for 3D rendering
Post by: Nexus on April 27, 2011, 01:38:52 am
Hey, your project looks really interesting. Maybe this could be the solution to my small 3D game planned since eternities ;)

Have you thought about using a 3D graphics library like Irrlicht as backend instead of re-implementing everything on your own? Or maybe about forming a connection between SFML and Irrlicht (especially for the render window and the event handling?)
Title: [sf3d] a project for 3D rendering
Post by: henrikno on June 08, 2011, 12:52:55 am
Nice! It looks a lot like my personal helper classes. Maybe I'll contribute :)
Did you consider using AssImp for loading 3d meshes?

@Jallen: What is more minimalistic than SFML? I wouldn't say SDL is simpler to use than SFML.

@Nexus: IMO I find it fascinating to have something so simple you can keep the whole code in your head :)
Title: [sf3d] a project for 3D rendering
Post by: Lokk on June 08, 2011, 08:41:59 am
Quote
Did you consider using AssImp for loading 3d meshes?

Yes, I definitely want to use the assimp loader.
It can load interchangeable formats and other game engine mesh files.
(see here for a complete list : http://assimp.sourceforge.net/main_features_formats.html)

It's NOT intended to be a complete engine, the goal is to have simple and performant helper classes  (Matrix, renderers, importers, scene graphs, culling classes, etc...) that fit as a higher level than OpenGL (like SFML does)
Title: [sf3d] a project for 3D rendering
Post by: Tank on June 10, 2011, 10:03:18 pm
I would go with a custom file format. Using Assimp to load models on the fly can be time-consuming when using optimizations (e.g. removing doubled vertices, recalculating normals, transformations to match your coordinate system etc.).

You can still provide a simple converter tool that uses Assimp to load a model and converts it to your format. In that case you have the great compatibility of Assimp together with optimizations and fast loading times.
Title: [sf3d] a project for 3D rendering
Post by: Alejandro on June 14, 2011, 02:48:29 pm
Sorry to bring up such an old thread, but it seems that anyway it has been sort of revived. As I see that the project's activity is close to none on the google page I would like to ask if it will be further supported.

I want to make a 2D isometric game, but to add character customization it would be an overkill to render all the possible variations of equipment on different classes in every animation sequence and direction, so I decided that I want to use a 3D character and attach the items to the corresponding parts of it's body.

I know that nothing about skeletal animation, bone attachment or 3ds file loading has been posted by the OP, but if there is any chance that the project will be further developed, will these things be in it's feature list? I have tried linking Irrlicht with SFML so that I render the map and everything else from SFML and draw the character with attached items from Irrlicht, but the closest I could get was a white changing (due to animation) non-textured silhouette of the character on the map (probably due to the un-fixable openGL states mess up).

I really like SFML and want to use it for my game as it is straightforward, faster and easier to understand than every other 2D library I have come across, but if I can't get it to work with some 3D rendering as well, I might have to move on to another potential library (which I still haven't found).
Title: [sf3d] a project for 3D rendering
Post by: Lokk on June 14, 2011, 09:00:25 pm
@Tank : sf3d is supposed to be as generic as possible. A converter tool ? Yes, why not using sf3d library ?
I can ensure that 3D integration is done as easily as possible within an SFML project. But, it's up to you to decide if you need a custom file format (for optimization reasons) for your project, and where appropriate, it will make sense to develop it, yes !

@Alejandro :
I know that some 2D engines uses 3D baked characters and split them to multiple tiles. (Holyspirit ?) It adds a lot of quality and realism to your scene.
To answer you, I will probably add keyframe animations and skinning since Assimp handle both of them.
Title: Re: [sf3d] a project for 3D rendering
Post by: The Floating Brain on July 30, 2012, 04:12:01 am
Hello

I know you may have to dust off this project, however recently I've been attempting to build it.
My dilemma is I do not know what version of SFML you based it off of. I tried 1.6 and 2.0 however neither worked.

It looks like a really interesting project, any help would be appreciated thank you!
Title: Re: [sf3d] a project for 3D rendering
Post by: eXpl0it3r on July 30, 2012, 09:06:00 am
It's based on SFML 2 like the opening thread states but since the last post was over a year old and the development proably too, you can't expect it to be uptodate with SFML 2. If your lucky you maybe find a note which SFML commit was used last, otherwise you'll have bring it up to speed on your own.
Title: Re: [sf3d] a project for 3D rendering
Post by: kurasu1415 on July 30, 2012, 05:53:12 pm
I suggest using the Autodesk FBX format. I have used Assimp in the past, and I have to say that it is slow, and a little bit overboard. FBX models have become a game industry standard because every 3D modelling program can easily export to it. It is also very easy to load. There is an open SDK made available by Autodesk (the creators of 3DS Max/Maya) specifically for loading and saving to this format. My suggestion would be to use FBX as your primary asset format. Feel free to PM me if you have any more questions. I am working on loading the FBX format myself, so when I get it working flawlessly, I can shoot some code your way.
Title: Re: [sf3d] a project for 3D rendering
Post by: The Floating Brain on August 02, 2012, 03:36:47 am
It's based on SFML 2 like the opening thread states but since the last post was over a year old and the development proably too, you can't expect it to be uptodate with SFML 2. If your lucky you maybe find a note which SFML commit was used last, otherwise you'll have bring it up to speed on your own.

Thank you :-D

If I can't find which poll it was I most certanly I'll port it!
I suggest using the Autodesk FBX format. I have used Assimp in the past, and I have to say that it is slow, and a little bit overboard. FBX models have become a game industry standard because every 3D modelling program can easily export to it. It is also very easy to load. There is an open SDK made available by Autodesk (the creators of 3DS Max/Maya) specifically for loading and saving to this format. My suggestion would be to use FBX as your primary asset format. Feel free to PM me if you have any more questions. I am working on loading the FBX format myself, so when I get it working flawlessly, I can shoot some code your way.


Hey maybe when I get it working I can shoot it your way :-)
Title: Re: [sf3d] a project for 3D rendering
Post by: theodor on August 07, 2012, 01:23:11 am
I would really appreciate if somebody would make this work for sfml 2.0
Title: Re: [sf3d] a project for 3D rendering
Post by: Nexus on August 07, 2012, 04:10:45 pm
I would really appreciate if somebody would make this work for sfml 2.0
The last commit was done 2 years ago, this project is apparently dead. So if you want sf3d to have a future, don't hesitate to adapt it yourself ;)
Title: Re: [sf3d] a project for 3D rendering
Post by: The Floating Brain on August 13, 2012, 05:51:09 pm
I would really appreciate if somebody would make this work for sfml 2.0

I am planning on it!  :D

I would really appreciate if somebody would make this work for sfml 2.0
The last commit was done 2 years ago, this project is apparently dead. So if you want sf3d to have a future, don't hesitate to adapt it yourself ;)


I plan to :-) it looks cool :-)
Title: Re: [sf3d] a project for 3D rendering
Post by: The Floating Brain on August 25, 2012, 08:47:32 pm
Okay so I got it to build and got rid of some bugs!

Bad news is I am unsure if it is working XD

I included a model my friend made of a cube with a blue texture.

If someone who knows more about 3D stuff and OpenGL than me would give me a hand that would be excellent!

Here is the project, it builds with SFML 2.0 RC under Microsoft Visual C++ 2010 Express Edition.

Download here: https://rapidshare.com/files/301558150/SF3DBinariesForWindows.zip
Title: Re: [sf3d] a project for 3D rendering
Post by: netpoetica on October 18, 2013, 05:45:02 am
Floating Brain - how would you feel about starting a Github repo for that port of sf3d? Would love to see about contributing and improving where I can.
Title: Re: [sf3d] a project for 3D rendering
Post by: eXpl0it3r on October 18, 2013, 05:53:47 am
Floating Brain - how would you feel about starting a Github repo for that port of sf3d? Would love to see about contributing and improving where I can.
You're aware that you just bumped an over 1 year old to large extend dead thread? ::)
Title: Re: [sf3d] a project for 3D rendering
Post by: netpoetica on October 18, 2013, 06:22:39 am
Totally aware, but it would be a shame to let good work go to waste :-) the source for sf3d is pretty interesting
Title: Re: [sf3d] a project for 3D rendering
Post by: Lolilolight on November 24, 2013, 09:45:56 pm
Hi, I'm interesting by this project, then, I'm developping something similar for 2D and 3D games.

Here is an exemple of code witch display a cube in a view.

#include "myRenderWindow.h"
#include <SFML/Window/Event.hpp>

using namespace sf3;
MyRenderWindow::MyRenderWindow (Vec2f size, std::string title) :
    RenderWindow(sf::VideoMode(size.x, size.y), title, Style::Default, ContextSettings(32)),
    //In perspective projection the x and y coordinates of the view are always between -1 and 1 with opengl.
    cube(Vec3f(-1, 1, 1), 2, 2, 2, Color(255, 0, 0)) {
    //Rotate the cube around a vector.  
    cube.rotate(45,Vec3f(0, 1, 0));
    view = getDefaultView();
    //The default view have a perspective projection, but you can set another view with the setView function.
    view->move(0, 0, 10);
    speed = 10.f;
    sensivity = 0.2f;
    oldX = Mouse::getPosition(*this).x;
    oldY = Mouse::getPosition(*this).y;
    verticalMotionActive = false;
    verticalMotionDirection = 0;
}
void MyRenderWindow::show () {
    while(isOpen()) {

        sf::Event event;
        while (pollEvent(event))
        {
            if (event.type == sf::Event::Closed)
            {
                close();
            }
            else if (event.type == sf::Event::Resized)
            {
                // Ajust the viewport size when the window is resized.
                view->reset(FloatRect(0, 0, event.size.width, event.size.height));
            } else if (event.type == sf::Event::MouseMoved && sf::Mouse::isButtonPressed(Mouse::Right)) {
                int relX = event.mouseMove.x - oldX;
                int relY = event.mouseMove.y - oldY;
                int teta = view->getTeta() - relX;
                int phi = view->getPhi() - relY;
                //Rotate the view, (Polar coordinates) but you can also use the lookAt function to look at a point.
                view->rotate(teta, phi);
                oldX = event.mouseMove.x;
                oldY = event.mouseMove.y;
            } else if (event.type == sf::Event::MouseWheelMoved) {
                if (event.mouseWheel.delta > 0) {
                    verticalMotionActive = true;
                    verticalMotionDirection = 1;
                    timeBeforeStoppingVerticalMotion = milliseconds(250);
                    clock2.restart();
                } else if (event.mouseWheel.delta < 0) {
                    verticalMotionActive = true;
                    verticalMotionDirection = -1;
                    timeBeforeStoppingVerticalMotion = milliseconds(250);
                    clock2.restart();
                }

            }
        }
        if (sf::Keyboard::isKeyPressed(sf::Keyboard::Up)) {
            //Move the view along a vector, but you case also move the view at a point.
            view->move(view->getForward(), speed * clock.getElapsedTime().asSeconds());
        }
        if (sf::Keyboard::isKeyPressed(sf::Keyboard::Down)) {
            view->move(view->getForward(), -speed * clock.getElapsedTime().asSeconds());
        }
        if (sf::Keyboard::isKeyPressed(sf::Keyboard::Right)) {
            view->move(view->getLeft(), -speed * clock.getElapsedTime().asSeconds());
        }
        if (sf::Keyboard::isKeyPressed(sf::Keyboard::Left)) {
            view->move(view->getLeft(), speed * clock.getElapsedTime().asSeconds());
        }
        oldX = Mouse::getPosition(*this).x;
        oldY = Mouse::getPosition(*this).y;
        if (clock2.getElapsedTime() > timeBeforeStoppingVerticalMotion) {
            verticalMotionActive = false;
            verticalMotionDirection = 0;
        } else {
            timeBeforeStoppingVerticalMotion -= clock2.getElapsedTime();
        }
        view->move(0, verticalMotionDirection * speed * clock2.getElapsedTime().asSeconds(), 0);
        clear(Color::Black);
        draw(cube);
        display();
        clock.restart();
    }
}
 

The library use 3 kinds of matrix : the projection matrix (for perspective or orthographic projection), the view matrix (for the moving of the view in the world), and the transformation matrix. (for entity's transformations)

The user can create any kind of entities has he wants, and he can also create a scene graph and combine transformations, he just have to herit from certain classes and redefines some methods.
This methods are used by the container to store entities (animations, lights, shadows, etc...) with the best performances to render only entities who are visible at the screen.

The library also contains a resource holder to store sounds, images, etc..., and maybe later a special format to load maps.

But actually I'm finishing the 2D part so..., there is not a lot of things that are implemented for 3D games, but, it's coming. :D

I think I'll look at the source code of this project and try to take it over.

I don't want to use other libraries excepts SFML because I want to use the newest features of the c++11 and make it the most simpliest and fastest library.
Title: Re: [sf3d] a project for 3D rendering
Post by: Laurent on November 24, 2013, 10:35:44 pm
If you have your own project, you should open a new thread for it rather than hijacking someone else's thread.
Title: Re: [sf3d] a project for 3D rendering
Post by: Lolilolight on November 25, 2013, 09:24:49 am
No, I just wanted to know if I can contribuate but, the project seems to be death then, I think I'll start a new thread soon. :)