Exemplo n.º 1
0
    // Use this for initialization
    void Start()
    {
        Mesh mesh = new Mesh();

        float xLeft  = LeftVertex.transform.position.x;
        float xRight = RightVertex.transform.position.x;

        // Create vertices
        Vector3[] vertices = new Vector3[4];
        vertices[0]   = new Vector3(xLeft, BottomEdge.CalculateYCoord(xLeft), 1);
        vertices[1]   = new Vector3(xRight, BottomEdge.CalculateYCoord(xRight), 1);
        vertices[2]   = new Vector3(xLeft, TopEdge.CalculateYCoord(xLeft), 1);
        vertices[3]   = new Vector3(xRight, TopEdge.CalculateYCoord(xRight), 1);
        mesh.vertices = vertices;

        // Create triangles
        int[] triangles = { 0, 2, 1, 2, 3, 1 };
        mesh.triangles = triangles;

        // Create normals
        Vector3[] normals = new Vector3[4];
        normals[0]   = -Vector3.forward;
        normals[1]   = -Vector3.forward;
        normals[2]   = -Vector3.forward;
        normals[3]   = -Vector3.forward;
        mesh.normals = normals;

        // Create UVs
        Vector2[] uv = new Vector2[4];
        uv[0]   = new Vector2(0, 0);
        uv[1]   = new Vector2(1, 0);
        uv[2]   = new Vector2(0, 1);
        uv[3]   = new Vector2(1, 1);
        mesh.uv = uv;

        // Assign collider
        GetComponent <MeshCollider>().sharedMesh = mesh;

        // Assign mesh
        GetComponent <MeshFilter>().mesh = mesh;

        // Create material
        GetComponent <MeshRenderer>().material = new Material(Shader.Find("Unlit/Transparent"));

        // Random color
        color = Random.ColorHSV(0, 1, 0.3f, 0.3f, 1, 1);
    }
Exemplo n.º 2
0
 internal RelativeLayoutResults(RectTransform transform, RelativeLayoutParams other)
 {
     Transform = transform ?? throw new ArgumentNullException(nameof(transform));
     if (other != null)
     {
         BottomEdge.CopyFrom(other.BottomEdge);
         TopEdge.CopyFrom(other.TopEdge);
         RightEdge.CopyFrom(other.RightEdge);
         LeftEdge.CopyFrom(other.LeftEdge);
         Insets       = other.Insets ?? ZERO;
         OverrideSize = other.OverrideSize;
     }
     else
     {
         Insets = ZERO;
     }
     BottomParams   = LeftParams = TopParams = RightParams = null;
     PreferredWidth = PreferredHeight = 0.0f;
     UseSizeDeltaX  = UseSizeDeltaY = false;
 }
Exemplo n.º 3
0
 /*_________________________________________________________Обработка_событий_______________________________________________________*/
 #region Event handles
 private void JuliaEditor_Load(object sender, EventArgs e)
 {
     LeftEdgeEdit.Text         = LeftEdge.ToString();
     RightEdgeEdit.Text        = RightEdge.ToString();
     TopEdgeEdit.Text          = TopEdge.ToString();
     BottomEdgeEdit.Text       = BottomEdge.ToString();
     RealPartEdit.Text         = RealPart.ToString();
     ImaginePartEdit.Text      = ImaginePart.ToString();
     LeftEdgeEdit.KeyPress    += FormEventHandlers.OnlyNumeric;
     RightEdgeEdit.KeyPress   += FormEventHandlers.OnlyNumeric;
     TopEdgeEdit.KeyPress     += FormEventHandlers.OnlyNumeric;
     BottomEdgeEdit.KeyPress  += FormEventHandlers.OnlyNumeric;
     RealPartEdit.KeyPress    += FormEventHandlers.OnlyNumeric;
     ImaginePartEdit.KeyPress += FormEventHandlers.OnlyNumeric;
     EditDescriptor.SetToolTip(LeftEdgeLabel, FractalGlobalDescriptions.LeftEdgeOf2DFractal);
     EditDescriptor.SetToolTip(LeftEdgeEdit, "Здесь необходимо вводить левую границу двухмерного фрактала джулии (десятиричное представления числа).\n" + FractalGlobalDescriptions.LeftEdgeOf2DFractal);
     EditDescriptor.SetToolTip(RightEdgeLabel, FractalGlobalDescriptions.RightEdgeOf2DFractal);
     EditDescriptor.SetToolTip(RightEdgeEdit, "Здесь необходимо вводить правую границу двухмерного фрактала джулии (десятиричной представления числа, в качестве разделителей на дроную часть используйте \",\" или \".\").\n" + FractalGlobalDescriptions.RightEdgeOf2DFractal);
     GlobalTemplates.SetTemplate(MainPanelOfJuliaEditor, "Шрифт окна для ввода фрактала джулии");
 }
Exemplo n.º 4
0
        protected override bool Initialize()
        {
            var rb = RigidBody?.GetInitialized <RigidBody>()?.Native;

            if (rb == null)
            {
                Debug.LogWarning("Unable to find RigidBody component for DeformableTerrainShovel - shovel instance ignored.", this);
                return(false);
            }

            if (!TopEdge.Valid)
            {
                Debug.LogWarning("Unable to create shovel - invalid Top Edge.", this);
            }
            if (!CuttingEdge.Valid)
            {
                Debug.LogWarning("Unable to create shovel - invalid Cutting Edge.", this);
            }
            if (!CuttingDirection.Valid)
            {
                Debug.LogWarning("Unable to create shovel - invalid Cutting Direction.", this);
            }

            if (!HasValidateEdges())
            {
                return(false);
            }

            Native = new agxTerrain.Shovel(rb,
                                           TopEdge.ToNativeEdge(gameObject),
                                           CuttingEdge.ToNativeEdge(gameObject),
                                           CuttingDirection.CalculateLocalDirection(gameObject).ToHandedVec3());

            if (Settings == null)
            {
                Settings      = ScriptAsset.Create <DeformableTerrainShovelSettings>();
                Settings.name = "[Temporary]Shovel Settings";
            }

            return(true);
        }