Exemplo n.º 1
0
 private void GetNodesForRendering(ref NumsbhNode meshNode, ref NuhlpbNode hlpbNode, ref RSkeleton skeleton, ref Matl material, Dictionary <string, SFGraphics.GLObjects.Textures.Texture> textureByName)
 {
     foreach (FileNode fileNode in Parent.Nodes)
     {
         if (fileNode is NuhlpbNode node)
         {
             hlpbNode = node;
         }
         else if (fileNode is NutexNode nutexNode)
         {
             var texture = (RTexture)nutexNode.GetRenderableNode();
             textureByName[nutexNode.TexName.ToLower()] = texture.RenderTexture;
         }
         else if (fileNode.Text.Equals(model.MeshString))
         {
             meshNode = (NumsbhNode)fileNode;
         }
         else if (fileNode.Text.Equals(model.SkeletonFileName))
         {
             skeleton = (RSkeleton)((SkelNode)fileNode).GetRenderableNode();
         }
         else if (fileNode.Text.Equals(model.MaterialFileNames[0].MaterialFileName))
         {
             material = ((MatlNode)fileNode).Material;
         }
     }
 }
Exemplo n.º 2
0
        private IRenderable CreateRenderableModel()
        {
            Rnumdl renderableNode = new Rnumdl
            {
                MODL = _model
            };

            NumsbhNode modelNode  = null;
            NuhlpbNode helperNode = null;

            foreach (FileNode fileNode in Parent.Nodes)
            {
                if (fileNode is NuhlpbNode node)
                {
                    helperNode = node;
                }
                if (fileNode is NutexNode nutexNode)
                {
                    var texture = (RTexture)nutexNode.GetRenderableNode();
                    // TODO: Why are there empty streams?
                    if (nutexNode.TexName != null)
                    {
                        renderableNode.sfTextureByName.Add(nutexNode.TexName.ToLower(), texture.renderTexture);
                    }
                }
                if (fileNode.Text.Equals(_model.MeshString))
                {
                    modelNode = (NumsbhNode)fileNode;
                }
                if (fileNode.Text.Equals(_model.SkeletonFileName))
                {
                    renderableNode.Skeleton = (RSkeleton)((SkelNode)fileNode).GetRenderableNode();
                }
                if (fileNode.Text.Equals(_model.MaterialFileNames[0].MaterialFileName))
                {
                    renderableNode.Material = ((MatlNode)fileNode).Material;
                }
            }

            if (modelNode != null)
            {
                renderableNode.Model = modelNode.GetRenderModel(renderableNode.Skeleton);
            }
            if (renderableNode.Material != null)
            {
                renderableNode.UpdateMaterial();
            }
            if (renderableNode.Skeleton != null)
            {
                helperNode?.AddToRenderSkeleton(renderableNode.Skeleton);
                renderableNode.UpdateBinds();
            }

            return(renderableNode);
        }
Exemplo n.º 3
0
        private IRenderable CreateRenderableModel()
        {
            NumsbhNode meshNode = null;
            NuhlpbNode hlpbNode = null;
            RSkeleton  skeleton = null;
            Matl       material = null;

            var textureByName = new Dictionary <string, SFGraphics.GLObjects.Textures.Texture>();

            GetNodesForRendering(ref meshNode, ref hlpbNode, ref skeleton, ref material, textureByName);

            return(new RNumdl(model, skeleton, material, meshNode, hlpbNode, textureByName));
        }
Exemplo n.º 4
0
        private IRenderable CreateRenderableModel()
        {
            NumsbhNode meshNode = null;
            NuhlpbNode hlpbNode = null;
            RSkeleton  skeleton = null;
            Matl       material = null;
            XmbNode    modelXmb = null;
            XmbNode    lodXmb   = null;

            var textureByName = new Dictionary <string, RTexture>();

            GetNodesForRendering(ref meshNode, ref hlpbNode, ref skeleton, ref material, ref modelXmb, ref lodXmb, textureByName);

            return(new RNumdl(model, skeleton, material, meshNode, hlpbNode, modelXmb, lodXmb, textureByName));
        }
Exemplo n.º 5
0
        private IRenderable CreateRenderableModel()
        {
            NumsbhNode meshNode = null;
            NuhlpbNode hlpbNode = null;
            RSkeleton  skeleton = null;
            Matl       material = null;
            // TODO: Add remaining default textures.
            var textureByName = new Dictionary <string, SFGraphics.GLObjects.Textures.Texture>
            {
                { "#replace_cubemap", Rendering.Resources.DefaultTextures.Instance.SpecularPbr },
                { "/common/shader/sfxpbs/default_normal", Rendering.Resources.DefaultTextures.Instance.DefaultNormal },
                { "/common/shader/sfxpbs/default_params", Rendering.Resources.DefaultTextures.Instance.DefaultPrm },
                { "/common/shader/sfxpbs/default_black", Rendering.Resources.DefaultTextures.Instance.DefaultBlack },
                { "/common/shader/sfxpbs/default_white", Rendering.Resources.DefaultTextures.Instance.DefaultWhite },
                { "/common/shader/sfxpbs/default_color", Rendering.Resources.DefaultTextures.Instance.DefaultWhite }
            };

            GetNodesForRendering(ref meshNode, ref hlpbNode, ref skeleton, ref material, textureByName);

            return(new RNumdl(model, skeleton, material, meshNode, hlpbNode, textureByName));
        }
Exemplo n.º 6
0
 private void GetNodesForRendering(ref NumsbhNode meshNode, ref NuhlpbNode hlpbNode, ref RSkeleton skeleton, ref Matl material, ref XmbNode modelXmb, ref XmbNode lodXmb,
                                   Dictionary <string, RTexture> textureByName)
 {
     // TODO: There's probably a cleaner way of doing this.
     foreach (FileNode fileNode in Parent.Nodes)
     {
         if (fileNode is NuhlpbNode node)
         {
             hlpbNode = node;
         }
         else if (fileNode is NutexNode nutexNode)
         {
             var texture = (RTexture)nutexNode.GetRenderableNode();
             textureByName[nutexNode.TexName.ToLower()] = texture;
         }
         else if (fileNode.Text.Equals(model.MeshString))
         {
             meshNode = (NumsbhNode)fileNode;
         }
         else if (fileNode.Text.Equals(model.SkeletonFileName))
         {
             skeleton = (RSkeleton)((SkelNode)fileNode).GetRenderableNode();
         }
         else if (fileNode.Text.Equals(model.MaterialFileNames[0].MaterialFileName))
         {
             material = ((MatlNode)fileNode).Material;
         }
         else if (fileNode.Text.Equals("model.xmb"))
         {
             modelXmb = (XmbNode)fileNode;
         }
         else if (fileNode.Text.Equals("lod.xmb"))
         {
             lodXmb = (XmbNode)fileNode;
         }
     }
 }