Forum
Contact





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



Latest Forum posts

 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

 Typo / Inconsistancy for 360 deployment.
  Posted by: Anonymous
  When: 14/03/2013 at 19:48:23




Topic: mistake found



  
Goto parent category
  
Create a new user account


   mistake found
 Poster : jaf23
 Posts: 1
 Country :
 City:

  
Posted by jaf23 on 14/01/2007 at 08:58:53


hi,

first i wanna say that i like your tutorials very much, the explanation is very good and easy to understand!

now to the mistake i have found...

i dont know if the mistake is only by me, but in the camera example of series 1: terrain, i only see my background color and no triangle!!

i have created this example so often and tried to find the reason by changing things, but it was always the same and i have never seen the triangle! after 2 days i have watched other examples where it works, and i changed every thing to your example step by step in it, to see if and when the triangle would not be seen anymore so that the other working example would become exactly like yours!

then it was done and worked already fine, but i have forgotten to change the formsize! you have told to change the formsize to (500, 500) in this line:

this.ClientSize = new System.Drawing.Size(500,
                                          500);
and in the example where it works it was

this.ClientSize = new System.Drawing.Size(292,
                                          266);

now i know that the reason is because of this line:

device.Transform.Projection = Matrix.PerspectiveFovLH((float)Math.PI / 4,
                        this.Width / this.Height,
                        1f, 50f);

the mistake is by the 2nd attribute "this.Width / this.Height"

by me that works only with a formsize of (292, 266)

and when you change the 2nd attribute to "1" it works by every formsize!

like so:

Matrix.PerspectiveFovLH((float)Math.PI / 4,
                        1, 1f, 50f);

i dont know if it is only by me and why it is...

maybe can you explain it why it is?

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

  
Posted by riemer on 16/01/2007 at 07:08:53
Indeed, this is something I should change..

you should use this line:

device.Transform.Projection = Matrix.PerspectiveFovLH((float)Math.PI / 4,
                        (float)this.Width / (float)this.Height,
                        1f, 50f);
<text>
For a reason I still have to find out, when setting the size to 500,500, the real window size is a bit different. So, without converting the width and height to a float, the division will be rounded to the nearest lower int, which is 0! If we convert to a float, the result of the division is also a float, and in this case something like 0.999, which is fine.
 Poster : Matthew
 Posts: 16
 Country : UK
 City:

  
Posted by Matthew on 16/01/2007 at 07:16:43
Just noticed your comment on window size:


this.Width = 500;
this.Height = 500;


... will change the external size of the form.


this.ClientSize.Width = 500;
this.ClientSize.Height = 500;


... will change the internal size of the form (the bit where the rendering takes place, not includng the border and the bar at the top).

Matthew.
 Poster : JenovaChild
 Posts: 15
 Country : Australia
 City: Townsville

  
Posted by JenovaChild on 18/01/2007 at 22:35:41
Good that this was discovered, I was wondering what was going on for a minute. As I was attempting to run the application the triangle would not appear until I had either maximised the window or simply resized it.

This must be due to the fact that the line

device.Transform.Projection = Matrix.PerspectiveFovLH((float)Math.PI / 4, (float)this.Width / (float)this.Height, 1f, 50f);


Works on what Matthew mentioned above, the window size including toolbars and things.

So by simply changing the line to..

device.Transform.Projection = Matrix.PerspectiveFovLH((float)Math.PI / 4, (float)this.ClientSize.Width / (float)this.ClientSize.Height, 1f, 50f);


Resolved my issue of needing to resize the window before the triangle would appear.
 Poster : Anonymous
 Posts:
 Country :
 City:

  
Posted by Anonymous on 29/01/2007 at 22:22:32
You also mentioned vertices for a polygon need to be in Clockwise order.  However, according to the MSDN docs, XNA uses a RightHand system, which means they should be a CCW order.  I am confused why your tutorials work?
 Poster : riemer
 Posts: 1392
 Country : Belgium
 City: Antwerp

  
Posted by riemer on 30/01/2007 at 13:38:58
Excellent, don't accept everything because someone tells you so :)

You're correct about XNA using a RH system. However, this doesn't effect the drawing order. The vector from the camera to the center of the triangle is still the same, so nothing has changed to the winding order of the vertices. CW stays CW, it's the winding order of the vertices, relative to the vector from the camera to the center of the triangle.
 Poster : Anonymous
 Posts:
 Country :
 City:

  
Posted by Anonymous on 27/08/2008 at 12:03:05
The confusion is in the surface normal. If the triangle is specified in CW order but in a RHS, then the surface normal will be pointed away from the frontside in the object's coordinate.

For example, if you have a triangle: (0, 0, 0), (3, 3, 0), (4, 0, 0) specified in CW order. The cross product (i.e., the surface normal) will be calculated to be (0, 0, -12) which point away from the front side in a Right-Handed System. However, in XNA, this will be defaulted to be visible.  This is completely incorrect... Did someone screw up at the beginning when designing XNA?
 Poster : riemer
 Posts: 1392
 Country : Belgium
 City: Antwerp

  
Posted by riemer on 27/08/2008 at 15:22:31
It's pretty hard to define THE surface normal: each triangle has 2 normals A and B, where A = -B.

Quite important here to note is that cross(side1,side2) = -cross(side1,side2). So in your explanation (or code that you're using), it might be sufficient to swap the 2 arguments of your cross method to make everything line up nicely.

Culling is not directly related to LHS or RHS, you just need to make sure the triangle is defined CW relative to the camera.
 Poster : Anonymous
 Posts:
 Country :
 City:

  
Posted by Anonymous on 28/08/2008 at 13:18:50
Let me elaborate my point using my example again--- a triangle v1(0, 0, 0), v2(3, 3, 0), v3(4, 0, 0) specified in CW order.  One can use their left hand (curl and rotate their 4 fingers Clockwise), then the surface normal (the thumb) will point toward the viewer. And if you calculate their cross product vector in the correct manner, i.e., Cross(v2-v1, v3-v1), it is (0, 0, -12), consistent to the Left-Hand System where -z is toward the viewer. In other words, CW order is natural to a LHS, but the opposite to a RHS in XNA.  
 Poster : OmerCakir
 Posts: 1
 Country : TURKEY
 City: Trabzon

  
Posted by OmerCakir on 05/09/2008 at 00:48:02
I agree with Anonymous. Because in the "Managed DirectX Kick Start" book Tom Miller says:

"What exactly is a left-handed coordinate system anyway, and why does it matter? In most Cartesian 3D coordinate systems, positive x coordinates move toward the right, while positive y coordinates move up. The only other coordinate left is z. In a left-handed coordinate system, positive z moves away from you, while in a right-handed coordinate system, positive z moves toward you. You can easily remember which coordinate system is which by taking either hand and having your fingers point toward positive x. Then twist and curl your fingers so they are now pointing to positive y. The direction your thumb is pointing is positive z. See Figure 1.1.

Direct3D uses a left-handed coordinate system. If you are porting code from a right-handed coordinate system, there are two things you need to do. First, flip the order of your triangles so they are ordered clockwise from front".

DirectX uses LHS and triangles are ordered clockwise. Why does XNA use RHS although triangles are ordered clockwise and culls CCW like DirectX? It's very confusing.

 Poster : Anonymous
 Posts:
 Country :
 City:

  
Posted by Anonymous on 31/08/2011 at 07:24:59
I'm trying to follow this tutorial but by using SlimDX. Works fine until I change to the PositionColored vertex... Since I don't use the Managed DirectX dll I don't have that one (or the TransformedColored vertex either). I was able to create my own "TransformColored" vertex wich rendered the triangle fine, but when I created my own PositionColor vertex it won't render anything, just the background...

I don't know what VertexFormat to use for the PositionColor vertex. For the TransformColor the format was:

VertexFormat.PositionRhw | VertexFormat.Diffuse

so I tried

VertexFormat.Position | VertexFormat.Diffuse

for the PositionColor vertex, but nothing is rendering (or, it might render but I can't see it).

Any ideas?
 Poster : Anonymous
 Posts:
 Country :
 City:

  
Posted by Anonymous on 31/08/2011 at 07:28:30
My mistake, it was the ClearFlags.ZBuffer I had forgot. Found that forum post after I posted my question.

  
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)