Jump to content
• Advertisement  # shazen

Member

22

291 Neutral

## About shazen

• Rank
Member
1. One difference I've noticed with people moving from 2d development to 3d development is that with 2d you can utilize angles/trig to express and represent the various orientations and directions objects have and use, and this serves well.    In 3d, linear algebra (Matrix & vector math) is leaned on to do much of the work that you once did with angles and trig.   People naturally go with what they are familiar with so I see people starting off in 3d trying to bring the angle/trig operations that served them well in 2d. Many times that becomes a headache.   When transitioning into 3d, don't put off learning all about matrices, vectors, and their associated manipulations and possibilities. Resist the temptation to store an angle between frames until you are competent with linear algebra.
2. Is the line:   Vector2 ringsPosition = Vector2.Zero;     being called every frame or just once at the beginning of the game?
3. Most frameworks or libraries have a method to transform a 3dvector. Vector3 temp = Vector3.Transfom(3dposition, view * projection);   Vector2 screenPosition = new Vector2(temp.x, temp.y);
4. Language/framework, during the learning stage, is mostly irrelevant for game programming. The principles, concepts, and math behind why you do this or that is what's really important to get a good understanding of. It doesn't matter what language/framework you learn those principles in, they translate to any language and are the practically the same in any language/framework.   Xna is a really great framework to learn those principles because the framework does a lot of the heavy lifting (of the non-game stuff) for you behind the scenes so you are free to concentrate on learning the principles of the what and why of game programming.   So I would encourage you not to simply throw Xna away just for that. It is (and will remain for a long time) a great learning tool and a tremendously efficient prototyping tool. You would be hard pressed to find another framework where you can go from zero to demo as quickly as Xna.
5. As you said, cross the lookat with 0,1,0 to get a side vector that will be used to move the points horizontally. But for a spherical billboard to move the points vertically, instead of using 0,1,0, use the cross of lookat and side
6. Get a hold of reflector so you can see how the Xna framework does it... public static Matrix CreateFromAxisAngle(Vector3 axis, float angle) { Matrix matrix; float x = axis.X; float y = axis.Y; float z = axis.Z; float num2 = (float) Math.Sin((double) angle); float num = (float) Math.Cos((double) angle); float num11 = x * x; float num10 = y * y; float num9 = z * z; float num8 = x * y; float num7 = x * z; float num6 = y * z; matrix.M11 = num11 + (num * (1f - num11)); matrix.M12 = (num8 - (num * num8)) + (num2 * z); matrix.M13 = (num7 - (num * num7)) - (num2 * y); matrix.M14 = 0f; matrix.M21 = (num8 - (num * num8)) - (num2 * z); matrix.M22 = num10 + (num * (1f - num10)); matrix.M23 = (num6 - (num * num6)) + (num2 * x); matrix.M24 = 0f; matrix.M31 = (num7 - (num * num7)) + (num2 * y); matrix.M32 = (num6 - (num * num6)) - (num2 * x); matrix.M33 = num9 + (num * (1f - num9)); matrix.M34 = 0f; matrix.M41 = 0f; matrix.M42 = 0f; matrix.M43 = 0f; matrix.M44 = 1f; return matrix; } Don't forget this depends on the axis parameter being unit length.
7. As a indie game dev... um, wanna be..., to me finishing a game means that the game is available for download (hopefully for a price) by the target audience. Anything else is falling short. So far I've fallen short.
8. I would disagree that this is a floating point error issue. After only six rotations, the floating point error is still in the 0.000001 or less of a radian and not discernible.   Not sure what the real problem is though. But with the proper matrix math it will come back to where it was.   here is a little routine I used to make sure: float yaw, pitch, roll; yaw = pitch = roll = MathHelper.ToRadians(15); Matrix m = Matrix.Identity; m *= Matrix.CreateRotationY(yaw); m *= Matrix.CreateRotationX(pitch); m *= Matrix.CreateRotationZ(roll); m *= Matrix.CreateRotationZ(-roll); m *= Matrix.CreateRotationX(-pitch); m *= Matrix.CreateRotationY(-yaw); The values of m after are essentially right back where it started, except for the floating point error which are miniscule. before after M11:1 M11:1 M12:0 M12:-1.462545E-08 M13:0 M13:0 M14:0 M14:0 M21:0 M21:-1.143128E-08 M22:1 M22:0.9999999 M23:0 M23:1.290801E-08 M24:0 M24:0 M31:0 M31:-1.336002E-08 M32:0 M32:-7.70093E-09 M33:1 M33:0.9999999 M34:0 M34:0 M41:0 M41:0 M42:0 M42:0 M43:0 M43:0 M44:1 M44:1 Can you post the code of how you are doing the rotation math. Are you using a framework or library? Are you feeding it rotation axis vectors & if so, are you normalizing them first?
9. Here's the way to do it for an axis aligned box. For an oriented box, first rotate both box and plane by the inverse of the box's orientation to make the box axis aligned and proceed as if it were axis aligned.   The box is represented by a min vector and a max vector. The plane is represented by a normal and a distance. Vector3 vec1, vec2;   if(normal.X >= 0) {   vec1.X = min.X;   vec2.X = max.X; } else {   vec1.X = max.X;   vec2.X = min.X; } if(normal.Y >= 0) {   vec1.Y = min.Y;   vec2.Y = max.Y; } else {   vec1.Y = max.Y;   vec2.Y = min.Y; } if(normal.Z >= 0) {   vec1.Z = min.Z;   vec2.Z = max.Z; } else {   vec1.Z = max.Z;   vec2.Z = min.Z; } float posSide = (normal.X * vec2.X)+(normal.Y * vec2.Y)+(normal.Y * vec2.Y)+planeDistance; if(posSide > 0) {   //box is completely on positive side of plane   return; } float negSide = (normal.X * vec1.X)+(normal.Y * vec1.Y)+(normal.Y * vec1.Y)+planeDistance; if(negSide < 0) {   //box is completely on negative side of plane   return; } //if you get this far, box is currently intersecting the plane.
10. Could you be a little more specific. Matrix.CreateScale(myUnitVector * scalar) will do what it seems like you are asking but maybe I'm missing something in your question.
11. For each value in your string, say "1.0123f", requires 7 bytes (one for each character including the decimal). A real float of the value 1.0123f is represented with 4 bytes.   so, no, unfortunately.
12. if this is like a first person shooter where you just want to pitch and yaw, then the yaw axis you want is your world up axis ( 0,1,0  if using a Y up sys).     D3DXMatrixRotationAxis(&T, &worldUp, angle); //use the world up instead of camera up here in the yaw method
13. A resource you might consider if you want to roll your own is to find a library written in C# or a .net language that does these things, then use reflector to look at the code to see how it was done and pattern your own after it. Xna has all the methods you require built in and is openly available to look behind and study.
14. What I notice is that you only have 16 vertices available in your vertex buffer. To make a cube you need 24.   Each corner has 3 faces meeting all with different normal directions. Since you need a unique normal for each triangle then you need 3 vertices per corner. 3 x 8 = 24.
15. the 2nd parameter looks wrong. Instead of just Vector2, try Vector3.Up,   The 2nd param is the axis that the rotation is to be around. that axis must be in 3d space so it needs a Vector3. Most likely, you want Vector3.Up for it.
• Advertisement
×

## Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!