示例#1
0
    public void Build()
    {
        poh               = GetComponent <PlanetObjectsHandler>();
        cVtex             = GetComponent <ColorVertexes>();
        deformingMesh     = GetComponent <MeshFilter>().mesh;
        updatingColors    = deformingMesh.colors;
        originalVerices   = deformingMesh.vertices;
        displacedVertices = new Vector3[originalVerices.Length];
        for (int i = 0; i < originalVerices.Length; i++)
        {
            displacedVertices[i] = originalVerices[i];
        }
        vertexVelocities = new Vector3[originalVerices.Length];
        colliderMesh     = GetComponent <MeshCollider>();

        built = true;
        //InvokeRepeating("DoAnUpdate", 0f, 0.05f);
    }
示例#2
0
    private void RandomMesh()
    {
        float           minRand = -200f;
        float           maxRand = 200f;
        Mesh            m       = GetComponent <MeshFilter>().sharedMesh;
        MeshDeformation md      = GetComponent <MeshDeformation>();
        ColorVertexes   cv      = GetComponent <ColorVertexes>();

        //raise and lower at random
        print("GenTerr vernum = " + m.vertices.Length);
        Vector3[] v = m.vertices;
        for (int i = 0; i < v.Length; i++)
        {
            float force = Random.Range(minRand, maxRand);
            md.GenAddHeight(v[i], v[i] + v[i], force, 1000);
        }
        cv.UpdateColors();
    }
示例#3
0
        private void Create3DObject(object sender, EventArgs e)
        {
            try
            {
                int   nx       = this.ToInt(this.tbNX);
                int   ny       = this.ToInt(this.tbNY);
                int   nz       = this.ToInt(this.tbNZ);
                float radius   = this.ToFloat(this.tbRadius);
                float minValue = this.ToFloat(this.tbRangeMin);
                float maxValue = this.ToFloat(this.tbRangeMax);
                if (minValue >= maxValue)
                {
                    throw new ArgumentException("min value equal or equal to maxValue");
                }


                //生成需要画的模型
                ColorVertexes colorVertexes = ColorVertexesFactory.Create(nx, ny, nz, radius, minValue, maxValue);


                ColorVertexesElement visualElement = new ColorVertexesElement(colorVertexes);


                //output(particles);
                Rect3D rect3D = colorVertexes.Bounds;
                Scene  scene  = new Scene();
                this.arcBallEffect = new ArcBallEffect();
                //initialize Scene3D
                InitializeModelScene(scene, colorVertexes.Bounds, this.sceneControl1, this.arcBallEffect);
                this.sceneControl1.Scene = scene;
                scene.SceneContainer.AddChild(visualElement);


                visualElement.AddEffect(this.arcBallEffect);



                this.sceneControl1.Invalidate();
            }
            catch (Exception error)
            {
                MessageBox.Show(error.Message);
            }
        }
示例#4
0
        private void output(ColorVertexes particles)
        {
            System.Console.WriteLine(String.Format("Particle Count:{0}", particles.Size));
            long size = particles.Size;

            for (long i = 0; i < size; i++)
            {
                unsafe
                {
                    Point3D p = particles.Centers[i];
                    System.Console.WriteLine(String.Format("P({0},{1},{2})", p.x, p.y, p.z));
                }
            }

            System.Console.WriteLine(String.Format("Particle Color:{0}", particles.Size));
            for (long i = 0; i < size; i++)
            {
                unsafe
                {
                    Model.Color color = particles.Colors[i];
                    System.Console.WriteLine(String.Format("rgb({0},{1},{2})", color.red, color.green, color.blue));
                }
            }
        }
示例#5
0
    public void GeneratePlanet()
    {
        ColorVertexes cv = GetComponent <ColorVertexes>();

        cv.DirtLevel  = terrainRadius - 3;
        cv.GrassLevel = terrainRadius + 1;
        cv.RockLevel  = terrainRadius + 4;
        cv.SnowLevel  = terrainRadius + 7;


        CubeSphere cs = GetComponent <CubeSphere>();

        cs.radius   = terrainRadius;
        cs.gridSize = detailLevel;
        cs.Build();

        MeshDeformation md = GetComponent <MeshDeformation>();

        md.Build();

        GetComponent <GenerateTerrain>().GenTerrain();
        //water
        transform.GetChild(0).localScale = new Vector3(terrainRadius * 2, terrainRadius * 2, terrainRadius * 2);
        transform.GetChild(0).gameObject.SetActive(true);
        //atmos
        transform.GetChild(1).localScale = new Vector3((terrainRadius + atmosphereRadius) * 2, (terrainRadius + atmosphereRadius) * 2, (terrainRadius + atmosphereRadius) * 2);
        transform.GetChild(1).gameObject.SetActive(true);
        //clouds
        //ParticleSystem.ShapeModule shapeModule = transform.GetChild(2).GetComponent<ParticleSystem>().shape;
        //shapeModule.radius = atmosphereRadius + terrainRadius;
        //ParticleSystem.MainModule mainMondule = transform.GetChild(2).GetComponent<ParticleSystem>().main;
        //mainMondule.maxParticles = (int)atmosphereRadius * 2;

        //objects
        GetComponent <PlanetObjectsHandler>().Build();
    }
示例#6
0
 public ColorVertexesElement(ColorVertexes particles)
 {
     this._colorVertexes = particles;
 }