public void AddWidget(Widget widget) { Node widgetNode = new Node(); widgetNode.SetScale(0.1f); widgetNode.Position += new Vector3(widget.Position[0] * 0.1f, widget.Position[1] * 0.1f, widget.Position[2] * 0.1f); //Background Plane Node backgroundPlaneNode = widgetNode.CreateChild(); backgroundPlaneNode.Scale = new Vector3(1.9f, 1f, 1f); backgroundPlaneNode.Rotation = new Quaternion(-90, 0, 0); backgroundPlaneNode.Position += new Vector3(0, 0, 0.05f); Urho.Shapes.Plane plane = backgroundPlaneNode.CreateComponent <Urho.Shapes.Plane>(); plane.SetMaterial(Material.FromColor(new Color(0.6f, 0.6f, 0.6f, 0.5f))); //Text Component Text3D text = widgetNode.CreateComponent <Text3D>(); text.HorizontalAlignment = HorizontalAlignment.Center; text.VerticalAlignment = VerticalAlignment.Center; text.SetFont(CoreAssets.Fonts.AnonymousPro, 12); text.SetColor(Color.Red); text.Text = "LOADING..."; switch (widget.type) { case WidgetType.Text: //Text Widget Display TextWidget textWidget = widgetNode.CreateComponent <TextWidget>(); textWidget.Text = text; textWidget.Key = widget.NetworkKey; textWidget.Label = widget.Label; break; case WidgetType.Camera: //remove text text.Remove(); //Camera Widget CameraWidget cameraWidget = new CameraWidget(widget.NetworkKey, plane); widgetNode.AddComponent(cameraWidget); break; case WidgetType.Status: //adjust the size of the background plane backgroundPlaneNode.Scale = new Vector3(0.5f, 1f, 0.25f); //Status Widget StatusWidget statusWidget = new StatusWidget(text, plane, widget.NetworkKey, widget.Label); widgetNode.AddComponent(statusWidget); break; } Node.AddChild(widgetNode); }
void textLampuDua() { // Create text textLampB = lampBNode.CreateChild(); text3DB = textLampB.CreateComponent <Text3D>(); text3DB.HorizontalAlignment = HorizontalAlignment.Center; text3DB.VerticalAlignment = VerticalAlignment.Top; //text3D.ViewMask = 0x80000000; //hide from raycasts text3DB.Text = "Lamp is Off"; text3DB.SetFont(CoreAssets.Fonts.AnonymousPro, 26); text3DB.SetColor(Color.White); textLampB.Translate(new Vector3(0, -1f, -0.5f)); }
private void CreateDebugInformationNode() { if (_positionNodeDebug != null) { return; } _positionNodeDebug = Scene.CreateChild(); _positionNodeDebug.Scale = new Vector3(0.3f, 0.15f, 0.2f); _text3DDebug = _positionNodeDebug.CreateComponent <Text3D>(); _text3DDebug.HorizontalAlignment = HorizontalAlignment.Center; _text3DDebug.VerticalAlignment = VerticalAlignment.Top; _text3DDebug.ViewMask = 0x80000000; //hide from raycasts _text3DDebug.Text = $@"@Debug {DateTime.Now:T}"; _text3DDebug.SetFont(CoreAssets.Fonts.AnonymousPro, 10); _text3DDebug.SetColor(Color.White); }
protected override async void Start() { base.Start(); _environmentNode = Scene.CreateChild(); // Allow tap gesture EnableGestureTapped = true; // Create a bucket _bucketNode = Scene.CreateChild(); _bucketNode.SetScale(0.15f); //var bucketBaseNode = bucketNode.CreateChild(); // Create instructions _textNode = _bucketNode.CreateChild(); _text3D = _textNode.CreateComponent <Text3D>(); _text3D.HorizontalAlignment = HorizontalAlignment.Center; _text3D.VerticalAlignment = VerticalAlignment.Top; _text3D.ViewMask = 0x80000000; //hide from raycasts _text3D.Text = @"El Bruno - @elbruno Place on a horizontal surface and AirTap"; _text3D.SetFont(CoreAssets.Fonts.AnonymousPro, 20); _text3D.SetColor(Color.White); _textNode.Translate(new Vector3(0, 1f, -1.5f)); // Model and Physics for the bucket var bucketModel = _bucketNode.CreateComponent <StaticModel>(); _bucketMaterial = Material.FromColor(Color.Yellow); bucketModel.Model = ResourceCache.GetModel("bucket1.mdl"); bucketModel.SetMaterial(_bucketMaterial); bucketModel.ViewMask = 0x80000000; //hide from raycasts var rigidBody = _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); var allowed = await StartSpatialMapping(new Vector3(50, 50, 10), 1200); }
public void SetText(string text) { if (TextComponent == null) { var cache = Application.ResourceCache; var node = Node; TextNode = node.CreateChild(); TextComponent = TextNode.CreateComponent <Text3D>(); TextComponent.HorizontalAlignment = HorizontalAlignment.Center; TextComponent.VerticalAlignment = VerticalAlignment.Top; TextComponent.ViewMask = 0x80000000; //hide from raycasts TextComponent.SetFont(cache.GetFont(Assets.Fonts.ChineseFont), 96); TextComponent.SetColor(Color.White); } Application.InvokeOnMain(() => { TextComponent.SetTextFix(text); }); }
public override void OnAttachedToNode(Node node) { this.Node?.RemoveChild(m_Geometry); this.Node?.RemoveChild(m_TextNode); this.Node?.RemoveChild(m_LevelTextNode); m_TextNode = node.CreateChild(); //m_TextNode.LookAt(new Vector3(0,-10,10), Vector3.Up, TransformSpace.World); // camera pos hardcoded !!! TODO: fix m_TextNode.Position += new Vector3(0f, 1f, 0f); m_Text = m_TextNode.CreateComponent <Text3D>(); m_Text.SetFont(CoreAssets.Fonts.AnonymousPro, 20); m_Text.SetColor(Color.Yellow); m_Text.EffectColor = Color.Black; m_Text.TextEffect = TextEffect.Shadow; m_LevelTextNode = node.CreateChild(); m_LevelTextNode.LookAt(new Vector3(-1f, -1f, 1f), Vector3.Up, TransformSpace.Local); // camera pos hardcoded !!! TODO: fix m_LevelTextNode.Position += new Vector3(0.25f, 0.5f, -0.5f); m_LevelText = m_LevelTextNode.CreateComponent <Text3D>(); m_LevelText.SetFont(CoreAssets.Fonts.AnonymousPro, 30); m_LevelText.SetColor(Color.Green); m_LevelText.EffectColor = Color.Black; m_LevelText.TextEffect = TextEffect.Shadow; m_LevelText.Text = Level.ToString(); m_Geometry = node.CreateChild(); var model = m_Geometry.CreateComponent <StaticModel>(); model.Model = Application.ResourceCache.GetModel(BuildingProperties.Model); model.SetMaterial(Application.ResourceCache.GetMaterial(BuildingProperties.Material)); m_Geometry.SetScale(BuildingProperties.Scale); m_Geometry.Position -= new Vector3(0f, 0.8f, 0f); Initialize(); m_ConstructionTask = m_Geometry.RunActionsAsync(new MoveTo(BuildingProperties.TimeToBuild, new Vector3(0, 0, 0))); }
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/Anonymous Pro.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)); }
private void MakeGameDetailScreen() { // Create a bucket leftGameDetailScreen = Scene.CreateChild("leftGameDetailScreen"); leftGameDetailScreen.Scale = leftDetail.WorldScale; leftGameDetailScreen.Position = leftDetail.WorldPosition; //leftGameDetailScreen.Scale = new Vector3(1f, 0.8f, 0.1f); //leftGameDetailScreen.Position = new Vector3(bucketNode.WorldPosition.X - 2.5f, bucketNode.WorldPosition.Y + 2, bucketNode.WorldPosition.Z - 3); leftGameDetailScreen.Rotation = new Quaternion(0, -LeftCamera.Node.Rotation.ToEulerAngles().Y, 0); // Model and Physics for the bucket var leftNodeModel = leftGameDetailScreen.CreateComponent <StaticModel>(); leftNodeModel.Model = CoreAssets.Models.Box; leftNodeModel.SetMaterial(Material.FromColor(Color.Transparent)); // Create instructions leftHitDetailScreen = leftGameDetailScreen.CreateChild(); leftHitDetailScreen.Position = new Vector3(0, 0.3f, 0); hitsText = leftHitDetailScreen.CreateComponent <Text3D>(); hitsText.HorizontalAlignment = HorizontalAlignment.Center; hitsText.VerticalAlignment = VerticalAlignment.Center; hitsText.ViewMask = 0x80000000; //hide from raycasts hitsText.Text = "Hits " + hits; hitsText.SetFont(CoreAssets.Fonts.AnonymousPro, 13); hitsText.SetColor(Color.FromHex("#5AC4BE")); leftHitDetailScreen.Translate(new Vector3(0, 0f, -0.55f)); // Create instructions var ballTextScreen = leftGameDetailScreen.CreateChild(); var ballText = ballTextScreen.CreateComponent <Text3D>(); ballText.HorizontalAlignment = HorizontalAlignment.Center; ballText.VerticalAlignment = VerticalAlignment.Center; ballText.ViewMask = 0x80000000; //hide from raycasts ballText.Text = "Balls"; ballText.SetFont(CoreAssets.Fonts.AnonymousPro, 13); ballText.SetColor(Color.FromHex("#5AC4BE")); ballTextScreen.Translate(new Vector3(0, 0f, -0.55f)); var availableBallsNode = leftGameDetailScreen.CreateChild(); availableBallsNode.Position = new Vector3(0, -0.3f, -0.55f); availableBallsNode.Scale = new Vector3(1f, 0.3f, 0.01f); var start = -0.4f; for (int i = 0; i < durationGame; i++) { var availableBall = availableBallsNode.CreateChild(); availableBall.Position = new Vector3(start, 0, 0); availableBall.Scale = new Vector3(0.15f, 0.5f, 1f); var availableBallModel = availableBall.CreateComponent <StaticModel>(); availableBallModel.Model = CoreAssets.Models.Sphere; availableBallModel.SetMaterial(Material.FromImage("Textures/Color_K04.jpg")); availableNodes[i] = availableBall; start += 0.2f; } // Create a bucket rightGameDetailScreen = Scene.CreateChild("rightGameDetailScreen"); rightGameDetailScreen.Scale = rightDetail.WorldScale; rightGameDetailScreen.Position = rightDetail.WorldPosition; rightGameDetailScreen.Rotation = new Quaternion(0, -LeftCamera.Node.Rotation.ToEulerAngles().Y, 0); // Create instructions righthitDetailScreen = rightGameDetailScreen.CreateChild(); righthitDetailScreen.Position = new Vector3(0, 0.3f, 0); missesText = righthitDetailScreen.CreateComponent <Text3D>(); missesText.HorizontalAlignment = HorizontalAlignment.Center; missesText.VerticalAlignment = VerticalAlignment.Center; missesText.ViewMask = 0x80000000; //hide from raycasts missesText.Text = misses + " Misses"; missesText.SetFont(CoreAssets.Fonts.AnonymousPro, 13); missesText.SetColor(Color.FromHex("#5AC4BE")); righthitDetailScreen.Translate(new Vector3(0, 0f, -0.55f)); // Model and Physics for the bucket var rightNodeModel = rightGameDetailScreen.CreateComponent <StaticModel>(); rightNodeModel.Model = CoreAssets.Models.Box; rightNodeModel.SetMaterial(Material.FromColor(Color.Transparent)); }