public HLSLStaticEntitySprite(Device device, string shaderPath, VertexDeclaration VertexDeclaration, iCBuffer CBPerFrame = null, EntryPoints shadersEntryPoint = null)
            : base(device, shaderPath, VertexDeclaration, new UtopiaIncludeHandler())
        {
            //Create Constant Buffers interfaces ==================================================
            CBPerFrameLocal = ToDispose(new CBuffer <CBPerFrame_Struct>(device, "PerFrameLocal"));
            CBuffers.Add(CBPerFrameLocal);

            if (CBPerFrame != null)
            {
                CBuffers.Add(CBPerFrame.Clone());
            }

            //Create the resource interfaces ==================================================
            DiffuseTexture = new ShaderResource("DiffuseTexture");
            ShaderResources.Add(DiffuseTexture);

            BiomesColors = new ShaderResource("BiomesColors");
            ShaderResources.Add(BiomesColors);

            //Create the Sampler interface ==================================================
            SamplerDiffuse = new ShaderSampler("SamplerDiffuse");
            ShaderSamplers.Add(SamplerDiffuse);

            //Load the shaders
            base.LoadShaders(shadersEntryPoint == null ? _shadersEntryPoint : shadersEntryPoint);
        }
        public void TestQueueUnQueue()
        {
            CBuffer Q = new CBuffer(2);

            Q.Queue(10);
            Q.Queue(20);

            if (Q.DeQueue() != 10)
            {
                Assert.Fail();
            }
            if (Q.DeQueue() != 20)
            {
                Assert.Fail();
            }

            Q.Queue(30);
            Q.Queue(40);
            if (Q.QtdElem() == 2)
            {
                Assert.Pass();
            }
            else
            {
                Assert.Fail();
            }
        }
Esempio n. 3
0
        public HLSLSprites2(Device device, bool withAlphaClip, string shaderFilePath)
            : base(device, shaderFilePath, VertexSprite2.VertexDeclaration, null)
        {
            if (!withAlphaClip)
            {
                _shadersEntryPoint.PixelShader_EntryPoint = "SpritePSNoClip";
            }

            //Create Constant Buffers interfaces ==================================================
            CBPerDraw = ToDispose(new CBuffer <CBPerDraw_Struct>(device, "PerDraw"));
            CBuffers.Add(CBPerDraw);

            CBTextureTransform = ToDispose(new CBuffer <CBTextureTransform_Struct>(device, "TextureTransform"));
            CBuffers.Add(CBTextureTransform);

            //Create the resource interfaces ==================================================
            SpriteTexture = new ShaderResource("SpriteTexture");
            ShaderResources.Add(SpriteTexture);

            //Create the Sampler interface ==================================================
            SpriteSampler = new ShaderSampler("SpriteSampler");
            ShaderSamplers.Add(SpriteSampler);

            //Load the shaders
            base.LoadShaders(_shadersEntryPoint);
        }
        public void BorderTestII()
        {
            CBuffer Q = new CBuffer(10);

            Q.Queue(10);
            Q.Queue(20);
            Q.Queue(30);
            Q.Queue(40);
            Q.Queue(50);
            Q.Queue(60);
            Q.Queue(70);
            Q.Queue(80);
            Q.Queue(90);
            Q.Queue(100);
            Q.DeQueue();
            Q.DeQueue();
            Q.DeQueue();
            Q.DeQueue();
            Q.Queue(110);

            if (Q.DeQueue() != 50)
            {
                Assert.Fail();
            }
            else
            {
                Assert.Pass();
            }
        }
Esempio n. 5
0
 public WidgetRenderer()
 {
     for (int i = 0; i < bgConstantBuffers.Length; i++)
     {
         bgConstantBuffers[i] = new CBuffer();
     }
 }
    private List <NetPack> DecodeBuffer(byte[] buffer, int bufSize)
    {
        List <NetPack> packs = new List <NetPack>();

        try
        {
            int offset    = 0;
            int restCount = bufSize;// 剩余缓存大小

            while (restCount > 0)
            {
                if (curPack == null)
                {
                    curPack = new NetPack();
                }

                if (curPack.FillPack(buffer, ref offset, ref restCount))
                {
                    CBuffer cBuffer = curPack.Assembly();
                    packs.Add(curPack);
                    curPack = null;
                }
            }
        }
        catch (System.Exception ex)
        {
            Debug.LogErrorFormat("Decode pack error. {1}", ex.ToString());
        }
        return(packs);
    }
Esempio n. 7
0
        public HLSLTerran(Device device, string shaderPath, VertexDeclaration VertexDeclaration, iCBuffer CBPerFrame = null, EntryPoints shadersEntryPoint = null)
            : base(device, shaderPath, VertexDeclaration, new UtopiaIncludeHandler())
        {
            //Create Contstant Buffers interfaces ==================================================
            CBPerDraw = ToDispose(new CBuffer <CBPerDraw_Struct>(device, "PerDraw"));
            CBuffers.Add(CBPerDraw);

            if (CBPerFrame != null)
            {
                CBuffers.Add(CBPerFrame.Clone());
            }

            //Create the resource interfaces ==================================================
            TerraTexture = new ShaderResource("TerraTexture");
            ShaderResources.Add(TerraTexture);

            SkyBackBuffer = new ShaderResource("SkyBackBuffer");
            ShaderResources.Add(SkyBackBuffer);

            BiomesColors = new ShaderResource("BiomesColors");
            ShaderResources.Add(BiomesColors);

            ShadowMap = new ShaderResource("ShadowMap");
            ShaderResources.Add(ShadowMap);

            //Create the Sampler interface ==================================================
            SamplerDiffuse = new ShaderSampler("SamplerDiffuse");
            ShaderSamplers.Add(SamplerDiffuse);

            SamplerBackBuffer = new ShaderSampler("SamplerBackBuffer");
            ShaderSamplers.Add(SamplerBackBuffer);

            //Load the shaders
            base.LoadShaders(shadersEntryPoint == null ? _shadersEntryPoint : shadersEntryPoint);
        }
Esempio n. 8
0
 public CLogicNode(CLogicNodeList _parent)
 {
     m_Parent = _parent;
     m_NodeConstantCollection = new CConstantCollection();
     m_NodeStringCollection   = new CStringCollection();
     m_6Buffer = new CBuffer();
     m_8Buffer = new CBuffer();
 }
Esempio n. 9
0
        public HLSLColorLine(Device engine, string shaderPath, VertexDeclaration VertexDeclaration, EntryPoints shadersEntryPoint = null)
            : base(engine, shaderPath, VertexDeclaration, null)
        {
            //Create Constant Buffers interfaces ==================================================
            CBPerDraw = new CBuffer <CBPerDrawStructure>(engine, "PerDraw");
            CBuffers.Add(CBPerDraw);

            //Load the shaders
            base.LoadShaders(shadersEntryPoint == null ? _shadersEntryPoint : shadersEntryPoint);
        }
Esempio n. 10
0
        public HLSLScreenSpaceRect(Device device)
            : base(device, @"Effects\Basics\ScreenSpaceRect.hlsl", VertexPosition2.VertexDeclaration, null)
        {
            //Create Constant Buffers interfaces
            CBPerDraw = ToDispose(new CBuffer <CBPerDraw_Struct>(device, "PerDraw"));
            CBuffers.Add(CBPerDraw);

            //Load the shaders only after the CBuffer have been defined
            base.LoadShaders(_shadersEntryPoint);
        }
        public HLSLVoxelModelInstancedShadow(Device device, string shaderPath, VertexDeclaration VertexDeclaration, EntryPoints shadersEntryPoint = null)
            : base(device, shaderPath, VertexDeclaration, null)
        {
            //Create Constant Buffers interfaces ==================================================
            CBPerDraw = ToDispose(new CBuffer <CBPerDraw_Struct>(device, "PerDrawShadow"));
            CBuffers.Add(CBPerDraw);

            //Load the shaders
            base.LoadShaders(shadersEntryPoint == null ? _shadersEntryPoint : shadersEntryPoint);
        }
Esempio n. 12
0
        public HLSLColumnChart(Device device)
            : base(device, @"Effects\Debug\ColumnChart.hlsl", VertexColumnChart.VertexDeclaration, null)
        {
            //Create Constant Buffers interfaces ==================================================
            CBPerDraw = ToDispose(new CBuffer <CBPerBatch_Struct>(device, "CBPerDraw"));
            CBuffers.Add(CBPerDraw);

            //Load the shaders
            base.LoadShaders(_shadersEntryPoint);
        }
Esempio n. 13
0
        public CDirectSoundRecord()
        {
            _Buffer = new CBuffer[CSettings.MaxNumPlayer];
            for (int i = 0; i < _Buffer.Length; i++)
            {
                _Buffer[i] = new CBuffer();
            }

            Init();
        }
Esempio n. 14
0
        public SharedFrameCB(D3DEngine engine,
                             CameraManager <ICamera> cameraManager)
        {
            _engine        = engine;
            _cameraManager = cameraManager;

            DrawOrders.UpdateIndex(0, 0); //Force the Draw call order to maximum priority, because its draw call must be done before everything else ! (As its used by all other components)

            CBPerFrame = ToDispose(new CBuffer <CBPerFrame_Struct>(_engine.Device, "PerFrameShared"));
        }
Esempio n. 15
0
        public HLSLTerranShadow(Device device, string shaderPath, VertexDeclaration VertexDeclaration, iCBuffer CBPerFrame = null, EntryPoints shadersEntryPoint = null)
            : base(device, shaderPath, VertexDeclaration, new UtopiaIncludeHandler())
        {
            //Create Contstant Buffers interfaces ==================================================
            CBPerDraw = ToDispose(new CBuffer <CBPerDraw_Struct>(device, "PerDrawShadow"));
            CBuffers.Add(CBPerDraw);

            //Load the shaders
            base.LoadShaders(shadersEntryPoint == null ? _shadersEntryPoint : shadersEntryPoint);
        }
Esempio n. 16
0
        public void SetSlienceCount(DeviceResources deviceResources, int count)
        {
            int slience1 = (count + sliencesPerBuffer - 1) / sliencesPerBuffer;

            while (constantBuffers.Count < slience1)
            {
                CBuffer buffer1 = new CBuffer();
                deviceResources.InitializeCBuffer(buffer1, bufferSize);
                constantBuffers.Add(buffer1);
            }
        }
Esempio n. 17
0
        public CPortAudioRecord()
        {
            _DeviceConfig = null;

            _Buffer = new CBuffer[CSettings.MaxNumPlayer];
            for (int i = 0; i < _Buffer.Length; i++)
            {
                _Buffer[i] = new CBuffer();
            }

            Init();
        }
Esempio n. 18
0
        public HLSLPointSpriteColor3DBillBoard(Device device, string shaderPath, VertexDeclaration VertexDeclaration, iCBuffer CBPerFrame, Include includeHandler, EntryPoints shadersEntryPoint = null)
            : base(device, shaderPath, VertexDeclaration, includeHandler)
        {
            //Create Constant Buffers interfaces ==================================================
            CBuffers.Add(CBPerFrame.Clone());

            PerFrame = ToDispose(new CBuffer <CBPerFrame_Struct>(device, "PerFrame"));
            CBuffers.Add(PerFrame);

            //Load the shaders
            base.LoadShaders(shadersEntryPoint == null ? _shadersEntryPoint : shadersEntryPoint);
        }
Esempio n. 19
0
        public CBuffer GetBuffer(GraphicsContext context)
        {
            if (cBuffer == null)
            {
                cBuffer = new CBuffer();
            }
            cBuffer.Mutable = true;

            context.UpdateResource(cBuffer, new Span <byte>(memoryStream.GetBuffer(), 0, (int)memoryStream.Position));
            binaryWriter.Seek(0, SeekOrigin.Begin);
            return(cBuffer);
        }
Esempio n. 20
0
        /// <summary>
        /// Write out the directory entry
        /// </summary>
        private void WriteDirectoryEntry(DataTrackIndexEntry entry)
        {
            SeekSector(entry.Lba);

            int size       = (int)entry.Size;
            int sectorSize = GetSectorDataSize(_defaultSectorMode);

            byte[] data = new byte[size];

            using (var stream = new CBinaryWriter(data))
            {
                // First directory entry of a directory entry is the directory itself
                stream.Write(GetDirectoryEntryBuffer(entry.DirectoryEntry, true, false));

                // Second directory entry is the parent directory entry.
                if (entry.ParentEntry != null)
                {
                    stream.Write(GetDirectoryEntryBuffer(entry.ParentEntry.DirectoryEntry, false, true));
                }
                else
                {
                    stream.Write(GetDirectoryEntryBuffer(entry.DirectoryEntry, false, true));
                }

                foreach (var subEntry in entry.SubEntries)
                {
                    // DirectoryEntry cannot be "splitted" on two sectors
                    if ((stream.Position - (stream.Position / sectorSize) * sectorSize) + subEntry.Length >= sectorSize)
                    {
                        stream.Position = ((stream.Position / sectorSize) + 1) * sectorSize;
                    }

                    if (stream.Position + subEntry.DirectoryEntry.Length < size)
                    {
                        stream.Write(GetDirectoryEntryBuffer(subEntry.DirectoryEntry));
                    }
                    else
                    {
                        throw new FrameworkException("Error while finalizing disk : directory \"{0}\" is too small", entry.FullPath);
                    }
                }
            }

            for (int i = 0; i < size; i += sectorSize)
            {
                WriteSector
                (
                    CBuffer.Create(data, i, sectorSize),
                    _defaultSectorMode,
                    (i + sectorSize >= size) ? XaSubHeader.EndOfFile : XaSubHeader.Basic
                );
            }
        }
Esempio n. 21
0
        /// <summary>
        /// Read several consecutives sectors's data
        /// </summary>
        /// <param name="count">Number of sectors to read</param>
        /// <param name="mode">Sector's mode</param>
        public byte[] ReadSectors(int count, SectorMode mode)
        {
            int dataSize = GetSectorDataSize(mode);

            byte[] data = new byte[count * dataSize];

            for (int i = 0, offset = 0; i < count; i++, offset += dataSize)
            {
                CBuffer.Copy(ReadSector(mode), data, 0, offset);
            }

            return(data);
        }
Esempio n. 22
0
        public HLSLLTree(Device device, string shaderPath, VertexDeclaration VertexDeclaration)
            : base(device, shaderPath, VertexDeclaration, null)
        {
            //Create Constant Buffers interfaces
            CBPerDraw = ToDispose(new CBuffer <CBPerDraw_Struct>(device, "PerDraw"));
            CBuffers.Add(CBPerDraw);

            CBPerFrame = ToDispose(new CBuffer <CBPerFrame_Struct>(device, "PerFrame"));
            CBuffers.Add(CBPerFrame);

            //Load the shaders
            base.LoadShaders(_shadersEntryPoint);
        }
Esempio n. 23
0
        public HLSLStars(Device device, string shaderPath, VertexDeclaration VertexDeclaration, EntryPoints shadersEntryPoint = null)
            : base(device, shaderPath, VertexDeclaration, null)
        {
            //Create Constant Buffers interfaces ==================================================
            CBPerDraw = ToDispose(new CBuffer <CBPerDraw_Struct>(device, "PerDraw"));
            CBuffers.Add(CBPerDraw);

            //Create the resource interfaces ==================================================

            //Create the Sampler interface ==================================================

            //Load the shaders
            base.LoadShaders(shadersEntryPoint == null ? _shadersEntryPoint : shadersEntryPoint);
        }
        public static void ReceiveVectors()
        {
            if (FakePosition)
            {
                if (SWatch == null)
                {
                    SWatch = Stopwatch.StartNew();
                }

                float   Rad = 300;
                float   TS  = 1000.0f;
                Vector3 Pos = new Vector3((float)Math.Sin(SWatch.ElapsedMilliseconds / TS) * Rad, 100, (float)Math.Cos(SWatch.ElapsedMilliseconds / TS) * Rad);

                MarkerA = MarkerB = MarkerC = Pos;
                return;
            }

            byte[] Bytes = ReceiveRaw();
            //Console.WriteLine(Bytes.Length);

            Vector3 *Vectors = stackalloc Vector3[3];

            Marshal.Copy(Bytes, 0, new IntPtr(Vectors), 3 * 3 * sizeof(float));

            Vector3 A = ABuffer.PushGetAverage(Vectors[0] + Program.OptotrakOffset);
            Vector3 B = BBuffer.PushGetAverage(Vectors[1] + Program.OptotrakOffset);
            Vector3 C = CBuffer.PushGetAverage(Vectors[2] + Program.OptotrakOffset);

            if (IsVisible(A))
            {
                MarkerA = A.YZX();
            }

            if (IsVisible(B))
            {
                MarkerB = B.YZX();
            }

            if (IsVisible(C))
            {
                MarkerC = C.YZX();
            }


            if (!FirstItemReceived)
            {
                FirstItemReceived = true;
                Console.WriteLine(ConsoleColor.Yellow, "Receiving Optotrak data! {0}", GetPos());
            }
        }
        public static void ReceiveVectors()
        {
            if (FakePosition)
            {
                if (SWatch == null)
                {
                    SWatch = Stopwatch.StartNew();
                }

                float   Rad = 300;
                float   TS  = 1000.0f;
                Vector3 Pos = new Vector3((float)Math.Sin(SWatch.ElapsedMilliseconds / TS) * Rad, 100, (float)Math.Cos(SWatch.ElapsedMilliseconds / TS) * Rad);

                MarkerA = MarkerB = MarkerC = Pos;
                return;
            }

            byte[] Bytes = ReceiveRaw();
            //Console.WriteLine(Bytes.Length);

            Vector3 *Vectors = stackalloc Vector3[3];

            Marshal.Copy(Bytes, 0, new IntPtr(Vectors), 3 * 3 * sizeof(float));             // Create vectors from bytes recieved over UDP

            Vector3 A = ABuffer.PushGetAverage(Vectors[0] + Program.OptotrakOffset);        // Method in CircularVectorBuffer class. This basically performs the running average filter
            Vector3 B = BBuffer.PushGetAverage(Vectors[1] + Program.OptotrakOffset);
            Vector3 C = CBuffer.PushGetAverage(Vectors[2] + Program.OptotrakOffset);

            if (IsVisible(A))             // Checks for marker visibility. If it is not the last value is used.
            {
                MarkerA = A.YZX();
            }

            if (IsVisible(B))
            {
                MarkerB = B.YZX();
            }

            if (IsVisible(C))
            {
                MarkerC = C.YZX();
            }


            if (!FirstItemReceived)
            {
                FirstItemReceived = true;
                Console.WriteLine(ConsoleColor.Yellow, "Receiving Optotrak data! {0}", GetPos());
            }
        }
Esempio n. 26
0
        public NoiseShader(Device device, iCBuffer PerFrameShared)
            : base(device, @"Visualisator3D\CustomShaders\NoiseShader.hlsl", VertexPosition4Color.VertexDeclaration, PerFrameShared)
        {
            //Create Constant Buffers interfaces ==================================================
            CBPerDraw = ToDispose(new CBuffer <CBPerDraw_Struct>(device, "PerDraw"));
            CBuffers.Add(CBPerDraw);

            //Create the resource interfaces (Textures, ...) ==================================================

            //Create the Sampler interface (Texture samplers, ...) ==================================================

            //Load the shaders only after the CBuffer have been defined
            base.LoadShaders(_shadersEntryPoint);
        }
Esempio n. 27
0
        /// <summary>
        /// Write out path table
        /// </summary>
        /// <param name="lba"></param>
        /// <param name="data"></param>
        private void WritePathTable(uint lba, byte[] data)
        {
            SeekSector(lba);
            int sectorSize = GetSectorDataSize(_defaultSectorMode);

            for (int i = 0; i < data.Length; i += sectorSize)
            {
                WriteSector
                (
                    CBuffer.Create(data, i, sectorSize),
                    _defaultSectorMode,
                    (i + sectorSize >= data.Length) ? XaSubHeader.EndOfFile : XaSubHeader.Basic
                );
            }
        }
Esempio n. 28
0
        public HLSLVoxelModel(Device device, string shaderPath, VertexDeclaration VertexDeclaration, EntryPoints shadersEntryPoint = null)
            : base(device, shaderPath, VertexDeclaration, null)
        {
            //Create Constant Buffers interfaces ==================================================
            CBPerFrame = ToDispose(new CBuffer <CBPerFrameStructure>(device, "VoxelModelPerFrame"));
            CBuffers.Add(CBPerFrame);

            CBPerModel = ToDispose(new CBuffer <CBPerModelStructure>(device, "VoxelModel", true));
            CBuffers.Add(CBPerModel);

            CBPerPart = ToDispose(new CBuffer <CBPerPartStructure>(device, "VoxelModelPerPart"));
            CBuffers.Add(CBPerPart);

            //Load the shaders
            base.LoadShaders(shadersEntryPoint == null ? _shadersEntryPoint : shadersEntryPoint);
        }
Esempio n. 29
0
        public HLSLClouds(Device device, string effectPath, VertexDeclaration vertexDeclaration, params iCBuffer[] externalCBuffers)
            : base(device, effectPath, vertexDeclaration, new UtopiaIncludeHandler(), externalCBuffers)
        {
            //Create Constant Buffers interfaces
            CBPerDraw = ToDispose(new CBuffer <CBPerDrawStruct>(device, "PerDraw"));
            CBuffers.Add(CBPerDraw);

            //Create the resource interfaces ==================================================
            SamplerBackBuffer = new ShaderSampler("SamplerBackBuffer");
            ShaderSamplers.Add(SamplerBackBuffer);

            SolidBackBuffer = new ShaderResource("SkyBackBuffer");
            ShaderResources.Add(SolidBackBuffer);

            //Load the shaders only after the CBuffer have been defined
            base.LoadShaders(_shadersEntryPoint);
        }
Esempio n. 30
0
        public HLSLSprites(Device device, string FileName)
            : base(device, @"Effects\Sprites\" + FileName, VertexSprite2.VertexDeclaration, null)
        {
            //Create Constant Buffers interfaces ==================================================
            CBPerDraw = ToDispose(new CBuffer <CBPerDraw_Struct>(device, "PerDraw"));
            CBuffers.Add(CBPerDraw);

            //Create the resource interfaces ==================================================
            SpriteTexture = new ShaderResource("SpriteTexture");
            ShaderResources.Add(SpriteTexture);

            //Create the Sampler interface ==================================================
            SpriteSampler = new ShaderSampler("SpriteSampler");
            ShaderSamplers.Add(SpriteSampler);

            //Load the shaders
            base.LoadShaders(_shadersEntryPoint);
        }