Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 21 Jan 2009
Offline Last Active Aug 31 2012 08:18 AM

Posts I've Made

In Topic: Accessing the dd surface directly in xna?

21 August 2012 - 08:20 AM

I know that changing code may be a risk to insert bugs, but on that case see this as an opportunity to start learn about 2D XNA rendering.

A method far simpler is to pack all the tiles you need in a paint program to create a theme, and use them to render the level.
The rendering of the tiles can be done with calls to SpriteBatch methods. This way you can achieve a maximum of 60 fps.

To increase performace you can skip all tiles completely outside current viewing position.
Also you can unlock XNA from vsync to check real performace adding IsFixedTimeStep = false; to the game object constructor.

Here http://msdn.microsof...y/bb194908.aspx you find all you need to load a texture (your packed tiles) and draw a sprite (in your case a tile).

Also you can use the same class to draw the ship, projectiles, etc.

At last notes:

Keep in mind that accessing resources at low level must be done only if no other ways are found. And that C# is a managed language and it's a little slower than C/C++.

To move blocks of data on .NET 4 you can use Buffer object http://msdn.microsoft.com/en-us/library/System.Buffer(v=vs.100).aspx .

In Topic: XNA wrong quad color interpolation.

21 August 2012 - 07:59 AM

GPUs operate only on triangles so, to have the same shading, you need that colors on vertices are the same and that the triangulation is the same (a quad is composed by 2 triangles).

However your quad (I think XNA shot it's the first) seem to be rotated of 90° around the axis you are looking.
I don't know if you use or not a camera.
If you directly render quad vertices without transformations you may be need to swap X/Y components and set Z (the depth onto the screen) to 0.0.

Also if you put the quad vertices directly to the shader use the Vector4 and specify a W = 1.0. (so {X, Y, 0.0, 1.0} ).
W=1.0 indicate a position and not a direction vector. This fourth component is important when you use matrix transforms onto the shaders.

Another thing: XNA is based on directX 9.0c that is a slightly different from DX 10 and later.

In Topic: How to find minimum distance between two polygons in 3D space

21 August 2012 - 02:27 AM

Thanks to all guys!
You've got me some differents solutions to the problem, now I test what fit better for me.

As an estimation (max bound), you can compute the minimum of all nine distances between the vertices of the triangles. Then, filtered by a threshold, you can choose candidates and compute the real distance between each vertex of one triangle and the plane that represents the other triangle.

I do this (I work with polys not triangles, but basically is the same).
Also I check for distance from center to center of the two polygons.
The only distance that I need to check is when the minimum distance is made by a segment with endpoints inside the polygons.

If speed's not a huge concern, perhaps the below would work:

Personally I'd just go the AABB way for simplicity and speed, and then optimise if it's needed. Assuming you don't use single huge polygons, the chances of AABBs overlapping for arbitrary polygons should be pretty low.

I've already seen this approach but is for 2D.
If I'm correct, when I translate to 3D, support lines become planes parallels to polygon's normal...

Thanks again.

In Topic: How to find minimum distance between two polygons in 3D space

19 August 2012 - 04:59 AM

I'm sorry, it's true....

The polygons are convex and planar and the vertices are ordered counter-clockwise.

I already have an algo to check if two convex polys intersects so I can filter it out and return zero distance, otherwise I will use the algorithm I search for.

The distance must be correct or at least underestimated. If the distance returned if bigger than real the contribution of lightmap is skipped making illuminations artifacts (darker regions).

I not search for speed, I precalculate these distances only once during radiosity setup.

I have another question now, a radiosity solution based on hemicubes is automatically unit-less?
I've thinked that the inverse square law is due to the area that a polygon fill onto the hemicube faces, so the perspective automatically reduce this.... and so the units of the scene are not important.
But now, misuring the distance directly from polys, i think i need to convert units it to meters to work well?

I've partially solved, the assertions made on the box above are wrong i need to check for solid angle and thus accounting for the square of distance between hemicube origin and patch center.
I have also set an UnitsToMeters float to define the scene scale. Now it's all more correct.

The distance algorithm is always needed...

In Topic: C# Game Programming Audio Issue Fix

18 August 2012 - 08:23 AM

The last Assert can fail only if the file or path don't exist, or if there is not enough memory to allocate the buffer.

Due to the today PC configuration I don't think is a memory problem, maybe a wrong construction of the path string or a folder name that contains spaces and can make problems. You can add this code at the beginning of the method to check if the path is correctly recognized:
System.Diagnostics.Debug.Assert(File.Exists(Path), "File not found");

To do a fast check be sure to have the game on the same folder on real and virtual machine and check if it work.

Check also that real and virtual machine run both a 32-bit or a 64-bit system. It's important for run-time DLL linking.
If you compile the project in 64-bit the OpenAL search for 64-bit libraries; compiling for 32-bit it check for 32-bit libs.

Another thing to check is the version of the .NET framework installed on real and virtual machines.