Friday, 16 February 2007
Thanks dad !
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
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 !
Wednesday, 7 February 2007
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:
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:
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:
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).
Friday, 2 February 2007
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 !!!!