Esempio n. 1
0
        /// <summary>
        /// Adds the selected mesh from the Scene to the editor
        /// </summary>
        /// <param name="scene"></param>
        public void SetSelectedMeshFromScene(SBScene scene)
        {
            // clear currently selected meshes
            SelectedMeshes = null;

            // loads the materials from the scene
            materialSelector.Items.Clear();
            foreach (var material in scene.GetMaterials())
            {
                materialSelector.Items.Add(material);
            }

            // loads the bone names from the scene
            parentBoneSelector.Items.Clear();
            foreach (var bone in scene.Skeleton.Bones)
            {
                parentBoneSelector.Items.Add(bone.Name);
            }

            // get selected meshes in scene
            List <ISBMesh> selected = new List <ISBMesh>();

            foreach (var mesh in scene.GetMeshObjects())
            {
                if (mesh.Selected)
                {
                    selected.Add(mesh);
                }
            }

            // for now just get the first selected
            if (selected.Count > 0)
            {
                meshName.Text = selected[0].Name + (selected.Count > 1 ? $" + {selected.Count - 1} Others" : "");
                materialSelector.SelectedItem   = selected[0].Material;
                parentBoneSelector.SelectedItem = selected[0].ParentBone;
            }

            //
            SelectedMeshes = selected.ToArray();
            PropertyGrid.SelectedObjects = SelectedMeshes;
            SelectedScene = scene;
        }
Esempio n. 2
0
        public void UpdateScene(float Frame, SBScene scene)
        {
            if (scene == null)
            {
                return;
            }

            // Materials
            foreach (SBMaterialAnimation a in MaterialNodes)
            {
                foreach (var material in scene.GetMaterials())
                {
                    if (material.Label.Equals(a.MaterialName))
                    {
                        material.AnimateParam(a.AttributeName, a.Keys.GetValue(Frame));
                    }
                }
            }
            // Visibility
            foreach (SBVisibilityAnimation a in VisibilityNodes)
            {
                foreach (var mesh in scene.GetMeshObjects())
                {
                    // names match with start ignoreing the _VIS tags
                    if (mesh.Name.StartsWith(a.MeshName))
                    {
                        mesh.Visible = a.Visibility.GetValue(Frame);
                    }
                }
            }
            // Bones
            foreach (SBTransformAnimation a in TransformNodes)
            {
                var bone = scene.Skeleton[a.Name];
                if (bone != null)
                {
                    bone.AnimatedTransform = a.Transform.GetValue(Frame);
                }
            }
        }
        /// <summary>
        /// sets and binds the material to an editor
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="material"></param>
        public void SetMaterialsFromScene(SBScene scene)
        {
            ISBMaterial[] material = scene.GetMaterials();

            if (material == null || material.Length == 0)
            {
                ClearMaterial();
                return;
            }
            typeLabel.Text = "Material Type: " + material[0].GetType().Name;

            SetMaterial(material[0]);

            materialList.Clear();
            foreach (var mat in material)
            {
                var listitem = new ListViewItem();
                listitem.Tag  = mat;
                listitem.Text = mat.Label;
                materialList.Items.Add(listitem);
            }
        }