Ejemplo n.º 1
0
        /// <summary>
        /// Creates geometries for the relevant lightmap meshes that are to be included in the collada file
        /// </summary>
        void CreateGeometryList()
        {
            H2.Tags.scenario_structure_bsp_group definition = tagManager.TagDefinition as H2.Tags.scenario_structure_bsp_group;

            if (bspInfo.IncludeRenderMesh())
            {
                // create a list of all the shaders used
                List <string> shader_list = new List <string>();
                foreach (var material in definition.Materials)
                {
                    shader_list.Add(Path.GetFileNameWithoutExtension(material.Shader.ToString()));
                }

                // create a geometry element for each cluster
                for (int i = 0; i < definition.Clusters.Count; i++)
                {
                    string name = String.Format("{0}-{1}", ColladaUtilities.FormatName(tagName, " ", "_"), i);

                    // create the geometry element
                    CreateGeometryHalo2(name, false,
                                        definition.Clusters[i].SectionInfo,
                                        definition.Clusters[i].ClusterData[0].Section.Value,
                                        shader_list);
                }
            }
            if (bspInfo.IncludePortalsMesh())
            {
                // create a geometry element for each cluster portal
                for (int i = 0; i < definition.ClusterPortals.Count; i++)
                {
                    CreatePortalsGeometry(i);
                }
            }
        }
Ejemplo n.º 2
0
        void CreateMarkerList()
        {
            H2.Tags.scenario_structure_bsp_group definition = tagManager.TagDefinition as H2.Tags.scenario_structure_bsp_group;

            List <Marker> marker_list = new List <Marker>();

            // create a list of generic marker definitions
            foreach (var marker in definition.Markers)
            {
                Marker common_marker = new Marker(marker.Name.ToString(),
                                                  marker.Position.ToPoint3D(100),
                                                  marker.Rotation.ToQuaternion(),
                                                  -1);

                marker_list.Add(common_marker);
            }

            // create the marker node elements
            CreateMarkers(marker_list, RotationVectorY, RotationVectorP, RotationVectorR);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Creates nodes for all the geometry elements in the collada file
        /// </summary>
        void CreateNodeList()
        {
            H2.Tags.scenario_structure_bsp_group definition = tagManager.TagDefinition as H2.Tags.scenario_structure_bsp_group;

            // create a list of all the shaders used
            List <string> shader_list = new List <string>();

            for (int shader_index = 0; shader_index < shaderInfo.GetShaderCount(); shader_index++)
            {
                shader_list.Add(ColladaUtilities.FormatName(Path.GetFileNameWithoutExtension(shaderInfo.GetShaderName(shader_index)), " ", "_"));
            }

            // if portals are included and the portals material to the list
            if (bspInfo.IncludePortalsMesh())
            {
                shader_list.Add("portals");
            }

            // create a geometry instances for the render geometry
            int geometry_offset = 0;

            if (bspInfo.IncludeRenderMesh())
            {
                for (int i = 0; i < definition.Clusters.Count; i++)
                {
                    CreateNodeInstanceGeometry(listGeometry[geometry_offset + i].Name, geometry_offset + i, shader_list);
                }
                geometry_offset += definition.Clusters.Count;
            }

            // create a geometry instances for the portal geometry
            if (bspInfo.IncludePortalsMesh())
            {
                for (int i = 0; i < definition.ClusterPortals.Count; i++)
                {
                    CreateNodeInstanceGeometry(listGeometry[geometry_offset + i].Name, geometry_offset + i, shader_list);
                }
                geometry_offset += definition.ClusterPortals.Count;
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Creates a geometry element for a single cluster portal
        /// </summary>
        /// <param name="portal_index">Index of the portal to create a geometry element for</param>
        /// <returns></returns>
        void CreatePortalsGeometry(int index)
        {
            H2.Tags.scenario_structure_bsp_group definition = tagManager.TagDefinition as H2.Tags.scenario_structure_bsp_group;

            List <Vertex> common_vertices = new List <Vertex>();

            // add the vertex position information to the position source
            foreach (var vertex in definition.ClusterPortals[index].Vertices)
            {
                common_vertices.Add(new Vertex(vertex.Point.ToPoint3D(100)));
            }

            List <Part> common_parts = new List <Part>();

            // only one part is needed since one one material is used
            Part common_part = new Part("portals");

            common_part.AddIndices(BuildFaceIndices(definition.ClusterPortals[index].Vertices.Count));
            common_parts.Add(common_part);

            // create the geometry element
            CreateGeometry("portal-" + index.ToString(), 0, VertexComponent.POSITION,
                           common_vertices, common_parts);
        }