Пример #1
0
        public GeometryToObjectConverter(
            GameCacheHaloOnlineBase destCache, Stream destStream, GameCache sourceCache,
            Stream sourceStream, Scenario scenario, int structureBspIndex)
        {
            DestCache         = destCache;
            DestStream        = destStream;
            SourceCache       = sourceCache;
            SourceStream      = sourceStream;
            StructureBspIndex = structureBspIndex;
            PortTag           = new PortTagCommand(destCache, sourceCache);
            PortTag.SetFlags(PortTagCommand.PortingFlags.Default);

            Scenario          = scenario;
            StructureBspIndex = structureBspIndex;
            StructureBsp      = SourceCache.Deserialize <ScenarioStructureBsp>(SourceStream, Scenario.StructureBsps[structureBspIndex].StructureBsp);
            sLdT = SourceCache.Deserialize <ScenarioLightmap>(SourceStream, Scenario.Lightmap);

            if (SourceCache.Version >= CacheVersion.Halo3ODST)
            {
                Lbsp = SourceCache.Deserialize <ScenarioLightmapBspData>(SourceStream, sLdT.LightmapDataReferences[StructureBspIndex]);
            }
            else
            {
                Lbsp = sLdT.Lightmaps[StructureBspIndex];
            }

            var resourceDefinition = SourceCache.ResourceCache.GetRenderGeometryApiResourceDefinition(Lbsp.Geometry.Resource);

            Lbsp.Geometry.SetResourceBuffers(resourceDefinition);

            StructureBspResources = SourceCache.ResourceCache.GetStructureBspTagResources(StructureBsp.CollisionBspResource);
        }
Пример #2
0
        private ScenarioLightmapBspData ConvertScenarioLightmapBspData(ScenarioLightmapBspData Lbsp)
        {
            var lightmapResourceDefinition = BlamCache.ResourceCache.GetRenderGeometryApiResourceDefinition(Lbsp.Geometry.Resource);

            if (lightmapResourceDefinition == null)
            {
                return(Lbsp);
            }

            var converter = new RenderGeometryConverter(CacheContext, BlamCache);
            var newLightmapResourceDefinition = converter.Convert(Lbsp.Geometry, lightmapResourceDefinition);

            //
            // convert vertex buffers and add them to the new resource
            //

            foreach (var staticPerVertexLighting in Lbsp.StaticPerVertexLightingBuffers)
            {
                if (staticPerVertexLighting.VertexBufferIndex != -1)
                {
                    staticPerVertexLighting.VertexBuffer = lightmapResourceDefinition.VertexBuffers[staticPerVertexLighting.VertexBufferIndex].Definition;
                    VertexBufferConverter.ConvertVertexBuffer(BlamCache.Version, CacheContext.Version, staticPerVertexLighting.VertexBuffer);
                    var d3dPointer = new D3DStructure <VertexBufferDefinition>();
                    d3dPointer.Definition = staticPerVertexLighting.VertexBuffer;
                    newLightmapResourceDefinition.VertexBuffers.Add(d3dPointer);
                    // set the new buffer index
                    staticPerVertexLighting.VertexBufferIndex = (short)(newLightmapResourceDefinition.VertexBuffers.Elements.Count - 1);
                }
            }

            Lbsp.Geometry.Resource = CacheContext.ResourceCache.CreateRenderGeometryApiResource(newLightmapResourceDefinition);

            return(Lbsp);
        }
Пример #3
0
        public ExtractRenderGeometryCommand(GameCache cache, ScenarioLightmapBspData definition)
            : base(true,

                   "ExtractRenderGeometry",
                   "Extracts render geometry from the current scenario_lightmap_bsp_data definition.",

                   "ExtractRenderGeometry <filetype> <filename>",

                   "Extracts render geometry from the current scenario_lightmap_bsp_data definition.\n" +
                   "Supported file types: obj")
        {
            Cache      = cache;
            Definition = definition;
        }
Пример #4
0
        public static CommandContext Create(CommandContext parent, HaloOnlineCacheContext cacheContext, CachedTagInstance tag, ScenarioLightmapBspData Lbsp)
        {
            var groupName = cacheContext.GetString(tag.Group.Name);

            var context = new CommandContext(parent,
                                             string.Format("{0:X8}.{1}", tag.Index, groupName));

            Populate(context, cacheContext, tag, Lbsp);

            return(context);
        }
Пример #5
0
 public static void Populate(CommandContext commandContext, HaloOnlineCacheContext cacheContext, CachedTagInstance tag, ScenarioLightmapBspData Lbsp)
 {
     commandContext.AddCommand(new DumpRenderGeometryCommand(cacheContext, Lbsp.Geometry, "Lightmap"));
     commandContext.AddCommand(new ExtractRenderGeometryCommand(cacheContext, Lbsp));
 }
 private ScenarioLightmapBspData ConvertScenarioLightmapBspData(ScenarioLightmapBspData Lbsp)
 {
     //Test
     return(Lbsp);
 }
Пример #7
0
        public static CommandContext Create(CommandContext parent, GameCache cache, CachedTag tag, ScenarioLightmapBspData Lbsp)
        {
            var groupName = cache.StringTable.GetString(tag.Group.Name);

            var context = new CommandContext(parent,
                                             string.Format("{0:X8}.{1}", tag.Index, groupName));

            Populate(context, cache, tag, Lbsp);

            return(context);
        }
Пример #8
0
 public static void Populate(CommandContext commandContext, GameCache cache, CachedTag tag, ScenarioLightmapBspData Lbsp)
 {
     commandContext.AddCommand(new DumpRenderGeometryCommand(cache, Lbsp.Geometry, "Lightmap"));
     commandContext.AddCommand(new ExtractRenderGeometryCommand(cache, Lbsp));
 }