|
||
|
|||||||
| XNA Tutorials and support for game development using Microsoft's XNA Game Studio framework. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 (permalink) |
|
ConnectUO Creator
Join Date: Jan 2004
Location: In your mom
Age: 27
Posts: 4,762
|
What’s needed?
Visual C# Express (Yes, express not Visual Studio) Visual C# Visual C# Express Service Pack 1 (VS80sp1-KB926749-X86-INTL.exe) Download details: Visual Studio® 2005 Express Editions SP1 XNA Game Studio Express 1.0 Refresh Download details: Microsoft XNA Game Studio Express 1.0 Refresh Additional Comments: For these tutorials I am assuming you have at least a beginner to intermediate understanding of C#. I also am assuming you’ve download and installed the items below, and have the project for this tutorial open in Visual C#. Some thing first before I begin, I love to explain things with analogies. I love when things are presented this way to me, so I will bring the same to you whenever necessary. The other thing I love to do is to just jump right in and start playing with stuff. I don’t learn well from books because I’m too much of a “hands on” type of person. Everything I’ve learned about XNA and pretty much programming in general I’ve taught myself with very little reading. I learn best from example and trial and error. So without further ado, let’s jump into so code. In this tutorial I will be showing you how to draw a simple triangle on the screen. This may sound dumb, and you may be thinking “I want to do something more fun”. Well, we will, but be patient because I assure you without the stuff I explain in this tutorial, you will be lost in the more heavy stuff I go over later on. Ok, so a game loop in itself is extremely simple and basically looks somewhat like this. Code:
while (game.Running)
{
Update();
Draw();
}
Lets you look at line 14 Code:
public class BasicsGame : Microsoft.Xna.Framework.Game Code:
GraphicsDeviceManager graphics; ContentManager content; Code:
//These are all the basic variables we need
//to draw a 3d object to the screen.
//Most of these are pretty self explanitory.
//Those that aren't will be explained along the way.
VertexDeclaration vertDec;
VertexPositionColor[] vertices;
BasicEffect effect;
Matrix world;
Matrix view;
Matrix projection;
Vector3 position;
float yaw;
float pitch;
float roll;
float scale;
int[] indices;
Anyway enough babbling, lets look at more code. Code:
protected override void LoadGraphicsContent(bool loadAllContent) Well, there really isnt a whole lot more I need to point out, that isnt already explained in the code itself. A lot of the things in the code that are explained also have examples of how they effect the game itself, the only one of these I wanted to go over in more detail is the projection matrix on line 153 Code:
projection = Matrix.CreatePerspectiveFieldOfView(MathHelper.Pi / 3.0f, graphics.GraphicsDevice.Viewport.Width / graphics.GraphicsDevice.Viewport.Height, 1, 1000); Well that’s about all I have for this tutorial, I will start working on a new one soon. If anyone has any questions, suggestions, or comments please feel free to leave them here. I will be happy to answer, any and all of them when I get a change.
__________________
Jeff Boulanger ConnectUO - Core Developer Want to help make ConnectUO better? Click here to submit your ideas/requests Use your talent to compete against other community members in RunUO hosted coding competitions If you know XNA (even if its just a little) or are a good artist(2d or 3d) and are interested in making games for a hobby send me a pm or drop by #xna in irc.runuo.com. I'm looking to put together a small game development team. Please do not pm me for support. If you are having issues please post in the appropriate forum. Thanks for your continued support of both ConnectUO and RunUO Last edited by Jeff; 11-05-2007 at 11:50 AM. |
|
|
|
|
|
#3 (permalink) |
|
ConnectUO Creator
Join Date: Jan 2004
Location: In your mom
Age: 27
Posts: 4,762
|
Ah ya, thanks.
__________________
Jeff Boulanger ConnectUO - Core Developer Want to help make ConnectUO better? Click here to submit your ideas/requests Use your talent to compete against other community members in RunUO hosted coding competitions If you know XNA (even if its just a little) or are a good artist(2d or 3d) and are interested in making games for a hobby send me a pm or drop by #xna in irc.runuo.com. I'm looking to put together a small game development team. Please do not pm me for support. If you are having issues please post in the appropriate forum. Thanks for your continued support of both ConnectUO and RunUO |
|
|
|
|
|
#4 (permalink) | |
|
Forum Expert
|
Definitely a helpful tutorial, I'm wasn't at home at the time of veiwing it, so I haven't been able to open up the project yet and start playing around with things you have taught, but I read through it and understood most of it.
The main things that confused me are: Code:
//The rotating of our primitive
//Yaw is the Y axis, so it rotates left and right(front to back).
//Pitch would be X axis and rotate up and down
//Roll would be Z axis and rolls left and right(top to bottom)
Y = up and down X = left and right Z = front to back and Code:
//Scale of our primitive. 1 = 100% of the original size.
//2 would be 200% and so on
scale = 1f;
__________________
Quote:
|
|
|
|
|
|
|
#6 (permalink) | ||
|
ConnectUO Creator
Join Date: Jan 2004
Location: In your mom
Age: 27
Posts: 4,762
|
Quote:
As far as matrix stuff goes, i don't think its important to understand what exactly they do at this point. Just more you need to know why, Basically all the information in a matrix tells the graphics card how to draw each vertex. So if you have a Matrix.Identity, the graphics card applies this matrix to the vertex data and it wont change because Matrix.Identity is like multiplying 9 * 1. The answer is 9 cause nothing changes. Matrix math is quite confusing. The point here is to not try and understand it to much but just remember the steps you need to take to get a proper matrix to apply to the shader effect. As for this Quote:
![]() This isnt the best example but you can sorta see what i mean.
__________________
Jeff Boulanger ConnectUO - Core Developer Want to help make ConnectUO better? Click here to submit your ideas/requests Use your talent to compete against other community members in RunUO hosted coding competitions If you know XNA (even if its just a little) or are a good artist(2d or 3d) and are interested in making games for a hobby send me a pm or drop by #xna in irc.runuo.com. I'm looking to put together a small game development team. Please do not pm me for support. If you are having issues please post in the appropriate forum. Thanks for your continued support of both ConnectUO and RunUO Last edited by Jeff; 11-05-2007 at 02:52 PM. |
||
|
|
|
|
|
#7 (permalink) | ||
|
Forum Expert
|
Quote:
__________________
Quote:
|
||
|
|
|
|
|
#8 (permalink) | |
|
ConnectUO Creator
Join Date: Jan 2004
Location: In your mom
Age: 27
Posts: 4,762
|
Quote:
There is something misleading about that picture though, it should be rotated on the Y axies 90 degrees.
__________________
Jeff Boulanger ConnectUO - Core Developer Want to help make ConnectUO better? Click here to submit your ideas/requests Use your talent to compete against other community members in RunUO hosted coding competitions If you know XNA (even if its just a little) or are a good artist(2d or 3d) and are interested in making games for a hobby send me a pm or drop by #xna in irc.runuo.com. I'm looking to put together a small game development team. Please do not pm me for support. If you are having issues please post in the appropriate forum. Thanks for your continued support of both ConnectUO and RunUO Last edited by Jeff; 11-05-2007 at 08:02 PM. |
|
|
|
|
|
|
#9 (permalink) |
|
ConnectUO Creator
Join Date: Jan 2004
Location: In your mom
Age: 27
Posts: 4,762
|
Would it help if I added a coordinate system to these tutorials? So in the game you would see something like this?
![]() At all times?
__________________
Jeff Boulanger ConnectUO - Core Developer Want to help make ConnectUO better? Click here to submit your ideas/requests Use your talent to compete against other community members in RunUO hosted coding competitions If you know XNA (even if its just a little) or are a good artist(2d or 3d) and are interested in making games for a hobby send me a pm or drop by #xna in irc.runuo.com. I'm looking to put together a small game development team. Please do not pm me for support. If you are having issues please post in the appropriate forum. Thanks for your continued support of both ConnectUO and RunUO |
|
|
|
|
|
#10 (permalink) |
|
Forum Expert
Join Date: Feb 2004
Location: colorado
Age: 47
Posts: 473
|
Another quik easy way to remember the Cartesian Coordinate System is to put your right hand palm up and parallel to the default world view with your thumb extended. for terrains the defualt view is your top view looking down this is also considered the global coordinate system. When viewing a model it is usually the front view of the model, also known as the construction plane. The thumb points to x+, the finger to y+, and the palm to z+. if the positive x or y axis rolls toward you it is rolling in the positive direction away from you is in a negative direction. the z axis rolls positive clockwise and negatively counter clockwise.
Where it really gets screwed up is when you start viewing an object that due to movement or placement is no longer inline with the world view of the scene, in those cases you must remember the models construction plane and use your hand accordingly. the models construction plane will always add up to the total movement and rotational vectors. Be aware the each individual feature or piece of any model may have its own distinct construction plane that may differ from the models collective construction plane. Usually it is a good idea to align the different construction planes to the collective construction plane, lol but thats way above the scope of the current teachings interesting note from a graphics arts perspective when using 3dstudio(and may be true of other applications using this file format), when saving an model as an .3ds file it will twist the model, so that the accumulated construction plane matches the the global coordinates. this can lead to some unexpected results .
__________________
"Some Scientists claim that hydrogen, because it is so plentiful, is the basic building block of the universe. I dispute that. I say there is more stupidity than hydrogen, and that is the basic building block of the universe." ~ Frank Zappa |
|
|
|
|
|
#12 (permalink) |
|
ConnectUO Creator
Join Date: Jan 2004
Location: In your mom
Age: 27
Posts: 4,762
|
Well ill prolly create it jsut because, but ask all the questions you want, thats what this forum is here for, if you dont understand something, ask. Ill answer best I can.
__________________
Jeff Boulanger ConnectUO - Core Developer Want to help make ConnectUO better? Click here to submit your ideas/requests Use your talent to compete against other community members in RunUO hosted coding competitions If you know XNA (even if its just a little) or are a good artist(2d or 3d) and are interested in making games for a hobby send me a pm or drop by #xna in irc.runuo.com. I'm looking to put together a small game development team. Please do not pm me for support. If you are having issues please post in the appropriate forum. Thanks for your continued support of both ConnectUO and RunUO |
|
|
|
|
|
#13 (permalink) | |
|
Forum Expert
|
Quote:
Might be helpful if you could draw a grid going out into the distance to get some spatial awareness of where you 'The Cam' are and where the 'object' is in 3d space, that would help me greatly and might help with knowing which axis things are spinning on. If i remember a good few years ago myself and some friends wanted to get into this sort of thing but the CPU power wasn't around in the 80's-90's... yeah i'm an old fart. ![]() Good work tho, hope to see more of this stuff here. ** Edit ** Don't most app's use Z for height ? |
|
|
|
|
|
|
#14 (permalink) |
|
ConnectUO Creator
Join Date: Jan 2004
Location: In your mom
Age: 27
Posts: 4,762
|
Ya, and thats just oreintation, you can turn on the x axis 90 degrees and Z will indicate height.
__________________
Jeff Boulanger ConnectUO - Core Developer Want to help make ConnectUO better? Click here to submit your ideas/requests Use your talent to compete against other community members in RunUO hosted coding competitions If you know XNA (even if its just a little) or are a good artist(2d or 3d) and are interested in making games for a hobby send me a pm or drop by #xna in irc.runuo.com. I'm looking to put together a small game development team. Please do not pm me for support. If you are having issues please post in the appropriate forum. Thanks for your continued support of both ConnectUO and RunUO |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|