当前位置: 首页>>代码示例>>C#>>正文


C# Scene.Render方法代码示例

本文整理汇总了C#中Scene.Render方法的典型用法代码示例。如果您正苦于以下问题:C# Scene.Render方法的具体用法?C# Scene.Render怎么用?C# Scene.Render使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Scene的用法示例。


在下文中一共展示了Scene.Render方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Run

        public static void Run()
        {
            try
            {
                // ExStart:Render3DModelImageFromCamera
                // The path to the documents directory.
                string MyDir = RunExamples.GetDataDir();

                // Load scene from file
                Scene scene = new Scene(MyDir + "camera.3ds");
                // Create a camera at (10,10,10) and look at the origin point for rendering,
                // It must be attached to the scene before render
                Camera camera = new Camera();
                scene.RootNode.CreateChildNode("camera", camera);
                camera.ParentNode.Transform.Translation = new Vector3(10, 10, 10);
                camera.LookAt = Vector3.Origin;

                // Specify the image render option
                ImageRenderOptions opt = new ImageRenderOptions();
                // Set the background color
                opt.BackgroundColor = Color.AliceBlue;
                // Tells renderer where the it can find textures
                opt.AssetDirectories.Add(MyDir + "textures");
                // Turn on shadow
                opt.EnableShadows = true;
                // Render the scene in given camera's perspective into specified png file with size 1024x1024
                scene.Render(camera, MyDir + "Render3DModelImageFromCamera_out.png", new Size(1024, 1024), ImageFormat.Png, opt);
                // ExEnd:Render3DModelImageFromCamera  
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }

            
        }
开发者ID:aspose-3d,项目名称:Aspose.3D-for-.NET,代码行数:36,代码来源:Render3DModelImageFromCamera.cs

示例2: Run

        public static void Run()
        {
            try
            {
                // ExStart:CastAndReceiveShadow
                // The path to the documents directory.
                string MyDir = RunExamples.GetDataDir();

                Scene scene = new Scene();
                Camera camera = new Camera();
                camera.NearPlane = 0.1;
                scene.RootNode.CreateChildNode("camera", camera);
                Light light;
                scene.RootNode.CreateChildNode("light", light = new Light()
                {
                    NearPlane = 0.1,
                    CastShadows = true,
                    Color = new Vector3(Color.White)
                }).Transform.Translation = new Vector3(9.4785, 5, 3.18);
                light.LookAt = Vector3.Origin;
                light.Falloff = 90;

                // Create a plane
                Node plane = scene.RootNode.CreateChildNode("plane", new Plane(20, 20));
                plane.Material = new PhongMaterial() { DiffuseColor = new Vector3(Color.DarkOrange) };
                plane.Transform.Translation = new Vector3(0, 0, 0);

                // Create a torus for casting shadows
                Mesh m = (new Torus("", 1, 0.4, 20, 20, Math.PI * 2)).ToMesh();
                Node torus = scene.RootNode.CreateChildNode("torus", m);
                torus.Material = new PhongMaterial() { DiffuseColor = new Vector3(Color.Cornsilk) };
                torus.Transform.Translation = new Vector3(2, 1, 1);

                { 
                    // Create a blue box don't cast shadows
                    m = (new Box()).ToMesh();
                    m.CastShadows = false;
                    Node box = scene.RootNode.CreateChildNode("box", m);
                    box.Material = new PhongMaterial() { DiffuseColor = new Vector3(Color.Blue) };
                    box.Transform.Translation = new Vector3(2, 1, -1);
                }
                {
                    // Create a red box that don't receive shadow but cast shadows
                    m = (new Box()).ToMesh();
                    m.ReceiveShadows = false;
                    Node box = scene.RootNode.CreateChildNode("box", m);
                    box.Material = new PhongMaterial() { DiffuseColor = new Vector3(Color.Red) };
                    box.Transform.Translation = new Vector3(-2, 1, 1);
                }
                camera.ParentNode.Transform.Translation = new Vector3(10, 10, 10);
                camera.LookAt = Vector3.Origin;
                ImageRenderOptions opt = new ImageRenderOptions() { EnableShadows = true };
                scene.Render(camera, MyDir + "CastAndReceiveShadow_out.png", new Size(1024, 1024), ImageFormat.Png, opt);
                // ExEnd:CastAndReceiveShadow  
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }


        }
开发者ID:aspose-3d,项目名称:Aspose.3D-for-.NET,代码行数:62,代码来源:CastAndReceiveShadow.cs


注:本文中的Scene.Render方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。