Profil de StefaneXtreme's PlacePhotosBlogListesPlus ![]() | Aide |
|
17 mars Introduction To 3D Game Developing3D Space In the game development (just like in the real life) 3D world is an empty space.Every object in that space can be defined by X, Y and Z coordinate.X represent horizontal line, Y represent vertical line while Z represent depth. The only one type of element that can be drawn in 3D space is point.Unbelievable as it might sound, every model you see in your everyday game is represented by a n-points.By connecting n-points you can draw anything from lines, to spheres.. But before you're able to do that, we need to learn another thing called Vector. Vector "Vector is a concept characterized by a magnitude and a direction." - Wikipedia says.Now because I'm not going to act as professional game developer (which I'm not) I'm going to say it using my words: Put it simple vector is an arrow graphically. It's invisible in the game or anywhere else you might be using it.. There are two types of it : Scalar and Quantity. Scalar type represent vector defined by magnitude but without any direction being associated. Quantity type represent vector defined by magnitude and direction (Arrow's head point in the vector is its direction). Example Imagine you have given a point A in 3D space.You know its X, Y as well as Z coordinate position, and you're asked to represent that point by using Vector. X = 2; Y = 3; Z = 15 First write down the Vector3 (3 means 3 value are involved) skeleton -> A (x, y, z) Next simply replace the given coordinates with your skeleton code -> A (2, 3, 15) That's it, working with vectors can only make your life easier! After knowing vector you're able to position your model in 3D Space using XNA (and even move it around), but to be able to render them you're going to need to know what Matrix is and how can it ruin your life.. Matrix Forget about popular movie called "Matrix" it's not such fun in game developing world.. I'll explain it using my method, if you're up for some complicated theoricaly explanation just google for it! In XNA (and game development in general?) when you want to render your model in the game, you're going to need to define three things - Matrix World, Matrix View and Matrix Projection. -Matrix World If you want to rotate your model in any direction, translate it and do such major things you'll mostly create World Matrix for that purpose. Example: Matrix World = transforms[mesh.ParentBone.Index] * Matrix.CreateRotationY(spaceShip.modelRotationY); -Matrix View View Matrix is very simply - it just affect your camera.You mostly just need to setup CameraLookAt method there using camera position, camera's target and UP vector. Example: Matrix View = Matrix.CreateLookAt(spaceShip.cameraPosition, Vector3.Zero, Vector3.Up); -Matrix Projection Projection used to be quite challenging at first, but once you get feel of it, you can master it.It creates perspective by combining aspectRatio and FieldOfView. Example: Matrix Projection = Matrix.CreatePerspectiveFieldOfView(MathHelper.ToRadians(45.0f), aspectRatio, 1.0f, 10000.0f); Now you might have learned something about Matrix, and next time you see them you'll at least know what each Matrix does.Of course you're going to need to understand them much better if you plan on making some complicated camera systems! Conclusion I hope you enjoyed reading this first article about 3D Space, there might be something wrong, etc but hopefully you learned something new.I'll soon introduce you to my hobby game I'm writing in free time and share some code out of it! Till then, Have Fun! CommentairesPour ajouter un commentaire, connectez-vous avec votre identifiant Windows Live ID (si vous utilisez Messenger ou Xbox LIVE, vous avez un identifiant Windows Live ID). Connectez-vous Vous n'avez pas d'identifiant Windows Live ID ? Inscrivez-vous RétroliensL'URL de rétrolien de ce billet est : http://yostefan.spaces.live.com/blog/cns!B0538EFE99343A0C!129.trak Blogs Web qui font référence à ce billet
|
|
|