• Advertisement

Shaarigan

Member
  • Content count

    432
  • Joined

  • Last visited

Community Reputation

1080 Excellent

5 Followers

About Shaarigan

  • Rank
    Member

Personal Information

  • Interests
    Art
    Design
    Programming

Social

  • Github
    Shaarigan
  1. C++ FreeGLUT - Making Planets Orbit

    So as it seems it is unclear what a scene graph does I post this Scene Graph Tutorial here. A scene graph isnt used to alter velocities,speeds or whatever you thought it is for, as explained, a scene graph just simplifies parent child relations in drawing in a simple tree structure. Your map is a root object while your character walking on the map is a child of it. Your character has an armor, a weapon and some stuff on its belt attached that are themselfs childs of your character. Moving your character means altering the position of its equipment too. And this is what your current problem is, you attach your planets to the sun. Rotating the sun means rotating its childs too so the planets would always rotate at the speed of the sun. This is what matrices are for. Calculating the transformation matrix of a child means firs calculate that oneof its parent and multiply those matrices together to get the childs model matrix. Vertex (each) * Model * View (your eye position) * Projection (perspective transformation) = pixel on the screen. This is what the immediate mode matrix and transform functions are in OpenGL. glPushMatrix adds a new matrix to the stack that inherits from the parent matrix glTranslate, glRotate, glScale do all the multiplication on the top matrix of the stack glPopMatrix removes the current matrix from the stack You normally start with an identity matrix glLoadIdentity(); glPushMatrix(); //Stack-Index 0 1, 0, 0, 0 0, 1, 0, 0 0, 0, 1, 0 0, 0, 0, 1 //Stack-Index 1 1, 0, 0, 0 0, 1, 0, 0 0, 0, 1, 0 0, 0, 0, 1 that means each vertex is placed at the same position it is used to. Then you translate the matrix by 1 and get glTranslatef(x, y, z); //Stack-Index 0 1, 0, 0, 0 0, 1, 0, 0 0, 0, 1, 0 0, 0, 0, 1 //Stack-Index 1 1, 0, 0, X 0, 1, 0, Y 0, 0, 1, Z 0, 0, 0, 1 what means a vertex at position { 0, 0, 0 } is translated by { X, Y, Z }. Now you take the scene graph and we assume that your root node is at stack index 1 and has one leaf node to render glPushMatrix(); //Stack-Index 0 1, 0, 0, 0 0, 1, 0, 0 0, 0, 1, 0 0, 0, 0, 1 //Stack-Index 1 1, 0, 0, X 0, 1, 0, Y 0, 0, 1, Z 0, 0, 0, 1 //Stack-Index 2 1, 0, 0, X 0, 1, 0, Y 0, 0, 1, Z 0, 0, 0, 1 The leaf starts at its parents current transform and calling the leafs transform will result in glTranslatef(x, y, z) //Stack-Index 0 1, 0, 0, 0 0, 1, 0, 0 0, 0, 1, 0 0, 0, 0, 1 //Stack-Index 1 1, 0, 0, X 0, 1, 0, Y 0, 0, 1, Z 0, 0, 0, 1 //Stack-Index 2 1, 0, 0, X1 + X2 0, 1, 0, Y1 + Y2 0, 0, 1, Z1 + Z2 0, 0, 0, 1 Next child of this leafe node would act the same, this is what a scene graph is used for. As I wrote, in AAA Games and Engines the scene graph also does culling of objects to speedup rendering so if a leaf is disabled for rendering, its childs could be skipped to and so on. What is the sense of this? The sense is simply to simplify rendering. Otherwise you would have to iterate through the list of objects and its parents each on its own and do a lot of matrix multiplications and visibility tests that slow down your game. Related to your entry post, you have had anything attached to the sun so transforming the sun meant you changed the entire root matrix for anything that is a leaf of the sun. Then transforming any leaf was iterative transforming the whole chain in a way that did'nt lead to the result you expected. So if you want to transform each planet on its own speed, you need each planet to inherit from the identity matrix so become a root node instead of a leaf of the sund root node. This is the most simple solution I can give ya
  2. C++ FreeGLUT - Making Planets Orbit

    As I wrote, you need a proxy object for each different orbit speed. Look at the second image
  3. You wrote just 7 minutes ago so come down and keep calm. People are working or sleeping depending on where on the world you are currently ... Have you checked that your file is processed correctly by setting a breakpoint and investigate the contents of the arrays? Have you checked for GLErrors? Have you checked for other non-exceptional errors? Have you setup your View- and Projection-Matrix aka the camera correctly? Have you checked that your model gets rendered correctly so push to graphics card is triggered, shader is set up correctly and model/view/projection matrices are setup correctly?
  4. C++ FreeGLUT - Making Planets Orbit

    You should imagine that what you actually have is a solar system model as something like this Anything is connected to each other and to rotate one means rotating all its children, so when you rotate the sun, any planet connected to the sun also rotates and any moon connected to the planets also rotates based on the planets rotation. What you need is something that looks like this Here each planet is connected to its own axis (so dont has a parent child relation to the sun. What you can do is to add proxy objects to your scene graph that themselfs hold the planets. Instead of rotating the sund, you rotate the proxy object at certain angle increase and so get 'individual' orbital movement
  5. C++ FreeGLUT - Making Planets Orbit

    The scene graph is simply a tree structure of entity references where each node is itself a leaf of its parent node. In AAA games and engines like Unity or Unreal, the scene graph simply holds some transform matrices and reference pointers to the entities. Then when an entity changes, the scene graph will update its matrix and update the matrices of all of its children. Then when rendering happens, the scene graph is traversed from root node to its leafs (leaving all the frustum culling and hidden object detection away) sets the transform to the pre-calculated matrix and then pushes the VBO onto the hardware pipeline
  6. Going one step further, do never split header (.h) and implementation (.cpp) files because it is pure bad design to do so especially but not limited to greater projects! I always feel wasting my time to seek for the coresponding .h or .cpp files when investigating projects on GitHub. A clear folder structure and strong naming will always be your best friend in such things. What you will still to have is setting VS options correctly because even if you structure your files correctly on disk, VS will throw them all together so either work in folder view or (in my case because my project structure has some more sub levels) use filters. But be aware of VS creating files for you, it will throw them into your main directory even if filters indicate something else. I personally have written my own in-house tool for that (and a lot of other) task(s) but CMake or anything else fill also fit it. I don't really like VS Code because it seems like a variant of Visual Studio but behaves completely different in some cases but thats my taste
  7. C++ FreeGLUT - Making Planets Orbit

    I see some problems in your code: The first is that your rotation depends on your frame rate so on a faster computer you will render more frames and rotate faster. Use some kind of time delta here to fix the update for every PC you run your code at You shoudldn't make a difference for "sun" an other objects in your scene. If it isnt a sun, you first rotate the planets last matrix, add a new matrix to the stack and then translate and rotate again, this couldnt work at all! You should first clean up your object class. An object has an origin from its parent that may or may not be in a linar hirachy. So you need first to load a clean matrix for your root object in the scene (your sun) and do the transformation for that object. Translate the object first to where it belongs to as the objects origin, scale the object because you would get mismatches in translation either and then rotate the object for each axis on its own so you wont get any rotation mismatches (like a planet is spinning arround a certain axis). The you should iterate any child object that is in this objects hirachy with the same matrix transformation as base so the origin of any child object is the origin and transform of the root object + the child objects relative coords and transform. This way you build the scene graph. In code it would look like this void Render() { glPushMatrix(); glTranslatef(position.X, position.Y, position.Z); glScalef(scale.X, scale.Y, scale.Z); glRotatef(rotation.X, 1, 0, 0); glRotatef(rotation.Y, 0, 1, 0); glRotatef(rotation.Z, 0, 0, 1); glDrawElements(GL_TRIANGLES, mesh->indiceCount, GL_UNSIGNED_SHORT, mesh->indices); for(int i = 0; i < childCount; i++) childs[i]->Render(); glPopMatrix(); } This is untested but should work in theory
  8. Do indie game designers play their own game?

    As any game developer/designer you will play your own game hours over hours over hours, especially when you are in a smaller team without dedicated QA. I dont know about AAA titles from bigger studios (a lot) but even there the designer will have to QA the game to check if it fits to whatever he/she has thought it should but QA is foremost done by automated tests as I know (they start the game and simulate a fixed procedure to see if single steps match to what they are intended to) I personally start my project(s) every day after the daily checkout to see if something changed and find new bugs and happenings that should be fixed for the next day. This results in Steam game times from arround 50 to 100 hours in the decade of development time even if I didn't play the game after release (if it isnt something I really really was proud of) It is true that you will know your game better as any player after release for the first few months/years (depending on the extents of your game) what will decrease the interest in playing after release depending on the kind of game. A more action or story driven game with smaller size has had a lower interest as the medival city building simulator I worked at. In general I would say, if the game is fun and you don't remeber anything, then chances are high that even a game developer/designer will play its own games
  9. Scripting Designing interesting Quests

    I like Bathesda games but only those that offer a huge world where you could just explore and meet people so you have a total ingame play time of 10 hours before going to do the first main quest But in the other points you are completely right and thats why I wrote somewhere earlier that it is more fun if an NPC just wants X of Y but the game dosent tell the player where/how Y is to obtain instead of pointing to a 2x2 meter area on the map spawning every 5 seconds an evil NPC that drops Y. It will still be a collect X of Y quest but with a little gathering background for information that could themselfs be obtained from other NPCs, books or experience of other players. I also would always work with consequences. Killing an NPC prevents you and/or other players from finishing there quests. NPCs never respawn and as long as this isn't a main story required one, it wont have any impact on the game itself but will punish players if there is later a quest that has an option to be solved more easy by just talking to that NPC. I think a game can sometimes be but shouldn't only be a place to just slaught anything that moves because 'we can do it'. I don't say that I never took my sword and simply slashed a guard or shot an NPC down but this shouldn't be a general approach to go (except for a relaxing turn Unreal Tournament ) So by the way, if anyone is interested in this discussion, I could still need some help writing and designing the core game mechanics and content creation rules! Just PM, Skype or Discord me
  10. Scripting Designing interesting Quests

    Agree, I ever felt that it was not a good idea to explore every dungeon in the game of Skyrim/Oblivion just to get an NPC that a few hours later want me to go in and fetch something for it. All enemies dead but the one "Ring of Ultimate Whatever" has spawned there so again walk through feeled 100 floors just to find the ring in a chest I looted just an hour or too ago? Yeah, thanks but no! What I'm twiddling arround at the moment is an approach where there are auto generated quests as same as human written story snippets that are just that generic so that the content generator could assemble it too. Anything, any NPC in the world should have a background story why he/she is there at the moment a player discovers it. Partially auto generated but also as some kind of principle of cause and effect. Based on that background-story (without going too deep into technical details) quest will be spreaded arround the world to make them "more plausible" to play. I personally like the Bathesda games for there "talk randomly to someone that tells you something you might find interesting enougth to get a quest for" principle. Regardless of if it is reading a book and gather some knowledge about some palce anywhere in the world or find people that need help with something because one heared from another one that there is someone that knows someone to need help I personally also dislike the typical "you have no choice because you are just the hero and go get the situation fixed that a mass of people has broken for the past 10 years" scenario. Especially in (bad designed) multiplayer/online games where each player is something special and the ultimate hero the citizens have waited for a century or two. What is the motivation for playing such kind of game? Sometimes it the story but mostly I feel it is just to explore the world. I can't immagine that WoW players play the game for the background story rather than exploring and raiding dungeons to beat down there bosses. So what I'm finally destinated to with this topic (and technology) is not making the story in a complex main quest but anything arround it so one might or might not tell his/her story and the content generator fills the world with anything else or quit on a main story but still provide a living world with all these interesting things to explore. I also like the idea that quests should react on the world and not vice versa, what would (I think) make them more plausible than the other way round
  11. Scripting Designing interesting Quests

    I agree the player is forced to may tend to a list of ergotherapy tasks to keep the gameplay up. But again, in similar games like Dungeons & Dragons Daggerdale where you are just sloughting goblins and other stuff for the full 6 to 8 hours of gameplay, it is similar but less boring (to me at least). You are thrown into some sort of "campaign" without any choices, hunted by a giant golem into a portal and forced to help some dwarfs. Here again, the game decides what to do not the player but this works and the other game dosent seem to work. Same as in Skyrim, you are forced to play for the or the other side even if you didnt want to go for both. The game decides to get both fractions onto a table to talk, not the player. The only real choice is that a player may or may not accept a quest if possible while in most games you didn't even have the choice (unless you stop playing) I can't believe that "a reasonable story" on its own makes the game, it must be something additionally !? This is right, for that reason I asked here to investigate how complex the generator has to be and what kind of rules should be applied to it. I could imagine it depends on the kind of context a quest is running into if it will fit or not. A quest that is like I described; "go to the place I marked on your map and collect 12 X then get it back to me" where the area is just half a minute away so the NPC himself could have been going there by its own instead of talking to the player is useless while giving the player a 'real' task might make it here. It will still be a collect X of Y task but as a side quest the player can decide when and how it will be done or the real task should be not collecting Y but discover where/how to get Y. I also think the fun is not seeking for the guy with the sign above its head rather than The Edler Scrolls is doing it: talk to people, listen for there stories and you might get some rumors to investigate, reading books and reveal new places on the map. Here it is all about talking, no one gives ya a quest just cause. Correct me if I'm going wrong in this thoughts BTW: The 'real task' with the auto generator will be to get NPCs dialogs different and a kind of responsive that a player might think it acts like a real character instead of the two or thrre standard clauses , but this is a more technical issue than a game design related one
  12. Scripting Designing interesting Quests

    I sadly must disagree that theory for some reasons of happening. I played a game yesterday where there is a town that s tourmented by pirates. The citizens decide to trap the pirates and collective form a plan to kill them once at all. You need to talk for the towns tinkerer that makes the decision to assemble some bombs digged into the beach to blow the pirates up but how to get them there? You meet an alchemist that gives ya a recipe for fool's gold but wait, how to get into the pirates camp without getting catched and killed? So you will also have to catch one of the pirates and ask him for there camp's location and watchword, also you need to mask and act like a pirate. This is just a summary of the quest line, more or less interesting story in theory but in practise all what you are doing over two hours was collect X of Y, collect another X of Z, talk to X, talk to Y, talk to Z, collect X of Z, carry W to another W, collect X of XY and a lot of kill X of whatever. In summary, a really boring gameplay sending the party over a really (really) small map where it just took only 2 minutes to reach the other end. What about this, how did this fit into your theory? How could have this be made better and worht playing if you say that it dosent depend on the archetype of the quest itself? Edit Dont ge me wrong, it dosent mean that any of those constellations have to be boring, in games like Dungeons & Dragons Daggerdale you are also just smashing a dozens of goblins with your party and run from the dwarfs to the goblins camp back to the dwarfs but this has made fun sloughting through the hordes of goblins and there wasnt any great told complicated story involved here (cause the game has had a total time for playing of not even 6 hours) but this was a lot (and I mean A LOT) more fun than what we have played yesterday. Even the boss fights (were as trivial so I'm not even sure these were boss fights but just some stronger foes to defeat) did not feel as they really were boss fights
  13. If you are using a memory pool you also need to use a custom allocator to your memory pool, otherwise the internal container code will still allocate on the heap btw.
  14. You act with the code like you would act with every other heap allocated code. A simple delete pSet; should/will call this containers destructor as any stl container has one freeing any space allocated on the heap using the defined allocator. You are not working on the stack so this might cause your confusion because stack allocated stuff mostly causes the compiler to call the destructor on leaving the scope (anything that is inside brackets is in it's own scope) it is in without the need to manually delete it while pointer code is used to share stuff between functions/scopes
  • Advertisement