Ejemplo n.º 1
0
        private void GenerateFloorObjectFromFloorShapes(List <GameTile> tiles)
        {
            GameObject      finalFloorShape = new GameObject();
            ProceduralShape finalShape      = new ProceduralShape();

            ProceduralPlane plane = new ProceduralPlane();

            plane.SetColor(Color.LightGray.ChangeTone(RandomHelper.GetRandomInt(-20, 20)));
            plane.Scale(tiles[0].Scale);
            plane.Translate(tiles[0].Center);


            finalShape = plane;
            AddLineBatch(plane);


            for (int i = 1; i < tiles.Count; i++)
            {
                ProceduralPlane newPlane = new ProceduralPlane();
                newPlane.SetColor(Color.LightGray.ChangeTone(RandomHelper.GetRandomInt(-20, 20)));
                newPlane.Scale(tiles[i].Scale);
                newPlane.Translate(tiles[i].Center);
                finalShape = ProceduralShape.Combine(finalShape, newPlane);
                AddLineBatch(newPlane);
            }

            finalFloorShape.AddComponent(new RenderGeometryComponent(finalShape));
            finalFloorShape.AddComponent(new EffectRenderComponent(EffectLoader.LoadSM5Effect("flatshaded")));
            finalFloorShape.AddComponent(new ShadowCasterComponent());
            SystemCore.GameObjectManager.AddAndInitialiseGameObject(finalFloorShape);
        }
Ejemplo n.º 2
0
        public static GameObject CreateRenderTextureSurface(ProceduralPlane plane, Effect renderTextureEffect)
        {
            var ob = new GameObject();

            ob.AddComponent(new RenderGeometryComponent(BufferBuilder.VertexBufferBuild(plane), BufferBuilder.IndexBufferBuild(plane), plane.PrimitiveCount));

            ob.AddComponent(new RenderTextureComponent(renderTextureEffect));
            return(ob);
        }
Ejemplo n.º 3
0
    static void Create()
    {
        GameObject      gameObject = new GameObject("ProceduralPlane");
        ProceduralPlane c          = gameObject.AddComponent <ProceduralPlane>();
        MeshFilter      meshFilter = gameObject.GetComponent <MeshFilter>();

        meshFilter.mesh = new Mesh();
        c.Rebuild();
        c.AssignDefaultShader();
    }
Ejemplo n.º 4
0
    private void Update()
    {
        var plane = new ProceduralPlane.Plane(planePosition, planeRotation, planeSize, planeResolution);

        ProceduralPlane.Create(planetPosition, planetRadius, plane, out NativeArray <Triangle> triangles, out NativeArray <Vertex> vertices).Complete();
        mesh.Update(triangles, vertices);

        vertices.Dispose();
        triangles.Dispose();
    }
Ejemplo n.º 5
0
    public override void OnInspectorGUI()
    {
        DrawDefaultInspector();
        ProceduralPlane plane = target as ProceduralPlane;

        if (GUILayout.Button("Generate"))
        {
            plane.Generate();
        }
    }
Ejemplo n.º 6
0
        private static void AddLineBatch(ProceduralPlane proceduralPlane)
        {
            LineBatch l = new LineBatch(proceduralPlane.GetLineBatchVerts().ToArray());

            for (int i = 0; i < l.Vertices.Count(); i++)
            {
                l.Vertices[i].Position = l.Vertices[i].Position.ReplaceYComponent(-1.9f);
            }

            GameObject lineObject = SystemCore.GameObjectManager.AddLineBatchToScene(l);
        }
Ejemplo n.º 7
0
    // Use this for initialization
    void Start()
    {
        plane = this.gameObject.GetComponent <ProceduralPlane>();
        //keystone = new KeystoneOffset(); // LOAD
        keystone = KeystoneOffset.Load();

        // apply stored (serialized) offsets
        plane.topLeftOffset     = keystone.TopLeftOffset;
        plane.topRightOffset    = keystone.TopRightOffset;
        plane.bottomLeftOffset  = keystone.BottomLeftOffset;
        plane.bottomRightOffset = keystone.BottomRightOffset;
        plane.Rebuild();
    }
    private void OnEnable()
    {
        shape     = (ProceduralPlane)target;
        sizeX     = serializedObject.FindProperty("sizeX");
        sizeZ     = serializedObject.FindProperty("sizeZ");
        segmentsX = serializedObject.FindProperty("segmentsX");
        segmentsZ = serializedObject.FindProperty("segmentsZ");

        var meshFilter = shape.GetComponent <MeshFilter>();
        var mesh       = meshFilter.sharedMesh;

        if (mesh == null)
        {
            shape.UpdateMesh();
        }
    }
Ejemplo n.º 9
0
        public override void OnInitialise()
        {
            base.OnInitialise();

            SystemCore.ActiveScene.SetUpBasicAmbientAndKey();
            mouseCamera.moveSpeed = 0.01f;

            ProceduralCube cube = new ProceduralCube();

            cube.SetColor(Color.OrangeRed);
            testObject = GameObjectFactory.CreateRenderableGameObjectFromShape(cube, EffectLoader.LoadSM5Effect("flatshaded"));
            testObject.AddComponent(new RotatorComponent(Vector3.Up, 0.0001f));
            SystemCore.GameObjectManager.AddAndInitialiseGameObject(testObject);

            ProceduralPlane plane = new ProceduralPlane();

            plane.Scale(10f);
            plane.SetColor(Color.LightBlue);
            planeToDrawOn = GameObjectFactory.CreateRenderTextureSurface(plane,
                                                                         EffectLoader.LoadSM5Effect("rendertexturesurface"));

            planeToDrawOn.Transform.Rotate(Vector3.Forward, MathHelper.ToRadians(90));
            planeToDrawOn.Transform.Rotate(Vector3.Left, MathHelper.ToRadians(-90));
            //planeToDrawOn.Transform.Rotate(Vector3.Up, MathHelper.ToRadians(-90));
            planeToDrawOn.Transform.SetPosition(new Vector3(-5, 0, 0));

            GameObject.InitialiseAllComponents(planeToDrawOn);

            spriteBatch  = new SpriteBatch(SystemCore.GraphicsDevice);
            renderTarget = new RenderTarget2D(SystemCore.GraphicsDevice, 500, 500);

            renderTextureCamera = new DummyCamera();
            renderTextureCamera.SetPositionAndLookDir(new Vector3(-5, 0, 0), Vector3.Zero, Vector3.Up);
            SystemCore.AddCamera("renderTextureCamera", renderTextureCamera);

            var secondCube = GameObjectFactory.CreateRenderableGameObjectFromShape(new ProceduralCube(),
                                                                                   EffectLoader.LoadSM5Effect("flatshaded"));

            secondCube.Transform.SetPosition(new Vector3(-20, 0, 0));
            SystemCore.GameObjectManager.AddAndInitialiseGameObject(secondCube);

            font = SystemCore.ContentManager.Load <SpriteFont>("Fonts/neuropolitical");
        }
Ejemplo n.º 10
0
    public static Mesh GenerateCube(int segmentsX, int segmentsY, int segmentsZ, float segmentSize)
    {
        //Mesh meshFilterMesh = this.meshFilter.mesh;

        // Generate Cube Loft
        Vector3[] spline   = GenerateSquareSpline(segmentsX, segmentsZ, segmentSize);
        Mesh      loftMesh = MeshUtils.GenerateLoftNurb(spline, segmentsY, segmentsY * segmentSize);
        //Debug.Log(loftMesh.vertices.Length);

        // Generate Bottom Cap
        Mesh bottomCapMesh = ProceduralPlane.GeneratePlane(segmentsX, segmentsZ, segmentSize, segmentSize, new Vector3(0, 0, 0), Quaternion.Euler(180, 0, 0));
        //Debug.Log(bottomCapMesh.vertices.Length);

        // Generate Top Cap
        Mesh topCapMesh = ProceduralPlane.GeneratePlane(segmentsX, segmentsZ, segmentSize, segmentSize, new Vector3(0, segmentsY * segmentSize, 0), Quaternion.Euler(0, 0, 0));

        //Debug.Log(topCapMesh.vertices.Length);

        // Combine the meshes
        //MeshUtils.CombineMeshes(this.meshFilter, MeshUtils.GenerateCombineMeshMatrixTransform(gameObject), loftMesh, bottomCapMesh, topCapMesh);

        return(MeshUtils.CombineMeshes(MeshUtils.GenerateCombineMeshMatrixTransform(), loftMesh, bottomCapMesh, topCapMesh));
    }
Ejemplo n.º 11
0
    // Use this for initialization
    void Start()
    {
        plane = this.gameObject.GetComponent<ProceduralPlane>();
        //keystone = new KeystoneOffset(); // LOAD
        keystone = KeystoneOffset.Load();

        // apply stored (serialized) offsets
        plane.topLeftOffset = keystone.TopLeftOffset;
        plane.topRightOffset = keystone.TopRightOffset;
        plane.bottomLeftOffset = keystone.BottomLeftOffset;
        plane.bottomRightOffset = keystone.BottomRightOffset;
        plane.Rebuild();
    }