public void ArrayBufferWithOffsetConstructorWorks() { var buf = new ArrayBuffer(80); var arr = new Float32Array(buf, 16); Assert.IsTrue((object)arr is Float32Array); Assert.IsTrue(arr.Buffer == buf, "buffer"); Assert.AreEqual(arr.Length, 16, "length"); }
public void CopyConstructorWorks() { var source = new Float32Array(new float[] { 3, 8, 4 }); var arr = new Float32Array(source); Assert.IsTrue(arr != source, "New object"); Assert.IsTrue((object)arr is Float32Array, "is Float32Array"); AssertContent(arr, new[] { 3, 8, 4 }, "content"); }
public void ArrayBufferWithOffsetAndLengthConstructorWorks() { var buf = new ArrayBuffer(80); var arr = new Float32Array(buf, 16, 12); Assert.True((object)arr is Float32Array); Assert.True(arr.Buffer == buf, "buffer"); Assert.AreEqual(12, arr.Length, "length"); }
public void SubarrayWithBeginAndEndWorks() { var source = new Float32Array(10); var arr = source.SubArray(3, 7); Assert.False(arr == source, "Should be a new array"); Assert.True(arr.Buffer == source.Buffer, "Should be the same buffer"); Assert.AreEqual(12, arr.ByteOffset, "ByteOffset should be correct"); Assert.AreEqual(4, arr.Length, "Length should be correct"); }
public Float32Array ReadRemainingI16(int i16Remaining) { Float32Array data = new Float32Array(i16Remaining); for (int i = 0; i < i16Remaining; i++) { data[i] = (float)this.ReadInt16(true); } return(data); }
public void ForeachWorks() { var arr = new Float32Array(new float[] { 3, 6, 2, 9, 5 }); var l = new List <float>(); foreach (var i in arr) { l.Add(i); } Assert.AreEqual(l, new[] { 3, 6, 2, 9, 5 }); }
public void TestJsItemProperty() { Action f = () => { var floatArray = new Float32Array(2); floatArray[0] = 7; floatArray[1] = 14; var sum = floatArray[0] + floatArray[1]; Done(sum == 21); }; this.Start(f); }
public void ForeachWorks_SPI_1401() { var arr = new Float32Array(new float[] { 3, 6, 2, 9, 5 }); var l = new List <float>(); // #1401 foreach (var i in arr) { l.Add(i); } Assert.AreEqual(l.ToArray(), new[] { 3, 6, 2, 9, 5 }); }
public void GetEnumeratorWorks() { var arr = new Float32Array(new float[] { 3, 6, 2, 9, 5 }); var l = new List <float>(); var enm = arr.GetEnumerator(); while (enm.MoveNext()) { l.Add(enm.Current); } Assert.AreEqual(l, new[] { 3, 6, 2, 9, 5 }); }
private void AssertContent(Float32Array actual, int[] expected, string message) { if (actual.Length != expected.Length) { Assert.Fail(message + ": Expected length " + expected.Length + ", actual: " + actual.Length); return; } for (int i = 0; i < expected.Length; i++) { if (actual[i] != expected[i]) { Assert.Fail(message + ": Position " + i + ": expected " + expected[i] + ", actual: " + actual[i]); return; } } Assert.IsTrue(true, message); }
public void ConvertFloat32ArrayToNativeArrayTest() { var data = new float[] { 1, 2, 3, 4 }; var srcArray = new Float32Array(data.Length); srcArray.set(new Arguments { data }); object res = ConvertJStoObj(srcArray, typeof(float[]), true); Assert.IsInstanceOfType(res, typeof(float[])); CollectionAssert.AreEqual(data, (float[])res); }
private unsafe void EnsureArrayCapacity(int numBatchItems) #endif { int neededCapacity = 6 * numBatchItems; if (_index != null && neededCapacity <= _index.Length) { // Short circuit out of here because we have enough capacity. return; } var newIndex = new short[6 * numBatchItems]; int start = 0; if (_index != null) { _index.CopyTo(newIndex, 0); start = _index.Length / 6; } var indexPtr = (start * 6); for (var i = start; i < numBatchItems; i++, indexPtr += 6) { /* * TL TR * 0----1 0,1,2,3 = index offsets for vertex indices * | /| TL,TR,BL,BR are vertex references in SpriteBatchItem. * | / | * | / | * |/ | * 2----3 * BL BR */ // Triangle 1 newIndex[indexPtr + 0] = (i * 4 + 0).As <short>(); newIndex[indexPtr + 1] = (i * 4 + 1).As <short>(); newIndex[indexPtr + 2] = (i * 4 + 2).As <short>(); newIndex[indexPtr + 3] = (i * 4 + 1).As <short>(); newIndex[indexPtr + 4] = (i * 4 + 3).As <short>(); newIndex[indexPtr + 5] = (i * 4 + 2).As <short>(); } _index = newIndex; _vertexArray = new ArrayBuffer(4 * numBatchItems * 6 * 4); _vertexArrayF = new Float32Array(_vertexArray); _vertexArrayC = new Uint32Array(_vertexArray); }
public void TypePropertiesAreCorrect() { Assert.AreEqual(typeof(Float32Array).FullName, "Float32Array", "FullName"); var interfaces = typeof(Float32Array).GetInterfaces(); Assert.AreEqual(interfaces.Length, 3, "Interface count should be 3"); Assert.IsTrue(interfaces.Contains(typeof(IEnumerable<float>)), "Interfaces should contain IEnumerable<float>"); Assert.IsTrue(interfaces.Contains(typeof(ICollection<float>)), "Interfaces should contain ICollection<float>"); Assert.IsTrue(interfaces.Contains(typeof(IList<float>)), "Interfaces should contain IList<float>"); object arr = new Float32Array(0); Assert.IsTrue(arr is Float32Array, "Is Float32Array"); Assert.IsTrue(arr is IEnumerable<float>, "Is IEnumerable<float>"); Assert.IsTrue(arr is ICollection<float>, "Is ICollection<float>"); Assert.IsTrue(arr is IList<float>, "Is IList<float>"); }
private void AssertContent(Float32Array actual, int[] expected, string message) { if (actual.Length != expected.Length) { Assert.Fail(message + ": Expected length " + expected.Length + ", actual: " + actual.Length); return; } for (int i = 0; i < expected.Length; i++) { if (actual[i] != expected[i]) { Assert.Fail(message + ": Position " + i + ": expected " + expected[i] + ", actual: " + actual[i]); return; } } Assert.True(true, message); }
/// <inheritdoc /> public override int Read(float[] buffer, int offset, int count) { var read = new Float32Array(count); _circularBuffer.Read(read, 0, System.Math.Min(read.Length, _circularBuffer.Count)); Buffer.BlockCopy(read.Data, 0, buffer, offset * sizeof(float), count * sizeof(float)); var samples = count / 2; ((EventEmitterOfT <double>)SamplesPlayed).Trigger(samples); RequestBuffers(); return(count); }
public static Sample DecodeData(DataMessage dmsg) { var returnSample = new Sample(dmsg.DataType, null); if (dmsg.DataType == DataMessage.Types.DataType.Image) { var msg = new ImageSamples(); msg.MergeFrom(dmsg.Data); returnSample.Data = msg; return(returnSample); } else if (dmsg.DataType == DataMessage.Types.DataType.Audio) { var msg = new AudioSamples(); msg.MergeFrom(dmsg.Data); returnSample.Data = msg; return(returnSample); } else if (dmsg.DataType == DataMessage.Types.DataType.String) { var msg = new StringSample(); msg.MergeFrom(dmsg.Data); returnSample.Data = msg; return(returnSample); } else if (dmsg.DataType == DataMessage.Types.DataType.Float32Arr) { var msg = new Float32Array(); msg.MergeFrom(dmsg.Data); returnSample.Data = msg; return(returnSample); } else if (dmsg.DataType == DataMessage.Types.DataType.Int64Arr) { var msg = new Int64Array(); msg.MergeFrom(dmsg.Data); returnSample.Data = msg; return(returnSample); } else { Debug.Log("Unknown message"); return(null); } }
public override void Animation(RenderControl render, float time) { var position = mGeometry.GetAttribute(0); position.SetDataUsage(EnumBufferDataUsage.DYNAMIC_DRAW); var mPosition = new Float32Array(position.GetData()); var count = mPosition.GetItemCount() / 3; for (uint i = 0; i < count; i++) { var z = (float)(35 * Math.Sin(i / 5 + (time * 50 + i) / 7)); mPosition.SetValue(i * 3 + 2, z); } position.RequestUpdate(); mGeometry.RequestUpdate(); render.RequestDraw(); }
public void Unlock() { VertexBuffer = Tile.PrepDevice.createBuffer(); Tile.PrepDevice.bindBuffer(GL.ARRAY_BUFFER, VertexBuffer); Float32Array f32array = new Float32Array(Count * 3); float[] buffer = (float[])(object)f32array; int index = 0; foreach (Vector3d pt in verts) { buffer[index++] = (float)pt.X; buffer[index++] = (float)pt.Y; buffer[index++] = (float)pt.Z; } Tile.PrepDevice.bufferData(GL.ARRAY_BUFFER, f32array, GL.STATIC_DRAW); }
public void TypePropertiesAreCorrect() { Assert.AreEqual(typeof(Float32Array).FullName, "Float32Array", "FullName"); var interfaces = typeof(Float32Array).GetInterfaces(); Assert.AreEqual(interfaces.Length, 3, "Interface count should be 3"); Assert.IsTrue(interfaces.Contains(typeof(IEnumerable <float>)), "Interfaces should contain IEnumerable<float>"); Assert.IsTrue(interfaces.Contains(typeof(ICollection <float>)), "Interfaces should contain ICollection<float>"); Assert.IsTrue(interfaces.Contains(typeof(IList <float>)), "Interfaces should contain IList<float>"); object arr = new Float32Array(0); Assert.IsTrue(arr is Float32Array, "Is Float32Array"); Assert.IsTrue(arr is IEnumerable <float>, "Is IEnumerable<float>"); Assert.IsTrue(arr is ICollection <float>, "Is ICollection<float>"); Assert.IsTrue(arr is IList <float>, "Is IList<float>"); }
public static void TestUseCase(Assert assert) { assert.Expect(10); var array1 = new Int8Array(1); Bridge550.TestMethod(array1, "Int8Array", assert); var array2 = new Uint8Array(1); Bridge550.TestMethod(array2, "Uint8Array", assert); var array3 = new Uint8ClampedArray(1); Bridge550.TestMethod(array3, "Uint8ClampedArray", assert); var array4 = new Int16Array(1); Bridge550.TestMethod(array4, "Int16Array", assert); var array5 = new Uint16Array(1); Bridge550.TestMethod(array5, "Uint16Array", assert); var array6 = new Int32Array(1); Bridge550.TestMethod(array6, "Int32Array", assert); var array7 = new Uint32Array(1); Bridge550.TestMethod(array7, "Uint32Array", assert); var array8 = new Float32Array(1); Bridge550.TestMethod(array8, "Float32Array", assert); var array9 = new Float64Array(1); Bridge550.TestMethod(array9, "Float64Array", assert); var array10 = new DataView(array9.Buffer); Bridge550.TestMethod(array10, "DataView", assert); }
public virtual void CleanUp(bool removeFromParent) { ReadyToRender = false; DemData = null; demFile = null; demDownloading = false; texReady = false; DemReady = false; errored = false; if (this.texture != null) { this.texture = null; } RenderTriangleLists = new List <RenderTriangle> [4]; GeometryCreated = false; if (removeFromParent && Parent != null) { Parent.RemoveChild(this); Parent = null; } if (PrepDevice != null) { foreach (WebGLBuffer buf in IndexBuffers) { PrepDevice.deleteBuffer(buf); } IndexBuffers = new WebGLBuffer[4]; if (VertexBuffer != null) { PrepDevice.deleteBuffer(VertexBuffer); VertexBuffer = null; } if (texture2d != null) { PrepDevice.deleteTexture(texture2d); texture2d = null; } } }
public spriteBatcher(WebGLRenderingContext webgl, shaderParser shaderparser) { this.webgl = webgl; this.shaderparser = shaderparser; this.vbo = webgl.CreateBuffer(); var asp = (this.webgl.DrawingBufferWidth / this.webgl.DrawingBufferHeight); //this.matrix= float[] array = { 1.0f / asp, 0, 0, 0,//å»ęaspēå½±å 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 };//ness this.matrix = new Float32Array(array); this.recorder = new stateRecorder(webgl);//ness }
public void RequestDem() { if (!ReadyToRender && !demDownloading) { demTile = true; demDownloading = true; callCount++; XMLHttpRequest2 xhr = new XMLHttpRequest2(); xhr.AddEventListener("load", delegate(ElementEvent e) { DemReady = true; demDownloading = false; ReadyToRender = texReady && (DemReady || !demTile); RequestPending = false; try { demFile = new Float32Array(xhr.Response); } catch { } TileCache.RemoveFromQueue(this.Key, true); }, false); xhr.AddEventListener("error", delegate(ElementEvent e) { demDownloading = false; DemReady = false; ReadyToRender = false; errored = true; RequestPending = false; TileCache.RemoveFromQueue(this.Key, true); }, false); xhr.Open(HttpVerb.Get, DemURL /*.Replace("cdn.", "www.")*/, true); xhr.ResponseType = "arraybuffer"; xhr.Send(); // TODO add event listener for failed! } }
public void Unlock() { VertexBuffer = Tile.PrepDevice.createBuffer(); Tile.PrepDevice.bindBuffer(GL.ARRAY_BUFFER, VertexBuffer); Float32Array f32array = new Float32Array(Count * 7); float[] buffer = (float[])(object)f32array; int index = 0; foreach (PositionColored pt in verts) { buffer[index++] = (float)pt.Position.X; buffer[index++] = (float)pt.Position.Y; buffer[index++] = (float)pt.Position.Z; buffer[index++] = (float)pt.Color.R / 255.0f; buffer[index++] = (float)pt.Color.G / 255.0f; buffer[index++] = (float)pt.Color.B / 255.0f; buffer[index++] = (float)pt.Color.A / 255.0f; } Tile.PrepDevice.bufferData(GL.ARRAY_BUFFER, f32array, GL.STATIC_DRAW); }
public override void Run(RenderControl render) { mGeometry = GeometryBuilder.CreatePlane(20000, 20000, worldWidth - 1, worldDepth - 1); var position = mGeometry.GetGeometry().GetAttribute(0); position.SetDataUsage(EnumBufferDataUsage.DYNAMIC_DRAW); var mPosition = new Float32Array(position.GetData()); for (uint i = 0; i < position.GetCount() / 3; i++) { float z = (float)(35 * Math.Sin(i / 2)); mPosition.SetValue(i * 3 + 2, z); } var material = BasicMaterial.Create("basic-water"); var img = FileImage.Create(GetResourcePath("textures/water.png")); var texture = new ImageTexture2D(); texture.SetSource(img); var desc = texture.GetDesc(); desc.SetWrapS(EnumTextureWrappingType.REPEAT); desc.SetWrapT(EnumTextureWrappingType.REPEAT); texture.SetRepeat(new Vector2(5, 5)); material.AddTexture("map", texture); var color = Vector3.ColorFromHex(0x0044ff); material.SetUniform("diffuse", Uniform.Create(color)); var node = new PrimitiveSceneNode(mGeometry, material); node.SetPickable(false); node.SetCulling(false); render.ShowSceneNode(node); }
public static IEnumerable <object[]> ArrayType_TestData() { _objectPrototype ??= new Function("return Object.prototype.toString;"); yield return(new object[] { _objectPrototype.Call(), "Uint8Array", Uint8Array.From(new byte[10]) }); yield return(new object[] { _objectPrototype.Call(), "Uint8ClampedArray", Uint8ClampedArray.From(new byte[10]) }); yield return(new object[] { _objectPrototype.Call(), "Int8Array", Int8Array.From(new sbyte[10]) }); yield return(new object[] { _objectPrototype.Call(), "Uint16Array", Uint16Array.From(new ushort[10]) }); yield return(new object[] { _objectPrototype.Call(), "Int16Array", Int16Array.From(new short[10]) }); yield return(new object[] { _objectPrototype.Call(), "Uint32Array", Uint32Array.From(new uint[10]) }); yield return(new object[] { _objectPrototype.Call(), "Int32Array", Int32Array.From(new int[10]) }); yield return(new object[] { _objectPrototype.Call(), "Float32Array", Float32Array.From(new float[10]) }); yield return(new object[] { _objectPrototype.Call(), "Float64Array", Float64Array.From(new double[10]) }); yield return(new object[] { _objectPrototype.Call(), "Array", new Array(10) }); }
public void Unlock() { VertexBuffer = Tile.PrepDevice.createBuffer(); Tile.PrepDevice.bindBuffer(GL.ARRAY_BUFFER, VertexBuffer); Float32Array f32array = new Float32Array(Count * 8); float[] buffer = (float[])(object)f32array; int index = 0; foreach (PositionNormalTextured pt in verts) { buffer[index++] = (float)pt.X; buffer[index++] = (float)pt.Y; buffer[index++] = (float)pt.Z; buffer[index++] = (float)pt.Nx; buffer[index++] = (float)pt.Ny; buffer[index++] = (float)pt.Nz; buffer[index++] = (float)pt.Tu; buffer[index++] = (float)pt.Tv; } Tile.PrepDevice.bufferData(GL.ARRAY_BUFFER, f32array, GL.STATIC_DRAW); }
private ArrayBuffer ConvertVertices <T>(T[] vertices, int startVertex, int numVertices, VertexDeclaration decl) { var result = new ArrayBuffer(numVertices * decl.VertexStride); var fa = new Float32Array(result); var fi = new Uint32Array(result); uint pos = 0; if (vertices[0] is VertexPositionColorTexture) // hardcoding types gives us a bit of performance { var tmp = vertices.As <VertexPositionColorTexture[]>(); for (uint i = 0; i < numVertices; i++) { fa[pos + 0] = tmp[i].Position.X; fa[pos + 1] = tmp[i].Position.Y; fa[pos + 2] = tmp[i].Position.Z; fi[pos + 3] = tmp[i].Color.PackedValue; fa[pos + 4] = tmp[i].TextureCoordinate.X; fa[pos + 5] = tmp[i].TextureCoordinate.Y; pos += 6; } } else { var props = object.GetOwnPropertyNames(vertices[0]).Where(p => p[0] != '$').ToArray(); var propertyIndex = 0; foreach (var el in decl.InternalVertexElements) { var prop = props[propertyIndex++]; CopyVertexElement(vertices, startVertex, numVertices, result, prop, el.Offset, el.VertexElementFormat, decl.VertexStride); } } return(result); }
/// <summary> /// Receive body parts information /// </summary> /// <param name="currSample"> /// The float array containing the body parts statuses. The parameters are -1.0 for no connection, /// 1.0 for connected but a problem with the system/ motor, 0.0 connected and no problem. /// </param> /// <returns>Success.</returns> public bool proprioception_set(Float32Array currSample) { //print("Proprio: " + currSample.Data); // check if the float array contains information for the 6 body parts if (currSample.CalculateSize() >= 6) { /* body_manager() handles the information in currSample for the 6 body parts * mapping: * 41 id of the head icon, position in currSample 0 * 42 id of the right_body icon, position in currSample 1 * 43 id of the left_body icon, position in currSample 2 * 44 id of the right_hand icon, position in currSample 3 * 45 id of the left_hand icon, position in currSample 4 * 46 id of the wheelchair icon, position in currSample 5 */ body_manager(41, 0, currSample); body_manager(42, 1, currSample); body_manager(43, 2, currSample); body_manager(44, 3, currSample); body_manager(45, 4, currSample); body_manager(46, 5, currSample); } return(true); }
/// <summary> /// Method to handle the information in currSample and control the color of the 6 body parts /// </summary> /// <param name="id">ID of the icon in the json file</param> /// <param name="position">Position of the float in currSample</param> /// <param name="currSample">Float array with 6 floats (-1.0; 0.0; 1.0)</param> public void body_manager(int id, int position, Float32Array currSample) { // get the instance of the widget with this id Widget widget = Manager.Instance.FindWidgetWithID(id); if ((int)(currSample.Data[position]) == -1) { // float equal to -1 then the widget changes to the icon/color at position 1 in the json file (yellow) widget.GetContext().currentIcon = widget.GetContext().icons[1]; } else if ((int)(currSample.Data[position]) == 0) { // float equal to 0 then the widget changes to the icon/color at position 0 in the json file (green) widget.GetContext().currentIcon = widget.GetContext().icons[0]; } else { // else or equal to 1 the widget changes to the icon/color at position 2 in the json file (red) widget.GetContext().currentIcon = widget.GetContext().icons[2]; } // Apply the changes to the instance of the widget with ProcessRosMessage widget.ProcessRosMessage(widget.GetContext()); }
public void Create(PositionColoredTextured[] verts) { VertexBuffer = Tile.PrepDevice.createBuffer(); Tile.PrepDevice.bindBuffer(GL.ARRAY_BUFFER, VertexBuffer); Float32Array f32array = new Float32Array(verts.Length * 9); float[] buffer = (float[])(object)f32array; int index = 0; foreach (PositionColoredTextured pt in verts) { buffer[index++] = (float)pt.Position.X; buffer[index++] = (float)pt.Position.Y; buffer[index++] = (float)pt.Position.Z; buffer[index++] = (float)pt.Color.R / 255.0f; buffer[index++] = (float)pt.Color.G / 255.0f; buffer[index++] = (float)pt.Color.B / 255.0f; buffer[index++] = (float)pt.Color.A / 255.0f; buffer[index++] = (float)pt.Tu; buffer[index++] = (float)pt.Tv; } Tile.PrepDevice.bufferData(GL.ARRAY_BUFFER, f32array, GL.DYNAMIC_DRAW); }
public void CopyFromChannel(Float32Array destination, int channelNumber) { }
public void ContainsWorks() { var arr = new Float32Array(new float[] { 3, 6, 2, 9, 5 }); Assert.IsTrue (arr.Contains(9), "9"); Assert.IsFalse(arr.Contains(1), "1"); }
public void VertexAttrib4fv(uint indx, Float32Array values) { }
public void GetFrequencyResponse(Float32Array frequencyHz, Float32Array magResponse, Float32Array phaseResponse) { }
public void LengthConstructorWorks() { var arr = new Float32Array(13); Assert.IsTrue((object)arr is Float32Array, "is Float32Array"); Assert.AreEqual(arr.Length, 13, "Length"); }
public void CopyToChannel(Float32Array source, int channelNumber, uint startInChannel) { }
public void uniformMatrix4fv(WebGLUniformLocation location, GLboolean transpose, Float32Array value) { Invoke("uniformMatrix4fv", location, transpose, value.Object); }
/// <summary> /// Creates a new Float32Array out of the specified Float32Array. /// </summary> /// <param name="typedArray">Float32Array to use as initial contents to the new array.</param> public Float32Array(Float32Array typedArray) { }
public void SubarrayWithBeginAndEndWorks() { var source = new Float32Array(10); var arr = source.Subarray(3, 7); Assert.IsFalse(arr == source, "Should be a new array"); Assert.IsTrue(arr.Buffer == source.Buffer, "Should be the same buffer"); Assert.AreEqual(arr.ByteOffset, 12, "ByteOffset should be correct"); Assert.AreEqual(arr.Length, 4, "Length should be correct"); }
public void GetFloatFrequencyData(Float32Array array) { }
public void BufferPropertyWorks() { var buf = new ArrayBuffer(100); var arr = new Float32Array(buf); Assert.IsTrue(arr.Buffer == buf, "Should be correct"); }
public void ByteOffsetPropertyWorks() { var buf = new ArrayBuffer(100); var arr = new Float32Array(buf, 32); Assert.AreEqual(arr.ByteOffset, 32, "Should be correct"); }
public void CopyFromChannel(Float32Array destination, int channelNumber, uint startInChannel) { }
public void CopyToChannel(Float32Array source, int channelNumber) { }
public void SetValueCurveAtTime(Float32Array values, double startTime, double duration) { }
public void UniformMatrix4fv(WebGLUniformLocation location, bool transpose, Float32Array value) { }
public void IndexOfWorks() { var arr = new Float32Array(new float[] { 3, 6, 2, 9, 5 }); Assert.AreEqual(arr.IndexOf(9), 3, "9"); Assert.AreEqual(arr.IndexOf(1), -1, "1"); }
public WaveTable createWaveTable(Float32Array real, Float32Array imag) { return default(WaveTable); }
public void ForeachWorks() { var arr = new Float32Array(new float[] { 3, 6, 2, 9, 5 }); var l = new List<float>(); foreach (var i in arr) { l.Add(i); } Assert.AreEqual(l, new[] { 3, 6, 2, 9, 5 }); }
public void SetNormalArrayWithOffsetWorks() { var arr = new Float32Array(6); arr.Set(new float[] { 3, 6, 7 }, 2); AssertContent(arr, new[] { 0, 0, 3, 6, 7, 0 }, "Content"); }
public void ByteLengthPropertyWorks() { var arr = new Float32Array(23); Assert.AreEqual(arr.ByteLength, 92, "Should be correct"); }
public void SetNormalArrayWorks() { var arr = new Float32Array(4); arr.Set(new float[] { 3, 6, 7 }); AssertContent(arr, new[] { 3, 6, 7, 0 }, "Content"); }
public void IndexingWorks() { var arr = new Float32Array(3); arr[1] = 42; AssertContent(arr, new[] { 0, 42, 0 }, "Content"); Assert.AreEqual(arr[1], 42, "[1]"); }
public void getFrequencyResponse(Float32Array frequencyHz, Float32Array magResponse, Float32Array phaseResponse) {}
public void LengthWorks() { var arr = new Float32Array(13); Assert.AreEqual(arr.Length, 13, "Length"); }
private static void SetTypedArrayFloat(JSObject obj) { float[] buffer = Enumerable.Repeat(3.14f, 17).ToArray(); obj.SetObjectProperty("typedArray", Float32Array.From(buffer)); }
public void GetEnumeratorWorks() { var arr = new Float32Array(new float[] { 3, 6, 2, 9, 5 }); var l = new List<float>(); var enm = arr.GetEnumerator(); while (enm.MoveNext()) { l.Add(enm.Current); } Assert.AreEqual(l, new[] { 3, 6, 2, 9, 5 }); }
public override bool CreateGeometry(RenderContext renderContext) { base.CreateGeometry(renderContext); if (GeometryCreated) { return(true); } GeometryCreated = true; for (int i = 0; i < 4; i++) { RenderTriangleLists[i] = new List <RenderTriangle>(); } ComputeMatrix(); Height = texture.NaturalHeight; Width = texture.NaturalWidth; double latMin = 0 + (ScaleY * (Height - PixelCenterY)); double latMax = 0 - (ScaleY * PixelCenterY); double lngMin = 0 + (ScaleX * PixelCenterX); double lngMax = 0 - (ScaleX * (Width - PixelCenterX)); TopLeft = GeoTo3dTan(latMin, lngMin); BottomRight = GeoTo3dTan(latMax, lngMax); TopRight = GeoTo3dTan(latMin, lngMax); BottomLeft = GeoTo3dTan(latMax, lngMin); Vector3d topCenter = Vector3d.Lerp(TopLeft, TopRight, .5f); Vector3d bottomCenter = Vector3d.Lerp(BottomLeft, BottomRight, .5f); Vector3d center = Vector3d.Lerp(topCenter, bottomCenter, .5f); Vector3d rightCenter = Vector3d.Lerp(TopRight, BottomRight, .5f); Vector3d leftCenter = Vector3d.Lerp(TopLeft, BottomLeft, .5f); //Vector3d center = Vector3d.MidPoint(TopLeft, BottomRight); //Vector3d leftCenter = Vector3d.MidPoint(TopLeft, BottomLeft); //Vector3d rightCenter = Vector3d.MidPoint(TopRight, BottomRight); //Vector3d topCenter = Vector3d.MidPoint(TopLeft, TopRight); //Vector3d bottomCenter = Vector3d.MidPoint(BottomLeft, BottomRight); //verts[0].Position = TopLeft; //verts[0].Normal = TopLeft; //verts[0].Tu = 0; //verts[0].Tv = 0; //verts[1].Position = TopRight; //verts[1].Normal = TopRight; //verts[1].Tu = 1; //verts[1].Tv = 0; //verts[2].Position = BottomRight; //verts[2].Normal = BottomRight; //verts[2].Tu = 1; //verts[2].Tv = 1; //verts[3].Position = BottomLeft; //verts[3].Normal = BottomLeft; //verts[3].Tu = 0; //verts[3].Tv = 1; if (renderContext.gl == null) { //RenderTriangleLists[0].Add(RenderTriangle.Create(PositionTexture.CreatePosSize(TopLeft, 0, 0, Width, Height), PositionTexture.CreatePosSize(BottomLeft, 0, 1, Width, Height), PositionTexture.CreatePosSize(TopRight, 1, 0, Width, Height), texture, Level)); //RenderTriangleLists[0].Add(RenderTriangle.Create(PositionTexture.CreatePosSize(BottomLeft, 0, 1, Width, Height), PositionTexture.CreatePosSize(BottomRight, 1, 1, Width, Height), PositionTexture.CreatePosSize(TopRight, 1, 0, Width, Height), texture, Level)); vertexList = new List <PositionTexture>(); vertexList.Add(PositionTexture.CreatePosSize(TopLeft, 0, 0, Width, Height)); vertexList.Add(PositionTexture.CreatePosSize(TopRight, 1, 0, Width, Height)); vertexList.Add(PositionTexture.CreatePosSize(BottomLeft, 0, 1, Width, Height)); vertexList.Add(PositionTexture.CreatePosSize(BottomRight, 1, 1, Width, Height)); childTriangleList = new List <Triangle>(); if (dataset.BottomsUp) { childTriangleList.Add(Triangle.Create(0, 1, 2)); childTriangleList.Add(Triangle.Create(2, 1, 3)); } else { childTriangleList.Add(Triangle.Create(0, 2, 1)); childTriangleList.Add(Triangle.Create(2, 3, 1)); } int count = 3; while (count-- > 1) { List <Triangle> newList = new List <Triangle>(); foreach (Triangle tri in childTriangleList) { tri.SubDivide(newList, vertexList); } childTriangleList = newList; } double miter = .6 / (Width / 256); foreach (Triangle tri in childTriangleList) { PositionTexture p1 = vertexList[tri.A]; PositionTexture p2 = vertexList[tri.B]; PositionTexture p3 = vertexList[tri.C]; RenderTriangleLists[0].Add(RenderTriangle.CreateWithMiter(p1, p2, p3, texture, Level, miter)); } } else { //process vertex list VertexBuffer = PrepDevice.createBuffer(); PrepDevice.bindBuffer(GL.ARRAY_BUFFER, VertexBuffer); Float32Array f32array = new Float32Array(9 * 5); float[] buffer = (float[])(object)f32array; int index = 0; index = AddVertex(buffer, index, PositionTexture.CreatePos(bottomCenter, .5, 1)); //0 index = AddVertex(buffer, index, PositionTexture.CreatePos(BottomLeft, 0, 1)); //1 index = AddVertex(buffer, index, PositionTexture.CreatePos(BottomRight, 1, 1)); //2 index = AddVertex(buffer, index, PositionTexture.CreatePos(center, .5, .5)); //3 index = AddVertex(buffer, index, PositionTexture.CreatePos(leftCenter, 0, .5)); //4 index = AddVertex(buffer, index, PositionTexture.CreatePos(rightCenter, 1, .5)); //5 index = AddVertex(buffer, index, PositionTexture.CreatePos(topCenter, .5, 0)); //6 index = AddVertex(buffer, index, PositionTexture.CreatePos(TopLeft, 0, 0)); //7 index = AddVertex(buffer, index, PositionTexture.CreatePos(TopRight, 1, 0)); //8 PrepDevice.bufferData(GL.ARRAY_BUFFER, f32array, GL.STATIC_DRAW); // process index buffers for (int i = 0; i < 4; i++) { index = 0; TriangleCount = 2; Uint16Array ui16array = new Uint16Array(TriangleCount * 3); UInt16[] indexArray = (UInt16[])(object)ui16array; switch (i) { case 0: indexArray[index++] = 7; indexArray[index++] = 4; indexArray[index++] = 6; indexArray[index++] = 4; indexArray[index++] = 3; indexArray[index++] = 6; break; case 1: indexArray[index++] = 6; indexArray[index++] = 5; indexArray[index++] = 8; indexArray[index++] = 6; indexArray[index++] = 3; indexArray[index++] = 5; break; case 2: indexArray[index++] = 4; indexArray[index++] = 0; indexArray[index++] = 3; indexArray[index++] = 4; indexArray[index++] = 1; indexArray[index++] = 0; break; case 3: indexArray[index++] = 3; indexArray[index++] = 2; indexArray[index++] = 5; indexArray[index++] = 3; indexArray[index++] = 0; indexArray[index++] = 2; break; } IndexBuffers[i] = PrepDevice.createBuffer(); PrepDevice.bindBuffer(GL.ELEMENT_ARRAY_BUFFER, IndexBuffers[i]); PrepDevice.bufferData(GL.ELEMENT_ARRAY_BUFFER, ui16array, GL.STATIC_DRAW); } } return(true); }
public void GetFloatTimeDomainData(Float32Array array) { }