C++ComponentsGame DevelopmentLanguage FeatureLearn C++

Quickly Learn About Working With 3D Windows Components In C++ Development

3-D in digital platforms are 2D projection drawings of 3D objects. We can mathematically calculate a solid object, its position, its projection on our 2D screen, we can add colors on it, light effects, textures, camera, movements and some other techniques to show our 3D object as good as possible. This may take a lot of time to develop all 2D and 3D mathematical operations. In C++ Builder we can use OpenGL, DirectX with their own methods. If we are developing a simple 3D application, we can also use its own 3D components. In this post we will list these 3D components.

Viewport3D

Viewport3D (TViewport3D) is a 3Dcomponent to display 3D objects in its space. TViewport3D implements IViewport3D methods to describe how a 3D object is seen. It is really simple and nice to develop some small 3D games or adding some 3D features in your applications. Viewport3D is a component that shows the view port of the camera or default view. You can arrange it’s position, Width and Height on any place of your form or you can use it in client view to do full screen. We can use viewport3D without a 3D Camera, it is using its own design camera view. If you want to use camera and want to see view from the view of that camera you must set its UseDesignCamera property to false from its properties or as below;

You can update any objects in Viewport3D with BeginUpdate(), EndUpdate() methods as given below;

This will update full 3D matrix of Viewport3D in one time. You can also change background color of this Viewport3D component like this;

Camera

Camera (TCamera) is a 3D component that used to define the scene perspective and projection of the objects in the scene to the viewport. Use Target to set the object to be watched. You can set its position and view. Camera component can be found in 3D Scenes section of Tools Palette in C++ Builder.

You can set camera X Y Z positions or Rotations, you can also increase them with a Timer to move your camera around your scene as below

Light

Light (TLight) is a 3D component that describes objects that are light sources. Use TLight to imitate the rays of light and their propagation on other 3D objects. Use Color to set the color of the rays of light. Use LightType to set how rays are propagated. SpotExponent specifies the intensity distribution of the light. Here is a example below;

Dummy Object

Dummy (TDummy) is generally used to define position and rotation of group of 3D objects, it is a class for 3D dummy objects. Dummy can be used as a container for 3D objects. Use a TDummy control to group other 3D controls so that they can be moved and rotated together. Dummy objects are good to do mechanical parts with different rotation point in 3D and object groups.

Proxy Object

Proxy Object (TProxyObject) is a class for proxy objects. SourceObject is the object that this TProxyObject represents. It is used for mechanical parts.

TColorMaterialSource

TColorMaterialSource defines a source of TColorMaterial, it is used to link a TColorMaterial to 3D objects. The link is made through the MaterialSource property of the 3D object. To change the color of the material, set the Color property.

TTextureMaterialSource

TTextureMaterialSource to link a TTextureMaterial to 3D objects. The link is made through the MaterialSource property of the 3D object.

By default, TTextureMaterialSource has no texture specified. The object that links to an empty TTextureMaterialSource cannot be seen on the form. The material’s texture is specified as a TBitmap. Specify the texture by setting the Texture property of the TTextureMaterialSource.

TLightMaterialSource

Use TLightMaterialSource to link a TLightMaterial to 3D objects. The link is made through MaterialSource property of the 3D object. By default, the color properties (AmbientEmissiveDiffuseSpecular) are set to simulate the shadows added to the object by the source of light. The material’s texture is specified as a TBitmap. Specify the texture by setting the Texture property of the TLightMaterialSource.

Oh hi there 👋
It’s nice to meet you.

Sign up to receive awesome C++ content in your inbox, every day.

We don’t spam! Read our privacy policy for more info.

About author

Dr. Yilmaz Yoru has 35+ years of coding with more than 30+ programming languages, mostly C++ on Windows, Android, Mac-OS, iOS, Linux, and some other operating systems. He graduated and received his MSc and PhD degrees from the Department of Mechanical Engineering of Eskisehir Osmangazi University. He is the founder and CEO of ESENJA LLC Company. His interests are Programming, Thermodynamics, Fluid Mechanics, Artificial Intelligence, 2D & 3D Designs, and high-end innovations.
Related posts
C++C++11C++14C++17C++20Introduction to C++Learn C++

Learn Copy Constructors in C++ Classes

C++C++11C++14C++17Introduction to C++Learn C++Syntax

Learn How To Use Types Of Destructors In C++?

C++C++11C++14Learn C++Syntax

How To Convert u32string To A wstring In C++

C++C++11C++14C++17C++20Introduction to C++Learn C++

How To Learn The Move Constructors In Modern C++?