예제 #1
0
        public IMeshGenerator GetGenerator(MeshGeneratorType type)
        {
            switch (type)
            {
            case MeshGeneratorType.SimpleGrid:
                if (m_SimpleGrid == null)
                {
                    m_SimpleGrid = new SimpleGridMesh();
                }
                return(m_SimpleGrid);

            case MeshGeneratorType.LodMesh:
                if (m_LodMesh == null)
                {
                    m_LodMesh = new LodMesh();
                }
                return(m_LodMesh);

            case MeshGeneratorType.QuadTreeMesh:
                if (m_QuadTreeMesh == null)
                {
                    m_QuadTreeMesh = new QuadTreeMesh();
                }
                return(m_QuadTreeMesh);

            case MeshGeneratorType.ModelFile:
            default:
                if (m_ModelMesh == null)
                {
                    m_ModelMesh = new ModelMesh();
                }
                return(m_ModelMesh);
            }
        }
예제 #2
0
        public void SetSize(MeshGeneratorType type, Vector2 size)
        {
            IMeshGenerator generator = GetGenerator(type);

            if (generator != null)
            {
                generator.SetSize(size);
            }
        }
예제 #3
0
        public Vector2 GetSize(MeshGeneratorType type)
        {
            IMeshGenerator generator = GetGenerator(type);

            if (generator != null)
            {
                return(generator.GetSize());
            }
            return(default(Vector2));
        }
        void LoadDefaultValues()
        {
            var tmpRope = new RopeGenerator(null, null, null);

            _radius            = tmpRope.Radius;
            _length            = tmpRope.Length;
            _massOfBone        = tmpRope.MassOfBone;
            _boneCount         = tmpRope.BoneCount;
            _jointAngleLimit   = tmpRope.JointAngleLimit;
            _restrictFirstBone = tmpRope.RestrictFirstBone;

            _meshGeneratorType = MeshGeneratorType.Cylinder;
        }
예제 #5
0
    private void DrawMeshSetting(Rect rect)
    {
        bool guienable = GUI.enabled;

        GUI.enabled = guienable && m_Painter.paintVertexChannel == UnlitWaterPainter.Channel.None;
        GUI.BeginGroup(new Rect(rect.x + 5, rect.y + 5, rect.width - 10, rect.height - 10));
        EditorGUI.BeginChangeCheck();
        m_TargetGameObject =
            EditorGUI.ObjectField(new Rect(0, 0, rect.width - 10, 17), "载体目标", m_TargetGameObject, typeof(GameObject), true) as
            GameObject;
        m_MeshGeneratorType = (MeshGeneratorType)EditorGUI.EnumPopup(new Rect(0, 20, rect.width - 10, 17), "Mesh生成器类型", m_MeshGeneratorType);
        if (EditorGUI.EndChangeCheck())
        {
            CheckTargetCorrectness();
            Vector2 size = default(Vector2);
            UnlitWaterUtils.CalculateAreaInfo(m_TargetGameObject, m_MeshGeneratorType != MeshGeneratorType.ModelFile, ref m_LocalCenter, ref size);
            m_MeshGeneratorFactory.SetSize(m_MeshGeneratorType, size);
        }


        GUI.Box(new Rect(3, 45, rect.width - 16, rect.height - 140), "", GUI.skin.FindStyle("WindowBackground"));

        GUILayout.BeginArea(new Rect(5, 48, rect.width - 20, rect.height - 146));

        if (meshGenerator != null)
        {
            meshGenerator.DrawGUI();
        }
        GUILayout.EndArea();


        if (m_TargetErrorDef != TargetErrorDef.None)
        {
            DrawTargetErrorHelpBox(new Rect(0, rect.height - 90, rect.width - 10, 80));
        }
        GUI.EndGroup();
    }
        void OnGUI()
        {
            Handles.BeginGUI();
            GUILayout.BeginVertical("box");

            _parrent  = (GameObject)EditorGUILayout.ObjectField("Parrent", _parrent, typeof(GameObject), true);
            _material = (Material)EditorGUILayout.ObjectField("Material", _material, typeof(Material), true);

            _radius            = EditorGUILayout.FloatField("Radius", _radius);
            _length            = EditorGUILayout.FloatField("Length", _length);
            _massOfBone        = EditorGUILayout.FloatField("Mass of bone", _massOfBone);
            _boneCount         = EditorGUILayout.IntField("Bone Count", _boneCount);
            _jointAngleLimit   = EditorGUILayout.IntField("Joint angle limit", _jointAngleLimit);
            _restrictFirstBone = EditorGUILayout.Toggle("Restrict first bone", _restrictFirstBone);

            GUILayout.Label("Mesh type:");
            _meshGeneratorType = (MeshGeneratorType)EditorGUILayout.EnumPopup(_meshGeneratorType);

            ++EditorGUI.indentLevel;
            switch (_meshGeneratorType)
            {
            case MeshGeneratorType.Cylinder:
                DrawPanelMeshGeneratorCylinder();
                break;

            default: throw new NotSupportedException();
            }
            --EditorGUI.indentLevel;

            if (GUILayout.Button("Make Rope"))
            {
                MakeRope();
            }

            GUILayout.EndVertical();
            Handles.EndGUI();
        }
예제 #7
0
        void OnGUI()
        {
            Handles.BeginGUI();
            GUILayout.BeginVertical("box");

            _parrent = (GameObject)EditorGUILayout.ObjectField("Parrent", _parrent, typeof(GameObject), true);

            _colliderRadius          = EditorGUILayout.FloatField("Collider radius", _colliderRadius);
            _massOfBone              = EditorGUILayout.FloatField("Mass of bone", _massOfBone);
            _boneCount               = EditorGUILayout.IntField("Bone Count", _boneCount);
            _jointAngleLimit         = EditorGUILayout.IntField("Joint angle limit", _jointAngleLimit);
            _rotateAngleLimit        = EditorGUILayout.IntField("Rotate angle limit", _rotateAngleLimit);
            _angularDriveSpringStart = EditorGUILayout.FloatField("Angular drive spring start", _angularDriveSpringStart);
            _angularDriveSpringStop  = EditorGUILayout.FloatField("Angular drive spring stop", _angularDriveSpringStop);
            _restrictFirstBone       = EditorGUILayout.Toggle("Restrict first bone", _restrictFirstBone);
            _optimizeMesh            = EditorGUILayout.Toggle("Optimize mesh", _optimizeMesh);
            _saveMesh = EditorGUILayout.Toggle("Save mesh", _saveMesh);

            GUILayout.Label("Length type:");
            _RangeType = (RangeType)EditorGUILayout.EnumPopup(_RangeType);
            ++EditorGUI.indentLevel;

            switch (_RangeType)
            {
            case RangeType.Length:
                _length = EditorGUILayout.FloatField("Length", _length);
                break;

            case RangeType.Interval:
                float interval = _length / _boneCount;
                interval = EditorGUILayout.FloatField("Interval", interval);
                _length  = interval * _boneCount;
                break;

            default: throw new NotSupportedException();
            }
            --EditorGUI.indentLevel;


            GUILayout.Label("Mesh type:");
            _meshGeneratorType = (MeshGeneratorType)EditorGUILayout.EnumPopup(_meshGeneratorType);

            ++EditorGUI.indentLevel;
            switch (_meshGeneratorType)
            {
            case MeshGeneratorType.Cylinder:
                DrawPanelMeshGeneratorCylinder();
                break;

            case MeshGeneratorType.Chain:
                DrawPanelMeshGeneratorChain();
                break;

            default: throw new NotSupportedException();
            }
            --EditorGUI.indentLevel;

            if (GUILayout.Button("Make Rope"))
            {
                MakeRope();
            }

            GUILayout.EndVertical();
            Handles.EndGUI();
        }