Arbeta med linjär extrusion
Utför linjär extrusion
Aspose. 3D for .NET erbjuder LinearExtrusion klass, som tar en 2D-form som ingång och utökar formen i den tredje dimensionen. Följande kod snutt visar hur man utför linjär extrusion:
// For complete examples and data files, please go to https://github.com/aspose-3d/Aspose.3D-for-.NET
// Initialize the base profile to be extruded
var profile = new RectangleShape()
{
RoundingRadius = 0.3
};
// Perform Linear extrusion by passing a 2D profile as input and extend the shape in the 3rd dimension
var extrusion = new LinearExtrusion(profile, 10) { Slices = 100, Center = true, Twist = 360, TwistOffset = new Vector3(10, 0, 0) };
// Create a scene
Scene scene = new Scene();
// Create a child node by passing extrusion
scene.RootNode.CreateChildNode(extrusion);
// Save 3D scene
scene.Save("LinearExtrusion.obj");
‘Slips’ i linjär extrusion
Aspose.3D for .NET erbjuder Slices egendom för LinearExtrusion klassen. Skivor egenskapen definierar antalet mellanpunkter längs strängvägen. Följande kod snutt visar hur man använder Slices egenskaper i linjär extrusion:
// For complete examples and data files, please go to https://github.com/aspose-3d/Aspose.3D-for-.NET
// Initialize the base profile to be extruded
var profile = new RectangleShape()
{
RoundingRadius = 0.3
};
// Create a scene
Scene scene = new Scene();
// Create left node
var left = scene.RootNode.CreateChildNode();
// Create right node
var right = scene.RootNode.CreateChildNode();
left.Transform.Translation = new Vector3(15, 0, 0);
// Slices parameter defines the number of intermediate points along the path of the extrusion
// Perform linear extrusion on left node using slices property
left.CreateChildNode(new LinearExtrusion(profile, 2) { Slices = 2 });
// Perform linear extrusion on right node using slices property
right.CreateChildNode(new LinearExtrusion(profile, 2) { Slices = 10 });
// Save 3D scene
scene.Save("SlicesInLinearExtrusion.obj");
‘Center’ i linjär extrusion
Aspose.3D for .NET erbjuder Center egendom för LinearExtrusion klassen. Om egenskapen är inställd till true är extruderingsområdet från -Höjd/2 till höjd/2, annars. extruderingen är från 0 till höjd. Följande kod snutt visar hur man använder Center egenskaper i linjär extrusion:
// For complete examples and data files, please go to https://github.com/aspose-3d/Aspose.3D-for-.NET
// Initialize the base profile to be extruded
var profile = new RectangleShape()
{
RoundingRadius = 0.3
};
// Create a scene
Scene scene = new Scene();
// Create left node
var left = scene.RootNode.CreateChildNode();
// Create right node
var right = scene.RootNode.CreateChildNode();
left.Transform.Translation = new Vector3(15, 0, 0);
// Slices parameter defines the number of intermediate points along the path of the extrusion
// Perform linear extrusion on left node using slices property
left.CreateChildNode(new LinearExtrusion(profile, 2) { Slices = 2 });
// Perform linear extrusion on right node using slices property
right.CreateChildNode(new LinearExtrusion(profile, 2) { Slices = 10 });
// Save 3D scene
scene.Save("SlicesInLinearExtrusion.obj");
‘Twist’ i linjär extrusion
Aspose.3D for .NET erbjuder Twist egendom för LinearExtrusion klassen. Twist egenskapen hanterar graden av rotationen samtidigt som den extruderar formen. Följande kodutslag visar hur man använder Twist-egenskapen i linjär extrusion:
// For complete examples and data files, please go to https://github.com/aspose-3d/Aspose.3D-for-.NET
// Initialize the base profile to be extruded
var profile = new RectangleShape()
{
RoundingRadius = 0.3
};
// Create a scene
Scene scene = new Scene();
// Create left node
var left = scene.RootNode.CreateChildNode();
// Create rifht node
var right = scene.RootNode.CreateChildNode();
left.Transform.Translation = new Vector3(15, 0, 0);
// Twist property defines the degree of the rotation while extruding the profile
// Perform linear extrusion on left node using twist and slices property
left.CreateChildNode(new LinearExtrusion(profile, 10) { Twist = 0, Slices = 100 });
// Perform linear extrusion on right node using twist and slices property
right.CreateChildNode(new LinearExtrusion(profile, 10) { Twist = 90, Slices = 100 });
// Save 3D scene
scene.Save("TwistInLinearExtrusion.obj");
‘TwistOffset’ i linjär extrusion
Aspose.3D for .NET erbjuder TwistOffset egendom för LinearExtrusion klassen. Twist Offset egenskapen översätter offset medan man roterar extruderingen. Följande kodutdrag visar hur egenskapen TwistOffset används i linjär extrusion:
using Aspose.ThreeD;
using Aspose.ThreeD.Entities;
using Aspose.ThreeD.Profiles;
using Aspose.ThreeD.Utilities;
// Initialize a Scene
Aspose.ThreeD.Scene scene = new Scene();
// Create a RectangleShape with width=2 and height=1
var rectangle = new RectangleShape()
{
XDim = 2,
YDim = 1
};
// Extrude the rectangle to create a 3D object (height=3)
var extrusion = new LinearExtrusion(rectangle, height: 3)
{
Slices = 10 // Number of subdivisions along the extrusion path
};
// Add the extruded mesh to the scene
scene.RootNode.CreateChildNode(extrusion);
// Save the scene to a file
scene.Save("output.fbx", FileFormat.FBX7400ASCII);
‘Riktning’ i linjär extrusion
Aspose.3D for .NET erbjuder Direction egendom för LinearExtrusion klassen. Riktningsegenskapen definierar extruderingens riktning. Följande kod snippet visar hur man använder Riktningsegenskaper i linjär extrusion:
// For complete examples and data files, please go to https://github.com/aspose-3d/Aspose.3D-for-.NET
// Initialize the base profile to be extruded
var profile = new RectangleShape()
{
RoundingRadius = 0.3
};
// Create a scene
Scene scene = new Scene();
// Create left node
var left = scene.RootNode.CreateChildNode();
// Create right node
var right = scene.RootNode.CreateChildNode();
left.Transform.Translation = new Vector3(8, 0, 0);
// Direction property defines the direction of the extrusion.
// Perform linear extrusion on left node using twist and slices property
left.CreateChildNode(new LinearExtrusion(profile, 10) { Twist = 360, Slices = 100 });
// Perform linear extrusion on right node using twist, slices, and direction property
right.CreateChildNode(new LinearExtrusion(profile, 10) { Twist = 360, Slices = 100, Direction = new Vector3(0.3, 0.2, 1) });
// Save 3D scene
scene.Save("DirectionInLinearExtrusion.obj");