Forum
Contact





DirectX using C#
DirectX using C++
DirectX using Visual Basic



Latest Forum posts

 Tutorial 3 for Windows Phone 7
  Posted by: Anonymous
  When: 20/05/2013 at 02:30:13

 No download link for 2d series: shooter
  Posted by: zaboleq
  When: 07/05/2013 at 15:46:28

 Collision Class?
  Posted by: Anonymous
  When: 05/05/2013 at 19:03:59

 stack overflow
  Posted by: cityguy
  When: 07/04/2013 at 01:58:38

 Meshes looks strange.
  Posted by: ab_saratov
  When: 01/04/2013 at 04:31:08

 Lamppost Not loaded
  Posted by: Anonymous
  When: 22/03/2013 at 06:43:52

 Collision Class?
  Posted by: Da_Boom
  When: 21/03/2013 at 01:23:09

 Math boggles me
  Posted by: cityguy
  When: 17/03/2013 at 03:44:48

 Collision Class?
  Posted by: Da_Boom
  When: 16/03/2013 at 03:44:42

 Tree update
  Posted by: Anonymous
  When: 15/03/2013 at 21:11:22

 XNA 4.0
  Posted by: Anonymous
  When: 15/03/2013 at 19:43:57

 Error when I try to run.
  Posted by: Anonymous
  When: 15/03/2013 at 19:21:06

 Error With the Effect File
  Posted by: Anonymous
  When: 15/03/2013 at 18:21:01

 Can only get shadowmap
  Posted by: Anonymous
  When: 15/03/2013 at 15:48:52

 Vertex and Pixel Shader Versions?
  Posted by: Anonymous
  When: 15/03/2013 at 15:07:16

 Unsupported properties
  Posted by: Anonymous
  When: 15/03/2013 at 14:23:00

 Problem Loading Skybox
  Posted by: Rana
  When: 15/03/2013 at 10:34:45

 Black Screen Of Death - Help!
  Posted by: Anonymous
  When: 15/03/2013 at 03:43:43

 2.0 anyone?
  Posted by: Anonymous
  When: 15/03/2013 at 02:19:48

 Defitinition of tha rotation axis
  Posted by: Anonymous
  When: 15/03/2013 at 00:55:14




Topic: Couple correction I had to make...



  
Goto parent category
  
Create a new user account


   Couple correction I had to make...
 Poster : maikai
 Posts: 2
 Country :
 City:

  
Posted by maikai on 17/12/2006 at 19:31:01
Your code for the translation of the world matrix in the text of the tutorial did not match the code at the bottom.  Neither worked for me so I changed it to:


Vector3 t = new Vector3(-HEIGHT / 2, -WIDTH / 2, 0);
worldMatrix.Translation = t;


Also the loading of the height map gave me a horizontally mirrored image of your screenshot so I changed the LoadHeightData() line to:


heightData[y, HEIGHT - 1 - i] = height;


...and now everything runs like it should.
 Poster : maikai
 Posts: 2
 Country :
 City:

  
Posted by maikai on 17/12/2006 at 19:36:35
Just noticed your code below has the mirror problem corrected but not the code in the text of the tutorial.
 Poster : riemer
 Posts: 1392
 Country : Belgium
 City: Antwerp

  
Posted by riemer on 18/12/2006 at 14:19:03
Thanks I've fixed it!
 Poster : Anonymous
 Posts:
 Country :
 City:

  
Posted by Anonymous on 21/12/2006 at 18:02:56
When working with the SetUpIndices funct. on the Intel 915 mobel card I had to change the int(s) to shorts in order to see the image at all.  I don't know why.

private void SetUpIndices()
        {
            short[] indices = new short[(WIDTH - 1) * (HEIGHT - 1) * 6];
            int count = 0;
            for (int y = 0; y < HEIGHT - 1; y++)
            {
                for (int x = 0; x < WIDTH - 1; x++)
                {
                    indices[count++] = (short)((x + 1) + (y + 1) * WIDTH);
                    indices[count++] = (short)((x + 1) + y * WIDTH);
                    indices[count++] = (short)(x + y * WIDTH);

                    indices[count++] = (short)(x + (y + 1) * WIDTH);
                    indices[count++] = (short)((x + 1) + (y + 1) * WIDTH);
                    indices[count++] = (short)(x + y * WIDTH);
                }
            }
            ib = new IndexBuffer(device, typeof(short), (WIDTH - 1) * (HEIGHT - 1) * 6, ResourceUsage.WriteOnly, ResourceManagementMode.Automatic);
            ib.SetData(indices);        
        }
 Poster : riemer
 Posts: 1392
 Country : Belgium
 City: Antwerp

  
Posted by riemer on 22/12/2006 at 03:18:54
Nice, thanks for posting, I know this had to be done with MDX, but I didn't know XNA would even run on these kind of graphics cards ;)

I'll post it as a comment in the chapter
 Poster : Anonymous
 Posts:
 Country :
 City:

  
Posted by Anonymous on 25/01/2007 at 18:00:17
I was wondering, is there a way to create a .raw file so i can customize a terrain to look the way i want it?

thanks

 Poster : riemer
 Posts: 1392
 Country : Belgium
 City: Antwerp

  
Posted by riemer on 26/01/2007 at 09:44:26
In one of the next chapters you'll see how to load from a .bmp file, which you can edit in Paint
 Poster : el_benito
 Posts: 12
 Country : USA
 City: Pittsburgh

  
Posted by el_benito on 26/01/2007 at 15:11:06
Hi Riemer, love the site!  I think the fix didn't get implemented on the XNA using C# 'Terrain from file' tutorial.  The code after "Change your LoadHeightData method to this" still reads
heightData[WIDTH-1-y,HEIGHT-1-i] = height;
but the bottom of the page has been fixed to
heightData[y, HEIGHT - 1 - i] = height;
 Poster : riemer
 Posts: 1392
 Country : Belgium
 City: Antwerp

  
Posted by riemer on 28/01/2007 at 15:36:04
OK thanks it's been fixed! I've also changed the final paragraph of the first series, so it refers to the 'Normal generation' chapter of the ShortTuts section, which is, in fact, the real final chapter of series 1.
 Poster : Anonymous
 Posts:
 Country :
 City:

  
Posted by Anonymous on 28/01/2007 at 20:36:09
Why is the camera position in CreateLookAt a -40.  Shouldn't it be a positive number?  When I make it positive it looks like I am below the grid.  This seems backwards to me.  
 Poster : riemer
 Posts: 1392
 Country : Belgium
 City: Antwerp

  
Posted by riemer on 29/01/2007 at 05:53:17
Hmmm the -40 is the Y coordinate, changing this to +40 will only change the impact of the light. The Z coordinate of the camera defines (in our case) whether the cam is above or under the terrain
 Poster : Anonymous
 Posts:
 Country :
 City:

  
Posted by Anonymous on 29/01/2007 at 21:51:39
Isn't the first vector in that call the position of the camera in world coordinates?

It looks like x=0, y=-40, z=60.  Are you doing something special in your effect file perhaps?  The   XNA docs also say the three args to a vector are Vector3(X, Y, Z).  Does XNA use a Z-axis as up and down?

Thanks!  Good tutorials by the way.
 Poster : riemer
 Posts: 1392
 Country : Belgium
 City: Antwerp

  
Posted by riemer on 30/01/2007 at 13:29:47
You're correct on that, but it is actually up to YOU to define which coord you're using as 'up'. Most people will use the Z coord to represent the height of a point in 3D space, and that's what's been done here.
 Poster : Anonymous
 Posts:
 Country :
 City:

  
Posted by Anonymous on 18/02/2007 at 12:37:12
Hi Riemer;

There's a minor error in your translation matrix.

You have:

Matrix worldMatrix = Matrix.CreateTranslation(-HEIGHT / 2, -WIDTH / 2, 0);

It should be:

Matrix worldMatrix = Matrix.CreateTranslation(-(HEIGHT-1) / 2, -(WIDTH-1) / 2, 0);

It's not noticeable with big meshes like your example, but if you create a small test mesh it becomes more and more visible.

Jamie



 Poster : riemer
 Posts: 1392
 Country : Belgium
 City: Antwerp

  
Posted by riemer on 19/02/2007 at 03:13:22
Isn't this rather a rounding error? Doesn't (float)HEIGHT/2.0f give the same or better results?
 Poster : Anonymous
 Posts:
 Country :
 City:

  
Posted by Anonymous on 21/02/2007 at 17:09:37
Afraid not ! :-)

Imagine you create a matrix with (2,2). The point values will range from 0,0 to 1,1 but we really want -.5 to .5. Translating by width/2 and length/2 gives us values from -1,-1 to 0,0 - incorrect! Translating by (width-1)/2 and (height-1)/2 works fine.

As the grid becomes larger it's less noticeable but exactly the same you must always subtract one. It's even visible in your example if you look at the top left and top right corners; they are unequal.

It wouldn't really matter of course unless you were trying to build a larger streaming world by stitching the meshes together --- then you would get weird matching errors.

Thanks for your tutes by the way in just 5 days I have gotten further than I ever did in years with Directx.

Jamie




 Poster : Anonymous
 Posts:
 Country :
 City:

  
Posted by Anonymous on 17/04/2007 at 11:35:59
i was always under the impression that
x = left/right
y = up/down
z = forward/back

for what they represented in 3d space? especially if you set your camera to having it's up vector as 0,1,0.. then wouldn't y be running straight up and down through your "camera" ?

so.. z is actually up and down?
 Poster : riemer
 Posts: 1392
 Country : Belgium
 City: Antwerp

  
Posted by riemer on 17/04/2007 at 15:17:40
It really is up to you to choose the axes... I've taken Z as up, because it seemed normal to me to take the height of the terrain as the Z coordinate.
 Poster : Anonymous
 Posts:
 Country :
 City:

  
Posted by Anonymous on 24/04/2007 at 17:34:09
this whole confusion over which axis is which is very silly.

if you'd read the code you're typing, you'll know exactly which axis you set as your 'up' axis, so on and so forth.
 Poster : Alaric
 Posts: 3
 Country : United States
 City: Columbus, OH

  
Posted by Alaric on 02/07/2007 at 19:27:35
...What's up with the code that parses the payload of the raw?  With the 'xna' file that was provided, everything works fine.  But, when I create a raw in photoshop and map it to the terrain, it bombs and turns the grid into a huge mangled mess.  ...Which raw format did your 'parsing' code write against?
 Poster : Extrakun
 Posts: 34
 Country : Singapore
 City: Singapore

  
Posted by Extrakun on 06/07/2007 at 03:42:12
Actually, which axes is up is important once you start coding in moving entities. For instance, take the flight-sim for example. The code for pitching gives the effect of yawing, and the code for yawing gives the effect of pitching, due to the way the x-wing is rotated so that it looks natural with the terrain.

(Correct me if I am wrong, but somehow I was following the code, which according to my textbook, should should pitch the x-wing, but it becomes yaw instead, and was quite surprised)
 Poster : Anonymous
 Posts:
 Country :
 City:

  
Posted by Anonymous on 09/08/2007 at 12:51:10
I think the reason for the slight confusion about axes is this:

In math, we're used to using only the x and y axes (at least in middle school).  When we reach 3-dimensional graphics, it's convenient to simply stick tack on the remaining dimension in the "forward/back" dimension, since it's the only direction left.

In 3d modeling, it seems like z is always "up".  I guess the simplest way to think about this is having some graph paper laid flat on a table containing the xy-plane, with z coming up.

I don't know why it's like that, but it is and it makes sense to me.
 Poster : Anonymous
 Posts:
 Country :
 City:

  
Posted by Anonymous on 29/08/2007 at 12:44:12
device.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0, WIDTH*HEIGHT, 0, (WIDTH-1)*(HEIGHT-1)*2);

In this part of the code sends me an error... It says "The method call is invalid", i download the bassic effect to make it work but it doesnt seems to work... any idea?
 Poster : ghanemabdo
 Posts: 5
 Country : egypt
 City: alexandria

  
Posted by ghanemabdo on 14/10/2007 at 02:22:29
for the problem with Intel 915 graphics card, i want to know why there was a problem when using int in the setupindices method and this problem was solved when using short instead of int.
i want an explanation please.
thanks for the solution of this problem and waiting for reply :D
 Poster : Nemo Krad
 Posts: 61
 Country : England
 City: Leicester

  
Posted by Nemo Krad on 15/10/2007 at 07:17:18
I got an answer to that once I posted it up on the XNA Creators Club forum.

http://forums.xna.com/thread/19421.aspx

It just does not support 32bit indices.

Hope this helps.
 Poster : stealthcoder
 Posts: 7
 Country : Canada
 City: Montreal

  
Posted by stealthcoder on 21/01/2008 at 09:35:08
A few posts up Jamie wrote:


Hi Riemer;

There's a minor error in your translation matrix.

You have:

Matrix worldMatrix = Matrix.CreateTranslation(-HEIGHT / 2, -WIDTH / 2, 0);

It should be:

Matrix worldMatrix = Matrix.CreateTranslation(-(HEIGHT-1) / 2, -(WIDTH-1) / 2, 0);

It's not noticeable with big meshes like your example, but if you create a small test mesh it becomes more and more visible.

Jamie


I agree with this adjustment to the world matix to get everything centered perfectly. But the HEIGHT and WIDTH varaibles are mistakingly interchanged on both Riemers and Jamies code. It should be:


Matrix worldMatrix = Matrix.CreateTranslation(
-(WIDTH-1) / 2, -(HEIGHT-1) / 2, 0);


WIDTH is for the horizontal so it should be in the x-coordinate, and HEIGHT is for the vertical so it goes in the y-coordinate.

This problem is not showing up because WIDTH and HEIGHT are equal. The problem shows when these varaibles are not equal.

  
Post a new reply
 





Google
 
Web www.riemers.net
If you appreciate the amount of time I spend creating and updating
these pages, feel free to donate -- any amount is welcome !
- Website design & DirectX code : Riemer Grootjans -
©2006 Riemer Grootjans


News
Home
Forum
XNA 2.0 Recipes Book (8)
XNA 3.0 Recipes Book (8)
Downloads
Extra Reading (3)
Matrices: geometrical
Matrix Mathematics
Homogenous matrices
Community Projects (1)
Tutorials (160)
XNA 4.0 using C# (89)
DirectX using C# (54)
Series 1:Terrain (14)
Opening a window
Linking to the Device
Drawing a triangle
Camera
Rotation - Translation
Indices
Terrain creation
Terrain from file
DirectInput
Importing bmp files
Colored vertices
DirectX Light basics
Mesh creation
Mesh lighting
Series 2: Flightsim (19)
Series 3: HLSL (19)
Short Tuts (2)
Resizing problem
Checking Device caps
DirectX using C++ (15)
DirectX using VB (2)