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

Author Topic: [ODFAEG] (Open Source Development Framework Adapted for Every Game)  (Read 158978 times)

0 Members and 2 Guests are viewing this topic.

Lolilolight

  • Hero Member
  • *****
  • Posts: 1232
    • View Profile
Re: [ODFAEG] (Open Source Development Framework Adapted for Every Game)
« Reply #210 on: April 11, 2014, 07:03:49 pm »
Yes I don't know about every kind of games that are existing so I need to check and make a list. (I only know about fps, hack and slash, rts and mmorpg and rpg's likes)

I've forgotten to mention that two new chapter'll see the day :

-The first'll talking about collisions.
-The second'll be talking about the network.

I don't know if I'll implement the thor's particule system un this version or not, but I'll try to make it in this version so, the only think with'll remains'll be full 3D features. (It'll not take too much time because the source code is very modular and I've already prepared all to integrate full 3D easily, I only hope that it won't be too slow and that the result'll be acceptable.)

PS: Ha yes, I've forgotten the sound and the 2D guis but, I don't think it'll be very difficult with SFML and sf::gui. :)
« Last Edit: April 11, 2014, 07:06:18 pm by Lolilolight »

StormWingDelta

  • Sr. Member
  • ****
  • Posts: 365
    • View Profile
Re: [ODFAEG] (Open Source Development Framework Adapted for Every Game)
« Reply #211 on: April 11, 2014, 08:17:02 pm »
yep there are a lot of game types out there.  You've got puzzle, shooter, space, rts, rpg, mmo, action, strategy, etc.

The general idea would be to start with the common things between them and than work down one branch of games in a particular area at a time so you don't get overwhelmed. :)
I have many ideas but need the help of others to find way to make use of them.

Lolilolight

  • Hero Member
  • *****
  • Posts: 1232
    • View Profile
Re: [ODFAEG] (Open Source Development Framework Adapted for Every Game)
« Reply #212 on: April 12, 2014, 07:51:59 am »
Ho god, since a long time ago I was checking a way to find the z position for 2D iso or 2D tiles, and it's very simple. :/

The z value is the same that the y value of the center of the tile. (Because more the tile is bot., more its z component is greater in 2D or 2D iso.)

So I think I'll compute the z of 2D entities in the entity class rather than pass it to the 2D entity constructor, so I've just to do a depth and an alpha test later, and it'll be very more simple for animated entities.


Lolilolight

  • Hero Member
  • *****
  • Posts: 1232
    • View Profile
Re: [ODFAEG] (Open Source Development Framework Adapted for Every Game)
« Reply #213 on: April 12, 2014, 10:41:11 am »
I think I'll change the gridmap and the map class, and make only one entity manager for 2D and 3D objects, it'll be more simple.

I'll also make only 3D collision volumes but they'll also can be used for the 2D.



Grimshaw

  • Hero Member
  • *****
  • Posts: 631
  • Nephilim SDK
    • View Profile
Re: [ODFAEG] (Open Source Development Framework Adapted for Every Game)
« Reply #214 on: April 12, 2014, 06:27:58 pm »
If your designs are really good and work very well why are you consistently refactoring your classes? :p

StormWingDelta

  • Sr. Member
  • ****
  • Posts: 365
    • View Profile
Re: [ODFAEG] (Open Source Development Framework Adapted for Every Game)
« Reply #215 on: April 12, 2014, 10:32:43 pm »
If your designs are really good and work very well why are you consistently refactoring your classes? :p

Yep would be a good idea to pick easy to remember and common names that don't need changing. XD
I have many ideas but need the help of others to find way to make use of them.

The Terminator

  • Full Member
  • ***
  • Posts: 224
  • Windows and Mac C++ Developer
    • View Profile
[ODFAEG] (Open Source Development Framework Adapted for Every Game)
« Reply #216 on: April 13, 2014, 02:24:58 am »


Yep would be a good idea to pick easy to remember and common names that don't need changing. XD

....?
Current Projects:
Technoport

Lolilolight

  • Hero Member
  • *****
  • Posts: 1232
    • View Profile
Re: [ODFAEG] (Open Source Development Framework Adapted for Every Game)
« Reply #217 on: April 13, 2014, 10:46:12 am »
Yeah sometimes I need to change the classes a bit but it doesn't take a lot of time, so I have more time to debug. (It's the advantage to have a good design)

But even with a good design I need to change them a bit to add functionnaities like full 3D here.

There's some misstakes in the class matrix4f and matix3f, I'll update the git-hub this evening.

I've changed the bounding areas to bounding volumes so the new classes becomes :

-BoundingSphere, BoundingEllipsoid, BoundingBox, OrientedBoundingBox and BoundingPolyhedron.


Lolilolight

  • Hero Member
  • *****
  • Posts: 1232
    • View Profile
Great news!!!
« Reply #218 on: April 16, 2014, 09:31:09 pm »
I've found the bugs with my render components and now I use a framebuffer and a depthbuffer texture by component (and not for all components anymore) I've adapted the gridMap class to store 3D entities for the final version of ODFAEG!!!

Now, 2D and 3D entities can be drawn on components correctly, the advantage of odfaeg's render components is that they have a dephtest which manage semi-tranparent pixels. (if your pc support the GLSL)

You can so cross semi-transparent textures on the z axis and create special effects. (pixel water which overlap the ground by exemple)
(But it only work for PC which support shader, otherwise rendercomponent'll use the default opengl depth test or the zsorting for flat textures)

The world class can so directly draw entities on component, and components'll be drawn directly on the window by the application, so in the onRender function you have just to specify which entity you want to draw on which component, here I draw the ground on a first render component and the other entities in a second render component, so, event if the z of the ground textures is greater than the z of the texture's caracter, the ground texture doesn't overlap the caracter because the ground is drawn on another component.
 void onRender() {
            World::drawOnComponents("E_TILE", 0);// draw the ground on the background component.
            World::drawOnComponents("E_WALL+E_DECOR+E_ANIMATION+E_CARACTER+E_PONCTUAL_LIGHT", 1);        
//Draw all other entities to the foreground component.  
 }
 

Component'll also be used to generate light map and shadow easy in 3D in the last version of ODFAEG.

The node of the framework is nearby finished so I'll wait to have a better source code before updating the git-hub with a source code example!

But maybe I'll need some help fore optimisation so I'll browse some other forums before, because drawing everything on rendertextures and passing params to shader is a bit slow. :/  (even with vbos)

#include "../../../../include/odfaeg/Graphics/2D/fastRenderComponent.h"
namespace odfaeg {
namespace g2d {
FastRenderComponent::FastRenderComponent (RenderWindow& window, int layer) :
    Transformable(Vec3f(window.getView().getPosition().x, window.getView().getPosition().y, layer),
                  Vec3f(window.getView().getSize().x, window.getView().getSize().y, 0),
                  Vec3f(window.getView().getSize().x + window.getView().getSize().x * 0.5f, window.getView().getPosition().y + window.getView().getSize().y * 0.5f, layer)),
    view(window.getView()) {
    sf::Vector3i resolution ((int) window.getSize().x, (int) window.getSize().y, window.getView().getSize().z);
    depthBuffer = new RenderTexture();
    frameBuffer = new RenderTexture();
    depthBuffer->create(resolution.x, resolution.y);
    frameBuffer->create(resolution.x, resolution.y);
    frameBuffer->setView(window.getView());
    depthBuffer->setView(window.getView());

    if (Shader::isAvailable()) {
        frameBufferGenerator = new Shader();
        depthBufferGenerator = new Shader();
        const std::string vertexShader =
        "void main () {"
            "gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;"
            "gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0;"
            "gl_FrontColor = gl_Color;"
        "}";
        const std::string  depthGenFragShader =
        "uniform sampler2D depthBuffer;"
        "uniform sampler2D texture;"
        "uniform vec3 resolution;"
        "void main () {"
              "vec2 position = ( gl_FragCoord.xy / resolution.xy );"
              "vec4 color = texture2D(depthBuffer, position);"
              "vec4 pixel = texture2D(texture, gl_TexCoord[0].xy);"
              "if (gl_FragCoord.z >= color.z && pixel.a >= color.a) {"
                 "gl_FragColor = vec4(0, 0,gl_FragCoord.z, pixel.a);"
              "} else {"
                 "gl_FragColor = color;"
              "}"
        "}";
        const std::string frameBufferGenFragShader =
        "uniform sampler2D depthBuffer;"
        "uniform sampler2D frameBuffer;"
        "uniform sampler2D texture;"
        "uniform vec3 resolution;"
        "void main () { "
            "vec2 position = ( gl_FragCoord.xy / resolution.xy );"
            "vec4 depth = texture2D(depthBuffer, position);"
            "vec4 color = texture2D(frameBuffer, position);"
            "vec4 pixel = texture2D(texture, gl_TexCoord[0].xy);"
            "if (gl_FragCoord.z >= depth.z) {"
                "gl_FragColor = pixel;"
            "} else if (color.a < pixel.a) {"
                "gl_FragColor = pixel;"
            "} else {"
                "gl_FragColor = color;"
            "}"
        "}";
        if (!depthBufferGenerator->loadFromMemory(vertexShader, depthGenFragShader))
            throw Erreur(50, "Failed to load depth buffer generator shader", 0);
        if (!frameBufferGenerator->loadFromMemory(vertexShader, frameBufferGenFragShader))
            throw Erreur(51, "Failed to load frame buffer generator shader", 0);
         depthBufferGenerator->setParameter("resolution",resolution.x, resolution.y, resolution.z);
         frameBufferGenerator->setParameter("resolution",resolution.x, resolution.y, resolution.z);
         backgroundColor = sf::Color::Transparent;
    }
}
void FastRenderComponent::setBackgroundColor(sf::Color color) {
    this->backgroundColor = color;
}
void FastRenderComponent::clearBufferBits() {
    frameBuffer->clear(backgroundColor);
}
void FastRenderComponent::clearDepthBits() {
    depthBuffer->clear(sf::Color::Transparent);
}
g2d::Tile FastRenderComponent::getFrameBufferTile () const {
    sf::IntRect subRect(0, 0, frameBuffer->getView().getSize().x, frameBuffer->getView().getSize().y);
    g2d::Tile tile (&frameBuffer->getTexture(), Vec2f(0, 0), Vec2f(frameBuffer->getView().getSize().x, frameBuffer->getView().getSize().y), subRect);
    return tile;
}
g2d::Tile FastRenderComponent::getDepthBufferTile() const {
    sf::IntRect subRect(0, 0, depthBuffer->getView().getSize().x, depthBuffer->getView().getSize().y);
    g2d::Tile tile (&depthBuffer->getTexture(), Vec2f(0, 0), Vec2f(depthBuffer->getView().getSize().x, depthBuffer->getView().getSize().y), subRect);
    return tile;
}
bool FastRenderComponent::load(std::vector<Entity*> visibleEntities)
{

    if (Shader::isAvailable()) {
        fg.clear();
        for (unsigned int i = 0; i < visibleEntities.size(); i++) {

            if (visibleEntities[i]->isLeaf()) {
                for (unsigned int j = 0; j < visibleEntities[i]->getFaces().size(); j++) {

                    visibleEntities[i]->getFaces()[j]->transform(visibleEntities[i]->getTransform());

                    fg.addFace(visibleEntities[i]->getFaces()[j]);
                }
            }
        }
        m_vertices = fg.getFaces();
    }
    this->visibleEntities = visibleEntities;
}

void FastRenderComponent::draw(RenderTarget& target, RenderStates states) const {
    const Shader* devShader = states.shader;
    states.transform = getTransform();
    if (Shader::isAvailable()) {
        frameBuffer->setView(target.getView());
        depthBuffer->setView(target.getView());
        for (unsigned int i = 0; i < m_vertices.size(); i++) {
            states.texture = const_cast<FastRenderComponent*>(this)->m_vertices[i].first.getMaterial().getTexture();
            for (unsigned int j = 0; j < m_vertices[i].second.size(); j++) {
                states.shader = frameBufferGenerator;
                frameBufferGenerator->setParameter("depthBuffer", depthBuffer->getTexture());
                frameBufferGenerator->setParameter("frameBuffer", frameBuffer->getTexture());
                frameBufferGenerator->setParameter("texture", Shader::CurrentTexture);
                frameBuffer->draw(*m_vertices[i].second[j], states);
                frameBuffer->display();
                depthBufferGenerator->setParameter("depthBuffer", depthBuffer->getTexture());
                depthBufferGenerator->setParameter("texture", Shader::CurrentTexture);
                states.shader = depthBufferGenerator;
                depthBuffer->draw(*m_vertices[i].second[j], states);
                depthBuffer->display();
            }
        }
        g2d::Tile tile = getFrameBufferTile();
        tile.setCenter(frameBuffer->getView().getPosition());
        states.shader = devShader;
        target.draw(tile, states);
    } else {
        for (unsigned int i = 0; i < visibleEntities.size(); i++) {
            for (unsigned int j = 0; j < visibleEntities[i]->getFaces().size(); j++) {
                states.texture = visibleEntities[i]->getFaces()[j]->getMaterial().getTexture();
                states.transform = visibleEntities[i]->getTransform();
                target.draw(visibleEntities[i]->getFaces()[j]->getVertexArray(), states);
            }
        }
    }
}
void FastRenderComponent::init() {
}
FastRenderComponent::~FastRenderComponent() {

}
View& FastRenderComponent::getView() {
    return view;
}
int FastRenderComponent::getLayer() {
    return getPosition().z;
}
}
}
 

I don't thing that's it's necessary to pass the transformation matrix if I update vertices in the vbo, in any case I'll have to browse other forums to get some optimisation advices, the source code of SFML is not sufficient anymore.

Lolilolight

  • Hero Member
  • *****
  • Posts: 1232
    • View Profile
Re: [ODFAEG] (Open Source Development Framework Adapted for Every Game)
« Reply #219 on: April 17, 2014, 08:08:26 pm »
I've  neverless updated the git-hub because there was important bug corrections.

The next updates'll be the remaining tests for bug corrections and rendering optimisations that I don't have found yet and almost documentation and source code examples.

And then, the release of the second version of ODFAEG'll see the day!

But I've set the implementation of lighting and shadow in pause because, as nexus as pointed out, I can't implement all features at once alone. (Or it'll take too much time to test everything and to debug/optimisate everything.)

But the main root of the framework is nearby finish, a have basic secure networking, graphics and physics classes which seems to work pretty well exepts for pixel per pixel rendering where it's a bit more difficult to have optimized result.
And I never had the occasion to program games with very evoluated graphism and I've hard to find help in this domain.
« Last Edit: April 17, 2014, 08:10:50 pm by Lolilolight »

Lolilolight

  • Hero Member
  • *****
  • Posts: 1232
    • View Profile
ODFAEG is now working on linux.
« Reply #220 on: April 21, 2014, 11:02:18 am »
I've switched to linux (distrib ubuntu 13.04 64 bits) to make it works, and corrected the last bugs.

I've get rid on my polluated windows 7 64 bits and it's now faster so I'll stay on ubuntu. ;)

I'll update the git-hub this evening so, just the time to install git-shell on linux.  :)

In the next update it'll be most of all code purification and new functionnalities implementation. (putting the templates in a .inl file like SFML, makes the library works in shared mode and configure the package files for linux, implementing the particule system of the thor library, implementing the SFML fonts and shapes to make it work with odfaeg, etc...)

I'll make a full 3D isometric game to test everything before making the final release which'll include more 3D functionnalities (3D terrain generation, 3D object loader, 3D object selection, animated entities interpolation, lighting and shadowing.) and the sound module.

I can't implement all functionnalities at once, because I'm alone to make this project and it'll be very unstable if I do that anyway, for full 3D games you'll have to be patient. :)
For those who don't still know me :
I'm a fullstack developper (it means that I can make a bit of everything (networking, database management, web and application developpment, os management and software usage)) but I'm not specialized in something.
But it doens't means that I can make everything at once. (I hope it's clear for you)




StormWingDelta

  • Sr. Member
  • ****
  • Posts: 365
    • View Profile
Re: [ODFAEG] (Open Source Development Framework Adapted for Every Game)
« Reply #221 on: April 21, 2014, 05:57:22 pm »
Luckily with github we can help out if needed so if you need help just ask since I'm sure those of us that specialize in specific areas could clean up and better some of the code or even add to it. :)
I have many ideas but need the help of others to find way to make use of them.

Lolilolight

  • Hero Member
  • *****
  • Posts: 1232
    • View Profile
Re: [ODFAEG] (Open Source Development Framework Adapted for Every Game)
« Reply #222 on: April 21, 2014, 09:59:12 pm »
Yep.  :D

The update'll be set tomorrow because, I've still improved the command system. (which was too slow)

Now the scene updates and renders even faster.  :)

I think I'll ad the possibility to do assynchrone or synchrone command execution like in opengl. (In assynchrone mode, one sf::event'll be send to the thread and then the thread'll process this event, in synchrone mode, all event'll be send to the thread and the thread'll process all the events.



Deathbeam

  • Jr. Member
  • **
  • Posts: 82
  • VB6, VB.NET, C#, HTML, PHP, CSS, JavaScript nerd.
    • View Profile
    • My portfolio
    • Email
Re: [ODFAEG] (Open Source Development Framework Adapted for Every Game)
« Reply #223 on: April 22, 2014, 10:56:23 am »
I like opening this thread always when you post something new @Lolilolight and then reading your posts and trying to understand all that things you are writing :) Take this as compliment, becouse I am totally unskilled in this core things what you are doing :D
Spooker Framework - Open source gaming library
My portfolio
Indie Armory - Small community of a game developers. Everyone is welcome. Bring your friends, family, pets...

Lolilolight

  • Hero Member
  • *****
  • Posts: 1232
    • View Profile
Re: [ODFAEG] (Open Source Development Framework Adapted for Every Game)
« Reply #224 on: April 22, 2014, 07:29:34 pm »
Ok, so, I'll update the git-hub this evening, including a tutorial and a source code example which'll show what we can actually do with the framework.

And it's only the beginning because I'm not very far compared to some projects that I've seen on other threads. (Like d3d by example)

It's not that I'm not able to to domething similar compared to these other projects but it's only because I don't want to put all the fonctionnalistes at once in my framework.

I hope that in a few years it'll looks like even better. (When I'll have finished to implement the 3D functionnalities)

And I hope that I'll have a more acceptable result than in the past with the 3D when displaying full 3D models. (I hope that my skills for the 2.5D'll help, but I think that it can help me a lot)

So..., there are always some points where I'm still unskilled, even if I spend a lot of energy for this framework and it's not very benefit.

So I'll create a less ambitious project first with this version and then create a more ambitious project with the final version of odfaeg.

 

anything