public MeshSceneNodeViewModel(Rmv2MeshNode node, PackFileService pfs, SkeletonAnimationLookUpHelper animLookUp, IComponentManager componentManager) { _meshNode = node; General = new MeshSceneNodeViewModel_General(_meshNode); Animation = new MeshSceneNodeViewModel_Animation(pfs, _meshNode, animLookUp, componentManager); Graphics = new MeshSceneNodeViewModel_Graphics(_meshNode, pfs); }
public BmiViewModel(GameSkeleton skeleton, Rmv2MeshNode meshNode, IComponentManager componentManager) { _componentManager = componentManager; _meshNode = meshNode; _skeleton = skeleton; CreateBoneOverview(_skeleton); }
private string UnknownMaterial(Rmv2MeshNode mesh) { var textureName = "?"; var texture = mesh.MeshModel.GetTexture(TexureType.Diffuse); if (texture.HasValue) { textureName = texture.Value.Path; } var vertextType = mesh.MeshModel.Header.VertextType; var alphaOn = mesh.MeshModel.AlphaSettings.Mode != AlphaMode.Opaque; var vertexName = "uknown"; if (vertextType == VertexFormat.Cinematic) { vertexName = "weighted4"; } else if (vertextType == VertexFormat.Weighted) { vertexName = "weighted2"; } else if (vertextType == VertexFormat.Default) { vertexName = "static"; } return($" MeshName='{mesh.Name}' Texture='{textureName}' VertType='{vertexName}' Alpha='{alphaOn}'"); }
public GrowMeshCommand(GameSkeleton skeleton, Rmv2MeshNode node, float factor, List <int> bonesAffectedScale) { _node = node; _factor = factor; _gameSkeleton = skeleton; _bonesAffectedScale = bonesAffectedScale; }
public RemapBoneIndexesCommand(Rmv2MeshNode meshOwner, List <IndexRemapping> mapping, string newSkeletonName, bool moveMeshToFit, GameSkeleton currentSkeleton, GameSkeleton targetSkeleton) { _meshOwner = meshOwner; _mapping = mapping; _newSkeletonName = newSkeletonName; _moveMeshToFit = moveMeshToFit; _currentSkeleton = currentSkeleton; _targetSkeleton = targetSkeleton; }
public void ReduceMesh(Rmv2MeshNode meshNode, float factor, bool undoable) { var command = new ReduceMeshCommand(new List <Rmv2MeshNode>() { meshNode }, factor); _commandManager.ExecuteCommand(command, undoable); }
public TextureViewModel(Rmv2MeshNode meshNode, PackFileService packfileService, TexureType texureType) { _packfileService = packfileService; _meshNode = meshNode; _texureType = texureType; Path = _meshNode.MeshModel.GetTexture(texureType)?.Path; PreviewCommand = new RelayCommand(() => TexturePreviewController.CreateVindow(Path, _packfileService)); BrowseCommand = new RelayCommand(BrowseTexture); RemoveCommand = new RelayCommand(RemoveTexture); }
public MeshSceneNodeViewModel_Graphics(Rmv2MeshNode meshNode, PackFileService pf) { _meshNode = meshNode; ShaderName = _meshNode.MeshModel.Header.ShaderParams.ShaderName; PossibleMaterialTypes = Enum.GetValues(typeof(GroupTypeEnum)).Cast <GroupTypeEnum>(); PossibleVertexTypes = Enum.GetValues(typeof(VertexFormat)).Cast <VertexFormat>(); Textures = new Dictionary <TexureType, TextureViewModel>(); Textures.Add(TexureType.Diffuse, new TextureViewModel(_meshNode, pf, TexureType.Diffuse)); Textures.Add(TexureType.Specular, new TextureViewModel(_meshNode, pf, TexureType.Specular)); Textures.Add(TexureType.Normal, new TextureViewModel(_meshNode, pf, TexureType.Normal)); Textures.Add(TexureType.Mask, new TextureViewModel(_meshNode, pf, TexureType.Mask)); Textures.Add(TexureType.Gloss, new TextureViewModel(_meshNode, pf, TexureType.Gloss)); }
string CreateKnownMaterial(Rmv2MeshNode mesh, List <WsModelMaterial> possibleMaterials) { foreach (var material in possibleMaterials) { if (mesh.MeshModel.Header.VertextType != material.VertexType) { continue; } var alphaOn = mesh.MeshModel.AlphaSettings.Mode != AlphaMode.Opaque; if (alphaOn && material.Alpha == false) { continue; } bool texturesOk = true; foreach (var modelTexture in mesh.MeshModel.Textures) { if (modelTexture.Path.Contains("test_mask", StringComparison.InvariantCultureIgnoreCase)) { continue; } var modelTextureType = modelTexture.TexureType; var materialHasTexture = material.Textures.TryGetValue(modelTextureType, out var materialTexurePath); if (materialHasTexture == false) { texturesOk = false; break; } var arePathsEqual = materialTexurePath.Contains(modelTexture.Path, StringComparison.InvariantCultureIgnoreCase); if (arePathsEqual == false) { texturesOk = false; break; } } if (texturesOk) { return(material.FullPath); } } return(null); }
protected override void ExecuteCommand() { _originalSelectionState = _selectionManager.GetStateCopy(); using (new WaitCursor()) { var meshService = new MeshSplitterService(); var splitMeshes = meshService.SplitMesh(_objectToSplit.Geometry); _logger.Here().Information($"{splitMeshes.Count} meshes generated from splitting"); var parent = _objectToSplit.Parent; if (parent is GroupNode groupNode && groupNode.IsUngroupable) { parent = parent.Parent; } _newGroupNode = (GroupNode)parent.AddObject(new GroupNode(_objectToSplit.Name + "_Collection") { IsSelectable = true, IsUngroupable = true, IsLockable = true }); int counter = 0; List <Rmv2MeshNode> createdMeshes = new List <Rmv2MeshNode>(); foreach (var mesh in splitMeshes) { var hack = _objectToSplit as Rmv2MeshNode; var originalRmvModel = hack.MeshModel; var context = new GeometryGraphicsContext(_resourceLib.GraphicsDevice); var meshNode = new Rmv2MeshNode(hack.MeshModel.Clone(), context, _resourceLib, hack.AnimationPlayer, mesh); meshNode.Name = $"{_objectToSplit.Name}_submesh_{counter++}"; createdMeshes.Add(meshNode); _newGroupNode.AddObject(meshNode); } _objectToSplit.Parent.RemoveObject(_objectToSplit as SceneNode); var newState = (ObjectSelectionState)_selectionManager.CreateSelectionSate(GeometrySelectionMode.Object); foreach (var node in createdMeshes) { newState.ModifySelection(node, false); } } }
public void SetModel(RmvRigidModel model, ResourceLibary resourceLibary, AnimationPlayer animationPlayer, IGeometryGraphicsContextFactory contextFactory) { Model = model; for (int lodIndex = 0; lodIndex < model.Header.LodCount; lodIndex++) { if (lodIndex >= Children.Count) { AddObject(new Rmv2LodNode("Lod " + lodIndex, lodIndex)); } var lodNode = Children[lodIndex]; for (int modelIndex = 0; modelIndex < model.LodHeaders[lodIndex].MeshCount; modelIndex++) { var node = new Rmv2MeshNode(model.MeshList[lodIndex][modelIndex], contextFactory.Create(), resourceLibary, animationPlayer); node.LodIndex = lodIndex; lodNode.AddObject(node); } } }
public MeshSceneNodeViewModel_Animation(PackFileService pfs, Rmv2MeshNode meshNode, SkeletonAnimationLookUpHelper animLookUp, IComponentManager componentManager) { _pfs = pfs; _meshNode = meshNode; _animLookUp = animLookUp; _componentManager = componentManager; SkeletonName = _meshNode.MeshModel.ParentSkeletonName; LinkDirectlyToBoneIndex = _meshNode.MeshModel.Header.LinkDirectlyToBoneIndex; AttachmentPoints = _meshNode.MeshModel.AttachmentPoints.OrderBy(x => x.BoneIndex).ToList(); var skeletonFile = _animLookUp.GetSkeletonFileFromName(_pfs, SkeletonName); var bones = _meshNode.Geometry.GetUniqeBlendIndices(); AnimatedBones = bones.Select(x => new AnimatedBone() { BoneIndex = x, Name = skeletonFile.Bones[x].Name }).OrderBy(x => x.BoneIndex).ToList(); OpenBoneRemappingToolCommand = new RelayCommand(OpenBoneRemappingTool); }
public void SetMountVertex() { var state = _selectionManager.GetState <VertexSelectionState>(); if (state == null || state.CurrentSelection().Count == 0) { SelectedVertexesText.Value = "No vertex selected"; _mountVertexes.Clear(); _mountVertexOwner = null; MessageBox.Show(SelectedVertexesText.Value); } else { SelectedVertexesText.Value = $"{state.CurrentSelection().Count} vertexes selected"; _mountVertexOwner = state.RenderObject as Rmv2MeshNode; _mountVertexes = new List <int>(state.CurrentSelection()); } UpdateCanSaveAndPreviewStates(); }
public MeshAnimationHelper(Rmv2MeshNode mesh, Matrix worldTransform) { _mesh = mesh; _worldTransform = worldTransform; }
public MountAnimationGeneratorService(AnimationSettingsViewModel animationSettings, Rmv2MeshNode mountMesh, int mountVertexId, int riderBoneIndex, AssetViewModel rider, AssetViewModel mount) { _animationSettings = animationSettings; _mountVertexId = mountVertexId; _riderBoneIndex = riderBoneIndex; _riderSkeleton = rider.Skeleton; _mountSkeleton = mount.Skeleton; float mountScale = (float)_animationSettings.Scale.Value; mount.SetTransform(Matrix.CreateScale(mountScale)); _mountVertexPositionResolver = new MeshAnimationHelper(mountMesh, Matrix.CreateScale(mountScale)); }