Heteroclinic.net logo

www.heteroclinic.net

In Depth 3D Computer Graphics
Chapter 1 Mesh File V

201601

Here is the Apache Maven* pom file to help resolving the Dependencies of CubeDemo.java.

* http://maven.apache.org/

In Depth 3D Computer Graphics
Chapter 1 Mesh File VI

201601
We can parse the file with a basic line reader.

The program will read "cube.gts" file located in src/test/resources folder. The test file itself is in src/test/java folder. The Java virtual machine will locate the file and get the absolute path as a URI thus it is operating system independent.

In Depth 3D Computer Graphics
Chapter 1 Mesh File VII

201601

Previously, in my projects no matter in Java or C/C++, I would use the method in the above section by processing a file line by line. This time, as I tried with my project -- Tiny CSV Reader: some experimenting code to parse CSV FILE, I was thinking to handle the mesh file(s) with regex. But we hit the wall, it is another obvious evidence that scale up is not an easy thing, maybe you would argue on this sentence. The design pricinple is that when we are dealing a file up to hundred mega-bytes level, we try to read it all into memory, the we split and parse individual elements in main memory. So it will speed up. First, we write a GTSModel.java class. We don't have very high security constraints, so we keep its member variables' visibility at package level.


In Depth 3D Computer Graphics
Chapter 1 Mesh File VIII

201601

Then we use a reader class to the mesh then instantiate a model -- how we read the mesh won't affect the model which is simple just to record the data.