Reading and displaying 3DS files in QT

Source: Internet
Author: User
Reading and displaying 3DS files in QT

After successfully reading and displaying 3DS files under the glut framework, I started to read and display 3DS files under the mature and dynamic QT framework. (The original article is from http://blog.csdn.net/jiangcaiyang123. please refer to this article for help .)

DemoProgram: Here

Source code: Here

In this transplantation, I did not use my own 3D Math library, but I used the built-in Math Library of QT. Therefore, you must include header files such as qvector3d and qmatrix4x4 in the header file. After using these header files, I felt that QT was fully done. We thought about it for us. Convenience though convenient, I still encountered many difficulties during the transplantation process.

First of all, there may be some problems with the mingw compiler. It is better not to add a Data Pointer before the vector data member; otherwise, a member function is generated in vector: size () (this function should be a statement containing the vector: push_back () class) an error occurs when calling the application again. Specifically, there are two situations:

 
Class Aclass {public :... PRIVATE: otherclass * m_poc; qvector <otherstruct> m_data ;}; class Aclass: publicbaseclass {public :... PRIVATE: qvector <otherstruct> m_data ;};

In both cases, m_data's size () members may encounter errors. The reason is probably that the content of the previous pointer (or from m_poc, or from the pointer to baseclass of the base class) scrubbed the member of the vector <otherstruct> m_data similar to m_size. Therefore, errors may occur. This problem exists in STD: vector and also exists in qvector. This problem may occur if I use mingw4.4. The solution is to avoid the above two situations. You must be extremely careful when using pointers.

Another troublesome issue is the qimage storage. The qimage class reads images from a file, but the image data in the class is upside down. That is to say, to access the data of the first pixel in qimage, you need to call qimage:: The Mirror () function is used to direct and re-access the reversed data, such as: image. mirror (). constbits () [0]. This should be noted in the texture display. I suspect that the texture is wrong, and no result is returned for half a day.

Solve these problems and try to read several3DSFile, found good. The problem only occurs when the model matrix is displayed. Sometimes the model location does not seem correct. InUbuntuIn this experiment, an error occurs in the deep test. I still don't know how to solve this problem. But should I not celebrate the completion of a major event?

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.