Thrive Game Development
Would you like to react to this message? Create an account in a few clicks or log in to continue.

Thrive Game Development

Development of the evolution game Thrive.
 
HomeHome  PortalPortal  Latest imagesLatest images  SearchSearch  RegisterRegister  Log inLog in  
Welcome new and returning members!
If you're new, read around a bit before you post: the odds are we've already covered your suggestion.
If you want to join the development team, sign up and tell us why.
ADMIN is pleased to note that this marquee has finally been updated.
ADMIN reminds you that the Devblog is REQUIRED reading.
Currently: The Microbe Stage GUI is under heavy development
Log in
Username:
Password:
Log in automatically: 
:: I forgot my password
Quick Links
Website
/r/thrive
GitHub
FAQs
Wiki
New Posts
Search
 
 

Display results as :
 
Rechercher Advanced Search
Statistics
We have 1675 registered users
The newest registered user is dejo123

Our users have posted a total of 30851 messages in 1411 subjects
Who is online?
In total there are 23 users online :: 0 Registered, 0 Hidden and 23 Guests

None

Most users ever online was 443 on Sun Mar 17, 2013 5:41 pm
Latest topics
» THIS FORUM IS NOW OBSOLETE
Earthium's Understanding 3d Gargantuan Tutorial Emptyby NickTheNick Sat Sep 26, 2015 10:26 pm

» To all the people who come here looking for thrive.
Earthium's Understanding 3d Gargantuan Tutorial Emptyby NickTheNick Sat Sep 26, 2015 10:22 pm

» Build Error Code::Blocks / CMake
Earthium's Understanding 3d Gargantuan Tutorial Emptyby crovea Tue Jul 28, 2015 5:28 pm

» Hello! I can translate in japanese
Earthium's Understanding 3d Gargantuan Tutorial Emptyby tjwhale Thu Jul 02, 2015 7:23 pm

» On Leave (Offline thread)
Earthium's Understanding 3d Gargantuan Tutorial Emptyby NickTheNick Wed Jul 01, 2015 12:20 am

» Devblog #14: A Brave New Forum
Earthium's Understanding 3d Gargantuan Tutorial Emptyby NickTheNick Mon Jun 29, 2015 4:49 am

» Application for Programmer
Earthium's Understanding 3d Gargantuan Tutorial Emptyby crovea Fri Jun 26, 2015 11:14 am

» Re-Reapplication
Earthium's Understanding 3d Gargantuan Tutorial Emptyby The Creator Thu Jun 25, 2015 10:57 pm

» Application (programming)
Earthium's Understanding 3d Gargantuan Tutorial Emptyby crovea Tue Jun 23, 2015 8:00 am

» Achieving Sapience
Earthium's Understanding 3d Gargantuan Tutorial Emptyby MitochondriaBox Sun Jun 21, 2015 7:03 pm

» Microbe Stage GDD
Earthium's Understanding 3d Gargantuan Tutorial Emptyby tjwhale Sat Jun 20, 2015 3:44 pm

» Application for Programmer/ Theorist
Earthium's Understanding 3d Gargantuan Tutorial Emptyby tjwhale Wed Jun 17, 2015 9:56 am

» Application for a 3D Modeler.
Earthium's Understanding 3d Gargantuan Tutorial Emptyby Kaiju4u Wed Jun 10, 2015 11:16 am

» Presentation
Earthium's Understanding 3d Gargantuan Tutorial Emptyby Othithu Tue Jun 02, 2015 10:38 am

» Application of Sorts
Earthium's Understanding 3d Gargantuan Tutorial Emptyby crovea Sun May 31, 2015 5:06 pm

» want to contribute
Earthium's Understanding 3d Gargantuan Tutorial Emptyby Renzope Sun May 31, 2015 12:58 pm

» Music List Thread (Post New Themes Here)
Earthium's Understanding 3d Gargantuan Tutorial Emptyby Oliveriver Thu May 28, 2015 1:06 pm

» Application: English-Spanish translator
Earthium's Understanding 3d Gargantuan Tutorial Emptyby Renzope Tue May 26, 2015 1:53 pm

» Want to be promoter or project manager
Earthium's Understanding 3d Gargantuan Tutorial Emptyby TheBudderBros Sun May 24, 2015 9:00 pm

» A new round of Forum Revamps!
Earthium's Understanding 3d Gargantuan Tutorial Emptyby Oliveriver Wed May 20, 2015 11:32 am


 

 Earthium's Understanding 3d Gargantuan Tutorial

Go down 
AuthorMessage
Guest
Guest




Earthium's Understanding 3d Gargantuan Tutorial Empty
PostSubject: Earthium's Understanding 3d Gargantuan Tutorial   Earthium's Understanding 3d Gargantuan Tutorial EmptyFri Jun 06, 2014 11:08 pm

For the people joining the forums or people that want to understand programming better this is the place for you. The code is written using Lua, C++, and Ogre.
Personally I would recommend learning C++ from this tutorial. A good Ogre tutorial is here Ogre's main functionally is to render (or display an image on the sceen) and set up windows and start the basic program.

Now some people may be familiar with programming in these languages but have no concept of how a 3d game works.

We must first understand how the computer sets up a three dimensional space. Programs like OpenGL and Ogre use the Cartesian Coordinate System, aka coordinate plane.

Earthium's Understanding 3d Gargantuan Tutorial Ts_6_12_wi-3

As you see in the image, basic shapes are drawn on this plane. If you place these basic shapes next to each other you can for a model or wireframe, which is almost always used by the aid of 3d modeling programs such as Blender. There is also a Z coordinate that simulates depth on your 2d computer screen, which the basic (X,Y) points will become (X,Y,Z).

Earthium's Understanding 3d Gargantuan Tutorial 200px-3D_Cartesian_coordinate_plane

As you can see from Princesses Peach castle from Mario 64, The landscape and the castle are all made from triangles. The computer program tells whether or not to put lines or render the objects as faces.

Earthium's Understanding 3d Gargantuan Tutorial 21914279_2a60b1c2e8

Rendering a simple cube in blender and exporting it as a .obj file, then opening it in notepad.
Earthium's Understanding 3d Gargantuan Tutorial Untitl11
Note:

We can clearly the (X,Y,Z) pattern at the top, the v tells the program that there is a new vertex. The people who created the .obj format try to use a little memory as possible so it keeps the same points in space and then defines the faces of the polygon which is read by the bottom lines by indicating an f followed by the points that will be used to render the polygon. There are other 3d model file types .obj is the most basic other file types compress or encrypt the data.

Now as a programmer, understanding this, you can use mathematics to understand the world that is created. This is of great use for collision detection. Collision detection is checking if the object or character is within a certain distance to another object, lets say a tree. If you do not have hit detection the character will walk through the tree. Detection makes sure that the character does not do this, and keeps realism in the game. This is also important for limiting the size of the world, because it cannot go on forever the computer will run out of memory, this also includes games such as minecraft where they appear to be infinite are limited by the amount of memory your computer uses.

Let us step all the way back to 1 dimensional space and to build off of this idea.

Earthium's Understanding 3d Gargantuan Tutorial Number10

Let this represent this numberline represent the X-axis.
Say we have a wall at 0 that extends all the way to infinity.

Earthium's Understanding 3d Gargantuan Tutorial Greate14

so if the character x value is greater then 0, don't move the character.
Code:
That's nice but how often would you have a wall that goes on for infinity?

Earthium's Understanding 3d Gargantuan Tutorial Greate16

This shows the other side of the wall that stops at 3.
The wall is from 0 to 3. If the player is > 0 and the player is < 3 don't move the character.
1d Wall Code:

Lets move up to a 2d collision detection.
The player has 3 coordinates at any time, moving to 2d this is what our previous wall at 0 to 3 would look like.

Earthium's Understanding 3d Gargantuan Tutorial Zeroto10

As you see this is correct, we specified nothing on the Y axis. We are checking for X > 0 and X < 3. The Y axis will go on forever, infinity.
As you have probably figured out, if we specify the Y axis we can then make a box where the character can not enter.

Earthium's Understanding 3d Gargantuan Tutorial Aabbco12

As you see we now have a rectangle such as a box on a 2d game in addition to the X-axis code we now add, if the Y is less then 6 and greater then -1.

Spoiler:

Circular collision can also be done very simply by using the distance formula

Earthium's Understanding 3d Gargantuan Tutorial Circle10

We are checking from the origin, (0,0). The distance to the outer edge is 3 anywhere around it.
realistically the hit detection on our character will not be a single point, but a box, simply check all the vertices that make up the box to see if they are inside the circle.

Earthium's Understanding 3d Gargantuan Tutorial Circle11

To get the detection of two circle simply check the distance of both radi.

Earthium's Understanding 3d Gargantuan Tutorial Circle12

Circles and squares are nice but we need some hardcore detection.
Take the slope formula Y = mX+b.

Earthium's Understanding 3d Gargantuan Tutorial Slope10

This formula is Y = 1*X -1.

Now say we have a ramp for a 2d game and we want to keep them on the ramp, we would stop gravity if they fell below the line.
so if the CharacterY is less then 1*X - 1, stop them from falling.

SlopeCollision:

Earthium's Understanding 3d Gargantuan Tutorial Slopes10

Now we can go more advanced.
A parabola, the formula X^2 - X - 6

Earthium's Understanding 3d Gargantuan Tutorial Parabo10

now foiling that out we can get (X+2)(X-3), which means the X will cross at +2 and at -3, while the Max Y value is shown in the first formula as -6.

Say we want the character to yet again fall on the hill but not let gravity make him fall through.
if the characterY greater than CharacterX to the power of 2 minus CharacterX minus 6
stop gravity

Parabolic:
Lets say you would only want half of the slope you would simply take the midpoint and do the AABB collision.

Half Parabolic:


Now 3d Collision you already know all the formula,
Remember when we made the jump from 1d to 2d how the Y axis extended forever? The same applies with the Z axis.
You can get a simple box using AABB and adding the and for the Z axis.
To get a Cylinder check the distance of the X and Y values but use AABB just for the Z, to rotate it change the X and Y values.
A sphere is just the 3d distance formula.

Earthium's Understanding 3d Gargantuan Tutorial Distan10

if you wanted to make a board leaning on a wall you would use the slope formula.

One thing i'm leaving out are angle, which do amazing things, like cones, triangles. You could use the distance formula to give a enemy cell its attack range and then use triangles to check the front of it if it has eyes to give it an extended attack range if it sees you. Other then that you really don't want to be checking a million collision that are high processing.

I also tried to write this with a level that everyone can understand so if there is problems of things that need clarity don't mind posting.

And I will leave you with this which you can type formulas in and it will make a graph or solve the pesky parabolic problems for you.
Back to top Go down
moopli
Developer
moopli


Posts : 318
Reputation : 56
Join date : 2013-09-30
Age : 29
Location : hanging from the chandelier

Earthium's Understanding 3d Gargantuan Tutorial Empty
PostSubject: Re: Earthium's Understanding 3d Gargantuan Tutorial   Earthium's Understanding 3d Gargantuan Tutorial EmptySun Jun 08, 2014 7:55 pm

Okay so for starters, some logistics (since you're setting a bit of a precedent here, so it's best to have an amazing example to follow)

Are you planning on adding new chapters in the same thread? That would make the most sense, so I'll assme you will. In that case, the simplest thing would be to add the next chapter in a reply so people get alerted to updates. Since I'm hoping we can use the body of a tutorial thread as discussion about the tutorial itself (improvements, etc); then I'd prefer extending/improving the OP as time goes on...

Then again, this is kinda off-topic, and to each his own.

Anyway -- it looks good so far, but:


  • You mention the acronym AABB but I don't see an explanation.
  • The collision between circles/spheres and rectangles/prisms isn't as simple as a corner check -- consider a collision in the center of a face. However, it's understandable if you're simplifying things for the first installment; so this isn't really an issue.


I'm looking forward to seeing how you handle some more nitty-gritty bits like homogenous coordinates, though, since I'm not too sure how I'd teach them myself.
Back to top Go down
 
Earthium's Understanding 3d Gargantuan Tutorial
Back to top 
Page 1 of 1
 Similar topics
-
» Miscellaneous Bugs And Questions That Don't Deserve Their Own Thread Thread
» good c++ tutorial series
» Miscellaneous Bugs And Questions That Don't Deserve Their Own Thread Thread
» On-Forum Tutorial series: Coding
» [ARC]-Roadkill's programming tutorial part I-

Permissions in this forum:You cannot reply to topics in this forum
Thrive Game Development :: Development :: Design :: Tutorials-
Jump to: