/** * this demo shows how to use the really convenient convenience layer. * the layer hides some concepts that might be a bit troublesome in the beginning. */ import gestalt.model.Model; import gestalt.p5.Ge; import gestalt.shape.Cube; import gestalt.shape.Disk; import gestalt.shape.Mesh; import gestalt.shape.Plane; import gestalt.shape.material.TexturePlugin; Cube myCube; Model myModel; Plane myPlane; Mesh myMesh; Disk myDisk; TexturePlugin myTexture; void setup() { /* setup p5 */ size(640, 480, OPENGL); /* intentionally causing an error. no plane object is returned. */ myPlane = Ge.plane(); /* gestalt */ Ge.setup(this); /* plane -- create a plane and put a texture on it from a file. */ myPlane = Ge.plane("police.png"); /* disk -- create a disk. */ myDisk = Ge.disk(); /* cube -- create a cube and set its size to 150 */ myCube = Ge.cube(); myCube.scale().set(150, 150, 150); /* texture -- create a texture and load its data from a file. */ myTexture = Ge.texture("police.png"); myCube.material().addTexture(myTexture); /* mesh -- create a mesh that */ float[] myVertices = new float[] { -100, -100, 25, 100, -100, 50, 100, 100, 75, -100, 100, 100 }; float[] myVertexColors = new float[] { 1, 1, 1, 1, 0.5f, 1, 0.5f, 1, 1, 1, 1, 1, 0.5f, 1, 0.5f, 1 }; myMesh = Ge.mesh(false, myVertices, myVertexColors, Ge.MESH_QUADS); /* model -- load a model from a file and store it in the internal mesh. * rescale the model to half the size. */ myModel = Ge.model("weirdobject.obj", false); myModel.mesh().scale().set(0.5f, 0.5f, 0.5f); } void draw() { background(127, 255, 127); myPlane.position().set(mouseX, mouseY); myDisk.position().set(mouseX, mouseY); myCube.position().set(mouseX, mouseY); myMesh.position().set(mouseX, mouseY); myModel.mesh().position().set(mouseX, mouseY); /* deactivate drawing of a shape when mouse is pressed */ myPlane.setActive(!mousePressed); } void keyPressed() { /* remove the cube permanently from the renderer */ Ge.remove(myCube); }