示例#1
0
        /// <summary>
        /// In the case where the old PaintTerrainInputReceiver has been collected by the garbage collector,
        /// then we try to make a replacement
        /// </summary>
        /// <param name="viewer"></param>
        private void addNewReceiver(NWN2AreaViewer viewer)
        {
            Console.WriteLine("The retained paintTerrianInputReceiver is null");
            PaintTerrainInputReceiver normalPaint = new PaintTerrainInputReceiver();

            normalPaint.Attach(viewer.ElectronPanel);
            viewer.ElectronPanel.AddInputReceiver(normalPaint);
        }
示例#2
0
        /// <summary>
        /// Given the number of points selected, this part allows us to take the selected points and paint them with the selected information
        /// </summary>
        public void drawPolygon()
        {
            pointsAlready.Clear();
            LinkedList <Pair <double, double> > points = new LinkedList <Pair <double, double> >();
            NWN2AreaViewer view = getAreaViewer();
            NWN2GameArea   area = view.Area;

            foreach (NWN2Toolset.NWN2.Data.Instances.NWN2WaypointInstance waypoint in area.Waypoints)
            {
                if (waypoint.Tag.Equals(WAYPOINT_TAG))
                {
                    Vector3 vector = waypoint.Position;
                    points.AddLast(new Pair <double, double>(vector.X, vector.Y));
                }
            }

            if (points.Count < 2)
            {
                debugOut("1 or 0 points");
            }
            else if (points.Count == 2)
            {
                debugOut("2 points");
                makeLine(points);
            }
            else
            {
                debugOut("3 or more points");
                LinkedList <Triangle> triangles = makeTriangles(points);
                if (triangles != null)
                {
                    paintTriangles(triangles);
                }
                else
                {
                    debugOut("The triangles are null!");
                }
            }
        }
示例#3
0
        /// <summary>
        /// This is called when the mousecurser moves around on the area so that we can either
        /// show the circle normally seen, or stop viewing it
        /// </summary>
        /// <param name="panel">The information from the </param>
        public void Move(MousePanel panel)
        {
            areaViewer = getAreaViewer();

            if (!panel.ButtonHeld || areaViewer == null || areaViewer.Area == null)
            {
                SFX.YATT.Tools.Vector <float> coor = findAreaCoor(panel.MouseX, panel.MouseY, areaViewer.Area);

                if (coor != null)
                {
                    showBrush(coor);
                }
                else
                {
                    stopShowingCircle();
                }
            }
            else
            {
                stopShowingCircle();
            }
        }
示例#4
0
        /// <summary>
        /// The code for painting on-line3
        /// </summary>
        /// <param name="X"></param>
        /// <param name="Y"></param>
        private void TerrianCode(int X, int Y)
        {
            try {
                areaViewer = getAreaViewer();
                SFX.YATT.Tools.Vector<float> coor = findAreaCoor(X, Y, areaViewer.Area);

                Random ran = new Random();

                if (coor != null) {
                    NWN2ToolsetMainForm.App.TerrainEditor.SetBrushType(NWN2TerrainEditorForm.BrushType.StandardTerrain);

                    // Textures:
                    opTexture.Checked = true;
                    if (data.randomize) {
                        ran = new Random(System.DateTime.Now.Millisecond);

                        ArrayList texData = new ArrayList(data.textures.Count);
                        texData.AddRange(data.textures);

                        while(texData.Count > 0) {
                            int num = ran.Next(0, texData.Count - 1);
                            textureData texture = (textureData)texData[num];
                            texturePreperation(coor, TerrainModificationType.Texture, texture);
                            texData.RemoveAt(num);
                        }
                    } else {

                        LinkedListNode<textureData> node = data.textures.Last;
                        while (node != null) {
                            DateTime dateTime = DateTime.Now;

                            double start = ((double)dateTime.Ticks) / 1000000.0;
                            texturePreperation(coor, TerrainModificationType.Texture, node.Value);
                            dateTime = DateTime.Now;
                            node = node.Previous;
                        }
                    }

                    if (data.grassOption == grassOption.Paint) {
                        opGrass.Checked = true;

                        barPressure.Value = data.grassDensity * 100;
                        grassSize.Value = (data.grassSize / 30);
                        grassSizeVariation.Value = (data.grassSizeVariation / 10);

                        object[] objList = new object[grassListBox.Items.Count];
                        grassListBox.Items.CopyTo(objList, 0);

                        int index = 0;

                        grassListBox.SelectedIndices.Clear();

                        foreach(TextureListItem textureItem in objList) {
                            string textStr = textureItem.Text;
                            if (textStr == data.grassTexture[0] ||
                                textStr == data.grassTexture[1] ||
                                textStr == data.grassTexture[2]) {
                                grassListBox.SelectedItem = textureItem;
                                index++;

                                if (index == 3)
                                    break;
                            }
                        }

                        NWN2ToolsetMainForm.App.TerrainEditor.SetBrushType(NWN2TerrainEditorForm.BrushType.FloraGrass);
                        texturePreperation(coor, TerrainModificationType.Grass, data.textures.First.Value);
                    }

                    if (data.colourOption == colourOption.Colour) {
                        opTerrain.Checked = true;
                        opColour.Checked = true;
                        colourButton.BackColor = data.col;
                        barPressure.Value = data.colourPresure * 100;
                        texturePreperation(coor, TerrainModificationType.Color, data.textures.First.Value);
                    }

                }

            } catch (Exception e) {
                Console.WriteLine(e);
            }
        }
示例#5
0
 /// <summary>
 /// Save the area given
 /// </summary>
 /// <param name="area">The area we want to save</param>
 private void SaveAreaTerrain(NWN2AreaViewer area)
 {
     area.SaveTerrain(true);
     area.SaveContents(true,OEIShared.UI.OEIMessageBoxResult .YesToAll );
 }
示例#6
0
        /// <summary>
        /// This is called when the mousecurser moves around on the area so that we can either
        /// show the circle normally seen, or stop viewing it
        /// </summary>
        /// <param name="panel">The information from the </param>
        public void Move(MousePanel panel)
        {
            areaViewer = getAreaViewer();

            if (!panel.ButtonHeld || areaViewer == null || areaViewer.Area == null) {

                SFX.YATT.Tools.Vector<float> coor = findAreaCoor(panel.MouseX, panel.MouseY, areaViewer.Area);

                if (coor != null) {
                    showBrush(coor);
                } else {
                    stopShowingCircle();
                }

            } else {
                stopShowingCircle();
            }
        }
 private void paintWaterOnMap(NWN2AreaViewer nwN2AreaViewer, NWN2TerrainEditorForm terrainEditor, SynchronousNetDisplayManager netDisplayManager, float z, Vector3 vector3, string texture)
 {
     netDisplayManager.TerrainBrush(nwN2AreaViewer.AreaNetDisplayWindow.Scene, 1, 1, vector3, 1f, 6f, z, 0.5f, terrainEditor.TerrainBrushColor, terrainEditor.CursorColor, texture, TerrainModificationType.Water);
     terrainEditor.UpdateWaterSliders();
     netDisplayManager.TerrainModify(nwN2AreaViewer.AreaNetDisplayWindow.Scene, TerrainModificationType.Water, -1);
 }
 private void paintGrass(TerrainImporterSettings importerSettings, NWN2AreaViewer nwN2AreaViewer, NWN2TerrainEditorForm terrainEditor, SynchronousNetDisplayManager netDisplayManager, float outerRight, float outerTop, float areaX, float areaY, Vector3 vector3, string texture, string textureName)
 {
     if (importerSettings.paintGrass != null)
     {
         Hashtable hashtable = (Hashtable)importerSettings.paintGrass[textureName];
         Decimal fullRadius = (Decimal)hashtable["innerRadius"] + (Decimal)hashtable["outerRadius"];
         float floatFullRadius = Convert.ToSingle(++fullRadius);
         if ((bool)hashtable["doPaint"] && areaX > floatFullRadius && (areaX < outerRight - floatFullRadius && areaY > floatFullRadius) && areaY < outerTop - floatFullRadius)
         {
             string[] textures = (string[])((ArrayList)hashtable["textures"]).ToArray(typeof(string));
             netDisplayManager.GrassParameters(nwN2AreaViewer.AreaNetDisplayWindow.Scene, (float)hashtable["bladeSize"], (float)hashtable["bladeSizeVariation"], textures.Length, textures);
             netDisplayManager.TerrainBrush(nwN2AreaViewer.AreaNetDisplayWindow.Scene, 1, 1, vector3, Convert.ToSingle(hashtable["innerRadius"]), Convert.ToSingle(hashtable["outerRadius"]), (float)hashtable["pressure"], 0.5f, terrainEditor.TerrainBrushColor, terrainEditor.CursorColor, texture, TerrainModificationType.Grass);
             netDisplayManager.TerrainModify(nwN2AreaViewer.AreaNetDisplayWindow.Scene, TerrainModificationType.Grass, -1);
         }
     }
 }
 private void manipulateTerrain(TerrainImporterSettings importerSettings, bool paintTerrain, float texturePressure, float textureInnerRadius, float textureOuterRadius, NWN2AreaViewer nwN2AreaViewer, NWN2TerrainEditorForm terrainEditor, SynchronousNetDisplayManager netDisplayManager, float zValue, ref Vector3 vector3, ref string texture, string textureName)
 {
     netDisplayManager.TerrainBrush(nwN2AreaViewer.AreaNetDisplayWindow.Scene, 1, 0, vector3, 1f, 1f, zValue, 0.5f, terrainEditor.TerrainBrushColor, terrainEditor.CursorColor, texture, TerrainModificationType.Flatten);
     netDisplayManager.TerrainModify(nwN2AreaViewer.AreaNetDisplayWindow.Scene, TerrainModificationType.Flatten, 0);
     if (paintTerrain)
     {
         texture = (string)importerSettings.paintTextures[textureName];
         netDisplayManager.TerrainBrush(nwN2AreaViewer.AreaNetDisplayWindow.Scene, 1, 0, vector3, textureInnerRadius, textureOuterRadius, texturePressure, 0.5f, terrainEditor.TerrainBrushColor, terrainEditor.CursorColor, texture, TerrainModificationType.Flatten);
         netDisplayManager.TerrainModify(nwN2AreaViewer.AreaNetDisplayWindow.Scene, TerrainModificationType.Texture, 0);
     }
 }
 private void handleWaterMap(TerrainImporterSettings importerSettings, NWN2AreaViewer nwN2AreaViewer, NWN2TerrainEditorForm terrainEditor, SynchronousNetDisplayManager netDisplayManager, int x, int y, float z, ref Vector3 vector3, string texture)
 {
     WaterMap waterMap = importerSettings.waterMap;
     if (importerSettings.paintWaterCheckbox.Checked)
     {
         float seaLevel = Convert.ToSingle(importerSettings.seaLevel.Value);
         if (waterMap == null && z < Convert.ToSingle(importerSettings.seaLevel.Value))
         {
             paintWaterOnMap(nwN2AreaViewer, terrainEditor, netDisplayManager, seaLevel, vector3, texture);
         }
         else if (waterMap != null)
         {
             bool paintWater = waterMap.PaintWater(x, y);
             if (paintWater)
             {
                 if (z > 0.0f)
                 {
                     paintWaterOnMap(nwN2AreaViewer, terrainEditor, netDisplayManager, z, vector3, texture);
                 }
                 else
                 {
                     paintWaterOnMap(nwN2AreaViewer, terrainEditor, netDisplayManager, seaLevel, vector3, texture);
                 }
             }
         }
     }
 }
        private void handleAttributeMap(TerrainImporterSettings importerSettings, NWN2AreaViewer nwN2AreaViewer, NWN2TerrainEditorForm terrainEditor, SynchronousNetDisplayManager netDisplayManager, float outerRight, float outerTop, int x, int y, float areaX, float areaY, float z, ref Vector3 vector3, string texture, ref string textureName)
        {
            if (importerSettings.attributeMap != null)
            {
                AmfAttributeMap amfAttributeMap = (AmfAttributeMap)importerSettings.attributeMap;
                if (textureName == "")
                {
                    textureName = (string)importerSettings.fullAttributeTable[amfAttributeMap.GetPixel(x, y)];
                }

                paintGrass(importerSettings, nwN2AreaViewer, terrainEditor, netDisplayManager, outerRight, outerTop, areaX, areaY, vector3, texture, textureName);
                paintTrees(importerSettings, areaX, areaY, z, textureName);
            }
        }
示例#12
0
 /// <summary>
 /// In the case where the old PaintTerrainInputReceiver has been collected by the garbage collector, 
 /// then we try to make a replacement
 /// </summary>
 /// <param name="viewer"></param>
 private void addNewReceiver(NWN2AreaViewer viewer)
 {
     Console.WriteLine("The retained paintTerrianInputReceiver is null");
     PaintTerrainInputReceiver normalPaint = new PaintTerrainInputReceiver();
     normalPaint.Attach(viewer.ElectronPanel);
     viewer.ElectronPanel.AddInputReceiver(normalPaint);
 }
示例#13
0
        /// <summary>
        /// The code for painting on-line3
        /// </summary>
        /// <param name="X"></param>
        /// <param name="Y"></param>
        private void TerrianCode(int X, int Y)
        {
            try {
                areaViewer = getAreaViewer();
                SFX.YATT.Tools.Vector <float> coor = findAreaCoor(X, Y, areaViewer.Area);

                Random ran = new Random();

                if (coor != null)
                {
                    NWN2ToolsetMainForm.App.TerrainEditor.SetBrushType(NWN2TerrainEditorForm.BrushType.StandardTerrain);


                    // Textures:
                    opTexture.Checked = true;
                    if (data.randomize)
                    {
                        ran = new Random(System.DateTime.Now.Millisecond);

                        ArrayList texData = new ArrayList(data.textures.Count);
                        texData.AddRange(data.textures);

                        while (texData.Count > 0)
                        {
                            int         num     = ran.Next(0, texData.Count - 1);
                            textureData texture = (textureData)texData[num];
                            texturePreperation(coor, TerrainModificationType.Texture, texture);
                            texData.RemoveAt(num);
                        }
                    }
                    else
                    {
                        LinkedListNode <textureData> node = data.textures.Last;
                        while (node != null)
                        {
                            DateTime dateTime = DateTime.Now;

                            double start = ((double)dateTime.Ticks) / 1000000.0;
                            texturePreperation(coor, TerrainModificationType.Texture, node.Value);
                            dateTime = DateTime.Now;
                            node     = node.Previous;
                        }
                    }

                    if (data.grassOption == grassOption.Paint)
                    {
                        opGrass.Checked = true;

                        barPressure.Value        = data.grassDensity * 100;
                        grassSize.Value          = (data.grassSize / 30);
                        grassSizeVariation.Value = (data.grassSizeVariation / 10);

                        object[] objList = new object[grassListBox.Items.Count];
                        grassListBox.Items.CopyTo(objList, 0);

                        int index = 0;

                        grassListBox.SelectedIndices.Clear();

                        foreach (TextureListItem textureItem in objList)
                        {
                            string textStr = textureItem.Text;
                            if (textStr == data.grassTexture[0] ||
                                textStr == data.grassTexture[1] ||
                                textStr == data.grassTexture[2])
                            {
                                grassListBox.SelectedItem = textureItem;
                                index++;

                                if (index == 3)
                                {
                                    break;
                                }
                            }
                        }

                        NWN2ToolsetMainForm.App.TerrainEditor.SetBrushType(NWN2TerrainEditorForm.BrushType.FloraGrass);
                        texturePreperation(coor, TerrainModificationType.Grass, data.textures.First.Value);
                    }


                    if (data.colourOption == colourOption.Colour)
                    {
                        opTerrain.Checked      = true;
                        opColour.Checked       = true;
                        colourButton.BackColor = data.col;
                        barPressure.Value      = data.colourPresure * 100;
                        texturePreperation(coor, TerrainModificationType.Color, data.textures.First.Value);
                    }
                }
            } catch (Exception e) {
                Console.WriteLine(e);
            }
        }
示例#14
0
 /// <summary>
 /// Save the area given
 /// </summary>
 /// <param name="area">The area we want to save</param>
 private void SaveAreaTerrain(NWN2AreaViewer area)
 {
     area.SaveTerrain(true);
     area.SaveContents(true, OEIShared.UI.OEIMessageBoxResult.YesToAll);
 }
示例#15
0
        private void HandlePluginLaunch(object sender, EventArgs e)
        {
            NWN2AreaViewer activeViewer = (NWN2ToolsetMainForm.App.GetActiveViewer() as NWN2AreaViewer);

            if (activeViewer == null || activeViewer.SelectedInstances.Count <= 0)
            {
                MessageBox.Show("No selection", DisplayName, MessageBoxButtons.OK);
                return;
            }

            using (ScaleForm frm = new ScaleForm())
            {
                DialogResult res = frm.ShowDialog();
                if (res == DialogResult.OK)
                {
                    float scaleFactor = frm.ScaleFactor;

                    Vector3 center = new Vector3(0f, 0f, 0f);
                    int     count  = 0;
                    foreach (INWN2Instance instance in activeViewer.SelectedInstances)
                    {
                        if (instance.Area == null)
                        {
                            continue;
                        }

                        if (instance is NWN2CreatureInstance)
                        {
                            center.Add((instance as NWN2CreatureInstance).Position);
                            count++;
                        }
                        if (instance is NWN2DoorInstance)
                        {
                            center.Add((instance as NWN2DoorInstance).Position);
                            count++;
                        }
                        if (instance is NWN2EncounterInstance)
                        {
                            center.Add((instance as NWN2EncounterInstance).Position);
                            count++;
                        }
                        if (instance is NWN2EnvironmentInstance)
                        {
                            center.Add((instance as NWN2EnvironmentInstance).Position);
                            count++;
                        }
                        if (instance is NWN2ItemInstance)
                        {
                            center.Add((instance as NWN2ItemInstance).Position);
                            count++;
                        }
                        if (instance is NWN2LightInstance)
                        {
                            center.Add((instance as NWN2LightInstance).Position);
                            count++;
                        }
                        if (instance is NWN2PlaceableInstance)
                        {
                            center.Add((instance as NWN2PlaceableInstance).Position);
                            count++;
                        }
                        if (instance is NWN2PlacedEffectInstance)
                        {
                            center.Add((instance as NWN2PlacedEffectInstance).Position);
                            count++;
                        }
                        if (instance is NWN2SoundInstance)
                        {
                            center.Add((instance as NWN2SoundInstance).Position);
                            count++;
                        }
                        if (instance is NWN2StaticCameraInstance)
                        {
                            center.Add((instance as NWN2StaticCameraInstance).Position);
                            count++;
                        }
                        if (instance is NWN2StoreInstance)
                        {
                            center.Add((instance as NWN2StoreInstance).Position);
                            count++;
                        }
                        if (instance is NWN2TreeInstance)
                        {
                            center.Add((instance as NWN2TreeInstance).Position);
                            count++;
                        }
                        if (instance is NWN2TriggerInstance)
                        {
                            center.Add((instance as NWN2TriggerInstance).Position);
                            count++;
                        }
                        if (instance is NWN2WaypointInstance)
                        {
                            center.Add((instance as NWN2WaypointInstance).Position);
                            count++;
                        }
                    }
                    center.Multiply(1.0f / Convert.ToSingle(count));
                    foreach (INWN2Instance instance in activeViewer.SelectedInstances)
                    {
                        if (instance.Area == null)
                        {
                            continue;
                        }

                        Vector3 position = new Vector3(0f, 0f, 0f);
                        Vector3 scale    = new Vector3(0f, 0f, 0f);
                        if (instance is NWN2CreatureInstance)
                        {
                            position = (instance as NWN2CreatureInstance).Position;
                            scale    = (instance as NWN2CreatureInstance).Scale;
                        }
                        if (instance is NWN2DoorInstance)
                        {
                            position = (instance as NWN2DoorInstance).Position;
                            scale    = (instance as NWN2DoorInstance).Scale;
                        }
                        if (instance is NWN2EncounterInstance)
                        {
                            position = (instance as NWN2EncounterInstance).Position;
                            // TODO scale Geometry and SpawnPoints
                        }
                        if (instance is NWN2EnvironmentInstance)
                        {
                            position = (instance as NWN2EnvironmentInstance).Position;
                            scale    = (instance as NWN2EnvironmentInstance).Scale;
                        }
                        if (instance is NWN2ItemInstance)
                        {
                            position = (instance as NWN2ItemInstance).Position;
                        }
                        if (instance is NWN2LightInstance)
                        {
                            position = (instance as NWN2LightInstance).Position;
                        }
                        if (instance is NWN2PlaceableInstance)
                        {
                            position = (instance as NWN2PlaceableInstance).Position;
                            scale    = (instance as NWN2PlaceableInstance).Scale;
                        }
                        if (instance is NWN2PlacedEffectInstance)
                        {
                            position = (instance as NWN2PlacedEffectInstance).Position;
                        }
                        if (instance is NWN2SoundInstance)
                        {
                            position = (instance as NWN2SoundInstance).Position;
                        }
                        if (instance is NWN2StaticCameraInstance)
                        {
                            position = (instance as NWN2StaticCameraInstance).Position;
                        }
                        if (instance is NWN2StoreInstance)
                        {
                            position = (instance as NWN2StoreInstance).Position;
                        }
                        if (instance is NWN2TreeInstance)
                        {
                            position = (instance as NWN2TreeInstance).Position;
                            scale    = (instance as NWN2TreeInstance).Scale;
                        }
                        if (instance is NWN2TriggerInstance)
                        {
                            position = (instance as NWN2TriggerInstance).Position;
                            // TODO scale Geometry
                        }
                        if (instance is NWN2WaypointInstance)
                        {
                            position = (instance as NWN2WaypointInstance).Position;
                        }
                        position.Subtract(center);
                        position.Scale(scaleFactor);
                        position.Add(center);
                        scale.Multiply(scaleFactor);
                        if (instance is NWN2CreatureInstance)
                        {
                            (instance as NWN2CreatureInstance).Position = position;
                            (instance as NWN2CreatureInstance).Scale    = scale;
                        }
                        if (instance is NWN2DoorInstance)
                        {
                            (instance as NWN2DoorInstance).Position = position;
                            (instance as NWN2DoorInstance).Scale    = scale;
                        }
                        if (instance is NWN2EncounterInstance)
                        {
                            (instance as NWN2EncounterInstance).Position = position;
                        }
                        if (instance is NWN2EnvironmentInstance)
                        {
                            (instance as NWN2EnvironmentInstance).Position = position;
                            (instance as NWN2EnvironmentInstance).Scale    = scale;
                        }
                        if (instance is NWN2ItemInstance)
                        {
                            (instance as NWN2ItemInstance).Position = position;
                        }
                        if (instance is NWN2LightInstance)
                        {
                            (instance as NWN2LightInstance).Position = position;
                        }
                        if (instance is NWN2PlaceableInstance)
                        {
                            (instance as NWN2PlaceableInstance).Position = position;
                            (instance as NWN2PlaceableInstance).Scale    = scale;
                        }
                        if (instance is NWN2PlacedEffectInstance)
                        {
                            (instance as NWN2PlacedEffectInstance).Position = position;
                        }
                        if (instance is NWN2SoundInstance)
                        {
                            (instance as NWN2SoundInstance).Position = position;
                        }
                        if (instance is NWN2StaticCameraInstance)
                        {
                            (instance as NWN2StaticCameraInstance).Position = position;
                        }
                        if (instance is NWN2StoreInstance)
                        {
                            (instance as NWN2StoreInstance).Position = position;
                        }
                        if (instance is NWN2TreeInstance)
                        {
                            (instance as NWN2TreeInstance).Position = position;
                            (instance as NWN2TreeInstance).Scale    = scale;
                        }
                        if (instance is NWN2TriggerInstance)
                        {
                            (instance as NWN2TriggerInstance).Position = position;
                        }
                        if (instance is NWN2WaypointInstance)
                        {
                            (instance as NWN2WaypointInstance).Position = position;
                        }
                    }
                }
            }
        }