C++Game DevelopmentLanguage FeatureLearn C++

Learn To Display 360 Degree Spherical Images In C++ Builder On Windows

360 Degree Spherical photos are good to capture all around in that moment. In this post here we give a simple example to display this pictures in eyeview with ability to rotate in any angle. This method can be used on drawings or generated drawings too. In this method we use a 3D environment, we put the camera to the center of this environment and we put a 3D Sphere with a texture which has this 360 spherical photo image.

These photos are taken by rotating camera sensors, or by two sided camera sensors, or by spherical sensors. This is good to display something wrapping around us. This method can be used on some simple 3D games, space simulations, inner views of cars, 360 degree photos, some applications might have this space as a menu or presenting a 3D shape in an environment. In addition to 360 degree spherical photos, as in this method; panoramic photos can be displayed as in here by using elliptic spheres , or cylinders in our 3D environment.

This spherical images are like wrapped images on a sphere, and it can be raw image, it’s image format should be bmp, jpg or png format first to display.

Photo by <strong><a href=httpswwwpexelscom rahulshah utm content=attributionCopyTextutm medium=referralutm source=pexels>Rahul Shah<a><strong> from <strong><a href=httpswwwpexelscomphotoround multicolored abstract painting 2268487utm content=attributionCopyTextutm medium=referralutm source=pexels>Pexels<a><strong>

As shown above, we can display 360 photos like this photo in our applications. Directly by using Image (TImage) component in your C++ Builder applications as here.

On the other side, if you want to see this image from the eye view, like you are sitting and looking around in the center of this environment; you should mathematically calculate the view portion in this image in that 3D XYZ degrees and you should copy this by calculations to a new 2D projection image for the eye . This might be little bit hard, but we can do this easily by using a 3D environment.

In C++ Builder we can develop this easily.by using ViewPort3D , Sphere, Camera Component, Light, and A LightMaterialSource with Bitmap Texture of our photo. Let’s develop a simple 3D View example.

In C++ Builder or in RAD Studio, first create a new on a Multi-Platform FireMonkey Project. Drag ViewPort3D , Sphere, Dummy Object, Camera Component, Light, and A LightMaterialSource from Palette at the right side to the Form. Arrange Viewport3D in an appropriate position. Drag Light and LightMaterialSource in to Sphere as in this structure;

In LightMaterialSource there is Texture property as shown above. Add you 360 deg photo as a image of this material. You can its arrange properties as given there too. Camera Position should be 0,0,-5 XYZ respectively and Sphere

In LightMaterialSource there is Texture property as shown above. Add you 360 deg photo as a image of this material. You can its arrange properties as given there too. Camera Position should be 0,0,-5 XYZ respectively.

Our Sphere will be used to display this image as a wrap on it. It should be big enough in appropriate with our photo image For example it’s Width, Depth, Height can be 64,64,64. Sphere XYZ position should be 0,0,0. Set SubDivisionAxes 16,32 or more and same on SubDivisionHeight. Normally textures are wrapped on the outer side of sphere, to see it from inside we must check TwoSide=True. Set its LightMaterialSource to LightMaterialSource. An example sphere parameters are given as below.

Now we have two options, we can rotate the camera or we can rotate the sphere. We will rotate camera here by the mouse pointer movement. To do this, go to Event Properties of Form, Double click on OnMouseMove, OnResize and add codes as below to rotate the camera by mouse.

Note that LX, LY are last X,Y mouse pointer positions, and here defined globally. You can define this in TForm class too.

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.

Reduce development time and get to market faster with RAD Studio, Delphi, or C++Builder.
Design. Code. Compile. Deploy.
Start Free Trial

Free C++Builder Community Edition

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
Artificial Intelligence TechC++C++11C++14C++17Language FeatureLearn C++

Learn How To Read The WAV Waveform Audio File Format In C++

C++C++11Learn C++

What Is Assignment Operator Overloading?

C++C++11Introduction to C++Learn C++Syntax

Full List Of Features In C++ 11

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

How To Use Basic Methods Of Strings In C++?