Ejemplo n.º 1
0
    public void SetupMainQuad(QuadPosition quadPosition)
    {
        GameObject go = new GameObject(string.Format("Quad_{0}", quadPosition));

        go.transform.parent        = QuadsRoot.transform;
        go.transform.position      = Vector3.zero;
        go.transform.rotation      = Quaternion.identity;
        go.transform.localPosition = Vector3.zero;
        go.transform.localRotation = Quaternion.identity;

        Mesh mesh = GetMesh(quadPosition);

        mesh.bounds = new Bounds(Vector3.zero, new Vector3(PlanetRadius * 2, PlanetRadius * 2, PlanetRadius * 2));

        Material material = MaterialHelper.CreateTemp(ColorShader, "Quad");

        Quad quadComponent = go.AddComponent <Quad>();

        quadComponent.Planetoid    = this;
        quadComponent.QuadMesh     = mesh;
        quadComponent.QuadMaterial = material;

        if (Atmosphere != null)
        {
            Atmosphere.InitUniforms(null, quadComponent.QuadMaterial, false);
        }

        QuadGenerationConstants gc = QuadGenerationConstants.Init(TerrainMaxHeight);

        gc.planetRadius = PlanetRadius;

        gc.cubeFaceEastDirection  = quadComponent.GetCubeFaceEastDirection(quadPosition);
        gc.cubeFaceNorthDirection = quadComponent.GetCubeFaceNorthDirection(quadPosition);
        gc.patchCubeCenter        = quadComponent.GetPatchCubeCenter(quadPosition);

        quadComponent.Position            = quadPosition;
        quadComponent.ID                  = QuadID.One;
        quadComponent.generationConstants = gc;
        quadComponent.SetupCorners(quadPosition);
        quadComponent.ShouldDraw       = true;
        quadComponent.ReadyForDispatch = true;

        Quads.Add(quadComponent);
        MainQuads.Add(quadComponent);
    }