本文整理汇总了C#中Scene.Save方法的典型用法代码示例。如果您正苦于以下问题:C# Scene.Save方法的具体用法?C# Scene.Save怎么用?C# Scene.Save使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Scene
的用法示例。
在下文中一共展示了Scene.Save方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Run
public static void Run()
{
// ExStart:Save3DScene
// The path to the documents directory.
string MyDir = RunExamples.GetDataDir();
// Load a 3D document into Aspose.3D
Scene scene = new Scene();
// Open an existing 3D scene
scene.Open(MyDir + "document.fbx");
// Save Scene to a stream
MemoryStream dstStream = new MemoryStream();
scene.Save(dstStream, FileFormat.FBX7500ASCII);
// Rewind the stream position back to zero so it is ready for next reader.
dstStream.Position = 0;
// Save Scene to a local path
scene.Save(MyDir + "output_out.fbx", FileFormat.FBX7500ASCII);
// ExEnd:Save3DScene
Console.WriteLine("\nConverted 3D document to stream successfully.");
}
示例2: WriteScene
public void WriteScene(string outputFile, string contentDir, string rootName)
{
Scene scene = new Scene(rootName);
Node entRoot = scene.CreateChild("Entities");
// Write 'void' entity nodes
foreach (Map.Entity entity in map.Entities)
{
if (entity.Brushes.Count == 0)
{
Node brushNode = entRoot.CreateChild();
brushNode.WriteVariables(entity.Properties);
}
}
// Write world geometry elements
Node geoNode = scene.CreateChild("Geometry");
foreach (Map.Entity entity in map.Entities)
{
Node entNode = geoNode.CreateChild();
entNode.WriteVariables(entity.Properties);
// Geometry entity
if (entity.Brushes.Count != 0)
{
Node brush = geoNode.CreateChild();
}
}
scene.Save(outputFile);
}
示例3: Run
public static void Run()
{
// ExStart:CreateCubeScene
// Initialize scene object
Scene scene = new Scene();
// Initialize Node class object
Node cubeNode = new Node("cube");
// Call Common class create mesh using polygon builder method to set mesh instance
Mesh mesh = Common.CreateMeshUsingPolygonBuilder();
// Point node to the Mesh geometry
cubeNode.Entity = mesh;
// Add Node to a scene
scene.RootNode.ChildNodes.Add(cubeNode);
// The path to the documents directory.
string MyDir = RunExamples.GetDataDir();
MyDir = MyDir + RunExamples.GetOutputFilePath("CubeScene.fbx");
// Save 3D scene in the supported file formats
scene.Save(MyDir, FileFormat.FBX7400ASCII);
// ExEnd:CreateCubeScene
Console.WriteLine("\nCube Scene created successfully.\nFile saved at " + MyDir);
}
示例4: Run
public static void Run()
{
// ExStart:TriangulateMesh
// The path to the documents directory.
string MyDir = RunExamples.GetDataDir();
// Initialize scene object
Scene scene = new Scene();
scene.Open(MyDir + "document.fbx");
scene.RootNode.Accept(delegate(Node node)
{
Mesh mesh = node.GetEntity<Mesh>();
if (mesh != null)
{
// Triangulate the mesh
Mesh newMesh = PolygonModifier.Triangulate(mesh);
// Replace the old mesh
node.Entity = mesh;
}
return true;
});
MyDir = MyDir + RunExamples.GetOutputFilePath("document.fbx");
scene.Save(MyDir, FileFormat.FBX7400ASCII);
// ExEnd:TriangulateMesh
Console.WriteLine("\nMesh has been Triangulated.\nFile saved at " + MyDir);
}
示例5: Run
public static void Run()
{
// Initialize scene object
Scene scene = new Scene();
// Initialize Node class object
Node cubeNode = new Node("box");
// ExStart:ConvertBoxMeshtoTriangleMeshCustomMemoryLayout
// Get mesh of the Box
Mesh box = (new Box()).ToMesh();
// Create a customized vertex layout
VertexDeclaration vd = new VertexDeclaration();
VertexField position = vd.AddField(VertexFieldDataType.FVector4, VertexFieldSemantic.Position);
vd.AddField(VertexFieldDataType.FVector3, VertexFieldSemantic.Normal);
// Get a triangle mesh
TriMesh triMesh = TriMesh.FromMesh(box);
// ExEnd:ConvertBoxMeshtoTriangleMeshCustomMemoryLayout
// Point node to the Mesh geometry
cubeNode.Entity = box;
// Add Node to a scene
scene.RootNode.ChildNodes.Add(cubeNode);
// The path to the documents directory.
string MyDir = RunExamples.GetDataDir() + RunExamples.GetOutputFilePath("BoxToTriangleMeshCustomMemoryLayoutScene.fbx");
// Save 3D scene in the supported file formats
scene.Save(MyDir, FileFormat.FBX7400ASCII);
Console.WriteLine("\n Converted a Box mesh to triangle mesh with custom memory layout of the vertex successfully.\nFile saved at " + MyDir);
}
开发者ID:aspose-3d,项目名称:Aspose.3D-for-.NET,代码行数:33,代码来源:ConvertBoxMeshtoTriangleMeshCustomMemoryLayout.cs
示例6: Run
public static void Run()
{
// ExStart:AddTransformationToNodeByEulerAngles
// Initialize scene object
Scene scene = new Scene();
// Initialize Node class object
Node cubeNode = new Node("cube");
// Call Common class create mesh using polygon builder method to set mesh instance
Mesh mesh = Common.CreateMeshUsingPolygonBuilder();
// Point node to the Mesh geometry
cubeNode.Entity = mesh;
// Euler angles
cubeNode.Transform.EulerAngles = new Vector3(0.3, 0.1, -0.5);
// Set translation
cubeNode.Transform.Translation = new Vector3(0, 0, 20);
// Add cube to the scene
scene.RootNode.ChildNodes.Add(cubeNode);
// The path to the documents directory.
string MyDir = RunExamples.GetDataDir();
MyDir = MyDir + RunExamples.GetOutputFilePath("TransformationToNode.fbx");
// Save 3D scene in the supported file formats
scene.Save(MyDir, FileFormat.FBX7500ASCII);
// ExEnd:AddTransformationToNodeByEulerAngles
Console.WriteLine("\nTransformation added successfully to node.\nFile saved at " + MyDir);
}
示例7: Run
public static void Run()
{
// ExStart:AddAssetInformationToScene
// Initialize a 3D scene
Scene scene = new Scene();
// Set application/tool name
scene.AssetInfo.ApplicationName = "Egypt";
// Set application/tool vendor name
scene.AssetInfo.ApplicationVendor = "Manualdesk";
// We use ancient egyption measurement unit Pole
scene.AssetInfo.UnitName = "pole";
// One Pole equals to 60cm
scene.AssetInfo.UnitScaleFactor = 0.6;
// The path to the documents directory.
string MyDir = RunExamples.GetDataDir();
MyDir = MyDir + RunExamples.GetOutputFilePath("InformationToScene.fbx");
// Save scene to 3D supported file formats
scene.Save(MyDir, FileFormat.FBX7500ASCII);
// ExEnd:AddAssetInformationToScene
Console.WriteLine("\nAsset information added successfully to Scene.\nFile saved at " + MyDir);
}
示例8: Run
public static void Run()
{
// Initialize scene object
Scene scene = new Scene();
// Initialize Node class object
Node cubeNode = new Node("box");
// ExStart:ConvertBoxPrimitivetoMesh
// Initialize object by Box class
IMeshConvertible convertible = new Box();
// Convert a Box to Mesh
Mesh mesh = convertible.ToMesh();
// ExEnd:ConvertBoxPrimitivetoMesh
// Point node to the Mesh geometry
cubeNode.Entity = mesh;
// Add Node to a scene
scene.RootNode.ChildNodes.Add(cubeNode);
// The path to the documents directory.
string MyDir = RunExamples.GetDataDir() + RunExamples.GetOutputFilePath("BoxToMeshScene.fbx");
// Save 3D scene in the supported file formats
scene.Save(MyDir, FileFormat.FBX7400ASCII);
Console.WriteLine("\n Converted the primitive Box to a mesh successfully.\nFile saved at " + MyDir);
}
示例9: Run
public static void Run()
{
// Initialize scene object
Scene scene = new Scene();
// Initialize Node class object
Node cubeNode = new Node("cube");
// Call Common class create mesh method to set mesh instance
Mesh mesh = Common.CreateMesh();
// Point node to the Mesh geometry
cubeNode.Entity = mesh;
// Set rotation
cubeNode.Transform.Rotation = Quaternion.FromRotation(new Vector3(0, 1, 0), new Vector3(0.3, 0.5, 0.1));
// Set translation
cubeNode.Transform.Translation = new Vector3(0, 0, 20);
// Add cube to the scene
scene.RootNode.ChildNodes.Add(cubeNode);
// The path to the documents directory.
string MyDir = RunExamples.GetDataDir_GeometryAndHierarchy();
MyDir = MyDir + "TransformationToNode.fbx";
// Save 3D scene in the supported file formats
scene.Save(MyDir, FileFormat.FBX7400ASCII);
Console.WriteLine("\nTransformation added successfully to node.\nFile saved at " + MyDir);
}
示例10: Run
public static void Run()
{
// ExStart:AddMaterialToCube
// Initialize scene object
Scene scene = new Scene();
// Initialize cube node object
Node cubeNode = new Node("cube");
// Call Common class create mesh using polygon builder method to set mesh instance
Mesh mesh = Common.CreateMeshUsingPolygonBuilder();
// Point node to the mesh
cubeNode.Entity = mesh;
// Add cube to the scene
scene.RootNode.ChildNodes.Add(cubeNode);
// Initiallize PhongMaterial object
PhongMaterial mat = new PhongMaterial();
// Initiallize Texture object
Texture diffuse = new Texture();
// The path to the documents directory.
string MyDir = RunExamples.GetDataDir();
// Set local file path
diffuse.FileName = MyDir + "surface.dds";
// Set Texture of the material
mat.SetTexture("DiffuseColor", diffuse);
// Embed raw content data to FBX (only for FBX and optional)
// Set file name
diffuse.FileName = "embedded-texture.png";
// Set binary content
diffuse.Content = File.ReadAllBytes(MyDir + "aspose-logo.jpg");
// Set color
mat.SpecularColor = new Vector3(Color.Red);
// Set brightness
mat.Shininess = 100;
// Set material property of the cube object
cubeNode.Material = mat;
MyDir = MyDir + RunExamples.GetOutputFilePath("MaterialToCube.fbx");
// Save 3D scene in the supported file formats
scene.Save(MyDir, FileFormat.FBX7400ASCII);
// ExEnd:AddMaterialToCube
Console.WriteLine("\nMaterial added successfully to cube.\nFile saved at " + MyDir);
}
示例11: Run
public static void Run()
{
// ExStart:FlipCoordinateSystem
// The path to the documents directory.
string MyDir = RunExamples.GetDataDir();
// Initialize scene object
Scene scene = new Scene();
scene.Open(MyDir + "camera.3ds", FileFormat.Discreet3DS);
MyDir = MyDir + "FlipCoordinateSystem.obj";
scene.Save(MyDir, FileFormat.WavefrontOBJ);
// ExEnd:FlipCoordinateSystem
Console.WriteLine("\nCoordinate system has been flipped successfully.\nFile saved at " + MyDir);
}
示例12: Run
public static void Run()
{
// ExStart:ConvertPolygonsToTriangles
// The path to the documents directory.
string MyDir = RunExamples.GetDataDir();
// Load an existing 3D file
Scene scene = new Scene(MyDir + "document.fbx");
// Triangulate a scene
PolygonModifier.Triangulate(scene);
// Save 3D scene
scene.Save(MyDir + "triangulated_out.fbx", FileFormat.FBX7400ASCII);
// ExEnd:ConvertPolygonsToTriangles
}
示例13: Run
public static void Run()
{
// ExStart:BuildTangentAndBinormalData
// The path to the documents directory.
string MyDir = RunExamples.GetDataDir();
// Load an existing 3D file
Scene scene = new Scene( MyDir + "document.fbx");
// Triangulate a scene
PolygonModifier.BuildTangentBinormal(scene);
// Save 3D scene
scene.Save("BuildTangentAndBinormalData_out.fbx", FileFormat.FBX7400ASCII);
// ExEnd:BuildTangentAndBinormalData
}
示例14: Run
public static void Run()
{
// ExStart:CreateEmpty3DDocument
// The path to the documents directory.
string MyDir = RunExamples.GetDataDir();
MyDir = MyDir + "document.fbx";
// Create an object of the Scene class
Scene scene = new Scene();
// Save 3D scene document
scene.Save(MyDir, FileFormat.FBX7500ASCII);
// ExEnd:CreateEmpty3DDocument
Console.WriteLine("\nAn empty 3D document created successfully.\nFile saved at " + MyDir);
}
示例15: Run
public static void Run()
{
// Initialize scene object
Scene scene = new Scene();
// Initialize cube node object
Node cubeNode = new Node("cube");
// Call Common class create mesh method to set mesh instance
Mesh mesh = Common.CreateMesh();
// Point node to the mesh
cubeNode.Entity = mesh;
// Add cube to the scene
scene.RootNode.ChildNodes.Add(cubeNode);
// Initiallize PhongMaterial object
PhongMaterial mat = new PhongMaterial();
// Initiallize Texture object
Texture diffuse = new Texture();
// The path to the documents directory.
string MyDir = RunExamples.GetDataDir_GeometryAndHierarchy();
// Set local file path
diffuse.FileName = MyDir + "surface.dds";
// Set Texture of the material
mat.SetTexture("DiffuseColor", diffuse);
// Set color
mat.SpecularColor = new Vector3(Color.Red);
// Set brightness
mat.Shininess = 100;
// Set material property of the cube object
cubeNode.Material = mat;
MyDir = MyDir + "MaterialToCube.fbx";
// Save 3D scene in the supported file formats
scene.Save(MyDir, FileFormat.FBX7400ASCII);
Console.WriteLine("\nMaterial added successfully to cube.\nFile saved at " + MyDir);
}