Implementation method of three-dimensional model in VB environment

Source: Internet
Author: User

At present, in the design of virtual design and NC simulation program, VC and three-dimensional modeling core are adopted to realize the display and dynamic operation of the three-dimensional model. Because VC more difficult to grasp, involving graphics rendering and operation of the part is so, and three-dimensional modeling core generally need to buy from abroad, for the general development of applications because of the high cost and lack of feasibility. VB as a completely object-oriented development tool, in the interface design and database has a considerable advantage, the general design staff can learn to master, but in the graphic design, especially the three-dimensional model of the display and operation of the research and application is not much. Therefore, the study of using VB to realize the graphic design of three-dimensional model will play a great role in the virtual design and simulation program.

The display of three-dimensional model

At present, most of the development of the three-dimensional graphics program is based on OpenGL to achieve, OpenGL is actually an independent window system and operating system open three-dimensional graphics standards, has been supported by many computer manufacturers. As an excellent three-dimensional graphics interface, OpenGL provides rich drawing commands that enable the development of high-performance, interactive, three-dimensional graphics applications. It has a close development interface with VC, but because VC for general non-computer professional engineering and technical personnel difficult to master, so to the engineering field simulation program design brought great inconvenience. But currently supporting the development tools such as VB OpenGL Development Library is also beginning to appear. This article is based on the Vbopengl (VBOGL.TLB) library to implement, this is a free use of third-party libraries, which encapsulates a large number of underlying OpenGL library functions, to a large extent simplifies the development work.

Before setting up the three-dimensional graphics environment in VB, we should first add the Vbopengl library under the "Reference" submenu under the "Project" menu, and then add a PictureBox control to the form as the display and operation area of the three-dimensional model.

As a virtual design or simulation program for engineering applications, the three-dimensional model can be designed by the general three-dimensional modeling software, such as SolidWorks, and then output as a neutral file through the graphics interface provided by the software. At present, the mainstream three-dimensional modeling software supports a variety of standard file formats, in which STL file is a more readable file format, suitable for use in engineering simulation programs. STL file format, as the interface standard in rapid prototyping field, has been widely used in all kinds of three-dimensional software, many mainstream commercial three-dimensional software supports STL file input and output. The STL model is a geometric model that represents the shape of the outer contour of the object by a triangular set, in which each triangular surface is represented by four data items, that is, the three vertex coordinates of the triangle and the outer normal vector of the triangular surface slice, and the STL file is the collection of multiple triangular patches.

Therefore, in the VB environment can be read into the STL file and in the drawing space to reproduce the method to display the three-dimensional model. First, the read STL file is decomposed by row, from which each surface element is parsed and stored in the structure array, then the work is rendered and shaded by the Glcolor3d function in Vbopengl. The rendered results are filled graphically into the plot area of the PictureBox control, and the entire model is finally displayed. It should be explained that the initial environment in VBOPENGL must be defined before the three-dimensional model is displayed.

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.