Exemple #1
0
        public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            if (context != null &&
                context.Instance != null &&
                provider != null)
            {
                IWindowsFormsEditorService edSvc = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));

                if (edSvc != null)
                {
                    SubMeshCollection subMeshes = value as SubMeshCollection;
                    if (subMeshes != null)
                    {
                        SubMeshDialog subMeshEditor = new SubMeshDialog(subMeshes);

                        if (edSvc.ShowDialog(subMeshEditor) == DialogResult.OK)
                        {
                            return(subMeshEditor.SubMeshCollection);
                        }
                    }
                }
            }

            return(value);
        }
Exemple #2
0
 public SubMeshInfo(SubMeshCollection parent, string name, string materialName, bool show)
 {
     this.parent       = parent;
     this.name         = name;
     this.materialName = materialName;
     this.show         = show;
 }
Exemple #3
0
 /// <summary>
 /// Copy constructor
 /// </summary>
 /// <param name="srcCollection"></param>
 public SubMeshCollection(SubMeshCollection srcCollection)
 {
     this.subMeshList = new List <SubMeshInfo>();
     foreach (SubMeshInfo srcInfo in srcCollection)
     {
         SubMeshInfo subMeshInfo = new SubMeshInfo(this, srcInfo.Name, srcInfo.MaterialName, srcInfo.Show);
         this.subMeshList.Add(subMeshInfo);
     }
 }
Exemple #4
0
        public SubMeshDialog(SubMeshCollection subMeshCollectionIn)
        {
            // Make a copy for us to muck with.  We don't touch the original.
            this.subMeshCollection = new SubMeshCollection(subMeshCollectionIn);

            InitializeComponent();
            foreach (SubMeshInfo info in subMeshCollection)
            {
                subMeshListBox.Items.Add(info.Name, info.Show);
            }
            subMeshListBox.SelectedIndex = 0;

            if (subMeshListBox.SelectedIndex >= 0)
            {
                materialTextBox.Text = subMeshCollection[subMeshListBox.SelectedIndex].MaterialName;
            }
        }
        public StaticObject(String objectName, IWorldContainer parentContainer, WorldEditor worldEditor, string meshName, Vector3 position, Vector3 scale, Vector3 rotation)
        {
            name   = objectName;
            parent = parentContainer;
            app    = worldEditor;

            children = new List <IWorldObject>();
            this.SetDirection(rotation.y, 90f);
            this.scale          = scale;
            this.location       = position;
            this.meshName       = meshName;
            this.nameValuePairs = new NameValueObject();
            this.terrainOffset  = 0f;


            displayObject = null;

            subMeshes = new SubMeshCollection(meshName);
        }
Exemple #6
0
        public DisplayObject(string name, WorldEditor app, string type, SceneManager scene, string meshName, Vector3 position, Vector3 scale, Vector3 rotation, SubMeshCollection subMeshCollection)
        {
            this.name     = name;
            this.scene    = scene;
            this.meshName = meshName;
            this.type     = type;
            oidCounter++;
            this.oid = oidCounter;
            this.app = app;

            // if we were passed a subMeshCollection, then use it, otherwise make one.
            if (subMeshCollection == null)
            {
                this.subMeshCollection = new SubMeshCollection(meshName);
            }
            else
            {
                this.subMeshCollection = subMeshCollection;
            }

            AddToScene(position, scale, rotation);
        }
        protected void FromXml(XmlReader r)
        {
            bool adjustHeightFound = false;
            bool offsetFound       = false;
            bool pRFound           = false;

            // first parse name and mesh, which are attributes
            for (int i = 0; i < r.AttributeCount; i++)
            {
                r.MoveToAttribute(i);

                // set the field in this object based on the element we just read
                switch (r.Name)
                {
                case "Name":
                    this.name = r.Value;
                    break;

                case "Mesh":
                    this.meshName = r.Value;
                    break;

                case "Sound":
                    string filename = r.Value;
                    if (!String.Equals(filename, ""))
                    {
                        ICommandFactory ret = new AddSoundCommandFactory(app, this, r.Value);
                        ICommand        com = ret.CreateCommand();
                        com.Execute();
                    }
                    break;

                case "TerrainOffset":
                    terrainOffset = float.Parse(r.Value);
                    offsetFound   = true;
                    break;

                case "AllowHeightAdjustment":
                    if (String.Equals(r.Value.ToLower(), "false"))
                    {
                        allowAdjustHeightOffTerrain = false;
                    }
                    break;

                case "AcceptObjectPlacement":
                    acceptObjectPlacement = bool.Parse(r.Value);
                    break;

                case "PerceptionRadius":
                    pRFound          = true;
                    perceptionRadius = float.Parse(r.Value);
                    break;

                case "CastShadows":
                    castShadows = bool.Parse(r.Value);
                    break;

                case "ReceiveShadows":
                    receiveShadows = bool.Parse(r.Value);
                    break;

                case "Azimuth":
                    azimuth = float.Parse(r.Value);
                    break;

                case "Zenith":
                    zenith = float.Parse(r.Value);
                    break;

                case "WorldViewSelect":
                    worldViewSelectable = bool.Parse(r.Value);
                    break;

                case "Targetable":
                    targetable = bool.Parse(r.Value);
                    break;
                }
            }
            r.MoveToElement(); //Moves the reader back to the element node.

            // now parse the sub-elements
            while (r.Read())
            {
                // look for the start of an element
                if (r.NodeType == XmlNodeType.Element)
                {
                    // parse that element
                    // save the name of the element
                    string elementName = r.Name;
                    switch (elementName)
                    {
                    case "Position":
                        location = XmlHelperClass.ParseVectorAttributes(r);
                        break;

                    case "Scale":
                        scale = XmlHelperClass.ParseVectorAttributes(r);
                        break;

                    case "Rotation":
                        Vector3 rotation = XmlHelperClass.ParseVectorAttributes(r);
                        // force rotation to be between -180 and 180
                        while (rotation.y < -180)
                        {
                            rotation.y += 360;
                        }
                        while (rotation.y > 180)
                        {
                            rotation.y -= 360;
                        }
                        SetDirection(rotation.y, 90f);
                        break;

                    case "Orientation":
                        orientation = XmlHelperClass.ParseQuaternion(r);
                        break;

                    case "SubMeshes":
                        subMeshes = new SubMeshCollection(r);
                        if (!subMeshes.CheckValid(app, meshName))
                        {
                            app.AddPopupMessage(string.Format("Some submesh names in {0} changed.  Submesh display and material parameters for this object were reset.", meshName));

                            // if the check fails, then reset the subMeshes from the mesh
                            subMeshes = new SubMeshCollection(meshName);
                        }
                        break;

                    case "NameValuePairs":
                        nameValuePairs = new NameValueObject(r);
                        break;

                    case "ParticleEffect":
                        ParticleEffect particle = new ParticleEffect(r, this, app);
                        Add(particle);
                        break;

                    case "PathData":
                        pathData      = new PathData(r);
                        locationDirty = pathData.Version != pathData.CodeVersion;
                        break;

                    case "Sound":
                        Sound sound = new Sound(r, this, app);
                        Add(sound);
                        break;
                    }
                }
                else if (r.NodeType == XmlNodeType.EndElement)
                {
                    break;
                }
            }
            if (!adjustHeightFound)
            {
                allowAdjustHeightOffTerrain = true;
            }
            if (!offsetFound)
            {
                terrainOffset = location.y - app.GetTerrainHeight(location.x, location.z);
            }
            if (!pRFound && nameValuePairs != null)
            {
                valueItem value = nameValuePairs.LookUp("perceptionRadius");
                if (value != null && ValidityHelperClass.isFloat(value.value))
                {
                    perceptionRadius = float.Parse(value.value);
                }
            }
            return;
        }