There are already many papers and books to refer to models in the 3DS file in OpenGL. But in many occasions, only read and display is not enough. We need to observe the model from all angles to better understand the shape of the model and form a more intuitive sense of understanding. For example, in a medical condylar fracture diagnosis, if the fracture is used, the three-dimensional model is simulated by the three-dimensional model, and only the mouse is dragged, it will be able to watch the fracture from any angle, which will do the doctor. It is beneficial to the correct diagnosis. This is also why we consider the original intention of implementing this feature. This article will briefly introduce 3DS file format, how to read and display the model, and focus on the mathematical foundation and experience of model free rotation through the mouse.
3DS file format and some experiences in reading and displaying models in files.
The 3DS file is composed of a number of chunks (in the mosa block in large blocks). Due to the so far, there is no official document that there is still a lot of unknown blocks. However, this does not affect the model we read in a 3DS file. Because we are reading, you can selectively read the blocks you need according to your needs, ignoring those who are not interested or unknown. This is the benefits that the block structure gives us.
A block consists of block information and block data. The block information is also composed of the ID of the block (two words and downs, such as 4D4D), and block length (four bytes, in fact, the number of offset bytes of the next block). Open a 3DS file with VC to open a 3DS file clearly to see its structure. When reading this block structure (the nested small piece in large blocks, the structure of the block is fixed), it can be implemented using the recursive method, and the last level (after the sub-block is read, return to the parent block) The condition is whether the number of bytes of the block currently read is equal to the length of the block. From the parent block to read its sub-block, the Switch statement can be implemented, and which branch entry is judged by the ID of the sub-block.
Since there are many ready-made such programs on the Internet, it is entirely a better program to find a class package to transplant it into your own project. Of course, you need to do some small changes, such as modifying the part of its display and control according to your needs.
Full text reading:
OpenGL realizes model free rotation in the 3DS file