Exemplo n.º 1
0
        private ObjectBase CreateObjectCopy(ObjectBase selectedObject)
        {
            Cursor tmpCursor = Cursor.Current;
            Cursor = Cursors.WaitCursor;

            if (selectedObject.GetType().Equals(typeof(Engine.Mesh)))
            {
                var mesh = new Engine.Mesh(core, Settings, selectedObject.FileName);
                mesh.IsAnimated = (selectedObject as Engine.Mesh).IsAnimated;
                mesh.CustomTexture = (selectedObject as Engine.Mesh).CustomTexture;
                mesh.Visible = selectedObject.Visible;
                mesh.Position = selectedObject.Position;
                mesh.Rotation = selectedObject.Rotation;
                mesh.Scale = selectedObject.Scale;
                mesh.Mass = (selectedObject as Engine.Mesh).Mass;
                mesh.Bounding = (selectedObject as Engine.Mesh).Bounding;
                mesh.KineticFriction = (selectedObject as Engine.Mesh).KineticFriction;
                mesh.StaticFriction = (selectedObject as Engine.Mesh).StaticFriction;
                mesh.Bounciness = (selectedObject as Engine.Mesh).Bounciness;
                mesh.Softness = (selectedObject as Engine.Mesh).Softness;
                mesh.Material = (selectedObject as Engine.Mesh).Material;
                mesh.EnableLightning = (selectedObject as Engine.Mesh).EnableLightning;
                mesh.SetCustomCollection((selectedObject as Engine.Mesh).CustomParams);
                mesh.TextureScale = (selectedObject as Engine.Mesh).TextureScale;
                mesh.ScriptEnabled = (selectedObject as Engine.Mesh).ScriptEnabled;
                mesh.Script = (selectedObject as Engine.Mesh).Script.Replace((selectedObject as Engine.Mesh).Name, mesh.Name);
                mesh.Update();
                AddToSceneTreeView(sceneObjectsNode, mesh);
                Cursor = tmpCursor;
                return mesh;
            }

            if (selectedObject.GetType().Equals(typeof(PointLight)))
            {
                VECTOR3D pos = selectedObject.Position;
                var pointLight = (PointLight)selectedObject;
                var light = new PointLight(core, new TV_3DVECTOR(pos.X, pos.Y, pos.Z));
                light.Color = pointLight.Color;
                light.Radius = pointLight.Radius;
                light.Visible = pointLight.Visible;
                light.SetCustomCollection(pointLight.CustomParams);
                light.Update();
                AddToSceneTreeView(sceneLightsNode, light);
                Cursor = tmpCursor;
                return light;
            }

            if (selectedObject.GetType().Equals(typeof(Sound)))
            {
                var sound = new Sound(core, selectedObject.FileName);
                sound.Position = selectedObject.Position;
                sound.Stopped = (selectedObject as Sound).Stopped;
                sound.Volume = (selectedObject as Sound).Volume;
                sound.Loop = (selectedObject as Sound).Loop;
                sound.Is3D = (selectedObject as Sound).Is3D;
                sound.SetCustomCollection((selectedObject as Sound).CustomParams);
                sound.Update();
                AddToSceneTreeView(sceneSoundsNode, sound);
                Cursor = tmpCursor;
                return sound;
            }

            if (selectedObject.GetType().Equals(typeof(Engine.Trigger)))
            {
                var trigger = new Engine.Trigger(core);
                trigger.Position = selectedObject.Position;
                trigger.Rotation = selectedObject.Rotation;
                trigger.Scale = selectedObject.Scale;
                trigger.Color = (selectedObject as Trigger).Color;
                trigger.SetCustomCollection((selectedObject as Engine.Trigger).CustomParams);
                trigger.Update();
                AddToSceneTreeView(sceneTriggersNode, trigger);
                Cursor = tmpCursor;
                return trigger;
            }

            if (selectedObject.GetType().Equals(typeof(Engine.Particle)))
            {
                var particle = new Engine.Particle(core, selectedObject.FileName);
                particle.Position = selectedObject.Position;
                particle.Rotation = selectedObject.Rotation;
                particle.Scale = selectedObject.Scale;
                particle.Visible = selectedObject.Visible;
                particle.SetCustomCollection((selectedObject as Engine.Particle).CustomParams);
                particle.Update();
                AddToSceneTreeView(sceneParticlesNode, particle);
                Cursor = tmpCursor;
                return particle;
            }

            return null;
        }