本文整理汇总了C#中Material.SetTechnique方法的典型用法代码示例。如果您正苦于以下问题:C# Material.SetTechnique方法的具体用法?C# Material.SetTechnique怎么用?C# Material.SetTechnique使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Material
的用法示例。
在下文中一共展示了Material.SetTechnique方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateScene
//.........这里部分代码省略.........
Rotator rotator = new Rotator();
boxNode.AddComponent(rotator);
rotator.SetRotationSpeed(new Vector3(10.0f, 20.0f, 30.0f));
}
// Create a camera for the render-to-texture scene. Simply leave it at the world origin and let it observe the scene
rttCameraNode = rttScene.CreateChild("Camera");
Camera camera = rttCameraNode.CreateComponent<Camera>();
camera.FarClip = 100.0f;
// Create a point light to the camera scene node
Light light = rttCameraNode.CreateComponent<Light>();
light.LightType = LightType.Point;
light.Range = 30.0f;
}
{
// Create the scene in which we move around
scene = new Scene();
// Create octree, use also default volume (-1000, -1000, -1000) to (1000, 1000, 1000)
scene.CreateComponent<Octree>();
// Create a Zone component for ambient lighting & fog control
Node zoneNode = scene.CreateChild("Zone");
Zone zone = zoneNode.CreateComponent<Zone>();
zone.SetBoundingBox(new BoundingBox(-1000.0f, 1000.0f));
zone.AmbientColor = new Color(0.1f, 0.1f, 0.1f);
zone.FogStart = 100.0f;
zone.FogEnd = 300.0f;
// Create a directional light without shadows
Node lightNode = scene.CreateChild("DirectionalLight");
lightNode.SetDirection(new Vector3(0.5f, -1.0f, 0.5f));
Light light = lightNode.CreateComponent<Light>();
light.LightType = LightType.Directional;
light.Color = new Color(0.2f, 0.2f, 0.2f);
light.SpecularIntensity = 1.0f;
// Create a "floor" consisting of several tiles
for (int y = -5; y <= 5; ++y)
{
for (int x = -5; x <= 5; ++x)
{
Node floorNode = scene.CreateChild("FloorTile");
floorNode.Position = new Vector3(x*20.5f, -0.5f, y*20.5f);
floorNode.Scale = new Vector3(20.0f, 1.0f, 20.0f);
StaticModel floorObject = floorNode.CreateComponent<StaticModel>();
floorObject.Model = cache.GetModel("Models/Box.mdl");
floorObject.SetMaterial(cache.GetMaterial("Materials/Stone.xml"));
}
}
// Create a "screen" like object for viewing the second scene. Construct it from two StaticModels, a box for the frame
// and a plane for the actual view
{
Node boxNode = scene.CreateChild("ScreenBox");
boxNode.Position = new Vector3(0.0f, 10.0f, 0.0f);
boxNode.Scale = new Vector3(21.0f, 16.0f, 0.5f);
StaticModel boxObject = boxNode.CreateComponent<StaticModel>();
boxObject.Model = cache.GetModel("Models/Box.mdl");
boxObject.SetMaterial(cache.GetMaterial("Materials/Stone.xml"));
Node screenNode = scene.CreateChild("Screen");
screenNode.Position = new Vector3(0.0f, 10.0f, -0.27f);
screenNode.Rotation = new Quaternion(-90.0f, 0.0f, 0.0f);
screenNode.Scale = new Vector3(20.0f, 0.0f, 15.0f);
StaticModel screenObject = screenNode.CreateComponent<StaticModel>();
screenObject.Model = cache.GetModel("Models/Plane.mdl");
// Create a renderable texture (1024x768, RGB format), enable bilinear filtering on it
Texture2D renderTexture = new Texture2D();
renderTexture.SetSize(1024, 768, Graphics.RGBFormat, TextureUsage.Rendertarget);
renderTexture.FilterMode = TextureFilterMode.Bilinear;
// Create a new material from scratch, use the diffuse unlit technique, assign the render texture
// as its diffuse texture, then assign the material to the screen plane object
Material renderMaterial = new Material();
renderMaterial.SetTechnique(0, cache.GetTechnique("Techniques/DiffUnlit.xml"), 0, 0);
renderMaterial.SetTexture(TextureUnit.Diffuse, renderTexture);
screenObject.SetMaterial(renderMaterial);
// Get the texture's RenderSurface object (exists when the texture has been created in rendertarget mode)
// and define the viewport for rendering the second scene, similarly as how backbuffer viewports are defined
// to the Renderer subsystem. By default the texture viewport will be updated when the texture is visible
// in the main view
RenderSurface surface = renderTexture.RenderSurface;
Viewport rttViewport = new Viewport(Context, rttScene, rttCameraNode.GetComponent<Camera>(), null);
surface.SetViewport(0, rttViewport);
}
// Create the camera. Limit far clip distance to match the fog
CameraNode = scene.CreateChild("Camera");
var camera = CameraNode.CreateComponent<Camera>();
camera.FarClip = 300.0f;
// Set an initial position for the camera scene node above the plane
CameraNode.Position = new Vector3(0.0f, 7.0f, -30.0f);
}
}