Wednesday, December 27, 2006

View frustum and the ilogical way to think

Hi, this is a little post to warn all can read it, about the ilogical way to think on the view frustum.
Suposse you have the bounding box (of an object to be rendered), your camera's frustum and you can calculate if a point is inside the camera's view frustum, then:

  • A = All points of the bounding box are inside the frustum.
  • B = Some part of the object are in the frustum and must be rendered.
We can say that:
  • A-->B, that is, if all points are into the view frustum then the object if completely inside the frustum.
but take care (and remember your old clases of "First-Order Logic"):
  • The oposit of A-->B is not (no A -->no B). That is, if all points of the bounding box are outside the view frustum then the object is outside the view frustum. This is false.
Supose you have a bounding box (an object) in the center of the view frustum. If you move the camera to put it in front and very close of the object (mantain it in the center), then left points of the bounding box are out of the frustum by the left plane, and the right points of the bounding box are outside by the right plane. In this situation, and by the above predicate, all points are outside the view frustum but the object would be drawn.

The right oposite proposition for A-->B is "not (A-->B)" or "not (no A or B)" or "A and no B", and this a very different thing than the previous and erroneous definition.

Finally (thanks Brandon) the right to think to know when to draw a object because it is present in the camera view frustum is (or could be):
  • If all points of the bounding box are inside the frustum, then the object is completely inside the frustum and must be render,
  • if all points are outside by the left plane, or all points are outside by the right plane, etc, then the object is completely outside the frustum and must not be drawn.
  • other cases, portions of the object intersects with the view frustum and can be drawn.

Sunday, December 03, 2006

Improving performance with display lists

Recently I have been working with shapefiles to add support for it in The Balloon Project. Thanks to the GeoTools I can read the format easyly and render it as line loops (GL_LINE_LOOP).
Initially I was using the brute force for rendering, that is, all points in the window are calculate every time they are going to be rendered. They work for polygons with few points and textures (tile images), but when a shapefile with a thousand of points appears in the scene the brute force is not a good solution.
For this, I change some code and now I am using display list in all my renderable object. The performance has increased surprising in my latpop even with a shapefile.

Saturday, December 02, 2006

NetBeans with your preferred LAF

To all that want to change the default LookAndFeel of its NetBeans:
Can I run NetBeans with a custom look and feel?
Also you can take a look at the themes way here.

Tips about "Out of memory" exception

Recently I have problems with the memory in The Balloon Project. By default, Java starts with a maximum configured memory of 64 Mb and when a layer is loaded with a great number of 512x512 image tiles that is not enought.
Here I want to put a couple of links to pages that talks about the JVM memory options and the out of memory exception:

Thursday, November 23, 2006

Glassfish and socket problems

I was trying use gnu.hylafax libraries (a libraries that implement the HylaFAX protocol, similar to the FTP) to comunicate with a HylaFAX server.
I had created an EJB module with a class containig all the necessary code. I had been tested it in a simple java application and works fine, but when I put it into the EJB class, it fails. See the post at: Hylafax connection into an EJB module to see the error.

To resume the error was in the socket implementation. Looking for help I saw that many people has the same problem, and the solution was to do (see
Unable to launch the Java AppServer or Timeout waiting for domain1 to start):

  • cd \domains\domain1
  • edit config\domain.xml
  • search for elements like
  • add -Dcom.sun.enterprise.server.ss.ASQuickStartup=false
  • save the file.

Saturday, November 18, 2006

A bit of quaternions

I need to implement some kind of "go to" function in The Balloon Project, that is, give the user the possility to go to any position of the planet experssed in lat/lon.

Looking for information about how to do this I found (an extensive list of links) but this two resumes very well the concepts and the utility of quaternions.

  1. http://www.isner.com/tutorials/quatSpells/quaternion_spells_14.htm
  2. http://www.gamedev.net/reference/articles/article1095.asp
Expressin rotations in Euler angles are not always a good way, first because exists the gimbal lock problem and second because I want interpolate between two angles to animate the rotation of the camera from one point to other. Quaternions solves this two problems.

Tuesday, October 31, 2006

New blog startted

Well, finally I decided to start a new blog about my actual project: the Baloon project.

Edgy upgrade problem

Unfortunately I sufer the same problem as this:
http://element14.wordpress.com/2006/10/27/ubuntu-edgy-upgrades-a-disaster-for-many/

In my case, I have an Pentium D machine with EMT-64. Because this I download the 64 version of Ubuntu. I have experienced problems on the bootsplash screen and my glassfish run very slow.

Finally I installed the 32 bit desktop (i386) version and all is right. I'm not getting all the power of the processor but it works right and glassfish runs quickly.

Saturday, October 21, 2006

Open Clip Art Library

There is no much to say. Open Clip Art Library is simply another open jewel :)
Remember you can download the entery clipart library in a simple compressed file (be worry with its size).

Friday, October 06, 2006

Glassfish and PostgreSQL problems

If you are working with Glassfish v1_ur1_b14, PostgreSQL and NetBeans 5.5 probably you had experienced some dificulties with entity class.

(1) you develop the code.
(2) you compile and build your code (an .ear or .war file)
(3) you can't deploy your application :(, Glassfish says you there is an error (with a null desciption) but if you chech your app with the verifier utility it is right.

Well, here are acouple of links describing the problem (related with the @GeneratedValue annotation) and describing a solution: