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

Author Topic: [sf3d] a project for 3D rendering  (Read 25562 times)

0 Members and 1 Guest are viewing this topic.

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6286
  • Thor Developer
    • View Profile
    • Bromeon
Re: [sf3d] a project for 3D rendering
« Reply #15 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 ;)
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

The Floating Brain

  • Newbie
  • *
  • Posts: 14
    • View Profile
    • http://www.gcggames.webs.com
Re: [sf3d] a project for 3D rendering
« Reply #16 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 :-)
« Last Edit: August 13, 2012, 06:51:48 pm by The Floating Brain »

The Floating Brain

  • Newbie
  • *
  • Posts: 14
    • View Profile
    • http://www.gcggames.webs.com
Re: [sf3d] a project for 3D rendering
« Reply #17 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

netpoetica

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: [sf3d] a project for 3D rendering
« Reply #18 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.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10815
    • View Profile
    • development blog
    • Email
Re: [sf3d] a project for 3D rendering
« Reply #19 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? ::)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

netpoetica

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: [sf3d] a project for 3D rendering
« Reply #20 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

Lolilolight

  • Hero Member
  • *****
  • Posts: 1232
    • View Profile
Re: [sf3d] a project for 3D rendering
« Reply #21 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.
« Last Edit: November 24, 2013, 10:00:58 pm by Lolilolight »

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: [sf3d] a project for 3D rendering
« Reply #22 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.
Laurent Gomila - SFML developer

Lolilolight

  • Hero Member
  • *****
  • Posts: 1232
    • View Profile
Re: [sf3d] a project for 3D rendering
« Reply #23 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. :)