本文整理汇总了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);
}
}
示例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);
}
}