本文整理汇总了C#中Urho.Node.CreateChild方法的典型用法代码示例。如果您正苦于以下问题:C# Node.CreateChild方法的具体用法?C# Node.CreateChild怎么用?C# Node.CreateChild使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Urho.Node
的用法示例。
在下文中一共展示了Node.CreateChild方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ShowStartMenu
public async Task ShowStartMenu(bool gameOver)
{
var cache = Application.ResourceCache;
bigAircraft = Node.CreateChild();
var model = bigAircraft.CreateComponent<StaticModel>();
if (gameOver)
{
model.Model = cache.GetModel(Assets.Models.Enemy1);
model.SetMaterial(cache.GetMaterial(Assets.Materials.Enemy1).Clone(""));
bigAircraft.SetScale(0.3f);
bigAircraft.Rotate(new Quaternion(180, 90, 20), TransformSpace.Local);
}
else
{
model.Model = cache.GetModel(Assets.Models.Player);
model.SetMaterial(cache.GetMaterial(Assets.Materials.Player).Clone(""));
bigAircraft.SetScale(1f);
bigAircraft.Rotate(new Quaternion(0, 40, -50), TransformSpace.Local);
}
bigAircraft.Position = new Vector3(10, 2, 10);
bigAircraft.RunActions(new RepeatForever(new Sequence(new RotateBy(1f, 0f, 0f, 5f), new RotateBy(1f, 0f, 0f, -5f))));
//TODO: rotor should be defined in the model + animation
rotor = bigAircraft.CreateChild();
var rotorModel = rotor.CreateComponent<Box>();
rotorModel.Color = Color.White;
rotor.Scale = new Vector3(0.1f, 1.5f, 0.1f);
rotor.Position = new Vector3(0, 0, -1.3f);
var rotorAction = new RepeatForever(new RotateBy(1f, 0, 0, 360f*6)); //RPM
rotor.RunActions(rotorAction);
menuLight = bigAircraft.CreateChild();
menuLight.Position = new Vector3(-3, 6, 2);
menuLight.AddComponent(new Light { LightType = LightType.Point, Brightness = 0.3f });
await bigAircraft.RunActionsAsync(new EaseIn(new MoveBy(1f, new Vector3(-10, -2, -10)), 2));
textBlock = new Text();
textBlock.HorizontalAlignment = HorizontalAlignment.Center;
textBlock.VerticalAlignment = VerticalAlignment.Bottom;
textBlock.Value = gameOver ? "GAME OVER" : "TAP TO START";
textBlock.SetFont(cache.GetFont(Assets.Fonts.Font), Application.Graphics.Width / 15);
Application.UI.Root.AddChild(textBlock);
menuTaskSource = new TaskCompletionSource<bool>();
finished = false;
await menuTaskSource.Task;
}
示例2: Start
protected override async void Start()
{
base.Start();
clientConnection = new ClientConnection();
clientConnection.Disconnected += ClientConnection_Disconnected;
clientConnection.RegisterForRealtimeUpdate(GetCurrentPositionDto);
clientConnection.RegisterFor<PointerPositionChangedDto>(OnClientPointerChanged);
Zone.AmbientColor = new Color(0.3f, 0.3f, 0.3f);
DirectionalLight.Brightness = 0.5f;
environmentNode = Scene.CreateChild();
EnableGestureTapped = true;
cubeNode = environmentNode.CreateChild();
cubeNode.SetScale(0.2f);
cubeNode.Position = new Vector3(1000, 1000, 1000);
var box = cubeNode.CreateComponent<Box>();
box.Color = Color.White;
var moveAction = new MoveBy(0.5f, new Vector3(0, 0.005f, 0));
cubeNode.RunActions(new RepeatForever(new RotateBy(1f, 0, 120, 0)));
cubeNode.RunActions(new RepeatForever(moveAction, moveAction.Reverse()));
//material = Material.FromColor(Color.Gray); //-- debug mode
material = Material.FromColor(Color.Transparent, true);
await RegisterCortanaCommands(new Dictionary<string, Action> {
{ "stop spatial mapping", StopSpatialMapping}
});
while (!await ConnectAsync()) { }
}
示例3: Start
protected override void Start()
{
// base.Start() creates a basic scene
base.Start();
// Create a node for the Earth
earthNode = Scene.CreateChild();
earthNode.Position = new Vector3(0, 0, 1); // One meter away
earthNode.SetScale(0.2f); // 20cm
// Create a static model component - Sphere:
var earth = earthNode.CreateComponent<Sphere>();
// Materials are usually more complicated than just textures, but for such
// simple cases we can use quick FromImage method to create a material from an image.
earth.SetMaterial(Material.FromImage("Textures/Earth.jpg"));
// Same steps for the Moon
var moonNode = earthNode.CreateChild();
moonNode.SetScale(0.27f); // Relative size of the Moon is 1738.1km/6378.1km
moonNode.Position = new Vector3(1.2f, 0, 0);
var moon = moonNode.CreateComponent<Sphere>();
moon.SetMaterial(Material.FromImage("Textures/Moon.jpg"));
// Run a an action to spin the Earth (5 degrees per second)
earthNode.RunActions(new RepeatForever(new RotateBy(duration: 1f, deltaAngleX: 0, deltaAngleY: -5, deltaAngleZ: 0)));
}
示例4: OnAttachedToNode
public override void OnAttachedToNode(Node node)
{
barNode = node.CreateChild();
barNode.Scale = new Vector3(1, 0, 1);
var box = barNode.CreateComponent<Box>();
box.Color = color;
textNode = node.CreateChild();
textNode.Position = new Vector3(0, 3, 0);
var text3D = textNode.CreateComponent<Text3D>();
text3D.SetFont(CoreAssets.Fonts.AnonymousPro, 60);
text3D.TextEffect = TextEffect.Stroke;
text3D.Text = name;
base.OnAttachedToNode(node);
}
示例5: CreateScene
async void CreateScene ()
{
Input.SubscribeToTouchEnd(OnTouched);
var cache = ResourceCache;
scene = new Scene ();
octree = scene.CreateComponent<Octree> ();
plotNode = scene.CreateChild();
var baseNode = plotNode.CreateChild().CreateChild();
var plane = baseNode.CreateComponent<StaticModel>();
plane.Model = ResourceCache.GetModel("Models/Plane.mdl");
var cameraNode = scene.CreateChild ("camera");
camera = cameraNode.CreateComponent<Camera>();
cameraNode.Position = new Vector3(10, 15, 10) / 1.75f;
cameraNode.Rotation = new Quaternion(-0.121f, 0.878f, -0.305f, -0.35f);
Node lightNode = cameraNode.CreateChild(name: "light");
var light = lightNode.CreateComponent<Light>();
light.LightType = LightType.Point;
light.Range = 100;
light.Brightness = 1.3f;
int size = 3;
baseNode.Scale = new Vector3(size * 1.5f, 1, size * 1.5f);
bars = new List<Bar>(size * size);
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, size / 2f - j);
var box = new Bar(new Color(RandomHelper.NextRandom(), RandomHelper.NextRandom(), RandomHelper.NextRandom(), 0.9f));
boxNode.AddComponent(box);
box.SetValueWithAnimation((Math.Abs(i) + Math.Abs(j) + 1) / 2f);
bars.Add(box);
}
}
SelectedBar = bars.First();
SelectedBar.Select();
await plotNode.RunActionsAsync(new EaseBackOut(new RotateBy(2f, 0, 360, 0)));
movementsEnabled = true;
}
示例6: Start
protected override void Start()
{
debugHud = new MonoDebugHud(this) { FpsOnly = true };
debugHud.Show();
scene = new Scene();
scene.CreateComponent<Octree>();
var zone = scene.CreateComponent<Zone>();
zone.AmbientColor = new Color(0.5f, 0.5f, 0.5f);
cameraNode = scene.CreateChild();
var camera = cameraNode.CreateComponent<Camera>();
var viewport = new Viewport(scene, camera, null);
// viewport.SetClearColor(Color.White);
Renderer.SetViewport(0, viewport);
lightNode = scene.CreateChild();
lightNode.Position = new Vector3(0, 3, 0);
var light = lightNode.CreateComponent<Light>();
light.LightType = LightType.Directional;
light.Brightness = 0.6f;
light.Range = 200;
environmentNode = scene.CreateChild();
environmentNode.SetScale(0.1f);
humanNode = environmentNode.CreateChild();
humanNode.Position = new Vector3(0, -1f, 0);
humanNode.SetScale(1f);
var model = humanNode.CreateComponent<StaticModel>();
model.Model = ResourceCache.GetModel("Jack.mdl");
material = Material.FromColor(new Color(72/255f, 99/255f, 142/255f));
yaw = -65;
pitch = 55;
cameraNode.Position = new Vector3(0.6f, 1.3f, -0.4f);
cameraNode.Rotation = new Quaternion(pitch, yaw, 0);
lightNode.SetDirection(new Vector3(-1, -1f, 0));
InitTouchInput();
var pointer = scene.CreateComponent<CubePointer>();
pointer.PositionChanged += Pointer_PositionChanged;
}
示例7: OnAttachedToNode
public override void OnAttachedToNode(Node node)
{
base.OnAttachedToNode(node);
Application.Input.TouchEnd += Input_TouchEnd;
Application.Input.TouchBegin += Input_TouchBegin;
cubeNode = node.CreateChild();
cubeNode.Position = new Vector3(1000, 1000, 1000);
cubeNode.SetScale(0.02f);
var box = cubeNode.CreateComponent<Box>();
box.Color = Color.White;
var moveAction = new MoveBy(0.5f, new Vector3(0, 0.005f, 0));
cubeNode.RunActionsAsync(new RepeatForever(new RotateBy(1f, 0, 120, 0)));
cubeNode.RunActionsAsync(new RepeatForever(moveAction, moveAction.Reverse()));
camera = Scene.GetChildrenWithComponent<Camera>(true).First().GetComponent<Camera>();
octree = Scene.GetComponent<Octree>(true);
}
示例8: Start
protected override async void Start()
{
base.Start();
environmentNode = Scene.CreateChild();
// Allow tap gesture
EnableGestureTapped = true;
// Create a bucket
bucketNode = Scene.CreateChild();
bucketNode.SetScale(0.1f);
// Create instructions
textNode = bucketNode.CreateChild();
var text3D = textNode.CreateComponent<Text3D>();
text3D.HorizontalAlignment = HorizontalAlignment.Center;
text3D.VerticalAlignment = VerticalAlignment.Top;
text3D.ViewMask = 0x80000000; //hide from raycasts
text3D.Text = "Place on a horizontal\n surface and click";
text3D.SetFont(CoreAssets.Fonts.AnonymousPro, 26);
text3D.SetColor(Color.White);
textNode.Translate(new Vector3(0, 3f, -0.5f));
// Model and Physics for the bucket
var bucketModel = bucketNode.CreateComponent<StaticModel>();
bucketMaterial = Material.FromColor(validPositionColor);
bucketModel.Model = ResourceCache.GetModel("Models/bucket.mdl");
bucketModel.SetMaterial(bucketMaterial);
bucketModel.ViewMask = 0x80000000; //hide from raycasts
bucketNode.CreateComponent<RigidBody>();
var shape = bucketNode.CreateComponent<CollisionShape>();
shape.SetTriangleMesh(bucketModel.Model, 0, Vector3.One, Vector3.Zero, Quaternion.Identity);
// Material for spatial surfaces
spatialMaterial = new Material();
spatialMaterial.SetTechnique(0, CoreAssets.Techniques.NoTextureUnlitVCol, 1, 1);
// make sure 'spatialMapping' capabilaty is enabled in the app manifest.
var spatialMappingAllowed = await StartSpatialMapping(new Vector3(50, 50, 10), 1200);
}
示例9: OnAttachedToNode
public override void OnAttachedToNode(Node node)
{
barNode = node.CreateChild();
barNode.Scale = new Vector3(1, 0, 1); //means zero height
var box = barNode.CreateComponent<Box>();
box.Color = color;
textNode = node.CreateChild();
textNode.Rotate(new Quaternion(0, 180, 0), TransformSpace.World);
textNode.Position = new Vector3(0, 10, 0);
text3D = textNode.CreateComponent<Text3D>();
text3D.SetFont(Application.ResourceCache.GetFont("Fonts/Anonymous Pro.ttf"), 60);
text3D.TextEffect = TextEffect.Stroke;
//textNode.LookAt() //Look at camera
base.OnAttachedToNode(node);
}
示例10: Start
protected override void Start()
{
// UI text
var helloText = new Text(Context);
helloText.Value = "UrhoSharp face detection";
helloText.HorizontalAlignment = Urho.Gui.HorizontalAlignment.Center;
helloText.VerticalAlignment = Urho.Gui.VerticalAlignment.Top;
helloText.SetColor(new Color(r: 0f, g: 0f, b: 1f));
helloText.SetFont(font: CoreAssets.Fonts.AnonymousPro, size: 30);
UI.Root.AddChild(helloText);
// 3D scene with Octree
scene = new Scene(Context);
scene.CreateComponent<Octree>();
// Mask
maskNode = scene.CreateChild();
maskNode.Position = new Vector3(x: 1, y: 0, z: 5);
maskNode.Scale = new Vector3(1, 1, 1) / 3f;
var leftEye = maskNode.CreateChild();
var leftEyeModel = leftEye.CreateComponent<Urho.Shapes.Sphere>();
var rightEye = maskNode.CreateChild();
var rightEyeModel = rightEye.CreateComponent<Urho.Shapes.Sphere>();
leftEye.Position = new Vector3(-0.6f, 0, 0);
rightEye.Position = new Vector3(0.6f, 0, 0);
leftEye.RunActions(new TintTo(1f, Randoms.Next(), Randoms.Next(), Randoms.Next()));
rightEye.RunActions(new TintTo(1f, Randoms.Next(), Randoms.Next(), Randoms.Next()));
// Light
Node lightNode = scene.CreateChild();
lightNode.Position = new Vector3(-2, 0, 0);
var light = lightNode.CreateComponent<Light>();
light.Range = 20;
light.Brightness = 1f;
// Camera
Node cameraNode = scene.CreateChild();
camera = cameraNode.CreateComponent<Camera>();
// Viewport
var vp = new Viewport(Context, scene, camera, null);
Renderer.SetViewport(0, vp);
vp.SetClearColor(Color.White);
}