Friday, 16 February 2007

More ski

Another great ski day. Here, my dad, great skier (Candanchu, 2003). This man didn´t ski for eleven years before that day... Just after getting down the chair lift, he went down the hardest track of the resort, at full speed... After 200m, he crashed and started to tumble downhill. I was worried as he´s 56, but when I got where he was, he standed up to his knees, with a great smile in his face, all his moustache, clothes and hat full white with snow.... jaaa jaaaa.
Thanks dad !



Friends and holydays

I decided to dedicate a post to my friends, an important part in my life:
In 2002, I had the chance to visit my friend David (third one in the pic), who was cursing an MBA at Hardvard University. One of the best holidays in my life, with no doubt. Here, after our visit to the Massachusetts Institute of Technology (M.I.T), cortesy of the great Aletia (in the right), who was studying there. Special mention to the photographer, Julius Maximus.

Another picture of a great moment. "Monasterio de Piedra", 2005

We also like to go skiing (to the pyrenees), but this year it´s not snowing at all. Never seen that. Anyway, this pictures were taken in Luz Ardiden (France), in 2005. Here, my wife and friends:


Magnificent view !!!!

Thursday, 15 February 2007

Honey moon

I´m happily married since October 2006. Our honey moon was FAN-TAS-TIC.
We spent 18 incredible days in Argentina. People is very kind, and if you like nature, it´s a must....
Here at Iguazú falls (Brazilian side). Despite the over-population and tourism, they´ll make you cry...


We had a 32 ºC trip from tropycal weather of iguazú to the cold but beautiful Calafate. Here at Lago Argentino.




We had the chance to walk on a glacier (Perito Moreno, wow!) and see some Icebergs of an extreme beauty. Like this ones:

What else can I say. A picture is worth a thousand words...

Thanks to my wife !






Hobbies and interests

I decided to post in this tag some pictures about my family, friends and myself.



Today, I´ll start with one of my hobbies. Enduro racing...



Here, Imanol and Jorge riding. Sorry about the quality... (cellphone picture)



Talk about refactoring, today in Pamplona

This evening, at 19:30 will take place, here in Pamplona, another NavarraDotNet event: a talk about Refactoring. It will be guided by Carlos Segura (Sharepoint MVP) and Sergio Jimenez, (member of navarraDotNet).


More info:
http://www.navarradotnet.com/Eventos/15febrero2007/tabid/79/Default.aspx

Wednesday, 7 February 2007

3D intersection concepts and the Mesh.Intersect() method

[Please NOTE: This article is OBSOLETE. It has been re-written and completed in this newer posts: part 1 and part 2]

Today I´ve posted an answer to somebody that wanted to know more about collision detection and the use of the Mesh.Intersect method. As I liked the post, I decided to put it in here. Hope it helps somebody else. You can find the original post here:
http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1197599&SiteID=1


Determining if any two 3D objects intersect and get useful information about the intersection is not a easy task. Specially if you want to do it fast.

The key to optimize this algorithms is quick discarding non colliding objects. To do so, a list of algorithms can be applied. The more usual are the BoundXXX discard tests:

- BoundSphere: Use a hipotetical sphere surrounding objects. If the distance between objects are bigger than the sum of both radius, then they don´t intersect. This fits well for objects similar to a sphere, but not at all for something like a hockey stick, for example. This one is supported in DirectX (BoundSphereTest)

- Axis Aligned Bound Box: Use a hipotetical box surrounding objects. This box is not aligned with the object, but with the world axis (it´s not rotated with the object). It just keeps track of the maximum and minimum values of X,Y,Z along the objects´s geometry. It´s also supported in DirectX (BoundBoxTest) and fits best with squared geometry, of course.

- Oriented Bound Box: This one is more accurate of the three, but of course more expensive to compute. It rotates the bounding box with the object, so it fits better it´s geometry. It´s not supported in DirectX and you´ll have to do it yourself. Let me know if you need help on this.

Once you are doing a good discard test of non-colliding objects, and once you got two objects that "may be intersecting", it´s time to go into a more detailed collision detection model.

There are dozens of intersection algorithms, each one optimized for the kind of geometry you want to test: Ray-Polygon, Ray-Mesh, Polygon-Mesh, Cylinder-Mesh, Cylinder-Ray, Sphere-Mesh, and so on...

The best is, if at least one of your two objects can be aproximated as a geometric shape like Sphere, Cylinder, Box, etc, because the Mesh-Mesh case is of course the most expensive. You can find very good resources about this algorithms here:

http://www.realtimerendering.com/int/

One of the most common methods is to define some BoundingSpheres that aproximate the real shape of an object, and use the sphere-mesh test. This method gives very good results sometimes (specially when objects are near to spherical) and it´s very fast.

Another usual method is to aproximate one of the two objects using a bunch of rays as collision testers and then perform the ray-mesh test. For example, if wanted to detect if a character is touching somethig, you can use rays describing it´s arms directions, and do a Ray-Mesh test against all other objects in the scene.

Thats where the Mesh.Intersect() methods comes in, because it performs the Mesh-Ray test. You can use it like this:

DX.Direct3D.IntersectInformation intersectionInfo;

if (mesh.Intersect(rayOrigin, rayDirection, out intersectionInfo))
{
// There is collision
}

The IntersectInformation structure gives you the exact Distance between the ray origin and the intersection point, the face index of the mesh with which the collision occurs, and the U,V coordinates of the intersection point (useful if you want to search something in the mesh texture, i.e. if the texture is transparent in that point).

If you want to know the exact 3D point of intersection you can easily calculate it like:

intersectionPoint = rayOrigin + (rayDirection * intersectInformation.Distance);

If you want the normal of the surface in the collision point, use the normal of the mesh´ face using the face index returned in IntersectInformation.

One thing you must be careful with: this method uses the current state of the mesh. It tests all of it´s polygons against the ray. If you move or rotate the mesh setting a transform matrix in the Device.Transforms.World, that transformation will not be taken into count in the Mesh.Intersect method. If your objects are dynamic, you should keep track of a mesh version with all it´s transformations applied to the vertices.

Lastly, if you want to do some serious collision detection, specially if you are planning to do any Rigid Body management, my suggestion would be to have a look to the SAT Algorithm (Separation Axes Algorithm). Its fast, accurate and gives you very useful information, like the MTD (minimum translation distance and direction to solve inter-penetration).

Cheers!

Friday, 2 February 2007

Windows vista disappointment

Just a couple of days ago, I took my hands onto the release version of Vista.

I have to say that I´ve been quite sceptic about installing vista, but finally I tried. In order to not interfering too much in my desktop computers, I tried to install it in my laptop (over a previous XP installation).

The installation process finished flawlessly. Slow, but flawless. After I booted for the first time, I realised that everything was very slow. And I mean veeeeeery slow.

In part, it is due to the hardware specs of my laptop: Pentium IV 2.8 Ghz, 512 Mb RAM, ATI Mobility Radeon 9700. I know that 512Mb are not enough at all for vista , but... man! So slow?May be the lack of performance is also due to the second problem I´ve found. The damn Code 43 error.

No matter what I try, but I cannot make the O.S. load the ATI card´s driver properly. Im trying with the new Catalyst 7.1 drivers. The install process works Ok, but after reboot the driver does not load properly and the card is not recognized.

Any help on this would be really appreciated !!!!

Cheers!