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");
		}
Ejemplo n.º 3
0
        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");
        }
Ejemplo n.º 4
0
        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");
        }
Ejemplo n.º 5
0
        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 });
        }
Ejemplo n.º 7
0
        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);
        }
Ejemplo n.º 8
0
        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);
		}
Ejemplo n.º 11
0
        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);
        }
Ejemplo n.º 12
0
        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>");
		}
Ejemplo n.º 14
0
 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);
 }
Ejemplo n.º 15
0
        /// <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();
        }
Ejemplo n.º 18
0
        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);
        }
Ejemplo n.º 19
0
        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>");
        }
Ejemplo n.º 20
0
        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);
        }
Ejemplo n.º 21
0
        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;
                }
            }
        }
Ejemplo n.º 22
0
        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
        }
Ejemplo n.º 23
0
        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!
            }
        }
Ejemplo n.º 24
0
        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);
        }
Ejemplo n.º 25
0
        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);
        }
Ejemplo n.º 26
0
        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) });
        }
Ejemplo n.º 27
0
        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);
        }
Ejemplo n.º 28
0
        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);
        }
Ejemplo n.º 29
0
 /// <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);
 }
Ejemplo n.º 30
0
    /// <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);
        }
Ejemplo n.º 32
0
 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) { }
Ejemplo n.º 35
0
 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");
		}
Ejemplo n.º 37
0
 public void CopyToChannel(Float32Array source, int channelNumber, uint startInChannel)
 {
 }
 public void uniformMatrix4fv(WebGLUniformLocation location, GLboolean transpose, Float32Array value)
 {
     Invoke("uniformMatrix4fv", location, transpose, value.Object);
 }
Ejemplo n.º 39
0
 /// <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");
		}
Ejemplo n.º 41
0
 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");
		}
Ejemplo n.º 44
0
 public void CopyFromChannel(Float32Array destination, int channelNumber, uint startInChannel)
 {
 }
Ejemplo n.º 45
0
 public void CopyToChannel(Float32Array source, int channelNumber)
 {
 }
Ejemplo n.º 46
0
 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");
		}
Ejemplo n.º 49
0
	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]");
		}
Ejemplo n.º 55
0
	public  void getFrequencyResponse(Float32Array frequencyHz, Float32Array magResponse, Float32Array phaseResponse) {}
		public void LengthWorks() {
			var arr = new Float32Array(13);
			Assert.AreEqual(arr.Length, 13, "Length");
		}
Ejemplo n.º 57
0
 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 });
		}
Ejemplo n.º 59
0
        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);
        }
Ejemplo n.º 60
0
 public void GetFloatTimeDomainData(Float32Array array)
 {
 }