Beispiel #1
0
    public void AsyncGenerateData()
    {
        if (queuedPoints == null)
        {
            queuedPoints = new List<Vector3>();
            Quaternion quat = new Quaternion();
            int rotationCounter = 0;

            float rotationStepSize = 10;
            for (float j = 2; j < 30; j *= 1.02f)
            {

                for (float f = 0 + rotationCounter; f < 360 + rotationCounter; f += rotationStepSize)
                {
                    quat.SetEulerAngles(new Vector3(0, f, 0));
                    AsyncQueueCount++;

                    queuedPoints.Add(origin + (quat * Vector3.forward * j));
                    //DebugOutput.Shout("BASDASD");

                }
                rotationStepSize *= 0.983f;
                //rotationCounter++;
            }
        }

        TerrainGenerator tgen = new TerrainGenerator(Mathf.Pow(2, worldSize));

        int queuedPos = AsyncQueuePlacement;
        int stepsize = 100;

        while ((queuedPos < (AsyncQueuePlacement + stepsize)) && queuedPos < queuedPoints.Count)
        {
            pendingData.Add(new SurveyDataPoint(queuedPoints[queuedPos], tgen.GeneratePointValueDouble(queuedPoints[queuedPos])));
            queuedPos++;
        }
        AsyncQueuePlacement += stepsize;
    }
Beispiel #2
0
    public void AsyncGenerateTexture()
    {
        TerrainGenerator tgen = new TerrainGenerator(Mathf.Pow(2, worldSize));
        Color col = new Color();
        Vector3 point = new Vector3(0,origin2.y,0);
        for (int i = asyncTexWidthCount; i < dataTextureWidth; i++)
        {
            asyncTexWidthCount++;
            for (int j = 0; j < dataTextureHeight; j++)
            {
                double pointValue = -1;

                if ((i % 2) == 1 && (j % 2) == 1)
                {

                    point.x = origin2.x - 30.0f + (i * (60.0f / (float)dataTextureWidth));
                    point.z = origin2.z- 30.0f + (j * (60.0f / (float)dataTextureWidth));

                    if ((point - origin).magnitude < 30.0f)
                    {
                        pointValue = tgen.GeneratePointValueDouble(point);
                        col = UtilityColor.hsv2rgb(1.0f - (float)pointValue, 1, 1);

                        if (pointValue == 0.0)
                        {
                            col = Color.gray;
                        }

                        col.a = 0.5f;

                    }
                }

                if (pointValue < 0.0)
                {
                    col.a = 0.0f;

                }
                pendingColorBlocks.Add(new ColorBlock(i, j, col));
            }
        }
    }