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; } } }
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); }
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)); }
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)); }
private void GetNodesForRendering(ref NumshbNode 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 NutexbNode nutexNode) { var texture = (RTexture)nutexNode.Renderable.Value; // Use the file name instead of the internal name. // Ignore case. var textureName = System.IO.Path.GetFileNameWithoutExtension(fileNode.Text).ToLower(); textureByName[textureName] = texture; } else if (fileNode.Text.Equals(model.MeshString)) { meshNode = (NumshbNode)fileNode; } else if (fileNode.Text.Equals(model.SkeletonFileName)) { skeleton = (RSkeleton)((NusktbNode)fileNode).Renderable.Value; } else if (fileNode.Text.Equals(model.MaterialFileNames[0].MaterialFileName)) { material = ((NumatbNode)fileNode).Material; } else if (fileNode.Text.Equals("model.xmb")) { modelXmb = (XmbNode)fileNode; } else if (fileNode.Text.Equals("lod.xmb")) { lodXmb = (XmbNode)fileNode; } } }
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)); }
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; } } }