コード例 #1
0
        private Visual3D CreateModel3D(bool isSelected, CraftModel craft)
        {
            int positionX = craft.PositionX * 256;
            int positionY = -craft.PositionY * 256;
            int positionZ = craft.PositionZ * 256;

            if (string.IsNullOrEmpty(craft.CraftName))
            {
                return(null);
            }

            var model = this.GetOptModel(craft.CraftName);

            if (model == null)
            {
                return(null);
            }

            var visual = new OptVisual3D
            {
                Cache            = model.Cache,
                SortingFrequency = 0.2,
                Version          = craft.Markings,
                IsWireframe      = isSelected
            };

            var transformGroup = new Transform3DGroup();

            transformGroup.Children.Add(new RotateTransform3D(new AxisAngleRotation3D(new Vector3D(1, 0, 0), -craft.Roll * 256 * 360.0 / 65536)));

            if (craft.UseStartWaypoint)
            {
                transformGroup.Children.Add(new RotateTransform3D(new AxisAngleRotation3D(new Vector3D(0, 1, 0), craft.HeadingZ)));
                transformGroup.Children.Add(new RotateTransform3D(new AxisAngleRotation3D(new Vector3D(0, 0, 1), -craft.HeadingXY)));
            }
            else
            {
                transformGroup.Children.Add(new RotateTransform3D(new AxisAngleRotation3D(new Vector3D(0, 1, 0), (craft.Pitch - 64) * 256 * 360.0 / 65536)));
                transformGroup.Children.Add(new RotateTransform3D(new AxisAngleRotation3D(new Vector3D(0, 0, 1), -craft.Yaw * 256 * 360.0 / 65536)));
            }

            transformGroup.Children.Add(new TranslateTransform3D(positionY, -positionX, positionZ));
            transformGroup.Freeze();

            visual.Transform = transformGroup;

            return(visual);
        }
コード例 #2
0
        private void AddMapModels(int region)
        {
            bool loadCraftList = this.craftList.Items.Count == 0;

            for (int flightGroupIndex = 0; flightGroupIndex < this.MissionFile.FlightGroups.Count; flightGroupIndex++)
            {
                var flightGroup = this.MissionFile.FlightGroups[flightGroupIndex];
                var model       = new CraftModel(flightGroup);

                if (this._missionObjects.TryGetValue(model.CraftName, out string value))
                {
                    model.CraftName = value;
                }

                if (loadCraftList)
                {
                    this.craftList.Items.Add(model);
                }

                if (model.Region != region)
                {
                    continue;
                }

                int craftsCount      = Math.Max(flightGroup.CraftsCount, (byte)1);
                int formationType    = flightGroup.FormationType;
                int formationSpacing = flightGroup.FormationSpacing + 1;

                for (int wingmanIndex = 0; wingmanIndex < craftsCount; wingmanIndex++)
                {
                    var visual = this.CreateModel3D(
                        !loadCraftList && this._selectedCrafts.Contains(flightGroupIndex),
                        model);

                    if (visual != null)
                    {
                        this.SetModel3DWingman(visual, model.CraftName, wingmanIndex, formationType, formationSpacing);
                        this.viewport3D.Children.Add(visual);
                    }
                }
            }
        }