Esempio n. 1
0
    public override void UpdateEntity(bool for_editor)
    {
        if (for_editor)
        {
            VCEComponentTool tool = m_Entity.GetComponent <VCEComponentTool>();
            tool.m_Data = this;
        }
        m_Rotation = VCEMath.NormalizeEulerAngle(m_Rotation);
        m_Entity.transform.localPosition    = m_Position;
        m_Entity.transform.localEulerAngles = m_Rotation;
        m_Entity.transform.localScale       = m_Scale;
        VCDecalHandler dh = m_Entity.GetComponent <VCDecalHandler>();

        if (for_editor)
        {
            dh.m_Guid       = m_Guid;
            dh.m_Iso        = null;
            dh.m_AssetIndex = -1;
        }
        else
        {
            dh.m_Guid       = 0;
            dh.m_Iso        = m_CurrIso;
            dh.m_AssetIndex = m_AssetIndex;
        }
        dh.m_Size        = m_Size;
        dh.m_Depth       = m_Depth;
        dh.m_Mirrored    = m_Mirrored;
        dh.m_ShaderIndex = m_ShaderIndex;
        dh.m_Color       = m_Color;
    }
    public override VCComponentData Get()
    {
        VCDecalData data = m_Data.Copy() as VCDecalData;

        data.m_Position = m_PositionInput.Vector;
        data.m_Rotation = VCEMath.NormalizeEulerAngle(m_RotationInput.Vector);
        Vector3 scale = m_ScaleInput.Vector;

        data.m_Size     = scale.x;
        data.m_Depth    = scale.z;
        scale.y         = scale.x;
        data.m_Mirrored = m_MirroredCheck.isChecked;
        data.m_Color    = m_ColorPicker.FinalColor;
        if (m_Shader0Check.isChecked)
        {
            data.m_ShaderIndex = 0;
        }
        else if (m_Shader1Check.isChecked)
        {
            data.m_ShaderIndex = 1;
        }
        else
        {
            data.m_ShaderIndex = 0;
        }

        data.Validate();
        m_PositionInput.Vector = data.m_Position;
        m_RotationInput.Vector = data.m_Rotation;
        m_ScaleInput.Vector    = scale;

        return(data);
    }
Esempio n. 3
0
    public override void UpdateEntity(bool for_editor)
    {
        if (for_editor)
        {
            VCEComponentTool tool = m_Entity.GetComponent <VCEComponentTool>();
            tool.m_Data = this;
        }
        m_Rotation = VCEMath.NormalizeEulerAngle(m_Rotation);
        m_Entity.transform.localPosition    = m_Position;
        m_Entity.transform.localEulerAngles = m_Rotation;
        m_Entity.transform.localScale       = m_Scale;

        VCPSimpleLight func = m_Entity.GetComponent <VCPSimpleLight>();

        if (func != null)
        {
            func.color = m_Color;
        }

        Renderer[] rs = m_Entity.GetComponentsInChildren <Renderer>(true);
        foreach (Renderer r in rs)
        {
            if (r is TrailRenderer)
            {
                r.enabled = true;
            }
            else if (r is ParticleRenderer)
            {
                r.enabled = true;
            }
            else if (r is ParticleSystemRenderer)
            {
                r.enabled = true;
            }
            else if (r is LineRenderer)
            {
                r.enabled = true;
            }
            else if (r is SpriteRenderer)
            {
                r.enabled = true;
            }
            else
            {
                r.enabled = m_Visible;
            }
        }
    }
    public override VCComponentData Get()
    {
        VCFixedHandPartData data = m_Data.Copy() as VCFixedHandPartData;

        data.m_Position = m_PositionInput.Vector;
        data.m_Rotation = VCEMath.NormalizeEulerAngle(m_RotationInput.Vector);
        data.m_Visible  = m_VisibleCheck ? m_VisibleCheck.isChecked : true;
        data.m_LeftHand = m_Phase0Check.isChecked;
        data.Validate();
        m_PositionInput.Vector = data.m_Position;
        m_RotationInput.Vector = data.m_Rotation;
        if (m_VisibleCheck)
        {
            m_VisibleCheck.isChecked = data.m_Visible;
        }

        return(data);
    }
    public override VCComponentData Get()
    {
        VCGeneralPartData data = m_Data.Copy() as VCGeneralPartData;

        data.m_Position = m_PositionInput.Vector;
        data.m_Rotation = VCEMath.NormalizeEulerAngle(m_RotationInput.Vector);
        data.m_Visible  = m_VisibleCheck ? m_VisibleCheck.isChecked : true;
        data.Validate();
        data.m_ExtendData      = VCEditor.Instance.m_UI.bonePanel.ArmorPartIndex;
        m_PositionInput.Vector = data.m_Position;
        m_RotationInput.Vector = data.m_Rotation;
        if (m_VisibleCheck)
        {
            m_VisibleCheck.isChecked = data.m_Visible;
        }
        m_ArmorPartIndex = data.m_ExtendData;

        return(data);
    }
Esempio n. 6
0
    public override VCComponentData Get()
    {
        VCObjectLightData data = m_Data.Copy() as VCObjectLightData;

        data.m_Position = m_PositionInput.Vector;
        data.m_Rotation = VCEMath.NormalizeEulerAngle(m_RotationInput.Vector);
        data.m_Scale    = m_ScaleInput.Vector;
        data.m_Color    = m_ColorPicker.FinalColor;
        data.m_Visible  = m_VisibleCheck.isChecked;

        data.Validate();
        m_PositionInput.Vector   = data.m_Position;
        m_RotationInput.Vector   = data.m_Rotation;
        m_ScaleInput.Vector      = data.m_Scale;
        m_ColorPicker.FinalColor = data.m_Color;
        m_VisibleCheck.isChecked = data.m_Visible;

        return(data);
    }
    public override VCComponentData Get()
    {
        VCObjectPivotData data = m_Data.Copy() as VCObjectPivotData;

        data.m_Position = m_PositionInput.Vector;
        data.m_Rotation = VCEMath.NormalizeEulerAngle(m_RotationInput.Vector);
        data.m_Scale    = m_ScaleInput.Vector;
        data.m_Visible  = m_VisibleCheck.isChecked;
        int ang = Float01ToIntAngle(m_AnlgeSlider.sliderValue);

        data.m_PivotAng = ang;

        data.Validate();
        m_PositionInput.Vector   = data.m_Position;
        m_RotationInput.Vector   = data.m_Rotation;
        m_ScaleInput.Vector      = data.m_Scale;
        m_VisibleCheck.isChecked = data.m_Visible;
        ang = data.m_PivotAng;
        m_AnlgeLable.text         = ang.ToString();
        m_AnlgeSlider.sliderValue = Convert.ToSingle(ang) / 720 + 0.5f;

        return(data);
    }
    private void MirrorComponentOnce(int mirror)
    {
        for (int i = 0; i < OutputCnt; ++i)
        {
            VCComponentData real  = ComponentOutput[i];
            VCComponentData image = ComponentOutput[i].Copy();
            ComponentOutput[i + OutputCnt] = image;
            image.m_Position.x             = ((mirror & 1) > 0)  ?  (2.0f * m_WorldPosX - real.m_Position.x)  :  (real.m_Position.x);
            image.m_Position.y             = ((mirror & 2) > 0)  ?  (2.0f * m_WorldPosY - real.m_Position.y)  :  (real.m_Position.y);
            image.m_Position.z             = ((mirror & 4) > 0)  ?  (2.0f * m_WorldPosZ - real.m_Position.z)  :  (real.m_Position.z);

            bool xsym = true;
            if (image is VCPartData)
            {
                xsym = (VCConfig.s_Parts[image.m_ComponentId].m_Symmetric == 1);
            }
            if (image is VCDecalData)
            {
                xsym = true;
            }

            if (xsym)
            {
                if ((mirror & 1) > 0)
                {
                    //image.m_Rotation.x = image.m_Rotation.x;
                    image.m_Rotation.y = -image.m_Rotation.y;
                    image.m_Rotation.z = -image.m_Rotation.z;
                    if (image is IVCMultiphaseComponentData)
                    {
                        (image as IVCMultiphaseComponentData).InversePhase();
                    }
                }
                if ((mirror & 2) > 0)
                {
                    image.m_Rotation.x = -image.m_Rotation.x;
                    //image.m_Rotation.y = image.m_Rotation.y;
                    image.m_Rotation.z = 180f - image.m_Rotation.z;
                    if (image is IVCMultiphaseComponentData)
                    {
                        (image as IVCMultiphaseComponentData).InversePhase();
                    }
                }
                if ((mirror & 4) > 0)
                {
                    //image.m_Rotation.x = image.m_Rotation.x;
                    image.m_Rotation.y = 180f - image.m_Rotation.y;
                    image.m_Rotation.z = -image.m_Rotation.z;
                    if (image is IVCMultiphaseComponentData)
                    {
                        (image as IVCMultiphaseComponentData).InversePhase();
                    }
                }
            }
            else
            {
                if ((mirror & 1) > 0)
                {
                    if (image is IVCMultiphaseComponentData)
                    {
                        (image as IVCMultiphaseComponentData).InversePhase();
                    }
                }
            }

            image.m_Rotation = VCEMath.NormalizeEulerAngle(image.m_Rotation);
        }
        OutputCnt = OutputCnt << 1;
    }
Esempio n. 9
0
    protected override void Do()
    {
        if (VCEditor.SelectedDecalGUID == 0)
        {
            return;
        }
        if (VCEditor.SelectedDecalIndex < 0)
        {
            return;
        }
        if (VCEditor.SelectedDecal == null)
        {
            return;
        }
        m_Action = new VCEAction();

        VCDecalData dcldata = VCComponentData.CreateDecal() as VCDecalData;

        if (dcldata != null)
        {
            dcldata.m_ComponentId = VCDecalData.s_ComponentId;
            dcldata.m_Type        = EVCComponent.cpDecal;
            dcldata.m_Position    = m_DecalInst.transform.localPosition;
            dcldata.m_Rotation    = VCEMath.NormalizeEulerAngle(m_DecalInst.transform.localEulerAngles);
            dcldata.m_Scale       = Vector3.one;
            dcldata.m_Visible     = true;
            dcldata.m_CurrIso     = VCEditor.s_Scene.m_IsoData;
            dcldata.m_Guid        = VCEditor.SelectedDecalGUID;
            dcldata.m_AssetIndex  = VCEditor.SelectedDecalIndex;
            dcldata.m_Size        = m_DecalInst.m_Size;
            dcldata.m_Depth       = m_DecalInst.m_Depth;
            dcldata.m_Mirrored    = m_DecalInst.m_Mirrored;
            dcldata.m_ShaderIndex = m_DecalInst.m_ShaderIndex;
            dcldata.m_Color       = m_DecalInst.m_Color;
            dcldata.Validate();

            ulong olddcl_guid = VCEditor.s_Scene.m_IsoData.DecalGUID(VCEditor.SelectedDecalIndex);
            ulong newdcl_guid = VCEditor.SelectedDecalGUID;
            if (olddcl_guid != newdcl_guid)
            {
                VCEAlterDecalMap modify = new VCEAlterDecalMap(VCEditor.SelectedDecalIndex, olddcl_guid, newdcl_guid);
                modify.Redo();
                m_Action.Modifies.Add(modify);
            }

            VCEditor.s_Mirror.CalcPrepare(VCEditor.s_Scene.m_Setting.m_VoxelSize);
            // Mirror
            if (VCEditor.s_Mirror.Enabled_Masked)
            {
                VCEditor.s_Mirror.MirrorComponent(dcldata);

                for (int i = VCEditor.s_Mirror.OutputCnt - 1; i >= 0; --i)
                {
                    VCComponentData image = VCEditor.s_Mirror.ComponentOutput[i];
                    if (VCEditor.s_Scene.m_IsoData.IsComponentIn(image.m_Position))
                    {
                        VCEAddComponent modify = new VCEAddComponent(VCEditor.s_Scene.m_IsoData.m_Components.Count, image);
                        modify.Redo();
                        m_Action.Modifies.Add(modify);
                    }
                }
            }
            // No mirror
            else
            {
                VCEAddComponent modify = new VCEAddComponent(VCEditor.s_Scene.m_IsoData.m_Components.Count, dcldata);
                modify.Redo();
                m_Action.Modifies.Add(modify);
            }
            m_Action.Register();
        }
        else
        {
            Debug.LogWarning("Decal data create failed");
        }
    }
    void OnRotating(Vector3 axis, float angle)
    {
        float hvs = VCEditor.s_Scene.m_Setting.m_VoxelSize * 0.5f;

        VCEditor.s_Mirror.CalcPrepare(hvs * 2);
        foreach (SelectInfo si in m_Selection)
        {
            Vector3 cached_rot = si.m_Component.transform.eulerAngles;
            si.m_Component.transform.eulerAngles = si.m_OldRotation;
            si.m_Component.transform.Rotate(axis, angle, Space.World);
            si.m_DragRotation = si.m_Component.transform.eulerAngles;
            si.m_DragRotation = VCEMath.NormalizeEulerAngle(si.m_DragRotation);
            si.m_NewRotation  = si.m_DragRotation;
            si.m_Component.transform.eulerAngles = cached_rot;

            Vector3 tmp_rot = si.m_Component.m_Data.m_Rotation;
            si.m_Component.m_Data.m_Rotation = si.m_NewRotation;
            si.m_Component.m_Data.Validate();
            if (si.m_Component.m_Data.m_Rotation != si.m_NewRotation)
            {
                si.m_NewRotation = cached_rot;
                si.m_Component.m_Data.m_Rotation = si.m_NewRotation;
                si.m_Component.m_Data.Validate();
            }
            si.m_NewRotation = si.m_Component.transform.eulerAngles = si.m_Component.m_Data.m_Rotation;

            if (m_DataInspector != null)
            {
                m_DataInspector.GetComponent <VCEUIComponentInspector>().Set(si.m_Component.m_Data);
            }

            si.m_Component.m_Data.m_Rotation = tmp_rot;

            // Mirror
            if (VCEditor.s_Mirror.Enabled_Masked)
            {
                Vector3[] old_rots = new Vector3[8];
                VCEditor.s_Mirror.MirrorComponent(si.m_Component.m_Data);
                for (int i = 0; i < VCEditor.s_Mirror.OutputCnt; ++i)
                {
                    old_rots[i] = VCEditor.s_Mirror.ComponentOutput[i].m_Rotation;
                }

                VCComponentData tmpdata = si.m_Component.m_Data.Copy();
                tmpdata.m_Rotation = si.m_NewRotation;
                VCEditor.s_Mirror.MirrorComponent(tmpdata);

                for (int i = 1; i < VCEditor.s_Mirror.OutputCnt; ++i)
                {
                    VCComponentData        image = VCEditor.s_Mirror.ComponentOutput[i];
                    List <VCComponentData> edits = VCEditor.s_Scene.m_IsoData.FindComponentsAtPos(image.m_Position, image.m_ComponentId);
                    foreach (VCComponentData iter in edits)
                    {
                        if (!VCEMath.IsEqualRotation(iter.m_Rotation, old_rots[i]))
                        {
                            continue;
                        }
                        if (iter.m_Scale != image.m_Scale)
                        {
                            continue;
                        }
                        if (iter.m_Visible != image.m_Visible)
                        {
                            continue;
                        }
                        if (image is IVCMultiphaseComponentData && iter is IVCMultiphaseComponentData)
                        {
                            if ((image as IVCMultiphaseComponentData).Phase != (iter as IVCMultiphaseComponentData).Phase)
                            {
                                continue;
                            }
                        }
                        if (m_Selection.Find(it => it.m_Component.m_Data == iter) == null)
                        {
                            iter.m_Entity.transform.eulerAngles = image.m_Rotation;
                        }
                    }
                }
            }
            // End 'mirror'
        }
    }