public StatusWidget(Text3D text, Urho.Shapes.Plane plane, string key, string label) { this.Text = text; this.plane = plane; this.Key = key; this.Label = label; }
private void DrawText() { Space3D space = new Space3D(); // Prepare text points and lines Text3D text = Text3D.FromString("This is a test string...", new Font("Times New Roman", 24), 10f, FontStyle.Regular, 50); // Set color for tag 1, if color is need to be specified directly use 0x7f000000 | rgb color (0xrrggbb) space.SetColor(0, Color.Black); space.Text(0, text, Text3DLocation.XY, Text3DFlip.None, 10f, 10f, 10f); text = Text3D.FromString("This is another test string...", new Font("Arial", 24), 10f, FontStyle.Bold, 50); space.Text(Form1.ColorToTag(Color.Orange), text, Text3DLocation.XZ, Text3DFlip.None, 10f, 10f, 10f); space.SetColor(1, Color.SandyBrown); space.SetColor(2, Color.RoyalBlue); space.SetColor(3, Color.SeaGreen); for (int i = 0; i < 5; i++) { text = Text3D.FromString(String.Format("String #{0}", i + 1), new Font("Courier New", 24), 10f, FontStyle.Italic, 50); space.Text(i % 4, text, Text3DLocation.YZ, Text3DFlip.None, 10f, 10f * (float)i, 10f); } this.view.Space = space; }
void Update3Dtext(Node myPlotNode, string objectLabel, string myText) { Node textNode = myPlotNode.GetChild(objectLabel); Text3D text3D = textNode.GetComponent <Text3D>(); text3D.Text = myText; }
protected BaseController(BaseControllerInfo info) : base(info) { baseControllerInfo = info; plcCube = new Cube(Color.Wheat, 1.3f, 1.8f, 0.4f); door1 = new Cube(Color.Wheat, 0.62f, 1.585f, 0.25f); door2 = new Cube(Color.Wheat, 0.62f, 1.585f, 0.25f); plinth = new Cube(Color.DimGray, 1.32f, 0.1985f, 0.42f); Font f = new Font("Helvetica", 0.4f, FontStyle.Bold, GraphicsUnit.Pixel); DisplayText = new Text3D(Color.Red, 0.4f, 0.3f, f); DisplayText.Pitch = (float)Math.PI / 2; Add((RigidPart)DisplayText, new Vector3(-0.62f, 1.25f, -0.125f)); Add((RigidPart)plcCube, new Vector3(0, 0.45f, 0)); Add((RigidPart)door1, new Vector3(-0.325f, 0.5425f, -0.1f)); Add((RigidPart)door2, new Vector3(0.325f, 0.5425f, -0.1f)); Add((RigidPart)plinth, new Vector3(0, -0.355f, 0)); DisplayText.Text = info.name; OnNameChanged += CaseDatcom_OnNameChanged; if (info.receiverID != 0) { ReceiverID = info.receiverID; } if (info.senderID != 0) { SenderID = info.senderID; } }
public static void spawnPlayer(Player player) { Text3D text3d = new Text3D(player, 2000, Types.ColorRGBA.Red, player.World, new Types.Vec3f(0, 100, 0)); text3d.addRow("Test1", 10000); text3d.addRow("Test2", 12000); text3d.addRow("Test3", 14000); text3d.addRow("Test4", 16000); text3d.addRow("Test5", 18000); text3d.show(); PlayerText playerText = new PlayerText(player); playerText.addRow("Okay", 80000); playerText.addRow("Okay2", 80000); playerText.addRow("Okay3", 80000); playerText.addRow("Okay4", 80000); playerText.addRow("Okay5", 80000); playerText.addRow("Okay6", 80000); playerText.addRow("Okay7", 80000); playerText.addRow("Okay8", 80000); playerText.addRow("Okay9", 80000); playerText.addRow("Okay10", 80000); playerText.addRow("Okay11", 80000); playerText.show(); }
Shape CreateText3D(uint id) { Text3D text = new Text3D(string.Format("Hello {0}", id), id, new Tes.Maths.Vector3(id)); text.ScreenFacing = true; return(text); }
/// <summary>Gets a 3D representation of this text.</summary> public Text3D Get3D(float scale, Color colour, ref float left, ref float top) { // Create the 3D text object: Text3D text = new Text3D(); int tris; int verts; GetExtrudeCounts(out verts, out tris, scale); // Create the sets: text.Vertices = new Vector3[verts]; text.Triangles = new int[tris * 3]; text.UVs = new Vector2[verts]; text.Colours = new Color[verts]; text.Normals = new Vector3[verts]; for (int i = 0; i < verts; i++) { text.Colours[i] = colour; } // Get the tris/ verts now: GetExtrude(text, 0, 0, verts, tris, scale, ref left, ref top); text.CreateGameObject(); return(text); }
public void Convert(Entity entity, EntityManager dstManager, GameObjectConversionSystem conversionSystem) { ushort fontId = 0; if (FontData != null) { fontId = FontData.DataId; } //bool isNeedUpdate = Text != ""; var textComp = new Text3D { FontId = fontId, Text = Text, FontSize = FontSize, HAlignType = HAlignType, VAlignType = VAlignType, HSpacing = HSpacing, VSpacing = VSpacing, //IsNeedUpdate = isNeedUpdate }; dstManager.AddComponentData(entity, textComp); var buffer = dstManager.AddBuffer <Char3DElement>(entity); //UnityEngine.Debug.Log("UI3DIconTextAuthoring: " + entity); }
protected BaseDCIController(BaseDCIControllerInfo info) : base(info) { baseControllerInfo = info; plcCube = new Cube(Color.Wheat, 1.3f, 1.8f, 0.4f); door1 = new Cube(Color.Wheat, 0.62f, 1.585f, 0.25f); door2 = new Cube(Color.Wheat, 0.62f, 1.585f, 0.25f); plinth = new Cube(Color.DimGray, 1.32f, 0.1985f, 0.42f); Font f = new Font("Helvetica", 0.4f, FontStyle.Bold, GraphicsUnit.Pixel); DisplayText = new Text3D(Color.Red, 0.4f, 0.3f, f); DisplayText.Pitch = (float)Math.PI / 2; Add((RigidPart)DisplayText, new Vector3(-0.62f, 1.25f, -0.125f)); Add((RigidPart)plcCube, new Vector3(0, 0.45f, 0)); Add((RigidPart)door1, new Vector3(-0.325f, 0.5425f, -0.1f)); Add((RigidPart)door2, new Vector3(0.325f, 0.5425f, -0.1f)); Add((RigidPart)plinth, new Vector3(0, -0.355f, 0)); DisplayText.Text = info.name; OnNameChanged += CaseDatcom_OnNameChanged; ConfigureTelegramTemplate(); if (info.connectionID != 0) { ConnectionID = info.connectionID; } ackTimer.Elapsed += AckTimer_Elapsed; }
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(CoreAssets.Fonts.AnonymousPro, 60); //var font = new Font(); //var fontStream = Tools.Helpers.GetResourceStream("AideDeJeu.Pdf.Cinzel-Regular.otf"); //var memoryStream = new MemoryStream(); //fontStream.CopyTo(memoryStream); //memoryStream.Seek(0, SeekOrigin.Begin); //MemoryBuffer mb = new MemoryBuffer(memoryStream); //bool res = font.Load(mb); //text3D.SetFont(font, 60); text3D.TextEffect = TextEffect.Stroke; base.OnAttachedToNode(node); }
public void ValidateText3D(Shape shapeArg, Shape referenceArg, Dictionary <ulong, Resource> resources) { ShapeTestFramework.ValidateShape(shapeArg, referenceArg, resources); Text3D shape = (Text3D)shapeArg; Text3D reference = (Text3D)referenceArg; Assert.Equal(reference.Text, shape.Text); }
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); }
public TextComponent(Node parentNode) { textNode = parentNode.CreateChild(); textNode.Rotate(new Quaternion(0, 180, 0), TransformSpace.World); //textNode.Position = new Vector3(0, 10, 0); text3D = textNode.CreateComponent <Text3D>(); text3D.SetFont(CoreAssets.Fonts.AnonymousPro, 10); text3D.TextEffect = TextEffect.Stroke; }
/// <summary> /// Creates a 3D text in this dimension. /// </summary> /// <param name="text">The content of the 3D text</param> /// <param name="size">The size of the 3D text</param> /// <param name="pos">The position of the 3D text</param> /// <param name="rot">The rotation of the 3D text</param> /// <returns>The wrapped 3D text object</returns> public Text3D CreateText3D(string text, int size, Vector pos, Vector rot = null) { rot ??= Vector.Empty; Text3D text3d = _server.CreateText3D(Onset.CreateText3D(text, size, pos.X, pos.Y, pos.Z, rot.X, rot.Y, rot.Z)); text3d.InternalText = text; text3d.SetDimension(Value); return(text3d); }
private void UpdateText() { text.Dispose(); text = new Text3D(textInfo.textColor, Size, Depth, font); text.Pitch = (float)Math.PI / 2; text.Text = textInfo.theText; Add((RigidPart)text);//, new Microsoft.DirectX.Vector3(0, 0, 0)); //text.LocalPosition = new Microsoft.DirectX.Vector3((0.75f * Size), -0.447f, -Size * 0.8f); text.LocalPosition = new Microsoft.DirectX.Vector3(0, 0, 0); }
public virtual void Start() { if (NameTag != null) { nameTag = GameObject.Instantiate(NameTag, this.transform); nameTag.transform.localPosition = new Vector3(0, 2.1f, 0); nameTag.SetText(UserName); } Audiosource = this.GetComponent <AudioSource>(); }
public void SetTextString(Text3D text, string str) { try { Text3D_SetText(text.Handle, Encoding.UTF8.GetBytes(str)); } catch (Exception e) { text.Text = str; } }
void CreateFlag(string text, float x, float y) // Used to create Tex3D flags { Node flagNode = scene.CreateChild("Flag"); flagNode.Position = (new Vector3(x, y, 0.0f)); Text3D flag3D = flagNode.CreateComponent <Text3D>(); // We use Text3D in order to make the text affected by zoom (so that it sticks to 2D) flag3D.Text = text; var cache = ResourceCache; flag3D.SetFont(cache.GetFont("Fonts/Anonymous Pro.ttf"), 15); }
public TextLabel3D(TextLabel3DInfo info) : base(info) { textInfo = info as TextLabel3DInfo; font = new Font("Helvetica", 0.4f, FontStyle.Bold, GraphicsUnit.Pixel); text = new Text3D(info.textColor, 1.5f, Depth, font); text.Pitch = (float)Math.PI / 2; Add((RigidPart)text); //text.LocalPosition = new Microsoft.DirectX.Vector3(0.57f, -0.447f, -0.5f); text.LocalPosition = new Microsoft.DirectX.Vector3(0, 0, 0); Size = textInfo.size; text.Text = info.theText; }
public List<Text3D> AggregateData(Object PtID, Object EqID) { List<Text3D> infoList = new List<Text3D>(); foreach (String control in patient.getControls(PtID,EqID,thisConnection)) { Text3D info = new Text3D(); //info.Text = equipment.getText(EqID, control) + patient.getSetting(PtID, EqID, control); info.Text = equipment.getText(EqID, control, thisConnection) + patient.getSetting(PtID, EqID, control, thisConnection); info.Transform = equipment.getLocation(EqID, control, thisConnection); infoList.Add(info); } return infoList; }
public void OSCADObject_ClonesContainChildren() { var text = new Text3D("Hi").Rotate(90, 0, 0); var clone = text.Clone(); //Clone has a child, and it should be the same thing Assert.IsTrue(clone.Children().Count() == 1); Assert.IsTrue(clone.Children().FirstOrDefault().GetType() == text.Children().FirstOrDefault().GetType()); //But the child should be a different instance Assert.IsFalse(clone.Children().FirstOrDefault() == text.Children().FirstOrDefault()); }
public static void SetTextFix(this Text3D text, string str) { var helper = BaobaoGameContextFactory.Instance.TextStringHelper; if (helper != null) { helper.SetTextString(text, str); } else { text.Text = str; } }
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 DrawXAxisLabels() { /// Prepare transformation for transfroming label /// from one side to the other side. Transform3D transform = new RotateTransform3D() { Rotation = new AxisAngleRotation3D() { Axis = new Vector3D(1, 0, 0), Angle = 90 } }; var transformGroup = new Transform3DGroup(); transformGroup.Children.Add(transform); transform = new TranslateTransform3D() { OffsetX = 0, OffsetY = _length * 2 + 1, OffsetZ = 0 }; transformGroup.Children.Add(transform); foreach (var tick in _xAxisMayorTicks) { var mayorTickLabel = Text3D.CreateTextLabel3D(this.TicksProvider.GetLabelText(tick), Brushes.Black, true, 0.2, new Point3D(tick.AxisValue, 0, _length + 0.5), new Vector3D(0, 0, -1), new Vector3D(-1, 0, 0)); var ticklabelCln = mayorTickLabel.Clone(); ticklabelCln.Transform = transformGroup; mayorTickLabelGroup.Children.Add(mayorTickLabel); mayorTickLabelGroup.Children.Add(ticklabelCln); } var xTextModel = Text3D.CreateTextLabel3D("X Axis", Brushes.Black, true, 0.2, new Point3D(_length / 2, 0, _length + 1.5), new Vector3D(1, 0, 0), new Vector3D(0, 0, 1)); var xTextModel2 = Text3D.CreateTextLabel3D("X Axis", Brushes.Black, true, 0.2, new Point3D(_length / 2, _length + 1.5, 0), new Vector3D(-1, 0, 0), new Vector3D(0, -1, 0)); axisLabelGroup.Children.Add(xTextModel); axisLabelGroup.Children.Add(xTextModel2); }
private void DrawZAxisLabels() { Transform3D transform = new RotateTransform3D() { Rotation = new AxisAngleRotation3D() { Axis = new Vector3D(0, 0, 1), Angle = 90 } }; var transformGroup = new Transform3DGroup(); transformGroup.Children.Add(transform); transform = new TranslateTransform3D() { OffsetX = _length * 2 + 1, OffsetY = 0, OffsetZ = 0 }; transformGroup.Children.Add(transform); var zAxisMayTicks = this.TicksProvider.CreateMayorTicks(_zRange, _length); for (int i = 1; i < zAxisMayTicks.Length; i++) { var mayorTickLabel = Text3D.CreateTextLabel3D(this.TicksProvider.GetLabelText(zAxisMayTicks[i]), Brushes.Black, true, 0.2, new Point3D(0, _length + 0.5, zAxisMayTicks[i].AxisValue), new Vector3D(0, 1, 0), new Vector3D(0, 0, 1)); var ticklabelCln = mayorTickLabel.Clone(); ticklabelCln.Transform = transformGroup; mayorTickLabelGroup.Children.Add(mayorTickLabel); mayorTickLabelGroup.Children.Add(ticklabelCln); } var zTextModel = Text3D.CreateTextLabel3D("Z Axis", Brushes.Black, true, 0.2, new Point3D(0, _length + 1.5, _length / 2), new Vector3D(0, 0, 1), new Vector3D(0, -1, 0)); var zTextModel2 = Text3D.CreateTextLabel3D("Z Axis", Brushes.Black, true, 0.2, new Point3D(_length + 1.5, 0, _length / 2), new Vector3D(0, 0, 1), new Vector3D(1, 0, 0)); axisLabelGroup.Children.Add(zTextModel); axisLabelGroup.Children.Add(zTextModel2); }
private void AddFixPoints(string[] fixPointList, LoadDirection direction, float leftPosition, float rightPosition) { var color = direction == LoadDirection.Source ? Color.Red : Color.Blue; var fixPointType = direction == LoadDirection.Source ? FixPoint.Types.Start : FixPoint.Types.End; foreach (var fixPoint in fixPointList) { var localYaw = Trigonometry.PI(Trigonometry.Angle2Rad(90.0f)); var fixPointArray = fixPoint.Split(':'); var side = fixPointArray[0]; var name = fixPointArray.Length > 2 ? fixPointArray[2] : ""; var trackSide = string.Equals("R", side) ? rightPosition : leftPosition; if (string.Equals("R", side) && direction == LoadDirection.Source) { localYaw = Trigonometry.PI(Trigonometry.Angle2Rad(270.0f)); } if (string.Equals("L", side) && direction == LoadDirection.Destination) { localYaw = Trigonometry.PI(Trigonometry.Angle2Rad(270.0f)); } var trackPosition = TCarLength / 2 - 0.05f; // Default value to be replaced by TryParse var isFloat = float.TryParse(fixPointArray[1], System.Globalization.NumberStyles.AllowDecimalPoint, System.Globalization.CultureInfo.CreateSpecificCulture("en-GB"), out trackPosition); if (isFloat) { // Find out which fixpoint is the furthest furthestFixPoint = furthestFixPoint < trackPosition ? trackPosition : furthestFixPoint; DematicFixPoint fp = new DematicFixPoint(color, fixPointType, this); fp.Name = name; if (direction == LoadDirection.Source) { fp.OnSnapped += new FixPoint.SnappedEvent(SourceFixPoint_OnSnapped); fp.OnUnSnapped += new FixPoint.UnSnappedEvent(SourceFixPoint_OnUnSnapped); } else { fp.OnSnapped += new FixPoint.SnappedEvent(DestinationFixPoint_OnSnapped); fp.OnUnSnapped += new FixPoint.UnSnappedEvent(DestinationFixPoint_OnUnSnapped); } Add(fp); fp.LocalPosition = new Vector3(-trackPosition, 0, trackSide); fp.LocalYaw = localYaw; // Label Text3D label = new Text3D(Color.Yellow, 0.08f, 0.1f, new Font(FontFamily.GenericSansSerif, 1.0f)); label.Text = name; Add(label); label.LocalPosition = new Vector3(-trackPosition + 0.08f, 0, trackSide - 0.02f); label.Pitch = Trigonometry.PI(Trigonometry.Angle2Rad(90.0f)); } } }
bool ValidateText3D(Shape shape, Shape referenceShape, MessageHandler handler) { Text3D text3D = (Text3D)shape; Text3D text3DReference = (Text3D)referenceShape; bool ok = true; if (string.Compare(text3D.Text, text3DReference.Text) != 0) { Debug.LogError($"Text mismatch : {text3D.Text} != {text3DReference.Text}"); ok = false; } return(ok); }
public void OSCADObject_ChildrenWithRecursiveFalseReturnsOnlyDirectChildren() { var firstLevel = new Sphere().Union(new Cube(), new Sphere(), new Cylinder()); firstLevel.Name = "Union"; var secondLevel = new Text3D() { Name = "Text" }.Difference(firstLevel); var children = secondLevel.Children(false).ToList(); Assert.AreEqual("Text", children[0].Name); Assert.AreEqual("Union", children[1].Name); }
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(CoreAssets.Fonts.AnonymousPro, 60); text3D.TextEffect = TextEffect.Stroke; base.OnAttachedToNode(node); }
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); }
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); }
public Player(PlayerSettings p, int i) { if (p.name == null) name = "Player " + (i + 1); else name = p.name; nameTag = new Text3D(name, Font3D.getFont("arial"), null); if (p.avatar == null) avatar = Texture2D.FromStream(Program.game.GraphicsDevice, System.IO.File.OpenRead("default.png")); else avatar = p.avatar; cam = new Camera(new Vector3(0.7f, i == 1 ? 0 : MathHelper.Pi, 0), 80, Vector3.Zero, Vector3.Up); selection = new Vector(0, i == 1 ? 0 : 7); index = i; }
public MenuItem(String s, Menu m) { text = new Text3D(s, m.font, m.cam); position = new Vector3(text.getWidth() / -2, -10 * m.items.Count, 0); spin = 0; }
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.None; //textNode.LookAt() //Look at camera base.OnAttachedToNode(node); }
/// <summary>Get the verts/ tris/ uv of this in 3D.</summary> public void GetExtrude(Text3D text,int vertIndex,int triIndex,int vertCount,int triCount,float scale,ref float left,ref float top){ // What's the curve accuracy? float accuracy=TextExtrude.CurveAccuracy; if(Characters==null){ return; } // Create a triangulator - it will "select" a letter one at a time: Triangulator triangulator=new Triangulator(text.Vertices,0,0); triangulator.Clockwise=TextExtrude.Inverse; for(int c=0;c<Characters.Length;c++){ Glyph character=Characters[c]; if(character==null || character.Space){ continue; } if(character.Width==0f){ character.RecalculateMeta(); } if(Kerning!=null){ left+=Kerning[c] * FontSize; } int frontIndex=vertIndex; // The set of first nodes - these essentially identify where contours start. 0 is always present if there is at least one contour. List<int> firstNodes=new List<int>(); // Compute the vertices: character.GetVertices(text.Vertices,text.Normals,accuracy,left,-top,scale,ref vertIndex,firstNodes); // Duplicate and offset: int count=vertIndex-frontIndex; if(count==0){ // Ignore continue; } // Future note: // - VectorPath.HoleSort seems to sort letters like i too. // - This results in a count of 1 (we're expecting 2) // - For each contour (foreach firstNodes), triangulate individually. // - Ensure the triangle count matches too. May need to move firstNodes set. // Select these verts in the triangulator: triangulator.Select(frontIndex,count); // Dupe the verts: for(int v=0;v<count;v++){ Vector3 vert=text.Vertices[frontIndex+v]; vert.z=Extrude; text.Vertices[vertIndex+v]=vert; text.Normals[vertIndex+v]=new Vector3(0f,0f,1f); text.Normals[frontIndex+v]=new Vector3(0f,0f,-1f); } // How many tri's in this char? (single face only) int charTris=count-2; // Perform triangulation of the front face: triangulator.Triangulate(text.Triangles,charTris,triIndex); // Seek: int triIndexCount=charTris*3; triIndex+=triIndexCount; // Duplicate the results for the back face and invert them: for(int t=0;t<charTris;t++){ text.Triangles[triIndex]=count+text.Triangles[triIndex-triIndexCount]; triIndex++; // Last two are inverted as the back face looks the other way: text.Triangles[triIndex]=count+text.Triangles[triIndex-triIndexCount+1]; triIndex++; text.Triangles[triIndex]=count+text.Triangles[triIndex-triIndexCount-1]; triIndex++; } // Time for the sides! // How many contours? int contourCount=firstNodes.Count; // Get the current first: int currentFirst=firstNodes[0]; int contourIndex=1; // Get the "next" first: int nextFirst; if(contourCount>1){ nextFirst=firstNodes[1]; }else{ nextFirst=-1; } // Get the back face vertex indices: int backIndex=vertIndex; // For each edge.. for(int i=0;i<count;i++){ // Get the next index: int next=i+1; if(next==count || next==nextFirst){ // Loop back instead: next=currentFirst; // Advance to the next one: currentFirst=nextFirst; contourIndex++; // Update nextFirst too: if(contourIndex<contourCount){ nextFirst=firstNodes[contourIndex]; }else{ nextFirst=-1; } } // Add two triangles from front face -> back face: text.Triangles[triIndex]=frontIndex+i; triIndex++; text.Triangles[triIndex]=backIndex+i; triIndex++; text.Triangles[triIndex]=backIndex+next; triIndex++; text.Triangles[triIndex]=frontIndex+next; triIndex++; text.Triangles[triIndex]=frontIndex+i; triIndex++; text.Triangles[triIndex]=backIndex+next; triIndex++; } // Seek vert index over the backface: vertIndex+=count; // Move left along: left+=(character.AdvanceWidth * FontSize)+LetterSpacing; } }
/// <summary>Gets a 3D representation of this text.</summary> public Text3D Get3D(float scale,Color colour,ref float left,ref float top){ // Create the 3D text object: Text3D text=new Text3D(); int tris; int verts; GetExtrudeCounts(out verts,out tris,scale); // Create the sets: text.Vertices=new Vector3[verts]; text.Triangles=new int[tris * 3]; text.UVs=new Vector2[verts]; text.Colours=new Color[verts]; text.Normals=new Vector3[verts]; for(int i=0;i<verts;i++){ text.Colours[i]=colour; } // Get the tris/ verts now: GetExtrude(text,0,0,verts,tris,scale,ref left,ref top); text.CreateGameObject(); return text; }