public override void Render(RenderingContext rc) { base.Render(rc); }
public override void PreRenderOnce(RenderingContext rc) { base.PreRenderOnce(rc); }
public void UnbindTextures(RenderingContext rc) { var stringTexture = stringTextures.First(); stringTexture.Value.Unbind(); }
public override void CollectGeometry( RenderingContext rc, out GeometryHandle handle, out BoundingBox bbox, out bool coloring, out bool texturing) { handle = GeometryHandle.Zero; bbox = BoundingBox.Zero; coloring = false; texturing = true; int line = 0; float newLinePositionY; List <Vertex> geometry = new List <Vertex>(); Vertex v; fontStyle = this.FontStyle; float z = 0f; float h = 0.5f; string combined = string.Empty; if (this._strings.Count == 0) { this._strings.Add("Abc"); } ForeColor = System.Drawing.Color.FromArgb(255, 255, 255, 255); ForeColor = System.Drawing.Color.Cyan; BackColor = System.Drawing.Color.FromArgb(0, 0, 0, 0); _start_position = new Vector3(0f, 0.5f, z); string family; float size; foreach (string text in this._strings) { family = FontStyle.Family.First(); family = string.IsNullOrEmpty(family) ? "Times New Roman" : family; size = FontStyle.size * 10; Font = new Font(family, size); newLinePositionY = (line * 0.5f); float scale = 0.01f; if (line == 0) { v = new Vertex() { Position = new Vector3(0f, 0f + newLinePositionY, z) * scale, TexCoord = new Vector2(0f, 1f) }; geometry.Add(v); v = new Vertex() { Position = new Vector3(1.0f, 0f + newLinePositionY, z) * scale, TexCoord = new Vector2(1f, 1f) }; geometry.Add(v); v = new Vertex() { Position = new Vector3(1.0f, h + newLinePositionY, z) * scale, TexCoord = new Vector2(1f, 0f) }; geometry.Add(v); v = new Vertex() { Position = new Vector3(0f, h + newLinePositionY, z) * scale, TexCoord = new Vector2(0f, 0f) }; geometry.Add(v); } combined += text + (line < this._strings.Count ? "\n" : ""); line++; } _combined_text = combined; UpdateString(combined, out bbox); Buffering.BufferShaderGeometry(geometry, out handle.vbo4, out handle.NumVerticies4); }
private Matrix4 calculateModelview( Shape transform_context, RenderingContext rc ) { Matrix4 MVP; Matrix4 model; // applied transformation hierarchy Matrix4 cameraRot; MVP = Matrix4.Identity; List <Transform> transformationHierarchy = transform_context .AscendantByType <Transform>() .Select(t => (Transform)t) .Where(t => t.Hidden == false) .ToList(); Matrix4 modelview = Matrix4.Identity * rc.matricies.worldview; Vector3 x3dScale = new Vector3(0.06f, 0.06f, 0.06f); Quaternion modelrotation = Quaternion.Identity; Matrix4 modelLocalRotation = Matrix4.Identity; Matrix4 localTranslations = Matrix4.Identity; Vector3 transAccum = Vector3.Zero; foreach (Transform transform in transformationHierarchy) { transAccum += transform.Translation; //localTranslations *= Matrix4.CreateTranslation(transform.Translation * x3dScale); localTranslations = SceneEntity.ApplyX3DTransform(Vector3.Zero, Vector3.Zero, Vector3.One, Vector3.Zero, transform.Translation * x3dScale, localTranslations); modelview *= localTranslations; } //Vector3 p = Vector3.Zero; //Vector3 p = transform_context.GetPosition(rc); //Vector3 p2 = localTranslations.ExtractTranslation(); //Vector3 origin = Vector3.Zero; //float dist = Vector3.Dot(origin, p2); //var p = p2 - new Vector3(dist); //Center = (new Vector3(((Width - p.X) / 2f), ( (Height-p.Y) / 2f), ((Depth - p.Z) / 2f) ) * x3dScale); //var Center2 = (new Vector3(((Width) / 2f), ((Height) / 2f), ((Depth) / 2f)) * x3dScale); //var top = (new Vector3((Width - p.X), (Height - p.Y) , (Depth - p.Z))) * x3dScale; //var left = Center + ((new Vector3(0, 0, Depth) * x3dScale)); //var top = (new Vector3(Width - (Width / 2), Height, Depth)) * x3dScale; //localTranslations = Matrix4.Identity; //Position = (localTranslations.ExtractTranslation()); //Quaternion qlocal = QuaternionExtensions.EulerToQuat(0, MathHelpers.PI, 0); //modelLocalRotation = Matrix4.CreateFromQuaternion(qlocal); //modelview = Matrix4.CreateTranslation(Position); //float distZ = Math.Abs(Maximum.Z) - Math.Abs(Minimum.Z); Vector3 center = new Vector3(Width / 2.0f, Height / 2.0f, Depth / 2.0f); Vector3 translation = new Vector3( //(((Minimum.X + (Maximum.X / 2.0f)) / 2.0f) ), //(((Minimum.Y + (Maximum.Y / 2.0f)) / 2.0f)), //(((Minimum.Z + (Maximum.Z / 2.0f)) / 2.0f)) //((((Maximum.X) - (((Width) / 2.0f)) + (Maximum.X )) / 2.0f)), //((((Maximum.Y) - (((Height ) / 2.0f)) + (Maximum.Y )) / 2.0f) ), //((((Maximum.Z) - (((Depth) / 2.0f)) + (Maximum.Z)) / 2.0f) ) //(Minimum.X) + (Width / 2.0f), //(Minimum.Y) + (Height / 2.0f), //(Minimum.Z) + (Depth / 2.0f) (Maximum.X) + (Width / 2.0f), (Maximum.Y) + (Height / 2.0f), (Maximum.Z) + (Depth / 2.0f) ); modelview = SceneEntity.ApplyX3DTransform( Vector3.Zero, Vector3.Zero, Vector3.One, Vector3.Zero, (translation) * x3dScale, Matrix4.Identity); model = modelview; Matrix4 cameraTransl = Matrix4.CreateTranslation(rc.cam.Position); cameraRot = Matrix4.CreateFromQuaternion(rc.cam.Orientation); // cameraRot = MathHelpers.CreateRotation(ref q); MVP = ((model) * cameraTransl) * cameraRot; //Matrix4 translation = Matrix4.CreateTranslation(left); //Matrix4 scale = Matrix4.CreateScale(1.0f, 1.0f, 1.0f); //Matrix4 rotationX = Matrix4.CreateRotationX(0.0f); // MathHelpers.PI //Matrix4 rotationY = Matrix4.CreateRotationY(0.0f); //Matrix4 rotationZ = Matrix4.CreateRotationZ(0.0f); //Matrix4 _model = scale * translation * (rotationX * rotationY * rotationZ); //MVP = (_model * cameraTransl )* cameraRot; return(MVP); }