#How do you manage a editor camera and scene cameras?

25 messages · Page 1 of 1 (latest)

gentle elm
#

I feel like a camera is a pretty straightforward concept to implement, but I've been going through a bit of an architectural crisis because I didn't realize how intertwine it can be with other systems. My current design has a scene class that's kind of like a database of things for the renderer to use so it made sense that the scene would have ownership of the camera since it sort of exisits in the scene and the renderer uses it.

class Camera {
public:
    glm::mat4 getViewMatrix() const;
    glm::mat4 getProjectionMatrix() const;
// ...
};

class Scene {
private:
    std::shared_ptr<Camera> activeCamera;
// ...
};

class Renderer {
public:
    void render(Scene* scene) {
        // use the camera from the scene
    }
};

The problem I'm facing with this though is for the editor camera (the one you would use to move around the scene while editing) although it's still a camera I feel like an editor camera is more of a tool that lives outside of the scene/gameworld rather than something that is part of it, but I want the ability to add camera nodes to my scene which would be part of the game so I guess what I'm trying to ask is if there two type of cameras are different/separate and if so how do you manage that? Hopefully that's not to confusing I'll try my best to clarify if needed.

kindred lintel
#

There are countless ways to approach this, what sort of input are you asking for

gentle elm
kindred lintel
#

There's no correct way

gentle elm
#

fair, but I feel like from a design(?) perspective it should make some sense

kindred lintel
#

Yes it should but I'm saying every project is different, your question basically amounts to "how do I organize a game/engine codebase" to which there are infinite answers

gentle elm
#

ah

#

hmm by chance do you know any open source engines I could look at? perhaps I can get a better idea/understanding through that.

kindred lintel
#

There's always doom and quake and stuff but I've never found that very useful since those engines are the end result of a long path of development, not a starting point

#

Just because it may end up that way after 10 years of development doesn't mean that's the best place to start

#

But already what you're showing seems like an overabstraction compared to a straightforward data-oriented solution

#

Like why does a camera need a class, what invariant is it maintaining

#

A camera is just a regular scene object with a few FOV params

gentle elm
#

but I guess that's where you're saying it's different for others

kindred lintel
#

Idk personally I don't have an editor, I just have a camera mode and a few random editor tools directly in my game

gentle elm
#

oh lol

kindred lintel
#

Imo an editor is a pretty low priority thing to build since it's laborious and not all that useful for most purposes unless your engine is like an actual mature commercial product

#

What is your engine for anyways

gentle elm
#

at first I was making a game, but I kind of became more interested in just making an editor

kindred lintel
#

That makes it pretty hard to design around

#

Since there is no purpose to guide the decisions

#

I would go back to making the game even if the game is sort of sandboxy and editor-like

gentle elm
#

well I have an idea of what games I would like to make although it's kind of stupid