public StateKey(EllipsoidalGlobe ellipsoidalGlobe) { this.globe = ellipsoidalGlobe; this._tessellator = ellipsoidalGlobe._tessellator; this.verticalExaggeration = 1; this.elevationModel = this.globe.getElevationModel(); }
public virtual void Draw(Tessellator par1Tessellator, float par2) { Vec3D vec3d = VertexPositions[1].Vector3D.Subtract(VertexPositions[0].Vector3D); Vec3D vec3d1 = VertexPositions[1].Vector3D.Subtract(VertexPositions[2].Vector3D); Vec3D vec3d2 = vec3d1.CrossProduct(vec3d).Normalize(); par1Tessellator.StartDrawingQuads(); if (InvertNormal) { par1Tessellator.SetNormal(-(float)vec3d2.XCoord, -(float)vec3d2.YCoord, -(float)vec3d2.ZCoord); } else { par1Tessellator.SetNormal((float)vec3d2.XCoord, (float)vec3d2.YCoord, (float)vec3d2.ZCoord); } for (int i = 0; i < 4; i++) { PositionTextureVertex positiontexturevertex = VertexPositions[i]; par1Tessellator.AddVertexWithUV((float)positiontexturevertex.Vector3D.XCoord * par2, (float)positiontexturevertex.Vector3D.YCoord * par2, (float)positiontexturevertex.Vector3D.ZCoord * par2, positiontexturevertex.TexturePositionX, positiontexturevertex.TexturePositionY); } par1Tessellator.Draw(); }
/// <summary> /// Draw the six sided box defined by this ModelBox /// </summary> public virtual void Render(Tessellator par1Tessellator, float par2) { for (int i = 0; i < QuadList.Length; i++) { QuadList[i].Draw(par1Tessellator, par2); } }
void Triangulate(Vector3 normal, List <Vector3> points) { if (points.Count == 3) { Facet facet = new Facet { Normal = normal, Vx1 = points[0], Vx2 = points[1], Vx3 = points[2] }; Model.Facets.Add(facet); } else { Vector3 up = Vector3.Subtract(points[0], points[1]).Normalized(); Matrix4 mt = Matrix4.LookAt(normal, Vector3.Zero, up); var projected = points.Select(x => Vector3.TransformPosition(x, mt)); List <float> data = projected.SelectMany(pt => new float[] { pt.X, pt.Y }).ToList(); IList <int> triangles = Tessellator.Tessellate(data); for (int i = 0; i < triangles.Count; i += 3) { Facet facet = new Facet { Normal = normal, Vx1 = points[triangles[i]], Vx2 = points[triangles[i + 1]], Vx3 = points[triangles[i + 2]] }; Model.Facets.Add(facet); } } }
/// <summary> /// Creates the triangles for all of the tiles. /// </summary> /// <param name="tiles">The tiles to tessellate.</param> /// <param name="tessellator">The tessellator used to draw the mesh.</param> protected override void RebuildMesh(Tile[] tiles, Tessellator tessellator) { foreach (Tile tile in tiles) { tessellator.Tessellate2D(tile.transform.localPosition, Tile.OUTER_RADIUS, tile.type.color); } }
/** * Draw this primitve. This is typically called only once as the generated drawing instructions are saved by the * renderer and reused later. */ public void draw(VertexBuffer renderer, float scale) { Vec3d vec3d = this.vertexPositions[1].vector3D.subtractReverse(this.vertexPositions[0].vector3D); Vec3d vec3d1 = this.vertexPositions[1].vector3D.subtractReverse(this.vertexPositions[2].vector3D); Vec3d vec3d2 = vec3d1.crossProduct(vec3d).normalize(); float f = (float)vec3d2.xCoord; float f1 = (float)vec3d2.yCoord; float f2 = (float)vec3d2.zCoord; if (this.invertNormal) { f = -f; f1 = -f1; f2 = -f2; } renderer.begin(7, DefaultVertexFormats.OLDMODEL_POSITION_TEX_NORMAL); for (int i = 0; i < 4; ++i) { PositionTextureVertex positiontexturevertex = this.vertexPositions[i]; renderer.pos(positiontexturevertex.vector3D.xCoord * (double)scale, positiontexturevertex.vector3D.yCoord * (double)scale, positiontexturevertex.vector3D.zCoord * (double)scale).tex((double)positiontexturevertex.texturePositionX, (double)positiontexturevertex.texturePositionY).normal(f, f1, f2).endVertex(); } Tessellator.getInstance().draw(); }
/// <summary> /// Creates the triangles for all of the tiles. /// </summary> /// <param name="tileRanges">The tile ranges to tessellate.</param> /// <param name="tessellator">The tessellator used to draw the mesh.</param> protected override void RebuildMesh(TileBorder[] tileRanges, Tessellator tessellator) { foreach (TileBorder tile in tileRanges) { tessellator.Tessellate2D(tile.coordinates.position, Tile.OUTER_RADIUS + 2f, 2f, tile.edge, World.selectedUnit.type.color); } }
/// <summary> /// Rebuilds the unit mehs with the given units. /// </summary> /// <param name="units">The units to include in this mesh.</param> /// <param name="tessellator">The tessellator used to draw the mesh.</param> protected override void RebuildMesh(Unit[] units, Tessellator tessellator) { foreach (Unit unit in units) { Color color = unit.type.isMilitary ? unit.faction.primaryColor : unit.faction.secondaryColor; tessellator.Tessellate3D(transform.position + unit.position, Unit.OUTER_RADIUS, Unit.HEIGHT, color); } }
protected override void DrawSlot(int par1, int par2, int par3, int par4, Tessellator par5Tessellator) { StatBase statbase = (StatBase)StatList.GeneralStats[par1]; Field_27276_a.DrawString(GuiStats.GetFontRenderer(Field_27276_a), StatCollector.TranslateToLocal(statbase.GetName()), par2 + 2, par3 + 1, par1 % 2 != 0 ? 0x909090 : 0xffffff); string s = statbase.Func_27084_a(GuiStats.GetStatsFileWriter(Field_27276_a).WriteStat(statbase)); Field_27276_a.DrawString(GuiStats.GetFontRenderer(Field_27276_a), s, (par2 + 2 + 213) - (int)GuiStats.GetFontRenderer(Field_27276_a).GetStringWidth(s), par3 + 1, par1 % 2 != 0 ? 0x909090 : 0xffffff); }
/** * Create a new globe, and set the position of the globe's center. The globe will be tessellated using tessellator * defined by the {@link AVKey#TESSELLATOR_CLASS_NAME} configuration parameter. * * @param equatorialRadius Radius of the globe at the equator. * @param polarRadius Radius of the globe at the poles. * @param es Square of the globe's eccentricity. * @param em Elevation model. May be null. * @param center Cartesian coordinates of the globe's center point. */ public EllipsoidalGlobe(double equatorialRadius, double polarRadius, double es, ElevationModel em, Vec4 center) { this.equatorialRadius = equatorialRadius; this.polarRadius = polarRadius; this.es = es; // assume it's consistent with the two radii this.center = center; this._elevationModel = em; this._tessellator = (Tessellator)WorldWind.createConfigurationComponent(AVKey.TESSELLATOR_CLASS_NAME); }
// // Unity Hooks // public void Awake() { // create the mesh GetComponent <MeshFilter>().mesh = (mesh = new Mesh()); mesh.name = meshName; // add the collider meshCollider = gameObject.AddComponent <MeshCollider>(); // create our tessellator tessellator = new Tessellator(mesh); }
public StateKey(DrawContext dc, EllipsoidalGlobe ellipsoidalGlobe) { if (dc == null) { string msg = Logging.getMessage("nullValue.DrawContextIsNull"); Logging.logger().severe(msg); throw new ArgumentException(msg); } this.globe = dc.getGlobe(); this._tessellator = ellipsoidalGlobe._tessellator; this.verticalExaggeration = dc.getVerticalExaggeration(); this.elevationModel = this.globe.getElevationModel(); }
/** * Compiles a GL display list for this model */ private void compileDisplayList(float scale) { this.displayList = GLAllocation.generateDisplayLists(1); GlStateManager.glNewList(this.displayList, 4864); VertexBuffer vertexbuffer = Tessellator.getInstance().getBuffer(); for (int i = 0; i < this.cubeList.size(); ++i) { ((ModelBox)this.cubeList.get(i)).render(vertexbuffer, scale); } GlStateManager.glEndList(); this.compiled = true; }
private void Awake() { lineRenderer.positionCount = vertices.Count; for (int i = 0; i < vertices.Count; i++) { lineRenderer.SetPosition(i, vertices[i]); } var tessellator = new Tessellator(); tessellator.AddContour(vertices); tessellator.Tessellate(normal: Vector3.back); meshFilter.mesh = tessellator.ToMesh(); }
public unsafe void PopulateCharColorData(CharInfo ci, IFontProvider font) { ColorF charRGB = ColorF.Init; ColorF[] lumaRGB = new ColorF[LumaComponentCount]; int[] pixelCounts = new int[LumaComponentCount]; for (int i = 0; i < LumaComponentCount; ++i) { lumaRGB[i] = ColorF.Init; pixelCounts[i] = 0; } for (int py = 0; py < font.CharSizeNoPadding.Height; ++py) { for (int px = 0; px < font.CharSizeNoPadding.Width; ++px) { ColorF pc = font.GetPixel(ci.srcIndex, px, py); charRGB = charRGB.Add(pc); int lumaIdx = Tessellator.GetLumaTileIndexOfPixelPosInCell(px, py, font.CharSizeNoPadding); lumaRGB[lumaIdx] = lumaRGB[lumaIdx].Add(pc); pixelCounts[lumaIdx]++; } } for (int i = 0; i < LumaComponentCount; ++i) { var pc = pixelCounts[i]; var lc = lumaRGB[i]; if (pixelCounts[i] < 1) { throw new Exception("!!!!!! Your fonts are just too small; i can't sample them properly."); } lc = lc.Div(pc); LCCColorDenorm lccc = Colorspace.RGBToLCC(lc); ci.actualValues.DenormalizedValues[i] = (float)lccc.L; ci.actualValues.NormalizedValues[i] = (float)Colorspace.NormalizeL(ci.actualValues.DenormalizedValues[i]); } if (UseChroma) { charRGB = charRGB.Div(Utils.Product(font.CharSizeNoPadding)); LCCColorDenorm charLAB = Colorspace.RGBToLCC(charRGB); ci.actualValues.DenormalizedValues[GetValueC1Index()] = (float)charLAB.C1; ci.actualValues.DenormalizedValues[GetValueC2Index()] = (float)charLAB.C2; ci.actualValues.NormalizedValues[GetValueC1Index()] = (float)Colorspace.NormalizeC1(ci.actualValues.DenormalizedValues[GetValueC1Index()]); ci.actualValues.NormalizedValues[GetValueC2Index()] = (float)Colorspace.NormalizeC2(ci.actualValues.DenormalizedValues[GetValueC2Index()]); } }
public SectorGeometryList tessellate(DrawContext dc) { if (_tessellator == null) { _tessellator = (Tessellator)WorldWind.createConfigurationComponent(AVKey.TESSELLATOR_CLASS_NAME); if (_tessellator == null) { string message = Logging.getMessage("Tessellator.TessellatorUnavailable"); Logging.logger().severe(message); throw new IllegalStateException(message); } } return(_tessellator.tessellate(dc)); }
public override void RenderParticle(Tessellator par1Tessellator, float par2, float par3, float par4, float par5, float par6, float par7) { float f = (((float)ParticleAge + par2) / (float)ParticleMaxAge) * 32F; if (f < 0.0F) { f = 0.0F; } if (f > 1.0F) { f = 1.0F; } ParticleScale = ParticleScaleOverTime * f; base.RenderParticle(par1Tessellator, par2, par3, par4, par5, par6, par7); }
/* * for analyzing an image, we don't want to sample every single pixel. but we * also don't want to only sample once per tile. since conceptually each * outer tile is supposed to cover multiple important regions, sample those * regions and average. */ public int GetMapIndexOfRegion(Bitmap img, int x, int y, Size sz) { ColorF charRGB = ColorF.Init; ColorF[] lumaRGB = new ColorF[LumaComponentCount]; int[] pixelCounts = new int[LumaComponentCount]; for (int i = 0; i < LumaComponentCount; ++i) { lumaRGB[i] = ColorF.Init; pixelCounts[i] = 0; } float[] vals = new float[DimensionCount]; for (int py = 0; py < sz.Height; ++py) { for (int px = 0; px < sz.Width; ++px) { ColorF pc = ColorF.From(img.GetPixel(x + px, y + py)); charRGB = charRGB.Add(pc); int lumaIdx = Tessellator.GetLumaTileIndexOfPixelPosInCell(px, py, sz); lumaRGB[lumaIdx] = lumaRGB[lumaIdx].Add(pc); pixelCounts[lumaIdx]++; } } for (int i = 0; i < LumaComponentCount; ++i) { ColorF lc = lumaRGB[i].Div(pixelCounts[i]); LCCColorNorm lccc = RGBToNormalizedLCC(lc); vals[i] = (float)lccc.L; } if (UseChroma) { charRGB = charRGB.Div(Utils.Product(sz)); LCCColorNorm charLAB = RGBToNormalizedLCC(charRGB); vals[GetValueC1Index()] = (float)charLAB.C1; vals[GetValueC2Index()] = (float)charLAB.C2; } int ID = NormalizedValueSetToMapID(vals); return(ID); }
public override MeshDraft Construct(Vector2 parentLayoutOrigin) { var roofDraft = ConstructRoofBase(out List <Vector2> roofPolygon2, out List <Vector3> roofPolygon3); var tessellator = new Tessellator(); tessellator.AddContour(roofPolygon3); tessellator.Tessellate(normal: Vector3.up); var roofTop = tessellator.ToMeshDraft() .Move(Vector3.up * roofConfig.thickness); for (var i = 0; i < roofTop.vertexCount; i++) { roofTop.normals.Add(Vector3.up); } return(roofDraft.Add(roofTop) .Paint(roofColor)); }
public override void RenderParticle(Tessellator par1Tessellator, float par2, float par3, float par4, float par5, float par6, float par7) { float f = ((float)(GetParticleTextureIndex() % 16) + ParticleTextureJitterX / 4F) / 16F; float f1 = f + 0.01560938F; float f2 = ((float)(GetParticleTextureIndex() / 16) + ParticleTextureJitterY / 4F) / 16F; float f3 = f2 + 0.01560938F; float f4 = 0.1F * ParticleScale; float f5 = (float)((PrevPosX + (PosX - PrevPosX) * (double)par2) - InterpPosX); float f6 = (float)((PrevPosY + (PosY - PrevPosY) * (double)par2) - InterpPosY); float f7 = (float)((PrevPosZ + (PosZ - PrevPosZ) * (double)par2) - InterpPosZ); float f8 = 1.0F; par1Tessellator.SetColorOpaque_F(f8 * ParticleRed, f8 * ParticleGreen, f8 * ParticleBlue); par1Tessellator.AddVertexWithUV(f5 - par3 * f4 - par6 * f4, f6 - par4 * f4, f7 - par5 * f4 - par7 * f4, f, f3); par1Tessellator.AddVertexWithUV((f5 - par3 * f4) + par6 * f4, f6 + par4 * f4, (f7 - par5 * f4) + par7 * f4, f, f2); par1Tessellator.AddVertexWithUV(f5 + par3 * f4 + par6 * f4, f6 + par4 * f4, f7 + par5 * f4 + par7 * f4, f1, f2); par1Tessellator.AddVertexWithUV((f5 + par3 * f4) - par6 * f4, f6 - par4 * f4, (f7 + par5 * f4) - par7 * f4, f1, f3); }
protected override void OnLoad(EventArgs e) { GL.ClearColor(0.2f, 0.3f, 0.3f, 1.0f); WindowState = WindowState.Maximized; GL.Viewport(ClientRectangle); GL.Enable(EnableCap.Blend); GL.BlendFunc(BlendingFactor.SrcAlpha, BlendingFactor.OneMinusSrcAlpha); _shader = new Shader("assets/shaders/sprite/vertex.glsl", "assets/shaders/sprite/fragment.glsl"); _shader.SetInt("image", 0); // _shader.SetMatrix4("matrix", Matrix4.Identity); _shader.SetMatrix4("matrix", Matrix4.CreateTranslation(500, 500, 0)); //_shader.SetMatrix4("projection",Matrix4.CreateOrthographicOffCenter(0, 800, 600, 0, -1, 1)); _shader.Use(); //_texture = new Texture2D("Resources/container.png"); _texture = new Texture2D("assets/sprites/sheet.png"); _texture.Use(); var tesselactor = new Tessellator(_texture); var dirt = new Rectangle(32, 0, 32, 32); for (var z = 0; z < 10; z++) { for (var x = 0; x < 10; x++) { for (int y = 0; y < 10; y++) { var ax = x * 16.0f; var ay = y * 16.0f; var aax = ax - ay; var aay = (ax + ay) / 2; tesselactor.Draw(new Vector3(aax, aay - (z * 16.0f), 0), dirt, Color.White); } } } // _buffer = tesselactor.GenerateBuffer(); base.OnLoad(e); }
protected override void RebuildMesh( Province[] provinces, Tessellator tessellator ) { foreach ( Province province in provinces ) { foreach ( Tile t in province.property ) { for ( int i = 0; i < t.neighbors.Length; i++ ) { Tile neighbor = t.neighbors[ i ]; // don't draw a border here // if the tile doesn't exist OR the tile isn't owned by this faction // (the faction border will be drawn here) // OR if the tile is still owned by this province if ( neighbor == null || neighbor.faction != province.faction || neighbor.province == province ) continue; // draw the province's border in black to set it off from other province territories tessellator.Tessellate2D( t.coordinates.position, Tile.OUTER_RADIUS + 0.5f, 0.5f, ( TileEdge ) i, province.faction.secondaryColor ); } } } }
protected static MeshDraft ConstructContourDraft(List <Vector2> skeletonPolygon2, float roofPitch) { Vector2 edgeA = skeletonPolygon2[0]; Vector2 edgeB = skeletonPolygon2[1]; Vector2 edgeDirection2 = (edgeB - edgeA).normalized; Vector3 roofNormal = CalculateRoofNormal(edgeDirection2, roofPitch); var skeletonPolygon3 = skeletonPolygon2.ConvertAll(v => v.ToVector3XZ()); var tessellator = new Tessellator(); tessellator.AddContour(skeletonPolygon3); tessellator.Tessellate(normal: Vector3.up); var contourDraft = tessellator.ToMeshDraft(); for (var i = 0; i < contourDraft.vertexCount; i++) { Vector2 vertex = contourDraft.vertices[i].ToVector2XZ(); float height = CalculateVertexHeight(vertex, edgeA, edgeDirection2, roofPitch); contourDraft.vertices[i] = new Vector3(vertex.x, height, vertex.y); contourDraft.normals.Add(roofNormal); } return(contourDraft); }
protected override void RebuildMesh(Faction[] factions, Tessellator tessellator) { // find and draw the borders of each faction foreach (Faction faction in factions) { // find the borders and draw the lines foreach (Tile t in faction.tiles) { for (int i = 0; i < t.neighbors.Length; i++) { Tile neighbor = t.neighbors[i]; // if the tile exists AND is owned by this faction, skip it if (neighbor != null && neighbor.faction == faction) { continue; } // this is a border edge, draw it now! tessellator.Tessellate2D(t.coordinates.position, Tile.OUTER_RADIUS + 2f, 2f, ( TileEdge )i, faction.primaryColor); } } } }
public BlockTessellator() { _tessellator = new Tessellator(); }
public override void RenderParticle(Tessellator tessellator, float f, float f1, float f2, float f3, float f4, float f5) { }
/// <summary> /// Rebuilds the mesh for the list of entities and with the given tessellator. /// /// This is called by the Rebuild method which handles the cleanup and updating /// of the mesh. /// </summary> /// <param name="entities">The entities to include in this mesh.</param> /// <param name="tessellator">The tessellator to use to create the mesh.</param> protected abstract void RebuildMesh(T[] entities, Tessellator tessellator);
public void setTessellator(Tessellator tessellator) { this._tessellator = tessellator; }