Ejemplo n.º 1
0
 // Use this for initialization
 void Start()
 {
     m_Target = new VCEMath.DrawTarget();
     m_CursorGizmoCube.m_Shrink = -0.03f;
     m_OffsetGizmoCube.m_Shrink = 0.03f;
     VCEStatusBar.ShowText("Pencil - Dot single voxel".ToLocalizationString(), 7, true);
 }
Ejemplo n.º 2
0
    void Start()
    {
        m_Radius   = s_RecentRadius;
        m_Hardness = s_RecentHardness;
        m_Strength = s_RecentStrength;

        m_GLCursor.m_Airbrush = this;
        m_MeshMgr             = VCEditor.Instance.m_MeshMgr;

        // continous drawing vars
        m_simDist  = VCEditor.s_Scene.m_Setting.EditorWorldSize.magnitude * 0.2f;
        m_lastHit  = Vector3.zero;
        m_lastDraw = Vector3.one * (-100);

        // Inspector
        m_Inspector = VCEUIFreeAirbrushInspector.Instantiate(m_InspectorRes) as VCEUIFreeAirbrushInspector;
        m_Inspector.transform.parent        = VCEditor.Instance.m_UI.m_InspectorGroup;
        m_Inspector.transform.localPosition = new Vector3(0, -10, 0);
        m_Inspector.transform.localScale    = Vector3.one;
        m_Inspector.m_ParentBrush           = this;
        m_Inspector.gameObject.SetActive(true);

        if (m_Eraser)
        {
            VCEStatusBar.ShowText("Eraser - Erase color on voxel blocks".ToLocalizationString(), 7, true);
        }
        else
        {
            VCEStatusBar.ShowText("Airbrush - Paint color on voxel blocks".ToLocalizationString(), 7, true);
        }
    }
Ejemplo n.º 3
0
    // begin a template scene
    public static void NewScene(VCESceneSetting setting, int template)
    {
        if (s_Instance == null)
        {
            return;
        }

        // Close current scene first
        CloseScene();

        // New VCEScene
        s_SceneId++;
        s_Scene = new VCEScene(setting, template);
        s_Scene.BuildScene();
        Debug.Log("VCE new scene. sceneid = " + s_SceneId.ToString());

        // After Scene Changed
        AfterSceneChanged(setting);
        if (OnSceneCreate != null)
        {
            OnSceneCreate(s_Scene);
        }

        // Show status
        string s = "New scene".ToLocalizationString() + " ";

        string[] scenepaths = s_Scene.m_IsoData.m_HeadInfo.ScenePaths();
        foreach (string sp in scenepaths)
        {
            s += "[" + sp.ToLocalizationString() + "] ";
        }
        s += "is ready".ToLocalizationString() + " !";
        VCEStatusBar.ShowText(s, 10, true);
    }
Ejemplo n.º 4
0
 // Use this for initialization
 protected void Start()
 {
     m_Target             = new VCEMath.DrawTarget();
     m_Begin              = null;
     m_End                = null;
     m_GizmoCube.m_Shrink = -0.04f;
     VCEStatusBar.ShowText(BrushDesc().ToLocalizationString(), 7, true);
 }
Ejemplo n.º 5
0
    public void DeleteSelection()
    {
        m_Action = new VCEAction();

        VCEditor.s_Mirror.CalcPrepare(VCEditor.s_Scene.m_Setting.m_VoxelSize);
        foreach (KeyValuePair <int, byte> kvp in m_SelectionMgr.m_Selection)
        {
            // Mirror
            if (VCEditor.s_Mirror.Enabled_Masked)
            {
                IntVector3 pos = VCIsoData.KeyToIPos(kvp.Key);
                VCEditor.s_Mirror.MirrorVoxel(pos);
                float strength = (float)(kvp.Value) / 255.0f;
                for (int i = 0; i < VCEditor.s_Mirror.OutputCnt; ++i)
                {
                    if (VCEditor.s_Scene.m_IsoData.IsPointIn(VCEditor.s_Mirror.Output[i]))
                    {
                        int     voxel_pos = VCIsoData.IPosToKey(VCEditor.s_Mirror.Output[i]);
                        VCVoxel old_voxel = VCEditor.s_Scene.m_IsoData.GetVoxel(voxel_pos);
                        VCVoxel new_voxel = old_voxel;
                        new_voxel.VolumeF = new_voxel.VolumeF * (1 - strength);
                        if (old_voxel != new_voxel)
                        {
                            VCEAlterVoxel modify = new VCEAlterVoxel(voxel_pos, old_voxel, new_voxel);
                            modify.Redo();
                            m_Action.Modifies.Add(modify);
                        }
                    }
                }
            }
            // No mirror
            else
            {
                float   strength  = (float)(kvp.Value) / 255.0f;
                int     voxel_pos = kvp.Key;
                VCVoxel old_voxel = VCEditor.s_Scene.m_IsoData.GetVoxel(voxel_pos);
                VCVoxel new_voxel = old_voxel;
                new_voxel.VolumeF = new_voxel.VolumeF * (1 - strength);
                if (old_voxel != new_voxel)
                {
                    VCEAlterVoxel modify = new VCEAlterVoxel(voxel_pos, old_voxel, new_voxel);
                    m_Action.Modifies.Add(modify);
                }
            }
        }
        ColorSelection(VCIsoData.BLANK_COLOR, false, true);
        if (m_Action.Modifies.Count > 0)
        {
            m_Action.DoButNotRegister();
            VCUtils.ISOCut(VCEditor.s_Scene.m_IsoData, m_Action);
            m_Action.Register();
            VCEStatusBar.ShowText("Selected voxels have been removed".ToLocalizationString(), 2);
        }
        ClearSelection();
    }
Ejemplo n.º 6
0
 public void OnRedoClick()
 {
     if (VCEditor.s_ProtectLock0)
     {
         return;
     }
     if (VCEHistory.Redo())
     {
         VCEditor.ClearSelections();
         VCEditor.SelectedMaterial = VCEditor.SelectedMaterial;
         VCEStatusBar.ShowText("Redo".ToLocalizationString(), 2);
     }
 }
Ejemplo n.º 7
0
 public void OnEffectTab(bool isChecked)
 {
     if (isChecked)
     {
         VCEditor.Instance.m_VoxelSelection.ClearSelection();
         VCEditor.Instance.m_NearVoxelIndicator.enabled = false;
         VCEStatusBar.ShowText("Add effects".ToLocalizationString(), 5, true);
     }
     else
     {
         VCEditor.DeselectBrushes();
         DestroyBrushInst(ref m_SelectComponentBrushInst);
     }
 }
Ejemplo n.º 8
0
 public void OnAddClick()
 {
     if (VCEAssetMgr.AddMaterialFromTemp(m_Material.m_Guid))
     {
         VCEditor.SelectedMaterial = m_Material;
         VCEditor.Instance.m_UI.m_MaterialWindow.Reset(m_Material);
         VCEditor.Instance.m_UI.m_MaterialList.RefreshMaterialList(VCEditor.Instance.m_UI.m_MatterPopupList.selection);
         VCEStatusBar.ShowText("Add material".ToLocalizationString() + " [" + m_Material.m_Name + "] " + "from the current ISO".ToLocalizationString() + " !", 6f, true);
     }
     else
     {
         VCEMsgBox.Show(VCEMsgBoxType.MATERIAL_NOT_SAVED);
     }
     s_CurrentDelMat = null;
 }
Ejemplo n.º 9
0
    public static void DoDeleteFromMsgBox()
    {
        string sguid = s_CurrentDelDecal.GUIDString;

        if (VCEAssetMgr.DeleteDecal(s_CurrentDelDecal.m_Guid))
        {
            VCEditor.SelectedDecal = null;
            VCEditor.Instance.m_UI.m_DecalList.RefreshDecalList();
            VCEStatusBar.ShowText("Decal".ToLocalizationString() + " [" + sguid + "] " + "has been deleted".ToLocalizationString() + " !", 6f, true);
        }
        else
        {
            VCEMsgBox.Show(VCEMsgBoxType.DECAL_NOT_SAVED);
        }
    }
Ejemplo n.º 10
0
 public void OnAddClick()
 {
     if (VCEAssetMgr.AddDecalFromTemp(m_GUID))
     {
         VCDecalAsset decal = VCEAssetMgr.GetDecal(m_GUID);
         VCEditor.SelectedDecalGUID = m_GUID;
         m_ParentList.RefreshDecalList();
         VCEStatusBar.ShowText("Add decal".ToLocalizationString() + " [" + decal.GUIDString + "] " + "from the current ISO".ToLocalizationString() + " !", 6f, true);
     }
     else
     {
         VCEMsgBox.Show(VCEMsgBoxType.DECAL_NOT_SAVED);
     }
     s_CurrentDelDecal = null;
 }
Ejemplo n.º 11
0
 void OnSelectClick()
 {
     m_ParentList.m_SelectedItem = this;
     if (m_Extension == VCConfig.s_IsoFileExt || m_Extension.Length == 0)
     {
         VCEStatusBar.ShowText("Double-click to open".ToLocalizationString(), 2);
     }
     else if (m_Extension == VCConfig.s_ObsoleteIsoFileExt)
     {
         VCEStatusBar.ShowText("This ISO version is NOT compatible with the current build, please download the converter from our website".ToLocalizationString() + "!", Color.red, 20);
     }
     else
     {
         VCEStatusBar.ShowText("Corrupt file".ToLocalizationString(), 2);
     }
 }
Ejemplo n.º 12
0
 public void OnDecalTab(bool isChecked)
 {
     if (isChecked)
     {
         VCEditor.Instance.m_VoxelSelection.ClearSelection();
         VCEditor.Instance.m_NearVoxelIndicator.enabled = false;
         VCEStatusBar.ShowText("Add decals".ToLocalizationString(), 5, true);
     }
     else
     {
         VCEditor.DeselectBrushes();
         VCEditor.SelectedDecal = null;
         DestroyBrushInst(ref m_SelectComponentBrushInst);
         DestroyBrushInst(ref m_DrawDecalBrushInst);
         m_DecalWindow.HideWindow();
     }
 }
Ejemplo n.º 13
0
    void CreateAsNew()
    {
        VCMaterial newmat = new VCMaterial();

        newmat.Import(m_TempMaterial.Export());
        VCEAssetMgr.s_Materials.Add(newmat.m_Guid, newmat);
        if (!VCEAssetMgr.CreateMaterialDataFile(newmat))
        {
            VCEMsgBox.Show(VCEMsgBoxType.MATERIAL_NOT_SAVED);
        }

        VCEditor.SelectedMaterial = newmat;
        VCEditor.Instance.m_UI.m_MaterialList.RefreshMaterialListThenFocusOnSelected();
        VCEditor.SelectedMaterial = newmat;
        Reset(newmat);
        VCEStatusBar.ShowText("New Material".ToLocalizationString() + " [" + newmat.m_Name + "]", 6f, true);
    }
Ejemplo n.º 14
0
 public void OnISOTab(bool isChecked)
 {
     if (isChecked)
     {
         VCEditor.Instance.m_MainCamera.GetComponent <VCEGL>().enabled = false;
         m_IsoList.enabled = true;
         m_IsoList.CreateInspector();
         m_IsoList.RefreshIsoList();
         VCEStatusBar.ShowText("ISO Browser".ToLocalizationString(), 5, true);
     }
     else
     {
         VCEditor.Instance.m_MainCamera.GetComponent <VCEGL>().enabled = true;
         m_IsoList.enabled = false;
         m_IsoList.DestroyInspector();
     }
 }
Ejemplo n.º 15
0
 public void OnPaintTab(bool isChecked)
 {
     if (isChecked)
     {
         VCEditor.Instance.m_NearVoxelIndicator.enabled = true;
         VCEditor.Instance.m_GLGroup.SetActive(false);
         VCEStatusBar.ShowText("Paint voxel blocks".ToLocalizationString(), 5, true);
     }
     else
     {
         VCEditor.DeselectBrushes();
         if (VCEditor.s_Ready)
         {
             VCEditor.Instance.m_GLGroup.SetActive(true);
         }
     }
 }
Ejemplo n.º 16
0
 public static void DoDeleteFromMsgBox()
 {
     if (VCEAssetMgr.DeleteMaterial(s_CurrentDelMat.m_Guid))
     {
         VCEditor.SelectedMaterial = null;
         if (VCEditor.Instance.m_UI.m_MaterialWindow.WindowVisible())
         {
             VCEditor.Instance.m_UI.m_MaterialWindow.HideWindow();
         }
         VCEditor.Instance.m_UI.m_MaterialList.RefreshMaterialList(VCEditor.Instance.m_UI.m_MatterPopupList.selection);
         VCEStatusBar.ShowText("Material".ToLocalizationString() + " [" + s_CurrentDelMat.m_Name + "] " + "has been deleted".ToLocalizationString() + " !", 6f, true);
     }
     else
     {
         VCEMsgBox.Show(VCEMsgBoxType.MATERIAL_NOT_SAVED);
     }
 }
Ejemplo n.º 17
0
    public void OnOKClick()
    {
        if (m_ErrorLabel.text.Trim().Length < 1 && m_TmpDecal != null && m_TmpDecal.m_Tex != null)
        {
            VCDecalAsset newdcl = new VCDecalAsset();
            newdcl.Import(m_TmpDecal.Export());
            VCEAssetMgr.s_Decals.Add(newdcl.m_Guid, newdcl);
            if (!VCEAssetMgr.CreateDecalDataFile(newdcl))
            {
                VCEMsgBox.Show(VCEMsgBoxType.DECAL_NOT_SAVED);
            }

            VCEditor.SelectedDecal = newdcl;
            VCEditor.Instance.m_UI.m_DecalList.RefreshDecalList();
            VCEditor.SelectedDecal = newdcl;

            VCEStatusBar.ShowText("Added new decal".ToLocalizationString() + " !", 4f, true);
        }
    }
Ejemplo n.º 18
0
    // Delete Selected Components
    public void DeleteSelection()
    {
        if (UsingGizmo)
        {
            return;
        }
        VCEditor.s_Mirror.CalcPrepare(VCEditor.s_Scene.m_Setting.m_VoxelSize);

        m_Action = new VCEAction();
        int del_cnt = 0;

        foreach (SelectInfo si in m_Selection)
        {
            VCEComponentTool        ct     = si.m_Component;
            List <VCEComponentTool> images = MirrorImage(ct);
            images.Add(ct);

            foreach (VCEComponentTool image in images)
            {
                int index = VCEditor.s_Scene.m_IsoData.GetComponentIndex(image.m_Data);
                if (index < 0)
                {
                    continue;
                }
                VCEDelComponent modify = new VCEDelComponent(index, image.m_Data);
                modify.Redo();
                m_Action.Modifies.Add(modify);
                del_cnt++;
            }
        }
        if (m_Action.Modifies.Count > 0)
        {
            m_Action.Register();
            ClearSelection();
        }
        if (del_cnt > 0)
        {
            VCEStatusBar.ShowText(del_cnt.ToString() + " " + "component(s) have been removed".ToLocalizationString(), 4);
        }
        m_MouseOnGizmo = false;
    }
Ejemplo n.º 19
0
 void OnSelectionChange()
 {
     s_LastCreate = null;
     if (m_Selection.Count == 1)
     {
         VCComponentData sel_data       = m_Selection[0].m_Component.m_Data;
         VCPartData      sel_part_data  = sel_data as VCPartData;
         VCDecalData     sel_decal_data = sel_data as VCDecalData;
         if (sel_part_data != null)
         {
             ShowDataInspector(VCConfig.s_PartTypes[sel_part_data.m_Type].m_InspectorRes, sel_data);
         }
         else if (sel_decal_data != null)
         {
             ShowDataInspector("GUI/Prefabs/Inspectors/Components Inspectors/inspector decal image", sel_data);
         }
     }
     if (m_Selection.Count > 0)
     {
         VCEStatusBar.ShowText(m_Selection.Count.ToString() + " " + "component(s)".ToLocalizationString() + " " + "selected".ToLocalizationString(), 4);
     }
 }
Ejemplo n.º 20
0
    // load an iso
    public static void LoadIso(string path)
    {
        if (s_Instance == null)
        {
            return;
        }

        // Close current scene first
        CloseScene();

        // Load a VCEScene from an specified iso
        try
        {
            s_SceneId++;
            s_Scene = new VCEScene(path);

            // Build scene
            s_Scene.BuildScene();

            // After Scene Changed
            AfterSceneChanged(s_Scene.m_Setting);
        }
        catch (Exception)
        {
            NewScene(VCConfig.FirstSceneSetting);
            VCEMsgBox.Show(VCEMsgBoxType.CORRUPT_ISO);
            return;
        }

        if (OnSceneCreate != null)
        {
            OnSceneCreate(s_Scene);
        }

        Debug.Log("VCE load iso " + path + " sceneid = " + s_SceneId.ToString());
        // Show status
        VCEStatusBar.ShowText("Load".ToLocalizationString() + " ISO [" + path + "] " + "Complete".ToLocalizationString() + " !", 10, true);
    }
Ejemplo n.º 21
0
 void OnSelectDbClick()
 {
     if (m_IsFolder)
     {
         if (Directory.Exists(m_FilePath))
         {
             m_ParentList.m_Path = m_FilePath;
             m_ParentList.RefreshIsoList();
         }
         else
         {
             VCEStatusBar.ShowText("This folder does not exist".ToLocalizationString() + "!", 2f, false);
             m_ParentList.RefreshIsoList();
         }
     }
     else
     {
         if (File.Exists(m_FilePath))
         {
             if (VCEHistory.s_Modified)
             {
                 s_IsoToLoad = m_FilePath.Substring(VCConfig.s_IsoPath.Length);
                 VCEMsgBox.Show(VCEMsgBoxType.LOAD_QUERY);
             }
             else
             {
                 VCEditor.LoadIso(m_FilePath.Substring(VCConfig.s_IsoPath.Length));
             }
         }
         else
         {
             VCEMsgBox.Show(VCEMsgBoxType.MISSING_ISO);
             VCEStatusBar.ShowText("ISO file is missing".ToLocalizationString() + "!", 2f, false);
             m_ParentList.RefreshIsoList();
         }
     }
 }
Ejemplo n.º 22
0
 void Awake()
 {
     s_Instance = this;
 }
Ejemplo n.º 23
0
    // Update is called once per frame
    void LateUpdate()
    {
        if (!VCEditor.DocumentOpen())
        {
            return;
        }

        GetComponent <Camera>().pixelRect = m_RenderRect;

        // Update view matrix
        float AxisCamDist = 7.5f;

        GetComponent <Camera>().transform.localPosition  = Vector3.zero;
        GetComponent <Camera>().transform.localRotation  = m_MainCameraBehaviour.transform.localRotation;
        GetComponent <Camera>().transform.localPosition -= GetComponent <Camera>().transform.forward *AxisCamDist;

        // Set axis transparent
        Vector3 sight = GetComponent <Camera>().transform.forward;

        m_alpha_pos_x  = AxisAlpha(Vector3.Angle(sight, -Vector3.right));
        m_alpha_pos_y  = AxisAlpha(Vector3.Angle(sight, -Vector3.up));
        m_alpha_pos_z  = AxisAlpha(Vector3.Angle(sight, -Vector3.forward));
        m_alpha_neg_x  = AxisAlpha(Vector3.Angle(sight, Vector3.right));
        m_alpha_neg_y  = AxisAlpha(Vector3.Angle(sight, Vector3.up));
        m_alpha_neg_z  = AxisAlpha(Vector3.Angle(sight, Vector3.forward));
        m_alpha_origin = 1.0f;

        m_XAxisMaterial.color  = new Color(m_XAxisMaterial.color.r, m_XAxisMaterial.color.g, m_XAxisMaterial.color.b, m_alpha_pos_x);
        m_YAxisMaterial.color  = new Color(m_YAxisMaterial.color.r, m_YAxisMaterial.color.g, m_YAxisMaterial.color.b, m_alpha_pos_y);
        m_ZAxisMaterial.color  = new Color(m_ZAxisMaterial.color.r, m_ZAxisMaterial.color.g, m_ZAxisMaterial.color.b, m_alpha_pos_z);
        m_NXAxisMaterial.color = new Color(m_NXAxisMaterial.color.r, m_NXAxisMaterial.color.g, m_NXAxisMaterial.color.b, m_alpha_neg_x);
        m_NYAxisMaterial.color = new Color(m_NYAxisMaterial.color.r, m_NYAxisMaterial.color.g, m_NYAxisMaterial.color.b, m_alpha_neg_y);
        m_NZAxisMaterial.color = new Color(m_NZAxisMaterial.color.r, m_NZAxisMaterial.color.g, m_NZAxisMaterial.color.b, m_alpha_neg_z);
        m_OriginMaterial.color = new Color(m_OriginMaterial.color.r, m_OriginMaterial.color.g, m_OriginMaterial.color.b, m_alpha_origin);

        // Pick axis
        m_MouseRay = GetComponent <Camera>().ScreenPointToRay(Input.mousePosition);
        Renderer focus     = null;
        float    MinDist   = 1000.0f;
        float    DestYaw   = 0.0f;
        float    DestPitch = 0.0f;

        m_mrXAxis.material  = m_XAxisMaterial;
        m_mrYAxis.material  = m_YAxisMaterial;
        m_mrZAxis.material  = m_ZAxisMaterial;
        m_mrNXAxis.material = m_NXAxisMaterial;
        m_mrNYAxis.material = m_NYAxisMaterial;
        m_mrNZAxis.material = m_NZAxisMaterial;
        m_mrOrigin.material = m_OriginMaterial;
        RaycastHit rchit;

        if (m_alpha_pos_x > m_alpha_threshold && m_mrXAxis.GetComponent <Collider>().Raycast(m_MouseRay, out rchit, 100))
        {
            if (rchit.distance < MinDist)
            {
                MinDist   = rchit.distance;
                focus     = m_mrXAxis;
                DestYaw   = 0.0f;
                DestPitch = 0.0f;
                VCEStatusBar.ShowText("Right view".ToLocalizationString(), 2);
            }
        }
        if (m_alpha_pos_y > m_alpha_threshold && m_mrYAxis.GetComponent <Collider>().Raycast(m_MouseRay, out rchit, 100))
        {
            if (rchit.distance < MinDist)
            {
                MinDist   = rchit.distance;
                focus     = m_mrYAxis;
                DestYaw   = 90.0f;
                DestPitch = 90.0f;
                VCEStatusBar.ShowText("Top view".ToLocalizationString(), 2);
            }
        }
        if (m_alpha_pos_z > m_alpha_threshold && m_mrZAxis.GetComponent <Collider>().Raycast(m_MouseRay, out rchit, 100))
        {
            if (rchit.distance < MinDist)
            {
                MinDist   = rchit.distance;
                focus     = m_mrZAxis;
                DestYaw   = 90.0f;
                DestPitch = 0.0f;
                VCEStatusBar.ShowText("Front view".ToLocalizationString(), 2);
            }
        }
        if (m_alpha_neg_x > m_alpha_threshold && m_mrNXAxis.GetComponent <Collider>().Raycast(m_MouseRay, out rchit, 100))
        {
            if (rchit.distance < MinDist)
            {
                MinDist   = rchit.distance;
                focus     = m_mrNXAxis;
                DestYaw   = 180.0f;
                DestPitch = 0.0f;
                VCEStatusBar.ShowText("Left view".ToLocalizationString(), 2);
            }
        }
        if (m_alpha_neg_y > m_alpha_threshold && m_mrNYAxis.GetComponent <Collider>().Raycast(m_MouseRay, out rchit, 100))
        {
            if (rchit.distance < MinDist)
            {
                MinDist   = rchit.distance;
                focus     = m_mrNYAxis;
                DestYaw   = 90.0f;
                DestPitch = -90.0f;
                VCEStatusBar.ShowText("Bottom view".ToLocalizationString(), 2);
            }
        }
        if (m_alpha_neg_z > m_alpha_threshold && m_mrNZAxis.GetComponent <Collider>().Raycast(m_MouseRay, out rchit, 100))
        {
            if (rchit.distance < MinDist)
            {
                MinDist   = rchit.distance;
                focus     = m_mrNZAxis;
                DestYaw   = -90.0f;
                DestPitch = 0.0f;
                VCEStatusBar.ShowText("Back view".ToLocalizationString(), 2);
            }
        }
        if (m_mrOrigin.GetComponent <Collider>().Raycast(m_MouseRay, out rchit, 100))
        {
            if (rchit.distance < MinDist)
            {
                MinDist   = rchit.distance;
                focus     = m_mrOrigin;
                DestYaw   = m_MainCameraBehaviour.BeginYaw;
                DestPitch = m_MainCameraBehaviour.BeginPitch;
                VCEStatusBar.ShowText("Reset camera".ToLocalizationString(), 2);
            }
        }

        // Click
        if (MinDist < 999)
        {
            focus.material = m_FocusMaterial;
            if (Input.GetMouseButtonDown(0))
            {
                while (DestYaw < m_MainCameraBehaviour.Yaw - 180.0f)
                {
                    DestYaw += 360.0f;
                }
                while (DestYaw > m_MainCameraBehaviour.Yaw + 180.0f)
                {
                    DestYaw -= 360.0f;
                }
                while (DestPitch < m_MainCameraBehaviour.Pitch - 180.0f)
                {
                    DestPitch += 360.0f;
                }
                while (DestPitch > m_MainCameraBehaviour.Pitch + 180.0f)
                {
                    DestPitch -= 360.0f;
                }
                m_MainCameraBehaviour.SetYaw(DestYaw);
                m_MainCameraBehaviour.SetPitch(DestPitch);
            }
        }

        // x,y,z Text calculate
        xpoint = GetComponent <Camera>().WorldToScreenPoint(Vector3.right * m_TextOffset + transform.parent.position);
        ypoint = GetComponent <Camera>().WorldToScreenPoint(Vector3.up * m_TextOffset + transform.parent.position);
        zpoint = GetComponent <Camera>().WorldToScreenPoint(Vector3.forward * m_TextOffset + transform.parent.position);

        Ray xRay = GetComponent <Camera>().ScreenPointToRay(xpoint);
        Ray yRay = GetComponent <Camera>().ScreenPointToRay(ypoint);
        Ray zRay = GetComponent <Camera>().ScreenPointToRay(zpoint);

        xShow = true;
        yShow = true;
        zShow = true;
        if (m_mrXAxis.GetComponent <Collider>().Raycast(xRay, out rchit, 100))
        {
            xShow = false;
        }
        if (m_mrYAxis.GetComponent <Collider>().Raycast(xRay, out rchit, 100))
        {
            xShow = false;
        }
        if (m_mrZAxis.GetComponent <Collider>().Raycast(xRay, out rchit, 100))
        {
            xShow = false;
        }
        if (m_mrNXAxis.GetComponent <Collider>().Raycast(xRay, out rchit, 100))
        {
            xShow = false;
        }
        if (m_mrNYAxis.GetComponent <Collider>().Raycast(xRay, out rchit, 100))
        {
            xShow = false;
        }
        if (m_mrNZAxis.GetComponent <Collider>().Raycast(xRay, out rchit, 100))
        {
            xShow = false;
        }
        if (m_mrOrigin.GetComponent <Collider>().Raycast(xRay, out rchit, 100))
        {
            xShow = false;
        }

        if (m_mrXAxis.GetComponent <Collider>().Raycast(yRay, out rchit, 100))
        {
            yShow = false;
        }
        if (m_mrYAxis.GetComponent <Collider>().Raycast(yRay, out rchit, 100))
        {
            yShow = false;
        }
        if (m_mrZAxis.GetComponent <Collider>().Raycast(yRay, out rchit, 100))
        {
            yShow = false;
        }
        if (m_mrNXAxis.GetComponent <Collider>().Raycast(yRay, out rchit, 100))
        {
            yShow = false;
        }
        if (m_mrNYAxis.GetComponent <Collider>().Raycast(yRay, out rchit, 100))
        {
            yShow = false;
        }
        if (m_mrNZAxis.GetComponent <Collider>().Raycast(yRay, out rchit, 100))
        {
            yShow = false;
        }
        if (m_mrOrigin.GetComponent <Collider>().Raycast(yRay, out rchit, 100))
        {
            yShow = false;
        }

        if (m_mrXAxis.GetComponent <Collider>().Raycast(zRay, out rchit, 100))
        {
            zShow = false;
        }
        if (m_mrYAxis.GetComponent <Collider>().Raycast(zRay, out rchit, 100))
        {
            zShow = false;
        }
        if (m_mrZAxis.GetComponent <Collider>().Raycast(zRay, out rchit, 100))
        {
            zShow = false;
        }
        if (m_mrNXAxis.GetComponent <Collider>().Raycast(zRay, out rchit, 100))
        {
            zShow = false;
        }
        if (m_mrNYAxis.GetComponent <Collider>().Raycast(zRay, out rchit, 100))
        {
            zShow = false;
        }
        if (m_mrNZAxis.GetComponent <Collider>().Raycast(zRay, out rchit, 100))
        {
            zShow = false;
        }
        if (m_mrOrigin.GetComponent <Collider>().Raycast(zRay, out rchit, 100))
        {
            zShow = false;
        }
    }
Ejemplo n.º 24
0
    public void ApplyInspectorChange()
    {
        if (m_Selection.Count != 1)
        {
            return;
        }
        if (m_DataInspector == null)
        {
            return;
        }

        VCEditor.s_Mirror.CalcPrepare(VCEditor.s_Scene.m_Setting.m_VoxelSize);
        m_Action = new VCEAction();
        VCComponentData old_data = m_Selection[0].m_Component.m_Data;
        VCComponentData new_data = m_DataInspector.GetComponent <VCEUIComponentInspector>().Get();

        // Mirror
        if (VCEditor.s_Mirror.Enabled_Masked)
        {
            VCComponentData[] old_img_data = new VCComponentData [8];
            VCEditor.s_Mirror.MirrorComponent(old_data);
            for (int i = 0; i < VCEditor.s_Mirror.OutputCnt; ++i)
            {
                old_img_data[i] = VCEditor.s_Mirror.ComponentOutput[i].Copy();
            }

            VCEditor.s_Mirror.MirrorComponent(new_data);
            for (int i = 0; i < VCEditor.s_Mirror.OutputCnt; ++i)
            {
                VCComponentData        image = VCEditor.s_Mirror.ComponentOutput[i];
                List <VCComponentData> edits = VCEditor.s_Scene.m_IsoData.FindComponentsAtPos(old_img_data[i].m_Position, image.m_ComponentId);
                foreach (VCComponentData iter in edits)
                {
                    if (i > 0 && m_Selection.Find(it => it.m_Component.m_Data == iter) != null)
                    {
                        continue;
                    }
                    if (!VCEMath.IsEqualRotation(iter.m_Rotation, old_img_data[i].m_Rotation))
                    {
                        continue;
                    }
                    if (!VCEMath.IsEqualVector(iter.m_Scale, old_img_data[i].m_Scale))
                    {
                        continue;
                    }
                    if (iter.m_Visible != old_img_data[i].m_Visible)
                    {
                        continue;
                    }
                    if (old_img_data[i] is IVCMultiphaseComponentData && iter is IVCMultiphaseComponentData)
                    {
                        if ((old_img_data[i] as IVCMultiphaseComponentData).Phase != (iter as IVCMultiphaseComponentData).Phase)
                        {
                            continue;
                        }
                    }
                    int index = VCEditor.s_Scene.m_IsoData.GetComponentIndex(iter);
                    if (index < 0)
                    {
                        continue;
                    }
                    // Special process for wheels
                    if (i != 0 && image is VCQuadphaseFixedPartData)
                    {
                        (image as VCQuadphaseFixedPartData).m_Phase =
                            ((image as VCQuadphaseFixedPartData).m_Phase & 1) | ((iter as VCQuadphaseFixedPartData).m_Phase & 2);
                    }

                    VCEAlterComponent modify = new VCEAlterComponent(index, iter, image);
                    m_Action.Modifies.Add(modify);
                }
            }
        }
        // No mirror
        else
        {
            int index = VCEditor.s_Scene.m_IsoData.GetComponentIndex(old_data);
            if (index < 0)
            {
                return;
            }
            VCEAlterComponent modify = new VCEAlterComponent(index, old_data, new_data);
            m_Action.Modifies.Add(modify);
        }
        VCEStatusBar.ShowText("Changes applied".ToLocalizationString(), 2);
        m_Action.Do();
    }
Ejemplo n.º 25
0
    public void OnCreationInfoRefresh()
    {
        CreationAttr attr = null;

        if (m_IsEditor)
        {
            CreationData.CalcCreationAttr(VCEditor.s_Scene.m_IsoData, 0, ref VCEditor.s_Scene.m_CreationAttr);
            attr = VCEditor.s_Scene.m_CreationAttr;
        }
        else
        {
            VCIsoRemark remark = new VCIsoRemark();
            remark.xml = m_NonEditorRemark;
            attr       = remark.m_Attribute;

            // 0.9 ID改变处理
            if (attr != null)
            {
                attr.CheckCostId();
            }
            m_CostList.m_NonEditorAttr = attr;
            if (remark.m_Error != null && remark.m_Error.Length > 1)
            {
                m_NonEditorError = "ISO version is obsolete".ToLocalizationString();
            }
            else
            {
                m_NonEditorError = "";
            }
        }

        UpdateItemsTrackState(attr);

        if (attr != null)
        {
            // 上面是否调用了 CalcCreationAttr ? 为什么属性会不同???

            // [VCCase] - Creation attribute info. UI
            if (attr.m_Type == ECreation.Sword || attr.m_Type == ECreation.SwordLarge || attr.m_Type == ECreation.SwordDouble || attr.m_Type == ECreation.Axe)
            {
                m_AttrNames.text = "Creation".ToLocalizationString() + ":\r\n" +
                                   "Weight".ToLocalizationString() + ":\r\n" +
                                   //"Volume".ToLocalizationString() + ":\r\n" +
                                   "Sell Price".ToLocalizationString() + ":\r\n\r\n" +
                                   "Attack".ToLocalizationString() + ":\r\n" +
                                   "Durability".ToLocalizationString() + ":\r\n\r\n";

                m_AttrValues.text = (attr.m_Type == ECreation.Sword || attr.m_Type == ECreation.SwordLarge || attr.m_Type == ECreation.SwordDouble? "Sword".ToLocalizationString() + "\r\n" : "Axe".ToLocalizationString() + "\r\n") +
                                    VCUtils.WeightToString(attr.m_Weight) + "\r\n" +
                                    //VCUtils.VolumeToString(attr.m_Volume) + "\r\n" +
                                    (attr.m_SellPrice).ToString("#,##0") + " " + "Meat".ToLocalizationString() +
                                    "\r\n\r\n" + (attr.m_Attack).ToString("0.0") + "\r\n" +
                                    (Mathf.CeilToInt(attr.m_Durability * WhiteCat.PEVCConfig.equipDurabilityShowScale)).ToString("0.0") + "\r\n";
            }

            else if (attr.m_Type == ECreation.Bow)
            {
                m_AttrNames.text = "Creation".ToLocalizationString() + ":\r\n" +
                                   "Weight".ToLocalizationString() + ":\r\n" +
                                   "Volume".ToLocalizationString() + ":\r\n" +
                                   "Sell Price".ToLocalizationString() + ":\r\n\r\n" +
                                   "Attack".ToLocalizationString() + ":\r\n" +
                                   "Durability".ToLocalizationString() + ":\r\n\r\n";

                m_AttrValues.text = "Bow".ToLocalizationString() + "\r\n" +
                                    VCUtils.WeightToString(attr.m_Weight) + "\r\n" +
                                    VCUtils.VolumeToString(attr.m_Volume) + "\r\n" +
                                    (attr.m_SellPrice).ToString("#,##0") +
#if PLANET_EXPLORERS
                                    " " + "Meat".ToLocalizationString() +
#endif
                                    "\r\n\r\n" + (attr.m_Attack).ToString("0.0") + "\r\n" +
                                    (Mathf.CeilToInt(attr.m_Durability * WhiteCat.PEVCConfig.equipDurabilityShowScale)).ToString("0.0") + "\r\n";
            }

            else if (attr.m_Type == ECreation.Shield)
            {
                m_AttrNames.text = "Creation".ToLocalizationString() + ":\r\n" +
                                   "Weight".ToLocalizationString() + ":\r\n" +
                                   "Volume".ToLocalizationString() + ":\r\n" +
                                   "Sell Price".ToLocalizationString() + ":\r\n\r\n" +
                                   "Defense".ToLocalizationString() + ":\r\n" +
                                   "Durability".ToLocalizationString() + ":\r\n\r\n";

                m_AttrValues.text = "Shield".ToLocalizationString() + "\r\n" +
                                    VCUtils.WeightToString(attr.m_Weight) + "\r\n" +
                                    VCUtils.VolumeToString(attr.m_Volume) + "\r\n" +
                                    (attr.m_SellPrice).ToString("#,##0") +
        #if PLANET_EXPLORERS
                                    " " + "Meat".ToLocalizationString() +
        #endif
                                    "\r\n\r\n" + (attr.m_Defense).ToString("0.0") + "\r\n" +
                                    (Mathf.CeilToInt(attr.m_Durability * WhiteCat.PEVCConfig.equipDurabilityShowScale)).ToString("0.0") + "\r\n";
            }
            else if (attr.m_Type == ECreation.HandGun || attr.m_Type == ECreation.Rifle)
            {
                m_AttrNames.text = "Creation".ToLocalizationString() + ":\r\n" +
                                   "Weight".ToLocalizationString() + ":\r\n" +
                                   "Volume".ToLocalizationString() + ":\r\n" +
                                   "Sell Price".ToLocalizationString() + ":\r\n\r\n" +
                                   "Increase".ToLocalizationString() + ":\r\n" +
                                   "Final Attack".ToLocalizationString() + ":\r\n" +
                                   "Firing Rate".ToLocalizationString() + ":\r\n" +
                                   "Accuracy".ToLocalizationString() + ":\r\n" +
                                   "Durability".ToLocalizationString() + ":\r\n\r\n";

                m_AttrValues.text = ((attr.m_Type == ECreation.HandGun) ? ("Hand Gun".ToLocalizationString() + "\r\n") : ("Rifle".ToLocalizationString() + "\r\n")) +
                                    VCUtils.WeightToString(attr.m_Weight) + "\r\n" +
                                    VCUtils.VolumeToString(attr.m_Volume) + "\r\n" +
                                    (attr.m_SellPrice).ToString("#,##0") +
        #if PLANET_EXPLORERS
                                    " " + "Meat".ToLocalizationString() +
        #endif
                                    "\r\n\r\n" + ((attr.m_MuzzleAtkInc == 0) ? ("-") : (attr.m_MuzzleAtkInc * 100.0f - 100.0f).ToString("0.0")) + " %\r\n" +
                                    (attr.m_Attack).ToString("0.0") + "\r\n" +
                                    (attr.m_FireSpeed).ToString("0.0") + "\r\n" +
                                    (1.0f / attr.m_Accuracy * 100).ToString("0.0") + " %\r\n" +
                                    (Mathf.CeilToInt(attr.m_Durability * WhiteCat.PEVCConfig.equipDurabilityShowScale)).ToString("0.0") + "\r\n";
            }
            else if (attr.m_Type == ECreation.Vehicle)
            {
                m_AttrNames.text = "Creation".ToLocalizationString() + ":\r\n" +
                                   "Weight".ToLocalizationString() + ":\r\n" +
                                   "Volume".ToLocalizationString() + ":\r\n" +
                                   "Sell Price".ToLocalizationString() + ":\r\n\r\n" +
                                   "Attack".ToLocalizationString() + ":\r\n" +
                                   "Durability".ToLocalizationString() + ":\r\n" +
                                   "Fuel".ToLocalizationString() + ":\r\n\r\n";

                m_AttrValues.text = "Vehicle".ToLocalizationString() + "\r\n" +
                                    VCUtils.WeightToString(attr.m_Weight) + "\r\n" +
                                    VCUtils.VolumeToString(attr.m_Volume) + "\r\n" +
                                    (attr.m_SellPrice).ToString("#,##0") +
        #if PLANET_EXPLORERS
                                    " " + "Meat".ToLocalizationString() +
        #endif
                                    "\r\n\r\n" +
                                    (attr.m_Attack).ToString("#,##0") + " /s\r\n" +
                                    (attr.m_Durability).ToString("#,##0") + "\r\n" +
                                    (attr.m_MaxFuel).ToString("#,##0") + "\r\n";
            }
            else if (attr.m_Type == ECreation.Aircraft)
            {
                m_AttrNames.text = "Creation".ToLocalizationString() + ":\r\n" +
                                   "Weight".ToLocalizationString() + ":\r\n" +
                                   "Volume".ToLocalizationString() + ":\r\n" +
                                   "Sell Price".ToLocalizationString() + ":\r\n\r\n" +
                                   "Attack".ToLocalizationString() + ":\r\n" +
                                   "Durability".ToLocalizationString() + ":\r\n" +
                                   "Fuel".ToLocalizationString() + ":\r\n\r\n";

                m_AttrValues.text = "Aircraft".ToLocalizationString() + "\r\n" +
                                    VCUtils.WeightToString(attr.m_Weight) + "\r\n" +
                                    VCUtils.VolumeToString(attr.m_Volume) + "\r\n" +
                                    (attr.m_SellPrice).ToString("#,##0") +
                                                #if PLANET_EXPLORERS
                                    " " + "Meat".ToLocalizationString() +
                                                #endif
                                    "\r\n\r\n" +
                                    (attr.m_Attack).ToString("#,##0") + " /s\r\n" +
                                    (attr.m_Durability).ToString("#,##0") + "\r\n" +
                                    (attr.m_MaxFuel).ToString("#,##0") + "\r\n";
            }
            else if (attr.m_Type == ECreation.Boat)
            {
                m_AttrNames.text = "Creation".ToLocalizationString() + ":\r\n" +
                                   "Weight".ToLocalizationString() + ":\r\n" +
                                   "Volume".ToLocalizationString() + ":\r\n" +
                                   "Sell Price".ToLocalizationString() + ":\r\n\r\n" +
                                   "Attack".ToLocalizationString() + ":\r\n" +
                                   "Durability".ToLocalizationString() + ":\r\n" +
                                   "Fuel".ToLocalizationString() + ":\r\n\r\n";

                m_AttrValues.text = "Boat".ToLocalizationString() + "\r\n" +
                                    VCUtils.WeightToString(attr.m_Weight) + "\r\n" +
                                    VCUtils.VolumeToString(attr.m_Volume) + "\r\n" +
                                    (attr.m_SellPrice).ToString("#,##0") +
                                                #if PLANET_EXPLORERS
                                    " " + "Meat".ToLocalizationString() +
                                                #endif
                                    "\r\n\r\n" +
                                    (attr.m_Attack).ToString("#,##0") + " /s\r\n" +
                                    (attr.m_Durability).ToString("#,##0") + "\r\n" +
                                    (attr.m_MaxFuel).ToString("#,##0") + "\r\n";
            }
            else if (attr.m_Type == ECreation.SimpleObject)
            {
                m_AttrNames.text = "Creation".ToLocalizationString() + ":\r\n" +
                                   "Weight".ToLocalizationString() + ":\r\n" +
                                   "Volume".ToLocalizationString() + ":\r\n" +
                                   "Sell Price".ToLocalizationString() + ":\r\n\r\n" +
                                   "Durability".ToLocalizationString() + ":\r\n\r\n";

                m_AttrValues.text = "Object".ToLocalizationString() + "\r\n" +
                                    VCUtils.WeightToString(attr.m_Weight) + "\r\n" +
                                    VCUtils.VolumeToString(attr.m_Volume) + "\r\n" +
                                    (attr.m_SellPrice).ToString("#,##0") +
                                                #if PLANET_EXPLORERS
                                    " " + "Meat".ToLocalizationString() +
                                                #endif
                                    "\r\n\r\n" + (attr.m_Durability).ToString("#,##0") + "\r\n";
            }
            else if (attr.m_Type == ECreation.Robot)
            {
                m_AttrNames.text = "Creation".ToLocalizationString() + ":\r\n" +
                                   "Weight".ToLocalizationString() + ":\r\n" +
                                   "Volume".ToLocalizationString() + ":\r\n" +
                                   "Sell Price".ToLocalizationString() + ":\r\n\r\n" +
                                   "Attack".ToLocalizationString() + ":\r\n" +
                                   "Durability".ToLocalizationString() + ":\r\n\r\n";

                m_AttrValues.text = "Object".ToLocalizationString() + "\r\n" +
                                    VCUtils.WeightToString(attr.m_Weight) + "\r\n" +
                                    VCUtils.VolumeToString(attr.m_Volume) + "\r\n" +
                                    (attr.m_SellPrice).ToString("#,##0") +
#if PLANET_EXPLORERS
                                    " " + "Meat".ToLocalizationString() +
#endif
                                    "\r\n\r\n" +
                                    (attr.m_Attack).ToString("#,##0") + " /s\r\n" +
                                    (attr.m_Durability).ToString("#,##0") + "\r\n";
            }
            else if (attr.m_Type == ECreation.AITurret)
            {
                m_AttrNames.text = "Creation".ToLocalizationString() + ":\r\n" +
                                   "Weight".ToLocalizationString() + ":\r\n" +
                                   "Volume".ToLocalizationString() + ":\r\n" +
                                   "Sell Price".ToLocalizationString() + ":\r\n\r\n" +
                                   "Attack".ToLocalizationString() + ":\r\n" +
                                   "Durability".ToLocalizationString() + ":\r\n\r\n";

                m_AttrValues.text = "Object".ToLocalizationString() + "\r\n" +
                                    VCUtils.WeightToString(attr.m_Weight) + "\r\n" +
                                    VCUtils.VolumeToString(attr.m_Volume) + "\r\n" +
                                    (attr.m_SellPrice).ToString("#,##0") +
#if PLANET_EXPLORERS
                                    " " + "Meat".ToLocalizationString() +
#endif
                                    "\r\n\r\n" +
                                    (attr.m_Attack).ToString("#,##0") + " /s\r\n" +
                                    (attr.m_Durability).ToString("#,##0") + "\r\n";
            }
            else if (attr.m_Type == ECreation.ArmorHead ||
                     attr.m_Type == ECreation.ArmorBody ||
                     attr.m_Type == ECreation.ArmorArmAndLeg ||
                     attr.m_Type == ECreation.ArmorHandAndFoot ||
                     attr.m_Type == ECreation.ArmorDecoration)
            {
                m_AttrNames.text = "Creation".ToLocalizationString() + ":\r\n" +
                                   "Weight".ToLocalizationString() + ":\r\n" +
                                   "Volume".ToLocalizationString() + ":\r\n" +
                                   "Sell Price".ToLocalizationString() + ":\r\n\r\n" +
                                   "Defense".ToLocalizationString() + ":\r\n" +
                                   "Durability".ToLocalizationString() + ":\r\n\r\n";

                m_AttrValues.text = "Object".ToLocalizationString() + "\r\n" +
                                    VCUtils.WeightToString(attr.m_Weight) + "\r\n" +
                                    VCUtils.VolumeToString(attr.m_Volume) + "\r\n" +
                                    (attr.m_SellPrice).ToString("#,##0") +
#if PLANET_EXPLORERS
                                    " " + "Meat".ToLocalizationString() +
#endif
                                    "\r\n\r\n" +
                                    (attr.m_Defense).ToString("#,##0") + "\r\n" +
                                    (attr.m_Durability).ToString("#,##0") + "\r\n";
            }
            else
            {
                m_AttrNames.text = "Creation".ToLocalizationString() + ":\r\n" +
                                   "Weight".ToLocalizationString() + ":\r\n" +
                                   "Volume".ToLocalizationString() + ":\r\n" +
                                   "Sell Price".ToLocalizationString() + ":\r\n";

                m_AttrValues.text = "[FF0000]???[-]\r\n" +
                                    VCUtils.WeightToString(attr.m_Weight) + "\r\n" +
                                    VCUtils.VolumeToString(attr.m_Volume) + "\r\n" +
                                    (attr.m_SellPrice).ToString("#,##0") +
        #if PLANET_EXPLORERS
                                    " " + "Meat".ToLocalizationString() +
        #endif
                                    "\r\n";
            }

            if (attr.m_Errors.Count > 0)
            {
                m_AttrNames.text += "\r\n[FF0000]" + "Errors".ToLocalizationString() + ":\r\n";
                foreach (string e in attr.m_Errors)
                {
                    m_AttrNames.text += ("> " + e.ToLocalizationString() + "\r\n");
                }
                m_AttrNames.text += "[-]";
            }
            if (attr.m_Warnings.Count > 0)
            {
                m_AttrNames.text += "\r\n[FFFF00]" + "Warnings".ToLocalizationString() + ":\r\n";
                foreach (string w in attr.m_Warnings)
                {
                    m_AttrNames.text += ("> " + w.ToLocalizationString() + "\r\n");
                }
                m_AttrNames.text += "[-]";
            }
            m_CostList.RefreshCostList();
            m_UITable.Reposition();
        }
        else            // attr == null
        {
            m_AttrNames.text  = "[FF0000]" + m_NonEditorError + "[-]";
            m_AttrValues.text = "";
            m_CostList.RefreshCostList();
            m_UITable.Reposition();
        }

        // Status
        if (m_IsEditor)
        {
            if (VCEditor.s_Scene.m_CreationAttr.m_Errors.Count > 0)
            {
                VCEStatusBar.ShowText("Your creation has some errors".ToLocalizationString(), Color.red, 10);
            }
            else if (VCEditor.s_Scene.m_CreationAttr.m_Warnings.Count > 0)
            {
                VCEStatusBar.ShowText("Your creation has some warnings".ToLocalizationString(), Color.yellow, 10);
            }

            if (attr.m_Weight > 0.0001f)
            {
                VCEditor.Instance.m_MassCenterTrans.localPosition = attr.m_CenterOfMass;
                VCEditor.Instance.m_MassCenterTrans.gameObject.SetActive(true);
            }
            else
            {
                VCEditor.Instance.m_MassCenterTrans.gameObject.SetActive(false);
            }

            VCIsoRemark remark = new VCIsoRemark();
            remark.m_Attribute = attr;
            VCEditor.s_Scene.m_IsoData.m_HeadInfo.Remarks = remark.xml;
        }
    }
Ejemplo n.º 26
0
    // Update is called once per frame
    protected void Update()
    {
        if (!VCEditor.DocumentOpen() ||
            VCEditor.SelectedVoxelType < 0)
        {
            m_Phase = EPhase.Free;
            m_GizmoCube.gameObject.SetActive(false);
            return;
        }

        float voxel_size = VCEditor.s_Scene.m_Setting.m_VoxelSize;

        m_GizmoCube.m_VoxelSize = voxel_size;

        ExtraAdjust();

        if (m_Phase == EPhase.Free)
        {
            if (!VCEInput.s_MouseOnUI)
            {
                // Cancel
                if (VCEInput.s_Cancel)
                {
                    ResetDrawing();
                    Cancel();
                }
                VCEMath.RayCastDrawTarget(VCEInput.s_PickRay, out m_Target, VCEMath.MC_ISO_VALUE);
                if (VCEditor.s_Scene.m_IsoData.IsPointIn(m_Target.cursor))
                {
                    m_GizmoCube.CubeSize           = IntVector3.One;
                    m_GizmoCube.transform.position = m_Target.cursor.ToVector3() * voxel_size;
                    m_GizmoCube.gameObject.SetActive(true);
                    if (Input.GetMouseButtonDown(0))
                    {
                        m_Begin = new IntVector3(m_Target.cursor);
                        m_End   = new IntVector3(m_Target.cursor);
                        m_Phase = EPhase.DragPlane;
                        VCEditor.Instance.m_UI.DisableFunctions();
                        VCEditor.s_ProtectLock0 = true;
                        VCEStatusBar.ShowText("Drag an area".ToLocalizationString(), 2);
                    }
                }
                else
                {
                    m_GizmoCube.gameObject.SetActive(false);
                }
            }
            else
            {
                m_GizmoCube.gameObject.SetActive(false);
            }
            VCEditor.Instance.m_NearVoxelIndicator.enabled = true;
        }
        else if (m_Phase == EPhase.DragPlane)
        {
            // Cancel
            if (VCEInput.s_Cancel)
            {
                ResetDrawing();
            }
            RaycastHit rch;
            if (VCEMath.RayCastCoordPlane(VCEInput.s_PickRay, ECoordPlane.XZ, m_Begin.y, out rch))
            {
                m_End = new IntVector3(Mathf.FloorToInt(rch.point.x), m_Begin.y, Mathf.FloorToInt(rch.point.z));
                VCEditor.s_Scene.m_IsoData.ClampPointI(m_End, m_Begin.x < 0.5f * VCEditor.s_Scene.m_IsoData.m_HeadInfo.xSize);
                m_PointBeforeAdjustHeight = rch.point;
                VCEditor.s_Scene.m_IsoData.ClampPointI(m_End, m_Begin.x < 0.5f * VCEditor.s_Scene.m_IsoData.m_HeadInfo.xSize);
                m_GizmoCube.CubeSize           = Size;
                m_GizmoCube.transform.position = Min.ToVector3() * voxel_size;
            }
            else
            {
                ResetDrawing();
            }
            if (Input.GetMouseButtonUp(0))
            {
                m_Phase = EPhase.AdjustHeight;
                VCEStatusBar.ShowText("Adjust height".ToLocalizationString(), 2);
            }
            VCEditor.Instance.m_NearVoxelIndicator.enabled = false;
        }
        else if (m_Phase == EPhase.AdjustHeight)
        {
            // Cancel
            if (VCEInput.s_Cancel)
            {
                ResetDrawing();
            }

            float height = m_PointBeforeAdjustHeight.y;
            VCEMath.RayAdjustHeight(VCEInput.s_PickRay, m_PointBeforeAdjustHeight, out height);
            m_End.y = Mathf.FloorToInt(height + 0.3f);

            VCEditor.s_Scene.m_IsoData.ClampPointI(m_End);
            m_GizmoCube.CubeSize           = Size;
            m_GizmoCube.transform.position = Min.ToVector3() * voxel_size;

            // Do the brush
            if (Input.GetMouseButtonDown(0))
            {
                m_Phase = EPhase.Drawing;
                Do();
                VCEStatusBar.ShowText("Done".ToLocalizationString(), 2);
            }
            VCEditor.Instance.m_NearVoxelIndicator.enabled = false;
        }
    }
Ejemplo n.º 27
0
 void OnDestroy()
 {
     s_Instance = null;
 }
Ejemplo n.º 28
0
    void Update()
    {
        // Common draw target
        VCEMath.RayCastDrawTarget(VCEInput.s_PickRay, out m_Target, 1, true);

        // Inspector
        if (VCEditor.s_Scene.m_IsoData.m_Voxels.Count > 0)
        {
            ShowMainInspector();
        }
        else
        {
            HideMainInspector();
        }

        // Cancel
        if (VCEInput.s_Cancel)
        {
#if CAN_CANCELALLMETHOD
            if (m_MethodExec == null)
            {
                m_SelectionMgr.ClearSelection();
            }
            else
            {
                m_MainInspector.GetComponent <VCEUISelectVoxelInspector>().CancelAllMethod();
            }
#else
            m_SelectionMgr.ClearSelection();
#endif
        }

        // Execute selection method
        if (m_MethodExec != null)
        {
            m_MethodExec.MainMethod();
            if (m_MethodExec.m_NeedUpdate)
            {
                m_SelectionMgr.RebuildSelectionBoxes();
                m_MethodExec.m_NeedUpdate = false;
            }
        }
        else
        {
            VCEditor.Instance.m_NearVoxelIndicator.enabled = false;
        }

        if (!m_MainInspector.activeInHierarchy)
        {
            m_MainInspector.GetComponent <VCEUISelectVoxelInspector>().Update();
        }

        if (m_SelectionMgr.m_Selection.Count > 0)
        {
            if (VCEInput.s_Shift && VCEInput.s_Left)
            {
                ExtrudeSelection(-1, 0, 0);
                VCEStatusBar.ShowText("Extrude left".ToLocalizationString(), 2);
            }
            if (VCEInput.s_Shift && VCEInput.s_Right)
            {
                ExtrudeSelection(1, 0, 0);
                VCEStatusBar.ShowText("Extrude right".ToLocalizationString(), 2);
            }
            if (VCEInput.s_Shift && VCEInput.s_Up)
            {
                ExtrudeSelection(0, 1, 0);
                VCEStatusBar.ShowText("Extrude up".ToLocalizationString(), 2);
            }
            if (VCEInput.s_Shift && VCEInput.s_Down)
            {
                ExtrudeSelection(0, -1, 0);
                VCEStatusBar.ShowText("Extrude down".ToLocalizationString(), 2);
            }
            if (VCEInput.s_Shift && VCEInput.s_Forward)
            {
                ExtrudeSelection(0, 0, 1);
                VCEStatusBar.ShowText("Extrude forward".ToLocalizationString(), 2);
            }
            if (VCEInput.s_Shift && VCEInput.s_Back)
            {
                ExtrudeSelection(0, 0, -1);
                VCEStatusBar.ShowText("Extrude back".ToLocalizationString(), 2);
            }
        }
        // Tips
        if (!Input.GetMouseButton(0) && VCEditor.s_Scene.m_IsoData.IsPointIn(m_Target.snapto))
        {
            tips_counter -= Time.deltaTime;
        }
    }
Ejemplo n.º 29
0
    public void TextureSelection()
    {
        if (!VCEditor.Instance.m_UI.m_MaterialTab.isChecked)
        {
            return;
        }
        if (VCEditor.SelectedVoxelType < 0)
        {
            return;
        }

        m_Action = new VCEAction();

        ulong oldmat_guid = VCEditor.s_Scene.m_IsoData.MaterialGUID(VCEditor.SelectedVoxelType);
        ulong newmat_guid = VCEditor.SelectedMaterial.m_Guid;

        if (oldmat_guid != newmat_guid)
        {
            VCEAlterMaterialMap modify = new VCEAlterMaterialMap(VCEditor.SelectedVoxelType, oldmat_guid, newmat_guid);
            m_Action.Modifies.Add(modify);
        }

        VCEditor.s_Mirror.CalcPrepare(VCEditor.s_Scene.m_Setting.m_VoxelSize);
        foreach (KeyValuePair <int, byte> kvp in m_SelectionMgr.m_Selection)
        {
            // Mirror
            if (VCEditor.s_Mirror.Enabled_Masked)
            {
                IntVector3 pos = VCIsoData.KeyToIPos(kvp.Key);
                VCEditor.s_Mirror.MirrorVoxel(pos);
                float strength = (float)(kvp.Value) / 255.0f;
                if (strength < 0.5f)
                {
                    continue;
                }
                for (int i = 0; i < VCEditor.s_Mirror.OutputCnt; ++i)
                {
                    if (VCEditor.s_Scene.m_IsoData.IsPointIn(VCEditor.s_Mirror.Output[i]))
                    {
                        int     voxel_pos = VCIsoData.IPosToKey(VCEditor.s_Mirror.Output[i]);
                        VCVoxel old_voxel = VCEditor.s_Scene.m_IsoData.GetVoxel(voxel_pos);
                        VCVoxel new_voxel = new VCVoxel(old_voxel.Volume, (byte)(VCEditor.SelectedVoxelType));
                        if (old_voxel != new_voxel)
                        {
                            VCEAlterVoxel modify = new VCEAlterVoxel(voxel_pos, old_voxel, new_voxel);
                            modify.Redo();
                            m_Action.Modifies.Add(modify);
                        }
                    }
                }
            }
            // No mirror
            else
            {
                float strength = (float)(kvp.Value) / 255.0f;
                if (strength < 0.5f)
                {
                    continue;
                }
                int     voxel_pos = kvp.Key;
                VCVoxel old_voxel = VCEditor.s_Scene.m_IsoData.GetVoxel(voxel_pos);
                VCVoxel new_voxel = new VCVoxel(old_voxel.Volume, (byte)(VCEditor.SelectedVoxelType));
                if (old_voxel != new_voxel)
                {
                    VCEAlterVoxel modify = new VCEAlterVoxel(voxel_pos, old_voxel, new_voxel);
                    m_Action.Modifies.Add(modify);
                }
            }
        }
        if (m_Action.Modifies.Count > 0)
        {
            m_Action.Do();
            VCEStatusBar.ShowText("Selected voxels have been textured".ToLocalizationString(), 2);
        }
    }
Ejemplo n.º 30
0
    public void ColorSelection(Color32 color, bool consider_strength = true, bool action_segment = false)
    {
        if (!VCEditor.Instance.m_UI.m_PaintTab.isChecked)
        {
            return;
        }

        if (!action_segment)
        {
            m_Action = new VCEAction();
        }

        bool modified = false;

        VCEUpdateColorSign sign_b = new VCEUpdateColorSign(false, true);

        m_Action.Modifies.Add(sign_b);

        VCEditor.s_Mirror.CalcPrepare(VCEditor.s_Scene.m_Setting.m_VoxelSize);
        foreach (SelBox sb in m_SelectionMgr.m_GL.m_Boxes)
        {
            float t = (float)(sb.m_Val) / 255.0f;
            byte  code;                 // This is a filter code, when color key was not on edge or vertex, their is no point to color this key.
            float x, y, z;
            for (x = sb.m_Box.xMin, code = 0; x <= sb.m_Box.xMax + 1.01f; x += 0.5f, code ^= 1)
            {
                for (y = sb.m_Box.yMin, code &= 1; y <= sb.m_Box.yMax + 1.01f; y += 0.5f, code ^= 2)
                {
                    if (code == 0 || code == 4)
                    {
                        continue;                               // code 0, 4, no point to color
                    }
                    for (z = sb.m_Box.zMin, code &= 3; z <= sb.m_Box.zMax + 1.01f; z += 0.5f, code ^= 4)
                    {
                        if (code == 1 || code == 2)
                        {
                            continue;                                   // code 1, 2, no point to color
                        }
                        // Mirror
                        if (VCEditor.s_Mirror.Enabled_Masked)
                        {
                            IntVector3 color_pos = VCIsoData.IPosToColorPos(new Vector3(x, y, z));
                            VCEditor.s_Mirror.MirrorColor(color_pos);

                            for (int i = 0; i < VCEditor.s_Mirror.OutputCnt; ++i)
                            {
                                if (VCEditor.s_Scene.m_IsoData.IsColorPosIn(VCEditor.s_Mirror.Output[i]))
                                {
                                    int     key       = VCIsoData.ColorPosToColorKey(VCEditor.s_Mirror.Output[i]);
                                    Color32 old_color = VCEditor.s_Scene.m_IsoData.GetColor(key);
                                    Color32 new_color = consider_strength ? Color32.Lerp(old_color, color, t) : color;
                                    if (old_color.r == new_color.r && old_color.g == new_color.g &&
                                        old_color.b == new_color.b && old_color.a == new_color.a)
                                    {
                                        continue;
                                    }
                                    VCEAlterColor modify = new VCEAlterColor(key, old_color, new_color);
                                    modify.Redo();
                                    m_Action.Modifies.Add(modify);
                                    modified = true;
                                }
                            }
                        }
                        // No mirror
                        else
                        {
                            int     key       = VCIsoData.IPosToColorKey(new Vector3(x, y, z));
                            Color32 old_color = VCEditor.s_Scene.m_IsoData.GetColor(key);
                            Color32 new_color = consider_strength ? Color32.Lerp(old_color, color, t) : color;
                            if (old_color.r == new_color.r && old_color.g == new_color.g &&
                                old_color.b == new_color.b && old_color.a == new_color.a)
                            {
                                continue;
                            }
                            VCEAlterColor modify = new VCEAlterColor(key, old_color, new_color);
                            m_Action.Modifies.Add(modify);
                            modified = true;
                        }
                    }
                }
            }
        }

        VCEUpdateColorSign sign_f = new VCEUpdateColorSign(true, false);

        m_Action.Modifies.Add(sign_f);
        if (action_segment && !modified)
        {
            m_Action.Modifies.RemoveRange(m_Action.Modifies.Count - 2, 2);
        }
        if (!action_segment && m_Action.Modifies.Count > 2)
        {
            m_Action.Do();
            if (color.r == VCIsoData.BLANK_COLOR.r &&
                color.g == VCIsoData.BLANK_COLOR.g &&
                color.b == VCIsoData.BLANK_COLOR.b &&
                color.a == VCIsoData.BLANK_COLOR.a)
            {
                VCEStatusBar.ShowText("Selection color have been erased".ToLocalizationString(), 2);
            }
            else
            {
                VCEStatusBar.ShowText("Selected voxels have been painted".ToLocalizationString(), 2);
            }
        }
    }