示例#1
0
        public void DisplayVertexInstructions(TagDatum vertexDatum, CacheStream cache)
        {
            var vertexBlock = ( VertexShaderBlock )cache.Deserialize(vertexDatum.Identifier);
            var code        = vertexBlock.GeometryClassifications[0].Code;
            var altCode     = vertexBlock.GeometryClassifications[0].CompiledShader;
            var strBuilder  = new StringBuilder();

            foreach (var s in altCode)
            {
                strBuilder.Append("$ " + s + " ");
            }
            strBuilder.AppendLine();
            if (code.Length < 4)
            {
                textEditorControl1.Text = strBuilder.ToString();
                textEditorControl1.Refresh(  );
                return;
            }
            using (BinaryReader binaryReader = new BinaryReader(new MemoryStream(code)))
            {
                var version = binaryReader.ReadInt16( );
                strBuilder.AppendLine("#" + version);
                var instructionCount = binaryReader.ReadInt16( );
                for (int i = 0; i < instructionCount; i++)
                {
                    var instructionBytes = binaryReader.ReadBytes(16);
                    var instruction      = new VertexProgramInstruction(instructionBytes);
                    strBuilder.AppendLine(instruction.ToAsm);
                }
            }
            textEditorControl1.Text = strBuilder.ToString( );
            textEditorControl1.Refresh();
        }
示例#2
0
        private List <VertexConstantInfo> GetVertexConstants(TagDatum vertexTag, CacheStream cache)
        {
            if (!cache.Index.Contains(vertexTag))
            {
                return(new List <VertexConstantInfo>( ));
            }

            var vertexConstantInfos = new List <VertexConstantInfo>( );

            foreach (var tagDatum in cache.Index.Where(TagClass.Spas))
            {
                var block      = ( ShaderPassBlock )cache.Deserialize(tagDatum.Identifier);
                var usesVertex =
                    block.PostprocessDefinition[0].Implementations.Any(
                        u => u.VertexShader.Ident == vertexTag.Identifier);
                if (!usesVertex)
                {
                    continue;
                }
                foreach (var templateDatum in cache.Index.Where(TagClass.Stem))
                {
                    var templateBlock = ( ShaderTemplateBlock )cache.Deserialize(templateDatum.Identifier);
                    var usesPass      =
                        templateBlock.PostprocessDefinition[0].Passes.Any(
                            v => v.Pass.Ident == tagDatum.Identifier);
                    if (!usesPass)
                    {
                        continue;
                    }
                    foreach (var shaderDatum in cache.Index.Where(TagClass.Shad))
                    {
                        var shaderBlock  = ( ShaderBlock )cache.Deserialize(shaderDatum.Identifier);
                        var usesTemplate = shaderBlock.Template.Ident == templateDatum.Identifier;
                        if (usesTemplate)
                        {
                            var items = GetVertexConstants(shaderBlock, templateBlock, block, vertexTag, tagDatum,
                                                           templateDatum,
                                                           shaderDatum, cache);
                            vertexConstantInfos.AddRange(items);
                        }
                    }
                }
            }
            return(vertexConstantInfos);
        }
示例#3
0
        private void DisplayVertexInstructions(TagDatum vertexDatum, CacheStream cache)
        {
            foreach (var documentsDockContent in documentsDockContents)
            {
                documentsDockContent.DockHandler.DockPanel = null;
                documentsDockContent.Dispose(  );
            }
            var vertexBlock = ( VertexShaderBlock )cache.Deserialize(vertexDatum.Identifier);

            for (var i = 0; i < vertexBlock.GeometryClassifications.Length; i++)
            {
                var asmEditor  = new AsmEditor($"vertex_{i}.glsl");
                var code       = vertexBlock.GeometryClassifications[i].Code;
                var altCode    = vertexBlock.GeometryClassifications[i].CompiledShader;
                var strBuilder = new StringBuilder( );
                foreach (var s in altCode)
                {
                    strBuilder.Append("$ " + s + " ");
                }
                strBuilder.AppendLine( );
                if (code.Length < 4)
                {
                    asmEditor.SetText(strBuilder.ToString( ));
                    return;
                }
                using (var binaryReader = new BinaryReader(new MemoryStream(code)))
                {
                    var version = binaryReader.ReadInt16( );
                    strBuilder.AppendLine("#" + version);
                    var instructionCount = binaryReader.ReadInt16( );
                    for (var index = 0; index < instructionCount; index++)
                    {
                        var instructionBytes = binaryReader.ReadBytes(16);
                        var instruction      = new VertexProgramInstruction(instructionBytes);
                        strBuilder.AppendLine(instruction.ToAsm);
                    }
                }
                documentsDockContents.Add(asmEditor);
                asmEditor.SetText(strBuilder.ToString( ));
                asmEditor.Show(dockPanel1, DockState.Document);
            }
        }
示例#4
0
        public DatumViewer( )
        {
            InitializeComponent( );

            _cacheStream = CacheStream.Open(Path.Combine(Local.MapsDirectory, "headlong.map"));
            var objectListView       = new TagDatumView( );
            var guerillaPropertyView = new GuerillaBlockPropertyViewer( );

            objectListView.LoadTagDatums(_cacheStream.Index);
            objectListView.NodeMouseDoubleClick += (sender, args) =>
            {
                if (objectListView.SelectedNode != null && objectListView.SelectedNode.Tag is TagDatum)
                {
                    var guerillaBlock = _cacheStream.Deserialize((( TagDatum )objectListView.SelectedNode.Tag).Identifier);
                    guerillaPropertyView.LoadGuerillaBlocks(guerillaBlock);
                }
            };

            guerillaPropertyView.Show(dockPanel1, DockState.Document);

            objectListView.Show(dockPanel1, DockState.DockLeft);
        }