Exemple #1
0
        /// <summary>
        /// Creates the library_visual_scenes element in the collada file
        /// </summary>
        void AddLibraryVisualScenes()
        {
            COLLADAFile.LibraryVisualScenes             = new Core.ColladaLibraryVisualScenes();
            COLLADAFile.LibraryVisualScenes.VisualScene = new List <Core.ColladaVisualScene>();
            COLLADAFile.LibraryVisualScenes.VisualScene.Add(new Core.ColladaVisualScene());
            COLLADAFile.LibraryVisualScenes.VisualScene[0].ID   = ColladaElement.FormatID <Core.ColladaVisualScene>("main");
            COLLADAFile.LibraryVisualScenes.VisualScene[0].Node = new List <Core.ColladaNode>();

            COLLADAFile.LibraryVisualScenes.VisualScene[0].Node.Add(listBone[0]);
            COLLADAFile.LibraryVisualScenes.VisualScene[0].Node.AddRange(listNode);
        }
Exemple #2
0
        ///-------------------------------------------------------------------------------------------------
        /// <summary>	Creates instances of all the controllers. </summary>
        ///-------------------------------------------------------------------------------------------------
        void CreateNodeList()
        {
            var materialReferences = new MaterialReferenceList();

            if (mShaderDataProvider != null)
            {
                // create a list of every shader used
                foreach (var effect in mShaderDataProvider.GetEffects())
                {
                    string effectName = ColladaUtilities.FormatName(Path.GetFileNameWithoutExtension(effect.Name), " ", "_");

                    materialReferences.Add(new MaterialReference(
                                               effectName,
                                               ColladaUtilities.BuildUri(ColladaElement.FormatID <Fx.ColladaMaterial>(effectName)),
                                               effectName));
                }
            }

            // create the controller instances
            var geometrySetList = mModelDataProvider.GetGeometries();

            for (int i = 0; i < geometrySetList.Count; i++)
            {
                var node = CreateNode(geometrySetList[i].Name, "", geometrySetList[i].Name, Enums.ColladaNodeType.NODE);

                // If there are no bones instance the static geometry, otherwise create a skinned instance
                string name = ColladaUtilities.FormatName(geometrySetList[i].Name, " ", "_");
                if (mModelDataProvider.GetBones().Count == 0)
                {
                    node.Add(
                        CreateInstanceGeometry(
                            ColladaUtilities.BuildUri(ColladaElement.FormatID <Core.ColladaGeometry>(name)),
                            name,
                            materialReferences
                            )
                        );
                }
                else
                {
                    node.Add(
                        CreateInstanceController(
                            ColladaUtilities.BuildUri(ColladaElement.FormatID <Core.ColladaController>(name)),
                            name,
                            materialReferences
                            )
                        );
                }

                listNode.Add(node);
            }
        }
        /// <summary>
        /// Creates the library_visual_scenes element in the collada file. The node list is added under a node named "frame" since that is
        /// required when creating new BSPs.
        /// </summary>
        void AddLibraryVisualScenes()
        {
            // add the main scene node
            COLLADAFile.LibraryVisualScenes             = new Core.ColladaLibraryVisualScenes();
            COLLADAFile.LibraryVisualScenes.VisualScene = new List <Core.ColladaVisualScene>();
            COLLADAFile.LibraryVisualScenes.VisualScene.Add(new Core.ColladaVisualScene());
            COLLADAFile.LibraryVisualScenes.VisualScene[0].ID   = ColladaElement.FormatID <Core.ColladaVisualScene>("main");
            COLLADAFile.LibraryVisualScenes.VisualScene[0].Node = new List <Core.ColladaNode>();

            Core.ColladaNode frame = new BlamLib.Render.COLLADA.Core.ColladaNode();
            frame.Name = "frame";
            frame.AddRange(listNode);

            COLLADAFile.LibraryVisualScenes.VisualScene[0].Node.Add(frame);
        }
Exemple #4
0
        ///-------------------------------------------------------------------------------------------------
        /// <summary>	Creates nodes for all the geometry elements in the collada file. </summary>
        ///-------------------------------------------------------------------------------------------------
        private void CreateNodeList()
        {
            // Create the list of materials for the geometry to use
            var materialReferences = new MaterialReferenceList();

            Action <string> addMaterialRef =
                effectName =>
            {
                string name = ColladaUtilities.FormatName(Path.GetFileNameWithoutExtension(effectName), " ", "_");

                materialReferences.Add(new MaterialReference(
                                           effectName,
                                           ColladaUtilities.BuildUri(ColladaElement.FormatID <Fx.ColladaMaterial>(name)),
                                           name));
            };

            if (mShaderDataProvider != null)
            {
                // create a list of every shader used
                if (mBSPDataProvider.IncludeRenderMesh)
                {
                    foreach (var effect in mShaderDataProvider.GetEffects())
                    {
                        addMaterialRef(effect.Name);
                    }
                }

                // if portals are included add the portals shader to the names
                if (mBSPDataProvider.IncludePortals)
                {
                    addMaterialRef("portals");
                }

                // if fogplanes are included add the fogplanes shader to the names
                if (mBSPDataProvider.IncludeFogPlanes)
                {
                    addMaterialRef("fogplanes");
                }
            }

            // Create a node with a geometry instance for all included geometry
            var definition = mTagManager.TagDefinition as H1.Tags.structure_bsp_group;

            Func <int, Core.ColladaNode> addGeometryInstance =
                geometryIndex =>
            {
                string name = listGeometry[geometryIndex].Name;
                var    node = CreateNode(name, "", name, Enums.ColladaNodeType.NODE);

                string url = ColladaUtilities.BuildUri(listGeometry[geometryIndex].ID);
                node.Add(CreateInstanceGeometry(url, name, materialReferences));

                return(node);
            };

            int geometry_offset = 0;

            if (mBSPDataProvider.IncludeRenderMesh)
            {
                // create geometry instance for all of the lightmaps
                for (int i = 0; i < definition.Lightmaps.Count; i++)
                {
                    listNode.Add(addGeometryInstance(geometry_offset + i));
                }
                geometry_offset += definition.Lightmaps.Count;
            }

            if (mBSPDataProvider.IncludePortals)
            {
                // create geometry instance for all of the portal meshes
                for (int i = 0; i < definition.ClusterPortals.Count; i++)
                {
                    listNode.Add(addGeometryInstance(geometry_offset + i));
                }
                geometry_offset += definition.ClusterPortals.Count;
            }

            if (mBSPDataProvider.IncludeFogPlanes)
            {
                // create geometry instance for all of the fogplane meshes
                for (int i = 0; i < definition.FogPlanes.Count; i++)
                {
                    listNode.Add(addGeometryInstance(geometry_offset + i));
                }
                geometry_offset += definition.FogPlanes.Count;
            }
        }