/// Returns the desired size of the stripe for the specified node of the curve. The size is determined from
    /// the settings of the curve textures used in the segment.
    private float GetNodeStripeSize(int nodeIndex)
    {
        e2dCurveTexture curveTexture = CurveTextures[TerrainCurve[nodeIndex].texture];
        float           size         = curveTexture.size.y;

        return(size);
    }
 /// Copy constructor.
 public e2dCurveTexture(e2dCurveTexture other)
 {
     texture       = other.texture;
     size          = other.size;
     fixedAngle    = other.fixedAngle;
     fadeThreshold = other.fadeThreshold;
 }
Esempio n. 3
0
 /// Copy constructor.
 public e2dCurveTexture(e2dCurveTexture other)
 {
     texture = other.texture;
     size = other.size;
     fixedAngle = other.fixedAngle;
     fadeThreshold = other.fadeThreshold;
 }
Esempio n. 4
0
    /// Tool for texturing the terrain surface using a brush.
    private void DrawCurveTextureTool()
    {
        DrawBrush(false, false);

        DrawCurveTextureSelector();

        bool rebuildMaterial = false;
        bool rebuildMesh     = false;

        e2dCurveTexture selectedTexture = new e2dCurveTexture(Terrain.CurveTextures[SelectedTexture]);

        // texture
        EditorGUILayout.BeginHorizontal(e2dStyles.TextureField);
        GUI.changed = false;
        EditorGUILayout.PrefixLabel(e2dStrings.LABEL_TEXTURE);
        selectedTexture.texture = (Texture)EditorGUILayout.ObjectField(selectedTexture.texture, typeof(Texture), !EditorUtility.IsPersistent(target));
        GUILayoutUtility.GetRect(70, 0, GUI.skin.label);
        if (GUI.changed)
        {
            rebuildMaterial = true;
        }
        EditorGUILayout.EndHorizontal();

        // size
        GUI.changed            = false;
        selectedTexture.size.x = EditorGUILayout.Slider(e2dStrings.LABEL_CURVE_TEXTURE_WIDTH, selectedTexture.size.x, e2dConstants.TEXTURE_WIDTH_MIN, e2dConstants.TEXTURE_WIDTH_MAX);
        selectedTexture.size.y = EditorGUILayout.Slider(e2dStrings.LABEL_CURVE_TEXTURE_HEIGHT, selectedTexture.size.y, e2dConstants.TEXTURE_HEIGHT_MIN, e2dConstants.TEXTURE_HEIGHT_MAX);
        if (GUI.changed)
        {
            rebuildMesh = rebuildMaterial = true;
        }

        // fade
        GUI.changed = false;
        selectedTexture.fadeThreshold = EditorGUILayout.Slider(e2dStrings.LABEL_CURVE_TEXTURE_FADE_THRESHOLD, selectedTexture.fadeThreshold, 0, 1);
        if (GUI.changed)
        {
            rebuildMaterial = true;
        }

        // fixed angle
        GUI.changed = false;
        selectedTexture.fixedAngle = EditorGUILayout.Toggle(e2dStrings.LABEL_CURVE_TEXTURE_FIXED_ANGLE, selectedTexture.fixedAngle);
        if (GUI.changed)
        {
            rebuildMaterial = true;
        }

        // update the structure
        if (rebuildMaterial || rebuildMesh)
        {
            Undo.RegisterUndo(Terrain, e2dStrings.UNDO_CURVE_TEXTURE);
            Terrain.CurveTextures[SelectedTexture] = selectedTexture;
        }

        if (rebuildMaterial)
        {
            Terrain.CurveMesh.RebuildMaterial();
            EditorUtility.SetDirty(Terrain);
        }
        if (rebuildMesh)
        {
            Terrain.CurveMesh.RebuildMesh();
            EditorUtility.SetDirty(Terrain);
        }

        if (e2dUtils.DEBUG_CONTROL_TEXTURES)
        {
            DrawCurveControlTextures();
        }
    }
Esempio n. 5
0
 /// Returns the default texture used when no other is defined by the user.
 public e2dCurveTexture GetDefaultCurveTexture()
 {
     e2dCurveTexture result = new e2dCurveTexture((Texture)Resources.Load("defaultCurveTexture", typeof(Texture)));
     return result;
 }
Esempio n. 6
0
    /// Tool for texturing the terrain surface using a brush.
    private void DrawCurveTextureTool()
    {
        DrawBrush(false, false);

        DrawCurveTextureSelector();

        bool rebuildMaterial = false;
        bool rebuildMesh = false;

        e2dCurveTexture selectedTexture = new e2dCurveTexture(Terrain.CurveTextures[SelectedTexture]);

        // texture
        EditorGUILayout.BeginHorizontal(e2dStyles.TextureField);
        GUI.changed = false;
        EditorGUILayout.PrefixLabel(e2dStrings.LABEL_TEXTURE);
        selectedTexture.texture = (Texture)EditorGUILayout.ObjectField(selectedTexture.texture, typeof(Texture), !EditorUtility.IsPersistent(target));
        GUILayoutUtility.GetRect(70, 0, GUI.skin.label);
        if (GUI.changed) rebuildMaterial = true;
        EditorGUILayout.EndHorizontal();

        // size
        GUI.changed = false;
        selectedTexture.size.x = EditorGUILayout.Slider(e2dStrings.LABEL_CURVE_TEXTURE_WIDTH, selectedTexture.size.x, e2dConstants.TEXTURE_WIDTH_MIN, e2dConstants.TEXTURE_WIDTH_MAX);
        selectedTexture.size.y = EditorGUILayout.Slider(e2dStrings.LABEL_CURVE_TEXTURE_HEIGHT, selectedTexture.size.y, e2dConstants.TEXTURE_HEIGHT_MIN, e2dConstants.TEXTURE_HEIGHT_MAX);
        if (GUI.changed) rebuildMesh = rebuildMaterial = true;

        // fade
        GUI.changed = false;
        selectedTexture.fadeThreshold = EditorGUILayout.Slider(e2dStrings.LABEL_CURVE_TEXTURE_FADE_THRESHOLD, selectedTexture.fadeThreshold, 0, 1);
        if (GUI.changed) rebuildMaterial = true;

        // fixed angle
        GUI.changed = false;
        selectedTexture.fixedAngle = EditorGUILayout.Toggle(e2dStrings.LABEL_CURVE_TEXTURE_FIXED_ANGLE, selectedTexture.fixedAngle);
        if (GUI.changed) rebuildMaterial = true;

        // update the structure
        if (rebuildMaterial || rebuildMesh)
        {
            Undo.RegisterUndo(Terrain, e2dStrings.UNDO_CURVE_TEXTURE);
            Terrain.CurveTextures[SelectedTexture] = selectedTexture;
        }

        if (rebuildMaterial)
        {
            Terrain.CurveMesh.RebuildMaterial();
            EditorUtility.SetDirty(Terrain);
        }
        if (rebuildMesh)
        {
            Terrain.CurveMesh.RebuildMesh();
            EditorUtility.SetDirty(Terrain);
        }

        if (e2dUtils.DEBUG_CONTROL_TEXTURES) DrawCurveControlTextures();
    }
    /// Returns the default texture used when no other is defined by the user.
    public e2dCurveTexture GetDefaultCurveTexture()
    {
        e2dCurveTexture result = new e2dCurveTexture((Texture)Resources.Load("defaultCurveTexture", typeof(Texture)));

        return(result);
    }
Esempio n. 8
0
    private float GetNodeStripeSize(int nodeIndex)
    {
        e2dCurveTexture e2dCurveTexture = base.CurveTextures[base.TerrainCurve[nodeIndex].texture];

        return(e2dCurveTexture.size.y);
    }