public void Show() { GL.EnableClientState(ArrayCap.VertexArray); GL.EnableClientState(ArrayCap.NormalArray); GL.EnableClientState(ArrayCap.TextureCoordArray); GL.ClientActiveTexture(TextureUnit.Texture0); GL.BindBuffer(BufferTarget.ArrayBuffer, IdVertexBuffer); GL.BindBuffer(BufferTarget.ElementArrayBuffer, IdIndexBuffer); GL.EnableVertexAttribArray(0); GL.VertexAttribPointer(0, 3, VertexAttribPointerType.Float, false, ModelPoint.Size(), ModelPoint.CoordinatesOffset()); GL.NormalPointer(NormalPointerType.Float, ModelPoint.Size(), ModelPoint.NormalsOffset()); GL.TexCoordPointer(2, TexCoordPointerType.Float, ModelPoint.Size(), ModelPoint.TexCoordsOffset()); switch (OutputMode) { case OutputMode.Triangles: GL.DrawElements(PrimitiveType.Triangles, indices.Length, DrawElementsType.UnsignedShort, 0); break; case OutputMode.Lines: GL.DrawElements(PrimitiveType.Lines, indices.Length, DrawElementsType.UnsignedShort, 0); break; default: GL.DrawElements(PrimitiveType.Triangles, indices.Length, DrawElementsType.UnsignedShort, 0); break; } GL.DisableClientState(ArrayCap.VertexArray); GL.DisableClientState(ArrayCap.NormalArray); GL.DisableClientState(ArrayCap.TextureCoordArray); }
public void BasicMPL_LifetimeTest() { ModelPoint endPoint = new ModelPoint(lifetime, 0.0f); bool status = (endPoint == basicList[1]) && (endPoint == basicList.End); Assert.IsTrue(status); }
public void BasicMPL_InitStrengthTest() { ModelPoint startPoint = new ModelPoint(0.0f, initStrength); bool status = (startPoint == basicList[0]) && (startPoint == basicList.Start); Assert.IsTrue(status); }
public bool AddToList(ModelPoint point) { ModelPointList pointList = new ModelPointList(initStrength, lifetime); bool status = pointList.Add(point); return(status); }
protected List <ModelPoint> InitializeModelPoints(CoverageModel model) { List <ModelPoint> modelPoints = new List <ModelPoint>(); double[] mu = GetProjectedMeanCoverage(model.DiploidCoverage); // Refine our estimate of diploid MAF: //double diploidMAF = this.EstimateDiploidMAF(2, model.DiploidCoverage); ///////////////////////////////////////////// // Update the parameters in each SegmentPloidy object, and construct corresponding SegmentInfo objects foreach (SegmentPloidy ploidy in _allPloidies) { ModelPoint point = new ModelPoint(); double pureCoverage = mu[ploidy.CopyNumber]; point.Coverage = pureCoverage; double pureMaf = ploidy.MinorAlleleFrequency; point.Maf = pureMaf; if (double.IsNaN(point.Maf)) { point.Maf = 0; } point.Ploidy = ploidy; modelPoints.Add(point); point.CopyNumber = ploidy.CopyNumber; ploidy.MixedMinorAlleleFrequency = point.Maf; ploidy.MixedCoverage = point.Coverage; } return(modelPoints); }
public void MPL_AddPointTest() { ModelPointList pointList = new ModelPointList(initStrength, lifetime); ModelPoint mp = new ModelPoint(2.0f, 3.5f); bool status = pointList.Add(mp); Assert.IsTrue(status && mp == pointList[1]); }
private void InitializeVBO() { IdVertexBuffer = GL.GenBuffer(); IdIndexBuffer = GL.GenBuffer(); GL.BindBuffer(BufferTarget.ArrayBuffer, IdVertexBuffer); GL.BufferData(BufferTarget.ArrayBuffer, (IntPtr)(points.Length * ModelPoint.Size()), points, BufferUsageHint.StaticDraw); GL.BindBuffer(BufferTarget.ElementArrayBuffer, IdIndexBuffer); GL.EnableVertexAttribArray(0); GL.VertexAttribPointer(0, 3, VertexAttribPointerType.Float, false, ModelPoint.Size(), 0); GL.BufferData(BufferTarget.ElementArrayBuffer, (IntPtr)(indices.Length * sizeof(ushort)), indices, BufferUsageHint.StaticDraw); }
public void MPL_ToArrayTest() { ModelPoint[] expectedArray = new ModelPoint[] { new ModelPoint(0.0f, initStrength), mp1, mp3, mp2, new ModelPoint(lifetime, 0.0f) }; ModelPoint[] actualArray = listWithInterPoints.ToArray(); Assert.AreEqual(expectedArray, actualArray); }
protected override void Start() { base.Start(); this.debugMode = true; ModelPoint mp1 = new ModelPoint(0.175f, 50.0f); ModelPoint mp2 = new ModelPoint(0.47f, 10.0f); ModelPointList pointList = new ModelPointList(200.0f, 0.7f, new ModelPoint[] { mp1, mp2 }); _dashDropoffModel = new MagnitudeDropoffModel(pointList); }
public void TestLineCreation() { ModelPoint p1 = new ModelPoint(0.15f, 80f); ModelPoint p2 = new ModelPoint(0.4f, 60f); ModelPointList list = new ModelPointList(initialStrength: 100.0f, lifetime: 1.0f); list.Add(p1); list.Add(p2); MagnitudeDropoffModel model = new MagnitudeDropoffModel(list); Debug.Log(model.ToString()); }
public static Model CreateHeavyBarrier() { _3dsReader reader = _3dsReader.GetReaderByFilename(HeavyObject.model.fileName, HeavyObject.model.roughNormals); ModelPoint[] points = new ModelPoint[reader.Vertices.Length]; int i = 0; foreach (Vector3 vertex in reader.Vertices) { points[i] = new ModelPoint(vertex * 2, reader.Normals[i], reader.TexCoords[i]); i++; } return(new Model(points, reader.Indices, ShapeMode.HeavyBarrier)); }
public Geometry Parse(string obj) { List <string> lines = obj.Replace(".", ",") .Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries) .Where(line => line[0] != '#').ToList(); List <float> vertices = new List <float>(); List <float> normals = new List <float>(); List <float> texCoords = new List <float>(); uint id = 0; List <uint> indexes = new List <uint>(); Dictionary <ModelPoint, uint> modelPoints = new Dictionary <ModelPoint, uint>(); foreach (string line in lines) { string[] lineData = line.Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries); switch (lineData[0]) { case "v": for (int i = 1; i < 4; ++i) { vertices.Add(Convert.ToSingle(lineData[i])); } break; case "vn": for (int i = 1; i < 4; ++i) { normals.Add(Convert.ToSingle(lineData[i])); } break; case "vt": for (int i = 1; i < 3; ++i) { texCoords.Add(Convert.ToSingle(lineData[i])); } break; case "f": uint?[] inds = lineData.Skip(1).Aggregate( new List <uint?>(), (acc, data) => acc.Concat(data.Split('/').Select(dt => ParseIndex(dt))).ToList(), acc => acc.ToArray() ); if (lineData.Length == 4) //triangle { for (int i = 0; i < 3; ++i) { ModelPoint point = new ModelPoint( inds[i * 3].Value, inds[i * 3 + 1].Value, inds[i * 3 + 2].Value ); if (!modelPoints.ContainsKey(point)) { modelPoints.Add(point, id++); } indexes.Add(modelPoints[point]); } } else if (lineData.Length == 5) //square is splitted onto two triangles { ModelPoint[] firstTriangle = new ModelPoint[] { new ModelPoint(inds[0].Value, inds[1].Value, inds[2].Value), new ModelPoint(inds[3].Value, inds[4].Value, inds[5].Value), new ModelPoint(inds[9].Value, inds[10].Value, inds[11].Value) }; for (int i = 0; i < firstTriangle.Length; ++i) { if (!modelPoints.ContainsKey(firstTriangle[i])) { modelPoints.Add(firstTriangle[i], id++); } indexes.Add(modelPoints[firstTriangle[i]]); } ModelPoint[] secondTriangle = new ModelPoint[] { new ModelPoint(inds[9].Value, inds[10].Value, inds[11].Value), new ModelPoint(inds[3].Value, inds[4].Value, inds[5].Value), new ModelPoint(inds[6].Value, inds[7].Value, inds[8].Value) }; for (int i = 0; i < secondTriangle.Length; ++i) { if (!modelPoints.ContainsKey(secondTriangle[i])) { modelPoints.Add(secondTriangle[i], id++); } indexes.Add(modelPoints[secondTriangle[i]]); } } break; } } List <ReusablePoint> points = new List <ReusablePoint>(); foreach (KeyValuePair <ModelPoint, uint> point in modelPoints) { Vector3 vertex = new Vector3( vertices[(int)point.Key.VertexIndex * 3], vertices[(int)point.Key.VertexIndex * 3 + 1], vertices[(int)point.Key.VertexIndex * 3 + 2] ); Vector3 normal = new Vector3( normals[(int)point.Key.NormalIndex * 3], normals[(int)point.Key.NormalIndex * 3 + 1], normals[(int)point.Key.NormalIndex * 3 + 2] ); Vector2 texCoord = new Vector2( texCoords[(int)point.Key.TexIndex * 2], 1.0f - texCoords[(int)point.Key.TexIndex * 2 + 1] ); points.Add(new ReusablePoint(vertex, normal, texCoord)); } return(new Geometry(points, indexes)); }
public ModelNode(ModelProblem modelProblem, int id) : base(modelProblem, id) { Coordinates = new ModelPoint(); }
public void MPL_ContainsStartTest() { ModelPoint startPoint = new ModelPoint(0.0f, initStrength); Assert.IsTrue(basicList.Contains(startPoint)); }
public void MPL_IdxOutOfRangeTest() { Assert.Throws <IndexOutOfRangeException>(delegate { ModelPoint nonexistantMP = basicList[2]; }); }
public void MPL_ContainsEndTest() { ModelPoint endPoint = new ModelPoint(lifetime, 0.0f); Assert.IsTrue(basicList.Contains(endPoint)); }
protected bool Equals(ModelPoint other) { return(X.Equals(other.X) && Y.Equals(other.Y) && Z.Equals(other.Z)); }