本文整理汇总了C#中Scene.CreateComponent方法的典型用法代码示例。如果您正苦于以下问题:C# Scene.CreateComponent方法的具体用法?C# Scene.CreateComponent怎么用?C# Scene.CreateComponent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Scene
的用法示例。
在下文中一共展示了Scene.CreateComponent方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateScene
void CreateScene()
{
scene = new Scene();
scene.CreateComponent<Octree>();
// Create camera node
CameraNode = scene.CreateChild("Camera");
// Set camera's position
CameraNode.Position = (new Vector3(0.0f, 0.0f, -10.0f));
Camera camera = CameraNode.CreateComponent<Camera>();
camera.Orthographic = true;
var graphics = Graphics;
camera.OrthoSize=graphics.Height * PixelSize;
camera.Zoom = 1.5f * Math.Min(graphics.Width / 1280.0f, graphics.Height / 800.0f); // Set zoom according to user's resolution to ensure full visibility (initial zoom (1.5) is set for full visibility at 1280x800 resolution)
var cache = ResourceCache;
AnimationSet2D animationSet = cache.GetAnimationSet2D("Urho2D/imp/imp.scml");
if (animationSet == null)
return;
spriteNode = scene.CreateChild("SpriterAnimation");
AnimatedSprite2D animatedSprite = spriteNode.CreateComponent<AnimatedSprite2D>();
animatedSprite.AnimationSet = animationSet;
animatedSprite.SetAnimation(AnimationNames[animationIndex], LoopMode2D.Default);
}
示例2: CreateScene
void CreateScene()
{
scene = new Scene();
scene.CreateComponent<Octree>();
// Create camera node
CameraNode = scene.CreateChild("Camera");
// Set camera's position
CameraNode.Position = (new Vector3(0.0f, 0.0f, -10.0f));
Camera camera = CameraNode.CreateComponent<Camera>();
camera.Orthographic = true;
var graphics = Graphics;
camera.OrthoSize = (float)graphics.Height * PixelSize;
camera.Zoom=1.2f * Math.Min((float)graphics.Width / 1280.0f, (float)graphics.Height / 800.0f); // Set zoom according to user's resolution to ensure full visibility (initial zoom (1.2) is set for full visibility at 1280x800 resolution)
var cache = ResourceCache;
ParticleEffect2D particleEffect = cache.GetParticleEffect2D("Urho2D/sun.pex");
if (particleEffect == null)
return;
particleNode = scene.CreateChild("ParticleEmitter2D");
ParticleEmitter2D particleEmitter = particleNode.CreateComponent<ParticleEmitter2D>();
particleEmitter.Effect=particleEffect;
ParticleEffect2D greenSpiralEffect = cache.GetParticleEffect2D("Urho2D/greenspiral.pex");
if (greenSpiralEffect == null)
return;
Node greenSpiralNode = scene.CreateChild("GreenSpiral");
ParticleEmitter2D greenSpiralEmitter = greenSpiralNode.CreateComponent<ParticleEmitter2D>();
greenSpiralEmitter.Effect=greenSpiralEffect;
}
示例3: CreateScene
void CreateScene()
{
scene = new Scene();
scene.CreateComponent<Octree>();
spriteNodes = new List<NodeInfo>((int) NumSprites);
// Create camera node
CameraNode = scene.CreateChild("Camera");
// Set camera's position
CameraNode.Position = (new Vector3(0.0f, 0.0f, -10.0f));
Camera camera = CameraNode.CreateComponent<Camera>();
camera.Orthographic = true;
var graphics = Graphics;
camera.OrthoSize=(float)graphics.Height * PixelSize;
var cache = ResourceCache;
// Get sprite
Sprite2D sprite = cache.GetSprite2D("Urho2D/Aster.png");
if (sprite == null)
return;
float halfWidth = graphics.Width * 0.5f * PixelSize;
float halfHeight = graphics.Height * 0.5f * PixelSize;
for (uint i = 0; i < NumSprites; ++i)
{
Node spriteNode = scene.CreateChild("StaticSprite2D");
spriteNode.Position = (new Vector3(NextRandom(-halfWidth, halfWidth), NextRandom(-halfHeight, halfHeight), 0.0f));
StaticSprite2D staticSprite = spriteNode.CreateComponent<StaticSprite2D>();
// Set random color
staticSprite.Color = (new Color(NextRandom(1.0f), NextRandom(1.0f), NextRandom(1.0f), 1.0f));
// Set blend mode
staticSprite.BlendMode = BlendMode.Alpha;
// Set sprite
staticSprite.Sprite=sprite;
// Add to sprite node vector
spriteNodes.Add(new NodeInfo(spriteNode, new Vector3(NextRandom(-2.0f, 2.0f), NextRandom(-2.0f, 2.0f), 0.0f), NextRandom(-90.0f, 90.0f)));
}
// Get animation set
AnimationSet2D animationSet = cache.GetAnimationSet2D("Urho2D/GoldIcon.scml");
if (animationSet == null)
return;
var spriteNode2 = scene.CreateChild("AnimatedSprite2D");
spriteNode2.Position = (new Vector3(0.0f, 0.0f, -1.0f));
AnimatedSprite2D animatedSprite = spriteNode2.CreateComponent<AnimatedSprite2D>();
// Set animation
animatedSprite.AnimationSet = animationSet;
animatedSprite.SetAnimation("idle", LoopMode2D.Default);
}
示例4: Start
protected override async void Start()
{
base.Start();
Input.SubscribeToKeyDown(k => { if (k.Key == Key.Esc) Exit(); });
Input.SubscribeToTouchEnd(OnTouched);
// 3D scene with Octree
var scene = new Scene(Context);
octree = scene.CreateComponent<Octree>();
// Camera
var cameraNode = scene.CreateChild(name: "camera");
cameraNode.Position = new Vector3(10, 14, 10);
cameraNode.Rotation = new Quaternion(-0.121f, 0.878f, -0.305f, -0.35f);
camera = cameraNode.CreateComponent<Camera>();
// Light
Node lightNode = cameraNode.CreateChild(name: "light");
var light = lightNode.CreateComponent<Light>();
light.LightType = LightType.Point;
light.Range = 100;
light.Brightness = 1.3f;
// Viewport
var viewport = new Viewport(Context, scene, camera, null);
Renderer.SetViewport(0, viewport);
viewport.SetClearColor(new Color(0.4f, 0.4f, 0.4f));
plotNode = scene.CreateChild();
var baseNode = plotNode.CreateChild().CreateChild();
var plane = baseNode.CreateComponent<StaticModel>();
plane.Model = ResourceCache.GetModel("Models/Plane.mdl");
int size = 5;
baseNode.Scale = new Vector3(size * 1.5f, 1, size * 1.5f);
for (var i = 0f; i < size * 1.5f; i += 1.5f)
{
for (var j = 0f; j < size * 1.5f; j += 1.5f)
{
var boxNode = plotNode.CreateChild();
boxNode.Position = new Vector3(size / 2f - i + 0.5f, 0, size / 2f - j + 0.5f);
var box = new Bar(h => Math.Round(h, 1).ToString(), new Color(Sample.NextRandom(), Sample.NextRandom(), Sample.NextRandom(), 0.9f));
boxNode.AddComponent(box);
box.Value = (Math.Abs(i) + Math.Abs(j) + 1) / 2f;
}
}
await plotNode.RunActionsAsync(new EaseBackOut(new RotateBy(2f, 0, 360, 0)));
movementsEnabled = true;
}
示例5: CreateScene
void CreateScene ()
{
var cache = ResourceCache;
scene = new Scene ();
// Create the Octree component to the scene. This is required before adding any drawable components, or else nothing will
// show up. The default octree volume will be from (-1000, -1000, -1000) to (1000, 1000, 1000) in world coordinates; it
// is also legal to place objects outside the volume but their visibility can then not be checked in a hierarchically
// optimizing manner
scene.CreateComponent<Octree> ();
// Create a child scene node (at world origin) and a StaticModel component into it. Set the StaticModel to show a simple
// plane mesh with a "stone" material. Note that naming the scene nodes is optional. Scale the scene node larger
// (100 x 100 world units)
var planeNode = scene.CreateChild("Plane");
planeNode.Scale = new Vector3 (100, 1, 100);
var planeObject = planeNode.CreateComponent<StaticModel> ();
planeObject.Model = cache.GetModel ("Models/Plane.mdl");
planeObject.SetMaterial (cache.GetMaterial ("Materials/StoneTiled.xml"));
// Create a directional light to the world so that we can see something. The light scene node's orientation controls the
// light direction; we will use the SetDirection() function which calculates the orientation from a forward direction vector.
// The light will use default settings (white light, no shadows)
var lightNode = scene.CreateChild("DirectionalLight");
lightNode.SetDirection (new Vector3(0.6f, -1.0f, 0.8f)); // The direction vector does not need to be normalized
var light = lightNode.CreateComponent<Light>();
light.LightType = LightType.Directional;
var rand = new Random();
for (int i = 0; i < 200; i++)
{
var mushroom = scene.CreateChild ("Mushroom");
mushroom.Position = new Vector3 (rand.Next (90)-45, 0, rand.Next (90)-45);
mushroom.Rotation = new Quaternion (0, rand.Next (360), 0);
mushroom.SetScale (0.5f+rand.Next (20000)/10000.0f);
var mushroomObject = mushroom.CreateComponent<StaticModel>();
mushroomObject.Model = cache.GetModel ("Models/Mushroom.mdl");
mushroomObject.SetMaterial (cache.GetMaterial ("Materials/Mushroom.xml"));
}
CameraNode = scene.CreateChild ("camera");
camera = CameraNode.CreateComponent<Camera>();
CameraNode.Position = new Vector3 (0, 5, 0);
}
示例6: CreateScene
void CreateScene()
{
scene = new Scene();
scene.CreateComponent<Octree>();
// Create camera node
CameraNode = scene.CreateChild("Camera");
// Set camera's position
CameraNode.Position = (new Vector3(0.0f, 0.0f, -10.0f));
Camera camera = CameraNode.CreateComponent<Camera>();
camera.Orthographic = true;
var graphics = Graphics;
camera.OrthoSize=(float)graphics.Height * PixelSize;
camera.Zoom = (1.0f * Math.Min((float)graphics.Width / 1280.0f, (float)graphics.Height / 800.0f)); // Set zoom according to user's resolution to ensure full visibility (initial zoom (1.0) is set for full visibility at 1280x800 resolution)
var cache = ResourceCache;
// Get tmx file
TmxFile2D tmxFile = cache.GetTmxFile2D("Urho2D/isometric_grass_and_water.tmx");
if (tmxFile == null)
return;
Node tileMapNode = scene.CreateChild("TileMap");
tileMapNode.Position = new Vector3(0.0f, 0.0f, -1.0f);
TileMap2D tileMap = tileMapNode.CreateComponent<TileMap2D>();
// Set animation
tileMap.TmxFile = tmxFile;
// Set camera's position
TileMapInfo2D info = tileMap.Info;
float x = info.MapWidth * 0.5f;
float y = info.MapHeight * 0.5f;
CameraNode.Position = new Vector3(x, y, -10.0f);
}
示例7: CreateScene
void CreateScene()
{
var cache = ResourceCache;
scene = new Scene();
// Create octree, use default volume (-1000, -1000, -1000) to (1000, 1000, 1000)
// Also create a DebugRenderer component so that we can draw debug geometry
scene.CreateComponent<Octree>();
scene.CreateComponent<DebugRenderer>();
// Create scene node & StaticModel component for showing a static plane
var planeNode = scene.CreateChild("Plane");
planeNode.Scale =new Vector3(100.0f, 1.0f, 100.0f);
var planeObject = planeNode.CreateComponent<StaticModel>();
planeObject.Model=cache.GetModel("Models/Plane.mdl");
planeObject.SetMaterial(cache.GetMaterial("Materials/StoneTiled.xml"));
// Create a Zone component for ambient lighting & fog control
var zoneNode = scene.CreateChild("Zone");
var zone = zoneNode.CreateComponent<Zone>();
zone.SetBoundingBox(new BoundingBox(-1000.0f, 1000.0f));
zone.AmbientColor=new Color(0.15f, 0.15f, 0.15f);
zone.FogColor=new Color(0.5f, 0.5f, 0.7f);
zone.FogStart=100.0f;
zone.FogEnd=300.0f;
// Create a directional light to the world. Enable cascaded shadows on it
var lightNode = scene.CreateChild("DirectionalLight");
lightNode.SetDirection(new Vector3(0.6f, -1.0f, 0.8f));
var light = lightNode.CreateComponent<Light>();
light.LightType = LightType.Directional;
light.CastShadows=true;
light.ShadowBias=new BiasParameters(0.00025f, 0.5f);
// Set cascade splits at 10, 50 and 200 world units, fade shadows out at 80% of maximum shadow distance
light.ShadowCascade=new CascadeParameters(10.0f, 50.0f, 200.0f, 0.0f, 0.8f);
// Create some mushrooms
const uint numMushrooms = 240;
for (uint i = 0; i < numMushrooms; ++i)
{
var mushroomNode = scene.CreateChild("Mushroom");
mushroomNode.Position = new Vector3(NextRandom(90.0f) - 45.0f, 0.0f, NextRandom(90.0f) - 45.0f);
mushroomNode.Rotation = new Quaternion(0.0f, NextRandom(360.0f), 0.0f);
mushroomNode.SetScale(0.5f + NextRandom(2.0f));
StaticModel mushroomObject = mushroomNode.CreateComponent<StaticModel>();
mushroomObject.Model=cache.GetModel("Models/Mushroom.mdl");
mushroomObject.SetMaterial(cache.GetMaterial("Materials/Mushroom.xml"));
mushroomObject.CastShadows=true;
}
// Create randomly sized boxes. If boxes are big enough, make them occluders
const uint numBoxes = 20;
for (uint i = 0; i < numBoxes; ++i)
{
var boxNode = scene.CreateChild("Box");
float size = 1.0f + NextRandom(10.0f);
boxNode.Position=new Vector3(NextRandom(80.0f) - 40.0f, size * 0.5f, NextRandom(80.0f) - 40.0f);
boxNode.SetScale(size);
StaticModel boxObject = boxNode.CreateComponent<StaticModel>();
boxObject.Model = cache.GetModel("Models/Box.mdl");
boxObject.SetMaterial(cache.GetMaterial("Materials/Stone.xml"));
boxObject.CastShadows=true;
if (size >= 3.0f)
boxObject.Occluder=true;
}
// Create the cameras. Limit far clip distance to match the fog
CameraNode = scene.CreateChild("Camera");
Camera camera = CameraNode.CreateComponent<Camera>();
camera.FarClip = 300.0f;
// Parent the rear camera node to the front camera node and turn it 180 degrees to face backward
// Here, we use the angle-axis constructor for Quaternion instead of the usual Euler angles
rearCameraNode = CameraNode.CreateChild("RearCamera");
rearCameraNode.Rotate(Quaternion.FromAxisAngle(Vector3.UnitY, 180.0f), TransformSpace.Local);
Camera rearCamera = rearCameraNode.CreateComponent<Camera>();
rearCamera.FarClip = 300.0f;
// Because the rear viewport is rather small, disable occlusion culling from it. Use the camera's
// "view override flags" for this. We could also disable eg. shadows or force low material quality
// if we wanted
rearCamera.ViewOverrideFlags = ViewOverrideFlags.DisableOcclusion;
// Set an initial position for the front camera scene node above the plane
CameraNode.Position = new Vector3(0.0f, 5.0f, 0.0f);
}
示例8: CreateScene
void CreateScene()
{
var cache = ResourceCache;
scene = new Scene();
// Create octree, use default volume (-1000, -1000, -1000) to (1000, 1000, 1000)
// Also create a DebugRenderer component so that we can draw debug geometry
scene.CreateComponent<Octree>();
scene.CreateComponent<DebugRenderer>();
// Create scene node & StaticModel component for showing a static plane
var planeNode = scene.CreateChild("Plane");
planeNode.Scale = new Vector3(100.0f, 1.0f, 100.0f);
var planeObject = planeNode.CreateComponent<StaticModel>();
planeObject.Model = cache.GetModel("Models/Plane.mdl");
planeObject.SetMaterial(cache.GetMaterial("Materials/StoneTiled.xml"));
// Create a Zone component for ambient lighting & fog control
var zoneNode = scene.CreateChild("Zone");
var zone = zoneNode.CreateComponent<Zone>();
zone.SetBoundingBox(new BoundingBox(-1000.0f, 1000.0f));
zone.AmbientColor=new Color(0.15f, 0.15f, 0.15f);
zone.FogColor = new Color(0.5f, 0.5f, 0.7f);
zone.FogStart=100.0f;
zone.FogEnd=300.0f;
// Create a directional light to the world. Enable cascaded shadows on it
var lightNode = scene.CreateChild("DirectionalLight");
lightNode.SetDirection(new Vector3(0.6f, -1.0f, 0.8f));
var light = lightNode.CreateComponent<Light>();
light.LightType= LightType.Directional;
light.CastShadows=true;
light.ShadowBias=new BiasParameters(0.00025f, 0.5f);
// Set cascade splits at 10, 50 and 200 world units, fade shadows out at 80% of maximum shadow distance
light.ShadowCascade=new CascadeParameters(10.0f, 50.0f, 200.0f, 0.0f, 0.8f);
// Create some mushrooms
const uint numMushrooms = 240;
for (uint i = 0; i < numMushrooms; ++i)
{
var mushroomNode = scene.CreateChild("Mushroom");
mushroomNode.Position=new Vector3(NextRandom(90.0f) - 45.0f, 0.0f, NextRandom(90.0f) - 45.0f);
mushroomNode.Rotation=new Quaternion(0.0f, NextRandom(360.0f), 0.0f);
mushroomNode.SetScale(0.5f + NextRandom(2.0f));
var mushroomObject = mushroomNode.CreateComponent<StaticModel>();
mushroomObject.Model=cache.GetModel("Models/Mushroom.mdl");
mushroomObject.SetMaterial(cache.GetMaterial("Materials/Mushroom.xml"));
mushroomObject.CastShadows=true;
}
// Create randomly sized boxes. If boxes are big enough, make them occluders. Occluders will be software rasterized before
// rendering to a low-resolution depth-only buffer to test the objects in the view frustum for visibility
const uint numBoxes = 20;
for (uint i = 0; i < numBoxes; ++i)
{
var boxNode = scene.CreateChild("Box");
float size = 1.0f + NextRandom(10.0f);
boxNode.Position=new Vector3(NextRandom(80.0f) - 40.0f, size * 0.5f, NextRandom(80.0f) - 40.0f);
boxNode.SetScale(size);
var boxObject = boxNode.CreateComponent<StaticModel>();
boxObject.Model=cache.GetModel("Models/Box.mdl");
boxObject.SetMaterial(cache.GetMaterial("Materials/Stone.xml"));
boxObject.CastShadows=true;
if (size >= 3.0f)
boxObject.Occluder = true;
}
// Create the camera. Limit far clip distance to match the fog
CameraNode = scene.CreateChild("Camera");
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, 5.0f, 0.0f);
}
示例9: CreateScene
void CreateScene()
{
var cache = ResourceCache;
scene = new Scene();
// Create octree, use default volume (-1000, -1000, -1000) to (1000, 1000, 1000)
// Create a physics simulation world with default parameters, which will update at 60fps. Like the Octree must
// exist before creating drawable components, the PhysicsWorld must exist before creating physics components.
// Finally, create a DebugRenderer component so that we can draw physics debug geometry
scene.CreateComponent<Octree>();
scene.CreateComponent<PhysicsWorld>();
scene.CreateComponent<DebugRenderer>();
// 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.15f, 0.15f, 0.15f);
zone.FogColor=new Color(1.0f, 1.0f, 1.0f);
zone.FogStart=300.0f;
zone.FogEnd=500.0f;
// Create a directional light to the world. Enable cascaded shadows on it
Node lightNode = scene.CreateChild("DirectionalLight");
lightNode.SetDirection(new Vector3(0.6f, -1.0f, 0.8f));
Light light = lightNode.CreateComponent<Light>();
light.LightType=LightType.Directional;
light.CastShadows=true;
light.ShadowBias=new BiasParameters(0.00025f, 0.5f);
// Set cascade splits at 10, 50 and 200 world units, fade shadows out at 80% of maximum shadow distance
light.ShadowCascade=new CascadeParameters(10.0f, 50.0f, 200.0f, 0.0f, 0.8f);
// Create skybox. The Skybox component is used like StaticModel, but it will be always located at the camera, giving the
// illusion of the box planes being far away. Use just the ordinary Box model and a suitable material, whose shader will
// generate the necessary 3D texture coordinates for cube mapping
Node skyNode = scene.CreateChild("Sky");
skyNode.SetScale(500.0f); // The scale actually does not matter
Skybox skybox = skyNode.CreateComponent<Skybox>();
skybox.Model=cache.GetModel("Models/Box.mdl");
skybox.SetMaterial(cache.GetMaterial("Materials/Skybox.xml"));
{
// Create a floor object, 1000 x 1000 world units. Adjust position so that the ground is at zero Y
Node floorNode = scene.CreateChild("Floor");
floorNode.Position=new Vector3(0.0f, -0.5f, 0.0f);
floorNode.Scale=new Vector3(1000.0f, 1.0f, 1000.0f);
StaticModel floorObject = floorNode.CreateComponent<StaticModel>();
floorObject.Model=cache.GetModel("Models/Box.mdl");
floorObject.SetMaterial(cache.GetMaterial("Materials/StoneTiled.xml"));
// Make the floor physical by adding RigidBody and CollisionShape components. The RigidBody's default
// parameters make the object static (zero mass.) Note that a CollisionShape by itself will not participate
// in the physics simulation
floorNode.CreateComponent<RigidBody>();
CollisionShape shape = floorNode.CreateComponent<CollisionShape>();
// Set a box shape of size 1 x 1 x 1 for collision. The shape will be scaled with the scene node scale, so the
// rendering and physics representation sizes should match (the box model is also 1 x 1 x 1.)
shape.SetBox(Vector3.One, Vector3.Zero, Quaternion.Identity);
}
{
// Create a pyramid of movable physics objects
for (int y = 0; y < 8; ++y)
{
for (int x = -y; x <= y; ++x)
{
Node boxNode = scene.CreateChild("Box");
boxNode.Position=new Vector3((float)x, -(float)y + 8.0f, 0.0f);
StaticModel boxObject = boxNode.CreateComponent<StaticModel>();
boxObject.Model=cache.GetModel("Models/Box.mdl");
boxObject.SetMaterial(cache.GetMaterial("Materials/StoneEnvMapSmall.xml"));
boxObject.CastShadows=true;
// Create RigidBody and CollisionShape components like above. Give the RigidBody mass to make it movable
// and also adjust friction. The actual mass is not important; only the mass ratios between colliding
// objects are significant
RigidBody body = boxNode.CreateComponent<RigidBody>();
body.Mass=1.0f;
body.Friction=0.75f;
CollisionShape shape = boxNode.CreateComponent<CollisionShape>();
shape.SetBox(Vector3.One, Vector3.Zero, Quaternion.Identity);
}
}
}
// Create the camera. Limit far clip distance to match the fog. Note: now we actually create the camera node outside
// the scene, because we want it to be unaffected by scene load / save
CameraNode = new Node();
Camera camera = CameraNode.CreateComponent<Camera>();
camera.FarClip = 500.0f;
// Set an initial position for the camera scene node above the floor
CameraNode.Position = (new Vector3(0.0f, 5.0f, -20.0f));
}
示例10: CreateScene
void CreateScene()
{
var cache = ResourceCache;
scene = new Scene();
// Create octree, use default volume (-1000, -1000, -1000) to (1000, 1000, 1000)
// Also create a DebugRenderer component so that we can draw debug geometry
scene.CreateComponent<Octree>();
scene.CreateComponent<DebugRenderer>();
// Create scene node & StaticModel component for showing a static plane
Node planeNode = scene.CreateChild("Plane");
planeNode.Scale = new Vector3(100.0f, 1.0f, 100.0f);
StaticModel planeObject = planeNode.CreateComponent<StaticModel>();
planeObject.Model = (cache.GetModel("Models/Plane.mdl"));
planeObject.SetMaterial(cache.GetMaterial("Materials/StoneTiled.xml"));
// 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.15f, 0.15f, 0.15f);
zone.FogColor = new Color(0.5f, 0.5f, 0.7f);
zone.FogStart = 100.0f;
zone.FogEnd = 300.0f;
// Create a directional light to the world. Enable cascaded shadows on it
Node lightNode = scene.CreateChild("DirectionalLight");
lightNode.SetDirection(new Vector3(0.6f, -1.0f, 0.8f));
Light light = lightNode.CreateComponent<Light>();
light.LightType = LightType.Directional;
light.CastShadows = true;
light.ShadowBias = new BiasParameters(0.00025f, 0.5f);
// Set cascade splits at 10, 50 and 200 world units, fade shadows out at 80% of maximum shadow distance
light.ShadowCascade = new CascadeParameters(10.0f, 50.0f, 200.0f, 0.0f, 0.8f);
// Create randomly sized boxes. If boxes are big enough, make them occluders
const uint numBoxes = 20;
Node boxGroup = scene.CreateChild("Boxes");
for (uint i = 0; i < numBoxes; ++i)
{
Node boxNode = boxGroup.CreateChild("Box");
float size = 1.0f + NextRandom(10.0f);
boxNode.Position = (new Vector3(NextRandom(80.0f) - 40.0f, size * 0.5f, NextRandom(80.0f) - 40.0f));
boxNode.SetScale(size);
StaticModel boxObject = boxNode.CreateComponent<StaticModel>();
boxObject.Model = (cache.GetModel("Models/Box.mdl"));
boxObject.SetMaterial(cache.GetMaterial("Materials/Stone.xml"));
boxObject.CastShadows = true;
if (size >= 3.0f)
boxObject.Occluder = true;
}
// Create a DynamicNavigationMesh component to the scene root
DynamicNavigationMesh navMesh = scene.CreateComponent<DynamicNavigationMesh>();
// Set the agent height large enough to exclude the layers under boxes
navMesh.AgentHeight = 10.0f;
navMesh.CellHeight = 0.05f;
navMesh.DrawObstacles = true;
navMesh.DrawOffMeshConnections = true;
// Create a Navigable component to the scene root. This tags all of the geometry in the scene as being part of the
// navigation mesh. By default this is recursive, but the recursion could be turned off from Navigable
scene.CreateComponent<Navigable>();
// Add padding to the navigation mesh in Y-direction so that we can add objects on top of the tallest boxes
// in the scene and still update the mesh correctly
navMesh.Padding = new Vector3(0.0f, 10.0f, 0.0f);
// Now build the navigation geometry. This will take some time. Note that the navigation mesh will prefer to use
// physics geometry from the scene nodes, as it often is simpler, but if it can not find any (like in this example)
// it will use renderable geometry instead
navMesh.Build();
// Create an off-mesh connection to each box to make them climbable (tiny boxes are skipped). A connection is built from 2 nodes.
// Note that OffMeshConnections must be added before building the navMesh, but as we are adding Obstacles next, tiles will be automatically rebuilt.
// Creating connections post-build here allows us to use FindNearestPoint() to procedurally set accurate positions for the connection
CreateBoxOffMeshConnections(navMesh, boxGroup);
// Create some mushrooms
const uint numMushrooms = 100;
for (uint i = 0; i < numMushrooms; ++i)
CreateMushroom(new Vector3(NextRandom(90.0f) - 45.0f, 0.0f, NextRandom(90.0f) - 45.0f));
// Create a CrowdManager component to the scene root
crowdManager = scene.CreateComponent<CrowdManager>();
var parameters = crowdManager.GetObstacleAvoidanceParams(0);
// Set the params to "High (66)" setting
parameters.VelBias = 0.5f;
parameters.AdaptiveDivs = 7;
parameters.AdaptiveRings = 3;
parameters.AdaptiveDepth = 3;
crowdManager.SetObstacleAvoidanceParams(0, parameters);
// Create some movable barrels. We create them as crowd agents, as for moving entities it is less expensive and more convenient than using obstacles
CreateMovingBarrels(navMesh);
// Create Jack node that will follow the path
SpawnJack(new Vector3(-5.0f, 0.0f, 20.0f), scene.CreateChild("Jacks"));
// Create the camera. Limit far clip distance to match the fog
//.........这里部分代码省略.........
示例11: CreateScene
void CreateScene()
{
var cache = ResourceCache;
scene = new Scene();
// Create octree, use default volume (-1000, -1000, -1000) to (1000, 1000, 1000)
// Create a physics simulation world with default parameters, which will update at 60fps. Like the Octree must
// exist before creating drawable components, the PhysicsWorld must exist before creating physics components.
// Finally, create a DebugRenderer component so that we can draw physics debug geometry
scene.CreateComponent<Octree>();
scene.CreateComponent<PhysicsWorld>();
scene.CreateComponent<DebugRenderer>();
// 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.15f, 0.15f, 0.15f);
zone.FogColor = new Color(0.5f, 0.5f, 0.7f);
zone.FogStart = 100.0f;
zone.FogEnd = 300.0f;
// Create a directional light to the world. Enable cascaded shadows on it
Node lightNode = scene.CreateChild("DirectionalLight");
lightNode.SetDirection(new Vector3(0.6f, -1.0f, 0.8f));
Light light = lightNode.CreateComponent<Light>();
light.LightType = LightType.Directional;
light.CastShadows=true;
light.ShadowBias=new BiasParameters(0.00025f, 0.5f);
// Set cascade splits at 10, 50 and 200 world units, fade shadows out at 80% of maximum shadow distance
light.ShadowCascade=new CascadeParameters(10.0f, 50.0f, 200.0f, 0.0f, 0.8f);
{
// Create a floor object, 500 x 500 world units. Adjust position so that the ground is at zero Y
Node floorNode = scene.CreateChild("Floor");
floorNode.Position = new Vector3(0.0f, -0.5f, 0.0f);
floorNode.Scale=new Vector3(500.0f, 1.0f, 500.0f);
StaticModel floorObject = floorNode.CreateComponent<StaticModel>();
floorObject.Model = cache.GetModel("Models/Box.mdl");
floorObject.SetMaterial(cache.GetMaterial("Materials/StoneTiled.xml"));
// Make the floor physical by adding RigidBody and CollisionShape components
/*RigidBody* body = */
floorNode.CreateComponent<RigidBody>();
CollisionShape shape = floorNode.CreateComponent<CollisionShape>();
shape.SetBox(Vector3.One, Vector3.Zero, Quaternion.Identity);
}
{
// Create static mushrooms with triangle mesh collision
const uint numMushrooms = 50;
for (uint i = 0; i < numMushrooms; ++i)
{
Node mushroomNode = scene.CreateChild("Mushroom");
mushroomNode.Position = new Vector3(NextRandom(400.0f) - 200.0f, 0.0f, NextRandom(400.0f) - 200.0f);
mushroomNode.Rotation=new Quaternion(0.0f, NextRandom(360.0f), 0.0f);
mushroomNode.SetScale(5.0f + NextRandom(5.0f));
StaticModel mushroomObject = mushroomNode.CreateComponent<StaticModel>();
mushroomObject.Model = (cache.GetModel("Models/Mushroom.mdl"));
mushroomObject.SetMaterial(cache.GetMaterial("Materials/Mushroom.xml"));
mushroomObject.CastShadows=true;
mushroomNode.CreateComponent<RigidBody>();
CollisionShape shape = mushroomNode.CreateComponent<CollisionShape>();
// By default the highest LOD level will be used, the LOD level can be passed as an optional parameter
shape.SetTriangleMesh(mushroomObject.Model, 0, Vector3.One, Vector3.Zero, Quaternion.Identity);
}
}
{
// Create a large amount of falling physics objects
const uint numObjects = 1000;
for (uint i = 0; i < numObjects; ++i)
{
Node boxNode = scene.CreateChild("Box");
boxNode.Position = new Vector3(0.0f, i * 2.0f + 100.0f, 0.0f);
StaticModel boxObject = boxNode.CreateComponent<StaticModel>();
boxObject.Model = cache.GetModel("Models/Box.mdl");
boxObject.SetMaterial(cache.GetMaterial("Materials/StoneSmall.xml"));
boxObject.CastShadows=true;
// Give the RigidBody mass to make it movable and also adjust friction
RigidBody body = boxNode.CreateComponent<RigidBody>();
body.Mass = 1.0f;
body.Friction = 1.0f;
// Disable collision event signaling to reduce CPU load of the physics simulation
body.CollisionEventMode = CollisionEventMode.Never;
CollisionShape shape = boxNode.CreateComponent<CollisionShape>();
shape.SetBox(Vector3.One, Vector3.Zero, Quaternion.Identity);
}
}
// Create the camera. Limit far clip distance to match the fog. Note: now we actually create the camera node outside
// the scene, because we want it to be unaffected by scene load / save
CameraNode = new Node();
Camera camera = CameraNode.CreateComponent<Camera>();
camera.FarClip = 300.0f;
// Set an initial position for the camera scene node above the floor
//.........这里部分代码省略.........
示例12: CreateScene
void CreateScene()
{
var cache = ResourceCache;
scene = new Scene();
// Create octree, use default volume (-1000, -1000, -1000) to (1000, 1000, 1000)
// Also create a DebugRenderer component so that we can draw debug geometry
scene.CreateComponent<Octree>();
scene.CreateComponent<DebugRenderer>();
// Create scene node & StaticModel component for showing a static plane
Node planeNode = scene.CreateChild("Plane");
planeNode.Scale=new Vector3(100.0f, 1.0f, 100.0f);
StaticModel planeObject = planeNode.CreateComponent<StaticModel>();
planeObject.Model = cache.GetModel("Models/Plane.mdl");
planeObject.SetMaterial(cache.GetMaterial("Materials/StoneTiled.xml"));
// 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.15f, 0.15f, 0.15f);
zone.FogColor = new Color(0.5f, 0.5f, 0.7f);
zone.FogStart = 100.0f;
zone.FogEnd = 300.0f;
// Create a directional light to the world. Enable cascaded shadows on it
Node lightNode = scene.CreateChild("DirectionalLight");
lightNode.SetDirection(new Vector3(0.6f, -1.0f, 0.8f));
Light light = lightNode.CreateComponent<Light>();
light.LightType = LightType.Directional;
light.CastShadows=true;
light.ShadowBias=new BiasParameters(0.00025f, 0.5f);
// Set cascade splits at 10, 50 and 200 world units, fade shadows out at 80% of maximum shadow distance
light.ShadowCascade=new CascadeParameters(10.0f, 50.0f, 200.0f, 0.0f, 0.8f);
// Create some mushrooms
const uint numMushrooms = 100;
for (uint i = 0; i < numMushrooms; ++i)
CreateMushroom(new Vector3(NextRandom(90.0f) - 45.0f, 0.0f, NextRandom(90.0f) - 45.0f));
// Create randomly sized boxes. If boxes are big enough, make them occluders
const uint numBoxes = 20;
for (uint i = 0; i < numBoxes; ++i)
{
Node boxNode = scene.CreateChild("Box");
float size = 1.0f + NextRandom(10.0f);
boxNode.Position = new Vector3(NextRandom(80.0f) - 40.0f, size * 0.5f, NextRandom(80.0f) - 40.0f);
boxNode.SetScale(size);
StaticModel boxObject = boxNode.CreateComponent<StaticModel>();
boxObject.Model = cache.GetModel("Models/Box.mdl");
boxObject.SetMaterial(cache.GetMaterial("Materials/Stone.xml"));
boxObject.CastShadows = true;
if (size >= 3.0f)
boxObject.Occluder = true;
}
// Create Jack node that will follow the path
jackNode = scene.CreateChild("Jack");
jackNode.Position = new Vector3(-5.0f, 0.0f, 20.0f);
AnimatedModel modelObject = jackNode.CreateComponent<AnimatedModel>();
modelObject.Model = cache.GetModel("Models/Jack.mdl");
modelObject.SetMaterial(cache.GetMaterial("Materials/Jack.xml"));
modelObject.CastShadows=true;
// Create a NavigationMesh component to the scene root
NavigationMesh navMesh = scene.CreateComponent<NavigationMesh>();
// Create a Navigable component to the scene root. This tags all of the geometry in the scene as being part of the
// navigation mesh. By default this is recursive, but the recursion could be turned off from Navigable
scene.CreateComponent<Navigable>();
// Add padding to the navigation mesh in Y-direction so that we can add objects on top of the tallest boxes
// in the scene and still update the mesh correctly
navMesh.Padding=new Vector3(0.0f, 10.0f, 0.0f);
// Now build the navigation geometry. This will take some time. Note that the navigation mesh will prefer to use
// physics geometry from the scene nodes, as it often is simpler, but if it can not find any (like in this example)
// it will use renderable geometry instead
navMesh.Build();
// Create the camera. Limit far clip distance to match the fog
CameraNode = scene.CreateChild("Camera");
Camera 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, 5.0f, 0.0f);
}
示例13: CreateScene
void CreateScene()
{
var cache = ResourceCache;
scene = new Scene();
// Create octree, use default volume (-1000, -1000, -1000) to (1000, 1000, 1000)
scene.CreateComponent<Octree>();
// Create a Zone component for ambient lighting & fog control
var zoneNode = scene.CreateChild("Zone");
var zone = zoneNode.CreateComponent<Zone>();
zone.SetBoundingBox(new BoundingBox(-1000.0f, 1000.0f));
zone.AmbientColor = new Color(0.15f, 0.15f, 0.15f);
zone.FogColor = new Color(1.0f, 1.0f, 1.0f);
zone.FogStart = 500.0f;
zone.FogEnd = 750.0f;
// Create a directional light to the world. Enable cascaded shadows on it
var lightNode = scene.CreateChild("DirectionalLight");
lightNode.SetDirection(new Vector3(0.6f, -1.0f, 0.8f));
var light = lightNode.CreateComponent<Light>();
light.LightType = LightType.Directional;
light.CastShadows = true;
light.ShadowBias = new BiasParameters(0.00025f, 0.5f);
light.ShadowCascade = new CascadeParameters(10.0f, 50.0f, 200.0f, 0.0f, 0.8f);
light.SpecularIntensity = 0.5f;
// Apply slightly overbright lighting to match the skybox
light.Color = new Color(1.2f, 1.2f, 1.2f);
// Create skybox. The Skybox component is used like StaticModel, but it will be always located at the camera, giving the
// illusion of the box planes being far away. Use just the ordinary Box model and a suitable material, whose shader will
// generate the necessary 3D texture coordinates for cube mapping
var skyNode = scene.CreateChild("Sky");
skyNode.SetScale(500.0f); // The scale actually does not matter
var skybox = skyNode.CreateComponent<Skybox>();
skybox.Model = cache.GetModel("Models/Box.mdl");
skybox.SetMaterial(cache.GetMaterial("Materials/Skybox.xml"));
// Create heightmap terrain
var terrainNode = scene.CreateChild("Terrain");
terrainNode.Position = new Vector3(0.0f, 0.0f, 0.0f);
var terrain = terrainNode.CreateComponent<Terrain>();
terrain.PatchSize = 64;
terrain.Spacing = new Vector3(2.0f, 0.5f, 2.0f); // Spacing between vertices and vertical resolution of the height map
terrain.Smoothing =true;
terrain.SetHeightMap(cache.GetImage("Textures/HeightMap.png"));
terrain.Material = cache.GetMaterial("Materials/Terrain.xml");
// The terrain consists of large triangles, which fits well for occlusion rendering, as a hill can occlude all
// terrain patches and other objects behind it
terrain.Occluder = true;
// Create 1000 boxes in the terrain. Always face outward along the terrain normal
uint numObjects = 1000;
for (uint i = 0; i < numObjects; ++i)
{
var objectNode = scene.CreateChild("Box");
Vector3 position = new Vector3(NextRandom(2000.0f) - 1000.0f, 0.0f, NextRandom(2000.0f) - 1000.0f);
position.Y = terrain.GetHeight(position) + 2.25f;
objectNode.Position = position;
// Create a rotation quaternion from up vector to terrain normal
objectNode.Rotation = Quaternion.FromRotationTo(new Vector3(0.0f, 1.0f, 0.0f), terrain.GetNormal(position));
objectNode.SetScale(5.0f);
var obj = objectNode.CreateComponent<StaticModel>();
obj.Model = cache.GetModel("Models/Box.mdl");
obj.SetMaterial(cache.GetMaterial("Materials/Stone.xml"));
obj.CastShadows = true;
}
// Create a water plane object that is as large as the terrain
waterNode = scene.CreateChild("Water");
waterNode.Scale = new Vector3(2048.0f, 1.0f, 2048.0f);
waterNode.Position = new Vector3(0.0f, 5.0f, 0.0f);
var water = waterNode.CreateComponent<StaticModel>();
water.Model = cache.GetModel("Models/Plane.mdl");
water.SetMaterial(cache.GetMaterial("Materials/Water.xml"));
// Set a different viewmask on the water plane to be able to hide it from the reflection camera
water.ViewMask = 0x80000000;
// Create the camera. Limit far clip distance to match the fog
CameraNode = new Node();
var camera = CameraNode.CreateComponent<Camera>();
camera.FarClip = 750.0f;
// Set an initial position for the camera scene node above the plane
CameraNode.Position = new Vector3(0.0f, 7.0f, -20.0f);
}
示例14: CreateScene
void CreateScene()
{
var cache = ResourceCache;
scene = new Scene();
// Create the Octree component to the scene. This is required before adding any drawable components, or else nothing will
// show up. The default octree volume will be from (-1000, -1000, -1000) to (1000, 1000, 1000) in world coordinates; it
// is also legal to place objects outside the volume but their visibility can then not be checked in a hierarchically
// optimizing manner
scene.CreateComponent<Octree>();
// Create a child scene node (at world origin) and a StaticModel component into it. Set the StaticModel to show a simple
// plane mesh with a "stone" material. Note that naming the scene nodes is optional. Scale the scene node larger
// (100 x 100 world units)
Node planeNode = scene.CreateChild("Plane");
planeNode.Scale=new Vector3(100.0f, 1.0f, 100.0f);
StaticModel planeObject = planeNode.CreateComponent<StaticModel>();
planeObject.Model = (cache.GetModel("Models/Plane.mdl"));
planeObject.SetMaterial(cache.GetMaterial("Materials/StoneTiled.xml"));
// Create a directional light to the world so that we can see something. The light scene node's orientation controls the
// light direction; we will use the SetDirection() function which calculates the orientation from a forward direction vector.
// The light will use default settings (white light, no shadows)
Node lightNode = scene.CreateChild("DirectionalLight");
lightNode.SetDirection(new Vector3(0.6f, -1.0f, 0.8f)); // The direction vector does not need to be normalized
Light light = lightNode.CreateComponent<Light>();
light.LightType = LightType.Directional;
// Create more StaticModel objects to the scene, randomly positioned, rotated and scaled. For rotation, we construct a
// quaternion from Euler angles where the Y angle (rotation about the Y axis) is randomized. The mushroom model contains
// LOD levels, so the StaticModel component will automatically select the LOD level according to the view distance (you'll
// see the model get simpler as it moves further away). Finally, rendering a large number of the same object with the
// same material allows instancing to be used, if the GPU supports it. This reduces the amount of CPU work in rendering the
// scene.
const uint numObjects = 200;
for (uint i = 0; i < numObjects; ++i)
{
Node mushroomNode = scene.CreateChild("Mushroom");
mushroomNode.Position = (new Vector3(NextRandom(90.0f) - 45.0f, 0.0f, NextRandom(90.0f) - 45.0f));
mushroomNode.SetScale(0.5f + NextRandom(2.0f));
StaticModel mushroomObject = mushroomNode.CreateComponent<StaticModel>();
mushroomObject.Model = (cache.GetModel("Models/Mushroom.mdl"));
mushroomObject.SetMaterial(cache.GetMaterial("Materials/Mushroom.xml"));
Node mushroomTitleNode = mushroomNode.CreateChild("MushroomTitle");
mushroomTitleNode.Position = (new Vector3(0.0f, 1.2f, 0.0f));
Text3D mushroomTitleText = mushroomTitleNode.CreateComponent<Text3D>();
mushroomTitleText.Text="Mushroom " + i;
mushroomTitleText.SetFont(cache.GetFont("Fonts/BlueHighway.sdf"), 24);//sdf, not ttf. size of font doesn't matter.
mushroomTitleText.SetColor(Color.Red);
if (i % 3 == 1)
{
mushroomTitleText.SetColor(Color.Green);
mushroomTitleText.TextEffect= TextEffect.Shadow;
mushroomTitleText.EffectColor = new Color(0.5f, 0.5f, 0.5f);
}
else if (i % 3 == 2)
{
mushroomTitleText.SetColor(Color.Yellow);
mushroomTitleText.TextEffect = TextEffect.Stroke;
mushroomTitleText.EffectColor = new Color(0.5f, 0.5f, 0.5f);
}
mushroomTitleText.SetAlignment(HorizontalAlignment.Center, VerticalAlignment.Center);
}
// Create a scene node for the camera, which we will move around
// The camera will use default settings (1000 far clip distance, 45 degrees FOV, set aspect ratio automatically)
CameraNode = scene.CreateChild("Camera");
CameraNode.CreateComponent<Camera>();
// Set an initial position for the camera scene node above the plane
CameraNode.Position = (new Vector3(0.0f, 5.0f, 0.0f));
}
示例15: CreateScene
void CreateScene()
{
var cache = ResourceCache;
scene = new Scene();
// Create the Octree component to the scene so that drawable objects can be rendered. Use default volume
// (-1000, -1000, -1000) to (1000, 1000, 1000)
scene.CreateComponent<Octree>();
// Create a Zone component into a child scene node. The Zone controls ambient lighting and fog settings. Like the Octree,
// it also defines its volume with a bounding box, but can be rotated (so it does not need to be aligned to the world X, Y
// and Z axes.) Drawable objects "pick up" the zone they belong to and use it when rendering; several zones can exist
var zoneNode = scene.CreateChild("Zone");
var zone = zoneNode.CreateComponent<Zone>();
// Set same volume as the Octree, set a close bluish fog and some ambient light
zone.SetBoundingBox(new BoundingBox(-1000.0f, 1000.0f));
zone.AmbientColor = new Color(0.05f, 0.1f, 0.15f);
zone.FogColor = new Color(0.1f, 0.2f, 0.3f);
zone.FogStart = 10;
zone.FogEnd = 100;
var boxesNode = scene.CreateChild("Boxes");
const int numObjects = 2000;
for (var i = 0; i < numObjects; ++i)
{
Node boxNode = new Node();
boxesNode.AddChild(boxNode, 0);
boxNode.Position = new Vector3(NextRandom(200f) - 100f, NextRandom(200f) - 100f, NextRandom(200f) - 100f);
// Orient using random pitch, yaw and roll Euler angles
boxNode.Rotation = new Quaternion(NextRandom(360.0f), NextRandom(360.0f), NextRandom(360.0f));
using (var boxObject = boxNode.CreateComponent<StaticModel>())
{
boxObject.Model = cache.GetModel("Models/Box.mdl");
boxObject.SetMaterial(cache.GetMaterial("Materials/Stone.xml"));
//we don't need this component in C# anymore so let's just delete a MCW for it (howerver, we can access it anytime if we need via GetComponent<>)
//it's just an optimization to reduce cached objects count
}
// Add our custom Rotator component which will rotate the scene node each frame, when the scene sends its update event.
// The Rotator component derives from the base class LogicComponent, which has convenience functionality to subscribe
// to the various update events, and forward them to virtual functions that can be implemented by subclasses. This way
// writing logic/update components in C++ becomes similar to scripting.
// Now we simply set same rotation speed for all objects
var rotationSpeed = new Vector3(10.0f, 20.0f, 30.0f);
// First style: use a Rotator instance, which is a component subclass, and
// add it to the boxNode.
var rotator = new Rotator() { RotationSpeed = rotationSpeed };
boxNode.AddComponent(rotator);
}
// Create the camera. Let the starting position be at the world origin. As the fog limits maximum visible distance, we can
// bring the far clip plane closer for more effective culling of distant objects
CameraNode = scene.CreateChild("Camera");
var camera = CameraNode.CreateComponent<Camera>();
camera.FarClip = 100.0f;
// Create a point light to the camera scene node
var light = CameraNode.CreateComponent<Light>();
light.LightType = LightType.Point;
light.Range = 30.0f;
}