Penguins Craft (Overworld)

Discussion in 'Development General' started by coyotte508, Jul 20, 2011.

  1. coyotte508

    coyotte508 Well-Known Member Administrator Server Owner Administrator Server Owner

    Joined:
    Apr 21, 2010
    Messages:
    6,363
    Likes Received:
    168
    [​IMG]

    Now presenting: Penguins Overworld Craft, or po-craft for short.

    This is a ball rolling on a field, and you can control the ball and you can even rotate the camera!!

    https://sourceforge.net/projects/po-craft/develop

    To compile, you need Qt, SFML, Glut, and SDL (I know... only SFML woul truly be necessary, others only play minor roles)

    This is my first 3D attempt. I hope to create a world a lot vaster, then i'll add blocky constructions, a jumping ball, a ball with a texture rotating correctly so it's cooler, plenty of fun 3D stuff like particle fountains etc, a camera that follows the ball, a blue sky, a shadow on the ball, and a zone in which you can connect to a server and find battle and battle in 3D with the 2D BW/animated pokemon sprites. The ball would have to jump on a move to trigger it, or hit a reserve pokemon to send him in!

    Once that's down, i could do some other things in 3D too, maybe eventually a 3D brick break , a way to use LUA AI for something, a building with several rooms to do different stuff, etc. I want to eventually have a world in which there are various things, that have nothing in relation and could be added by different people, maybe like minecraft, but not too similar either! And maybe add other players in the world, but that's a big maybe.

    Anyway the code is open source & cross platform, and the screen above is my awesome ball rolling on the field.

    So, why a thread so early in the development? I'm just starting 3D, and I need encouragements and to document my steps in order to show off a bit and have the desire to continue further and further. I'd also welcome ideas of cool stuff. Remember that programming 3D is very diverse in a few lines, i could make the light of the world move in a circle over the world or throw a bunch of balls bouncing around and so on, or have a red sky, ...! So if you have any idea that will be pretty simple to do, don't hesitate!

    Next step: Make the camera follow behind the ball!

    Also, I'm learning 3D for the first time, so I may take my time to try new things and all as I really know nothing for now...
    Don't hesitate to post dev related things in there too.
     
    Last edited: Jul 25, 2011
  2. Darkness

    Darkness DN

    Joined:
    Apr 21, 2010
    Messages:
    206
    Likes Received:
    7
    Superb! *0*
     
  3. Blastcore

    Blastcore Developer

    Joined:
    Jul 19, 2010
    Messages:
    763
    Likes Received:
    1
    Haha, let's make a Pokemon RPG! =D

    EDIT: Downloading source, i'm curious of how that works. =P
     
  4. Viderizer

    Viderizer Admin/Developer

    Joined:
    Mar 12, 2011
    Messages:
    277
    Likes Received:
    0
    This... sounds... AWESOME! Downloading source atm

    EDIT: Wait how do I build this? /n00b
     
    Last edited: Jul 21, 2011
  5. coyotte508

    coyotte508 Well-Known Member Administrator Server Owner Administrator Server Owner

    Joined:
    Apr 21, 2010
    Messages:
    6,363
    Likes Received:
    168
    I'm using QtCreator as an IDE, so you need either qmake or qtcreator.

    If you're on windows, it should compile and run automatically. On linux, you need to install freeglut-dev as well as libsdl-dev. If you got problems tell me more about them.
     
  6. Viderizer

    Viderizer Admin/Developer

    Joined:
    Mar 12, 2011
    Messages:
    277
    Likes Received:
    0
    Ok, I am missing those packages, I'm on Linux/Ubuntu 11.04

    EDIT: So I opened po-craft.pro and pressed build and this came

    error: SFML/Window.hpp: Tiedostoa tai hakemistoa ei ole
    Translated: File or Directory is missing, I set the build dir as defaultl when Qt asked it (po-craft-build-desktop) should I set it to something else?
     
    Last edited: Jul 21, 2011
  7. coyotte508

    coyotte508 Well-Known Member Administrator Server Owner Administrator Server Owner

    Joined:
    Apr 21, 2010
    Messages:
    6,363
    Likes Received:
    168
    I uploaded, you should have no problems anymore, I removed all SFML dependencies!

    Also the controls only work for a qwerty keyboard atm, I hope you have one.

    [​IMG]

    Now by pressing 'R' you can view the scene from a first person perspective. Beware, an enemy may be hiding behind one of those hills!

    Next, I'll make the camera able to look up and down, and make it follow behind the ball instead of being the ball.
     
    Last edited: Jul 21, 2011
  8. Viderizer

    Viderizer Admin/Developer

    Joined:
    Mar 12, 2011
    Messages:
    277
    Likes Received:
    0
    Ok, now I get not found errors :-(

    [​IMG]
     
  9. coyotte508

    coyotte508 Well-Known Member Administrator Server Owner Administrator Server Owner

    Joined:
    Apr 21, 2010
    Messages:
    6,363
    Likes Received:
    168
  10. coyotte508

    coyotte508 Well-Known Member Administrator Server Owner Administrator Server Owner

    Joined:
    Apr 21, 2010
    Messages:
    6,363
    Likes Received:
    168
    I made the ball smaller, and now the camera can follow behind the ball

    [​IMG]

    Next step, make the camera able to go in the air or under the ground...
     
  11. Viderizer

    Viderizer Admin/Developer

    Joined:
    Mar 12, 2011
    Messages:
    277
    Likes Received:
    0
    Managed to compile, this feels great, also made some heightmaps of my own, I can post them if you want

    // What key I need to press to get the camera behind the ball?

    [​IMG]
     
    Last edited: Jul 21, 2011
  12. coyotte508

    coyotte508 Well-Known Member Administrator Server Owner Administrator Server Owner

    Joined:
    Apr 21, 2010
    Messages:
    6,363
    Likes Received:
    168
    I'd love heightmaps!!

    I press the R key to change between camera modes, there a 3 modes: from above, inside the ball, behind the ball (make sure you got the latest update from git). I'll improve the camera to change the vertical inclination.
     
  13. Viderizer

    Viderizer Admin/Developer

    Joined:
    Mar 12, 2011
    Messages:
    277
    Likes Received:
    0
    Here are some: I will create more though.

    [​IMG]

    [​IMG]

    [​IMG]

    // I need to learn programming 3D games/apps P:
     
  14. coyotte508

    coyotte508 Well-Known Member Administrator Server Owner Administrator Server Owner

    Joined:
    Apr 21, 2010
    Messages:
    6,363
    Likes Received:
    168
    Cool i'll test them. I'll also change the TERRAIN_WIDTH constant to 100.f to have larger fields.
     
    Last edited: Jul 21, 2011
  15. coyotte508

    coyotte508 Well-Known Member Administrator Server Owner Administrator Server Owner

    Joined:
    Apr 21, 2010
    Messages:
    6,363
    Likes Received:
    168
    [​IMG]

    Now the camera behind the character works pretty well. Had a little headache but now it's pretty simple to figure out how to move the camera on openGL: list all the operations you would do to, from the origin, to reach the point of view desired, and then write them all in the reverse order with the reverse arguments, and poof it works!

    Next step will be implementing a menu for different controls depending on the keyboard layout and storing them.

    Btw, your heightmaps are awesome, they're definitely something I will use when the project is more complete!
     
    Last edited: Jul 22, 2011
  16. coyotte508

    coyotte508 Well-Known Member Administrator Server Owner Administrator Server Owner

    Joined:
    Apr 21, 2010
    Messages:
    6,363
    Likes Received:
    168
    Added: Menu when you press F2 in order to change controls (looks pretty basic, I know!)

    Press Enter to save the controls, escape to cancel.

    Next: more Camera stuff.
     
  17. Chispy

    Chispy Member

    Joined:
    Jun 16, 2010
    Messages:
    106
    Likes Received:
    0
    In a few months, we'll be throwing this ball at Mewtwo and raging.
     
  18. coyotte508

    coyotte508 Well-Known Member Administrator Server Owner Administrator Server Owner

    Joined:
    Apr 21, 2010
    Messages:
    6,363
    Likes Received:
    168
    Ok, now camera can zoom in/out.

    Now i need to make it a proper ball - like it doesn't go inside the terrain when the slope is too sloppy, or have a texture which rotates according to the movement of the ball.

    Next I could do a gravity engine. If that happens, I need a proper collision manager and we could do jumps / races on heightmaps! I'd do few graphical adjustments and maybe release something :)

    Next: Proper terrain/ball detection. This is gonna ask some mathematical stuff and maybe take a bit of time, but once it's done it will make the rest easier.
     
  19. coyotte508

    coyotte508 Well-Known Member Administrator Server Owner Administrator Server Owner

    Joined:
    Apr 21, 2010
    Messages:
    6,363
    Likes Received:
    168
    While on my quest to perfect detection collision, I rendered the wireframe of the terrain:

    [​IMG]

    Dang, I hope i'll really find the problem and carry on )x
     
  20. Chispy

    Chispy Member

    Joined:
    Jun 16, 2010
    Messages:
    106
    Likes Received:
    0
    :O

    Please make that an option.
     
  21. coyotte508

    coyotte508 Well-Known Member Administrator Server Owner Administrator Server Owner

    Joined:
    Apr 21, 2010
    Messages:
    6,363
    Likes Received:
    168
    Wheeeeee!

    Now the ball moves perfectly on the surface. <3 maths.

    Next steps: implement a blue sky and make the ball roll. I'll put a screen when there's the blue sky just bragging rights even though it's very easy.
     
  22. coyotte508

    coyotte508 Well-Known Member Administrator Server Owner Administrator Server Owner

    Joined:
    Apr 21, 2010
    Messages:
    6,363
    Likes Received:
    168
    [​IMG]

    Now i'll make the ball roll
     
  23. coyotte508

    coyotte508 Well-Known Member Administrator Server Owner Administrator Server Owner

    Joined:
    Apr 21, 2010
    Messages:
    6,363
    Likes Received:
    168
    The ball rolls!

    I'll be working on velocity and acceleration and then i can proceed to gravity, and jumps after that!
     
  24. twofivefive

    twofivefive don't call it a comeback

    Joined:
    Dec 28, 2010
    Messages:
    1,395
    Likes Received:
    2
    I REALLY want to try this out. But I can't find the download link *facepalm*. When I go to "Files" Sourceforge says it has no files.
     
  25. Blastcore

    Blastcore Developer

    Joined:
    Jul 19, 2010
    Messages:
    763
    Likes Received:
    1
    You need to compile it.
     
  26. twofivefive

    twofivefive don't call it a comeback

    Joined:
    Dec 28, 2010
    Messages:
    1,395
    Likes Received:
    2
    Right... what do I compile?
    This?

    git clone git://po-craft.git.sourceforge.net/gitroot/po-craft/po-craft (read-only)
     
  27. coyotte508

    coyotte508 Well-Known Member Administrator Server Owner Administrator Server Owner

    Joined:
    Apr 21, 2010
    Messages:
    6,363
    Likes Received:
    168
    This isn't released yet, and you're not a developer, so shush!
     
  28. twofivefive

    twofivefive don't call it a comeback

    Joined:
    Dec 28, 2010
    Messages:
    1,395
    Likes Received:
    2
    Oh, ok. Ignore me then. :3
     
  29. coyotte508

    coyotte508 Well-Known Member Administrator Server Owner Administrator Server Owner

    Joined:
    Apr 21, 2010
    Messages:
    6,363
    Likes Received:
    168
    Some math talk so i don't forget.

    The problem at hand is dealing about the slope changes, for example when the slope gets upwards.

    1) Player controls.

    Player controls determine the acceleration in both x and z axis. For now the program assumes a flat terrain, so it's pretty straight forward. However, if the slope is not horizontal, we don't want an acceleration vector going 'inside' the terrain, rather have the x/z components decreased a little to introduce an y component.

    What's important to notice is that the normal of the terrain determines the rotation of the acceleration vector: if we had an upside down normal (meaning rolling on the ceiling), we'd want the up arrow to go the opposite direction than when on the floor, this can be expressed in loops for example (ever played sonic?).

    So we need the new acceleration vector to be orthogonal to the normal. It also needs to be rotated around an axis orthogonal to the direction we'd have on a flat terrain. So in short we have 3 vector: the normal n, the direction on a flat terrain d, the axis of rotation a which must be orthogonal to both, hence easy to deduce . Let a be d.cross(n).normalize(). (We ignore the case in which d and n are in the same direction). Then the new direction d' would be n.cross(a) * d.magnitude(). (Note that in case of the surface being flat and the direction being horizontal, d = d')

    Problem solved! Thank god cross products are there and I don't have to do rotation manually. I actually feared I would have had to do a rotation manually around the axis.

    Now there's the problem of changing the velocity vector when the terrain change, it's the same thing actually.

    There. Of course there would be consideration of bouncing back if the normals changed too much, but it's of no concern here.
     
    Last edited: Aug 8, 2011
  30. coyotte508

    coyotte508 Well-Known Member Administrator Server Owner Administrator Server Owner

    Joined:
    Apr 21, 2010
    Messages:
    6,363
    Likes Received:
    168
    Mmm, acceleration / velocity is consistent with terrain now.

    Next step: Gravity.
     
  31. coyotte508

    coyotte508 Well-Known Member Administrator Server Owner Administrator Server Owner

    Joined:
    Apr 21, 2010
    Messages:
    6,363
    Likes Received:
    168
    Ok, noticed what an error I made when I gave up dev on this project.

    Started with a commit today to do a major cleanup of the code (mainly dependencies).