Пример #1
0
    public void AddScatterObject(GameObject _go, Vector3 _pos, Vector3 _scale, Vector3 _normal, bool _useNormal)
    {
        GeoPainterPoint myNewPoint = new GeoPainterPoint();

        myNewPoint.go        = _go;
        myNewPoint.pos       = _pos;
        myNewPoint.scale     = _scale;
        myNewPoint.normal    = _normal;
        myNewPoint.useNormal = _useNormal;
        myPointsList.Add(myNewPoint);
    }
Пример #2
0
    void RandomizeSolo(GeoPainterPoint element)
    {
        Transform obj   = element.go.transform;
        var       myRot = Quaternion.identity;

        if (element.useNormal)
        {
            //myRot = Quaternion.LookRotation(hit.normal);
            myRot = Quaternion.FromToRotation(obj.up, element.normal) * obj.rotation;
        }
        obj.position   = element.pos;
        obj.rotation   = myRot;
        obj.localScale = element.scale;

        // Position
        var tmpPosX = painter.currentGroup.posOffset.x + Random.Range(painter.currentGroup.minPosOffset.x, painter.currentGroup.maxPosOffset.x);
        var tmpPosY = painter.currentGroup.posOffset.y + Random.Range(painter.currentGroup.minPosOffset.y, painter.currentGroup.maxPosOffset.y);
        var tmpPosZ = painter.currentGroup.posOffset.z + Random.Range(painter.currentGroup.minPosOffset.z, painter.currentGroup.maxPosOffset.z);

        obj.Translate(tmpPosX, tmpPosY, tmpPosZ);

        // Rotation
        var tmpRotX = painter.currentGroup.rotOffset.x + Random.Range(painter.currentGroup.minRotOffset.x, painter.currentGroup.maxRotOffset.x);
        var tmpRotY = painter.currentGroup.rotOffset.y + Random.Range(painter.currentGroup.minRotOffset.y, painter.currentGroup.maxRotOffset.y);
        var tmpRotZ = painter.currentGroup.rotOffset.z + Random.Range(painter.currentGroup.minRotOffset.z, painter.currentGroup.maxRotOffset.z);

        obj.Rotate(tmpRotX, tmpRotY, tmpRotZ);

        // Scale
        var tmpSclX = painter.currentGroup.scaleOffset.x + Random.Range(painter.currentGroup.minScaleOffset.x, painter.currentGroup.maxScaleOffset.x);
        var tmpSclY = painter.currentGroup.scaleOffset.y + Random.Range(painter.currentGroup.minScaleOffset.y, painter.currentGroup.maxScaleOffset.y);
        var tmpSclZ = painter.currentGroup.scaleOffset.z + Random.Range(painter.currentGroup.minScaleOffset.z, painter.currentGroup.maxScaleOffset.z);

        if (!painter.currentGroup.scaleUniform)
        {
            obj.localScale += new Vector3(tmpSclX, tmpSclY, tmpSclZ);
        }
        else
        {
            obj.localScale += new Vector3(tmpSclX, tmpSclX, tmpSclX);
        }
    }