Cylinders are commonly used in three-dimensional scenes. In different graphics processing applications, you may need to create different types of cylinders. Here we will discuss how to make various kinds of three-dimensional cylinders with different transforms and variations. It explains how to create a 3D cylinder with a shear bottom, shear top, and fan cylinder with different theta lengths programmatically in C#.
- Create 3D Cylinders Programmatically – C# API Installation
- Make a Cylinder in C#
- Create a Fan Cylinder in C#
Create 3D Cylinders Programmatically – C# API Installation
Aspose.3D for .NET API can be used to create or manipulate 3D scenes and objects. Moreover, you do not need to install any other 3D processing applications or tools to work with the API. Just configure the API quickly from the New Releases page or run the NuGet installation command below:
PM> Install-Package Aspose.3D
Make a Cylinder in C#
You can make a cylinder in a three-dimensional scene by following the steps below:
- Initialize an object of the Scene class.
- Set the vertices to transform the offset of the bottom side.
- Add the cylinder to the scene.
- Create another cylinder and customize the shear bottom.
- Add the cylinder and Save the output scene.
The code snippet below demonstrates how to follow these steps and make a cylinder programmatically in C#:
// Create a scene | |
Scene scene = new Scene(); | |
// Create cylinder 1 | |
var cylinder1 = new Aspose.ThreeD.Entities.Cylinder(2, 2, 10, 20, 1, false); | |
// Set OffsetBottom | |
cylinder1.OffsetBottom = new Aspose.ThreeD.Utilities.Vector3(5, 3, 0); | |
// Add cylinder to without a ShearBottom to the scene | |
scene.RootNode.CreateChildNode(cylinder1); | |
// Create cylinder 2 | |
var cylinder2 = new Aspose.ThreeD.Entities.Cylinder(2, 2, 10, 20, 1, false); | |
// Customized shear bottom for cylinder 2 | |
cylinder2.ShearBottom = new Aspose.ThreeD.Utilities.Vector2(0, 0.83); | |
// Add cylinder 2 to the scene | |
scene.RootNode.CreateChildNode(cylinder2).Transform.Translation = new Aspose.ThreeD.Utilities.Vector3(10, 0, 0); | |
// Save scene | |
scene.Save("CustomizedCylinder.obj", FileFormat.WavefrontOBJ); |
Moreover, the following image shows the output image generated using the above code snippet.

Create a Fan Cylinder in C#
The following steps explain how to create a fan cylinder in a 3D scene:
- Create a Scene class object.
- Create a cylinder and set GenerateFanCylinder to true.
- Set the length of theta and create a child node.
- Create a cylinder without a fan and repeat the above steps.
- Save the output scene.
The following code snippet elaborates on how to create a fan cylinder programmatically in C#:
// Create a Scene | |
Scene scene = new Scene(); | |
// Create a cylinder | |
var fan = new Aspose.ThreeD.Entities.Cylinder(2, 2, 10, 20, 1, false); | |
// Set GenerateGanCylinder to true | |
fan.GenerateFanCylinder = true; | |
// Set ThetaLength | |
fan.ThetaLength = Aspose.ThreeD.Utilities.MathUtils.ToRadian(270); | |
// Create ChildNode | |
scene.RootNode.CreateChildNode(fan).Transform.Translation = new Aspose.ThreeD.Utilities.Vector3(10, 0, 0); | |
// Create a cylinder without a fan | |
var nonfan = new Aspose.ThreeD.Entities.Cylinder(2, 2, 10, 20, 1, false); | |
// Set GenerateGanCylinder to false | |
nonfan.GenerateFanCylinder = false; | |
// Set ThetaLengeth | |
nonfan.ThetaLength = Aspose.ThreeD.Utilities.MathUtils.ToRadian(270); | |
// Create ChildNode | |
scene.RootNode.CreateChildNode(nonfan); | |
// Save scene | |
scene.Save("FanCylinder.obj", FileFormat.WavefrontOBJ); |
The following screenshot shows the output scene created using this sample code:

Get Free Temporary License
You may request a free temporary license to test the API to its full capacity.
Conclusion
In this article, you have learned how to create a 3D cylinder programmatically in C#. It covers how to modify the code snippet to create a variety of cylinder shapes. Furthermore, you can explore many other features of the API by taking a look at the documentation section. In case of any ambiguities, please reach out to us at forum.