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; }
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); }