コード例 #1
0
        private void PopulateFromProcessorInfo(ProcessorInfo info)
        {
            ModelFiles.files.Clear();
            foreach (string m in info.models)
            {
                ModelFiles.Add(m, false);
            }
            ModelFiles.RefreshList();

            TextureFiles.files.Clear();
            foreach (string t in info.textures)
            {
                TextureFiles.Add(t, false);
            }
            TextureFiles.RefreshList();

            DoMergeModels.IsChecked      = info.mergeModels;
            Padding.Value                = info.padding;
            DoKeepTransparency.IsChecked = info.keepTransparency;

            string[] exportIds = (string[])ExportModelFormats.Tag;
            ExportModelFormats.SelectedIndex   = Array.IndexOf(exportIds, info.modelExportFormatId);
            ExportTextureFormats.SelectedIndex = (int)info.textureOutputType;

            FilesPrefix.Text         = info.outputFilesPrefix;
            ExportDirectory.FullPath = info.outputDir;
        }
コード例 #2
0
        private IntPtr HandleDropFiles(IntPtr hDrop)
        {
            const int MAX_PATH = 260;

            uint count = DragQueryFile(hDrop, 0xFFFFFFFF, null, 0);

            for (uint i = 0; i < count; i++)
            {
                int size = (int)DragQueryFile(hDrop, i, null, 0);

                StringBuilder filename = new StringBuilder(size + 1);
                DragQueryFile(hDrop, i, filename, MAX_PATH);

                string droppedFile = filename.ToString();

                if (Path.GetExtension(droppedFile) == ".xml")
                {
                    LoadSettingsFile(droppedFile);
                    break;
                }

                if (Utils.IsModelExtensionSupported(Path.GetExtension(droppedFile)))
                {
                    ModelFiles.Add(droppedFile, false);
                }
                else
                {
                    if (Utils.IsImageSupported(droppedFile))
                    {
                        TextureFiles.Add(droppedFile, false);
                    }
                    else
                    {
                        Log.Line(LogType.Warning, "Dropped file '{0}' is not supported", droppedFile);
                    }
                }
            }

            DragFinish(hDrop);

            ModelFiles.RefreshList();
            TextureFiles.RefreshList();

            return(IntPtr.Zero);
        }
コード例 #3
0
ファイル: ModelSelector.cs プロジェクト: ushadow/handinput
        public void Refresh()
        {
            Log.Debug("Refresh models.");
            var files = Directory.GetFiles(dir, ModelFilePattern);

            ModelFiles.Clear();
            SelectedModel = null;
            for (var i = files.Length - 1; i >= 0; i--)
            {
                var f = files[i];
                ModelFiles.Add(f);
                var fileName = Path.GetFileName(f);
                if (SelectedModel == null && Regex.IsMatch(fileName, TimeRegex))
                {
                    SelectedModel = f;
                }
            }
        }
コード例 #4
0
        /// <summary>
        /// Loads the file from the specified stream.
        /// </summary>
        /// <param name="stream">The stream to read from.</param>
        public override void Load(Stream stream)
        {
            BinaryReader reader = new BinaryReader(stream, Encoding.GetEncoding("us-ascii"));

            short modelFileCount = reader.ReadInt16();

            for (int i = 0; i < modelFileCount; i++)
            {
                string modelFile = reader.ReadNullTerminatedString();

                ModelFiles.Add(modelFile);
            }

            short textureFileCount = reader.ReadInt16();

            for (int i = 0; i < textureFileCount; i++)
            {
                TextureFile texture = new TextureFile();
                texture.FilePath          = reader.ReadNullTerminatedString();
                texture.UseSkinShader     = reader.ReadInt16() != 0;
                texture.AlphaEnabled      = reader.ReadInt16() != 0;
                texture.TwoSided          = reader.ReadInt16() != 0;
                texture.AlphaTestEnabled  = reader.ReadInt16() != 0;
                texture.AlphaReference    = reader.ReadInt16();
                texture.DepthTestEnabled  = reader.ReadInt16() != 0;
                texture.DepthWriteEnabled = reader.ReadInt16() != 0;
                texture.BlendType         = (BlendType)reader.ReadInt16();
                texture.UseSpecularShader = reader.ReadInt16() != 0;
                texture.Alpha             = reader.ReadSingle();
                texture.GlowType          = (GlowType)reader.ReadInt16();
                texture.GlowColour        = reader.ReadColour3();

                TextureFiles.Add(texture);
            }

            short effectFileCount = reader.ReadInt16();

            for (int i = 0; i < effectFileCount; i++)
            {
                string effectFile = reader.ReadNullTerminatedString();

                EffectFiles.Add(effectFile);
            }

            short objectCount = reader.ReadInt16();

            for (int i = 0; i < objectCount; i++)
            {
                ModelListObject @object = new ModelListObject();

                int cylinderRadius = reader.ReadInt32();
                @object.BoundingCylinder = new BoundingCylinder(new Vector2(reader.ReadInt32(), reader.ReadInt32()), cylinderRadius);

                int partCount = reader.ReadInt16();

                if (partCount > 0)
                {
                    for (int j = 0; j < partCount; j++)
                    {
                        ModelListPart part = new ModelListPart();
                        part.Model   = reader.ReadInt16();
                        part.Texture = reader.ReadInt16();

                        byte propertyType = 0;

                        while ((propertyType = reader.ReadByte()) != 0)
                        {
                            byte size = reader.ReadByte();

                            switch ((ModelListPropertyType)propertyType)
                            {
                            case ModelListPropertyType.Position:
                                part.Position = reader.ReadVector3();
                                break;

                            case ModelListPropertyType.Rotation:
                                part.Rotation = reader.ReadQuaternion(true);
                                break;

                            case ModelListPropertyType.Scale:
                                part.Scale = reader.ReadVector3();
                                break;

                            case ModelListPropertyType.AxisRotation:
                                part.AxisRotation = reader.ReadQuaternion(true);
                                break;

                            case ModelListPropertyType.Parent:
                                part.Parent = reader.ReadInt16();
                                break;

                            case ModelListPropertyType.Collision:
                                part.Collision = (CollisionType)reader.ReadInt16();
                                break;

                            case ModelListPropertyType.ConstantAnimation:
                                part.AnimationFilePath = reader.ReadString(size);
                                break;

                            case ModelListPropertyType.VisibleRangeSet:
                                part.VisibleRangeSet = reader.ReadInt16();
                                break;

                            case ModelListPropertyType.UseLightmap:
                                part.UseLightmap = reader.ReadInt16() != 0;
                                break;

                            case ModelListPropertyType.BoneIndex:
                                part.BoneIndex = reader.ReadInt16();
                                break;

                            case ModelListPropertyType.DummyIndex:
                                part.DummyIndex = reader.ReadInt16();
                                break;

                            default:
                                if (propertyType >= (int)ModelListPropertyType.Animation && propertyType < (int)ModelListPropertyType.Animation + ModelListPart.ANIMATION_COUNT)
                                {
                                    propertyType -= (int)ModelListPropertyType.Animation;

                                    if (propertyType < ModelListPart.MONSTER_ANIMATION_COUNT)
                                    {
                                        part.MonsterAnimations[propertyType] = reader.ReadString(size);
                                    }
                                    else
                                    {
                                        propertyType -= ModelListPart.MONSTER_ANIMATION_COUNT;
                                        part.AvatarAnimations[propertyType] = reader.ReadString(size);
                                    }
                                }
                                else
                                {
                                    stream.Seek(size, SeekOrigin.Current);
                                }
                                break;
                            }
                        }

                        @object.Parts.Add(part);
                    }

                    int effectCount = reader.ReadInt16();

                    for (int j = 0; j < effectCount; j++)
                    {
                        ModelListEffect effect = new ModelListEffect();
                        effect.EffectType = (EffectType)reader.ReadInt16();
                        effect.Effect     = reader.ReadInt16();

                        byte propertyType = 0;

                        while ((propertyType = reader.ReadByte()) != 0)
                        {
                            byte size = reader.ReadByte();

                            switch ((ModelListPropertyType)propertyType)
                            {
                            case ModelListPropertyType.Position:
                                effect.Position = reader.ReadVector3();
                                break;

                            case ModelListPropertyType.Rotation:
                                effect.Rotation = reader.ReadQuaternion(true);
                                break;

                            case ModelListPropertyType.Scale:
                                effect.Scale = reader.ReadVector3();
                                break;

                            case ModelListPropertyType.Parent:
                                effect.Parent = reader.ReadInt16();
                                break;

                            default:
                                stream.Seek(size, SeekOrigin.Current);
                                break;
                            }
                        }

                        @object.Effects.Add(effect);
                    }

                    @object.BoundingBox = new BoundingBox(reader.ReadVector3(), reader.ReadVector3());
                }

                Objects.Add(@object);
            }
        }