1 /* 2 * Copyright (C) 2008 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.example.android.apis.graphics.kube; 18 19 20 public class Cube extends GLShape { 21 22 public Cube(GLWorld world, float left, float bottom, float back, float right, float top, float front) { 23 super(world); 24 GLVertex leftBottomBack = addVertex(left, bottom, back); 25 GLVertex rightBottomBack = addVertex(right, bottom, back); 26 GLVertex leftTopBack = addVertex(left, top, back); 27 GLVertex rightTopBack = addVertex(right, top, back); 28 GLVertex leftBottomFront = addVertex(left, bottom, front); 29 GLVertex rightBottomFront = addVertex(right, bottom, front); 30 GLVertex leftTopFront = addVertex(left, top, front); 31 GLVertex rightTopFront = addVertex(right, top, front); 32 33 // vertices are added in a clockwise orientation (when viewed from the outside) 34 // bottom 35 addFace(new GLFace(leftBottomBack, leftBottomFront, rightBottomFront, rightBottomBack)); 36 // front 37 addFace(new GLFace(leftBottomFront, leftTopFront, rightTopFront, rightBottomFront)); 38 // left 39 addFace(new GLFace(leftBottomBack, leftTopBack, leftTopFront, leftBottomFront)); 40 // right 41 addFace(new GLFace(rightBottomBack, rightBottomFront, rightTopFront, rightTopBack)); 42 // back 43 addFace(new GLFace(leftBottomBack, rightBottomBack, rightTopBack, leftTopBack)); 44 // top 45 addFace(new GLFace(leftTopBack, rightTopBack, rightTopFront, leftTopFront)); 46 47 } 48 49 public static final int kBottom = 0; 50 public static final int kFront = 1; 51 public static final int kLeft = 2; 52 public static final int kRight = 3; 53 public static final int kBack = 4; 54 public static final int kTop = 5; 55 56 57 } 58