This Library for DOGS-102 Graphic LCD module. Based on Igor Skochinsky's "DOGLCDDemo" program.
Dependents: DOGS102_Example1 DOGS102_Example2
Fork of DOGLCDDemo by
Graphics/Cuboid.cpp@0:2a5dccfd318f, 2010-01-14 (annotated)
- Committer:
- igorsk
- Date:
- Thu Jan 14 00:49:39 2010 +0000
- Revision:
- 0:2a5dccfd318f
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
igorsk | 0:2a5dccfd318f | 1 | /* |
igorsk | 0:2a5dccfd318f | 2 | * libmbed-graphics 2D and wireframe 3D graphics library for the MBED |
igorsk | 0:2a5dccfd318f | 3 | * microcontroller platform |
igorsk | 0:2a5dccfd318f | 4 | * Copyright (C) <2009> Michael Sheldon <mike@mikeasoft.com> |
igorsk | 0:2a5dccfd318f | 5 | * |
igorsk | 0:2a5dccfd318f | 6 | * This library is free software; you can redistribute it and/or |
igorsk | 0:2a5dccfd318f | 7 | * modify it under the terms of the GNU Library General Public |
igorsk | 0:2a5dccfd318f | 8 | * License as published by the Free Software Foundation; either |
igorsk | 0:2a5dccfd318f | 9 | * version 2 of the License, or (at your option) any later version. |
igorsk | 0:2a5dccfd318f | 10 | * |
igorsk | 0:2a5dccfd318f | 11 | * This library is distributed in the hope that it will be useful, |
igorsk | 0:2a5dccfd318f | 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
igorsk | 0:2a5dccfd318f | 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
igorsk | 0:2a5dccfd318f | 14 | * Library General Public License for more details. |
igorsk | 0:2a5dccfd318f | 15 | * |
igorsk | 0:2a5dccfd318f | 16 | * You should have received a copy of the GNU Library General Public |
igorsk | 0:2a5dccfd318f | 17 | * License along with this library; if not, write to the |
igorsk | 0:2a5dccfd318f | 18 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
igorsk | 0:2a5dccfd318f | 19 | * Boston, MA 02111-1307, USA. |
igorsk | 0:2a5dccfd318f | 20 | */ |
igorsk | 0:2a5dccfd318f | 21 | |
igorsk | 0:2a5dccfd318f | 22 | #include "Cuboid.h" |
igorsk | 0:2a5dccfd318f | 23 | |
igorsk | 0:2a5dccfd318f | 24 | // six sides, four vertices in each |
igorsk | 0:2a5dccfd318f | 25 | int _cube[6][4][3]={ |
igorsk | 0:2a5dccfd318f | 26 | { |
igorsk | 0:2a5dccfd318f | 27 | {-10,-10,-10}, |
igorsk | 0:2a5dccfd318f | 28 | { 10,-10,-10}, |
igorsk | 0:2a5dccfd318f | 29 | { 10, 10,-10}, |
igorsk | 0:2a5dccfd318f | 30 | {-10, 10,-10} |
igorsk | 0:2a5dccfd318f | 31 | },{ |
igorsk | 0:2a5dccfd318f | 32 | {-10,-10, 10}, |
igorsk | 0:2a5dccfd318f | 33 | { 10,-10, 10}, |
igorsk | 0:2a5dccfd318f | 34 | { 10, 10, 10}, |
igorsk | 0:2a5dccfd318f | 35 | {-10, 10, 10} |
igorsk | 0:2a5dccfd318f | 36 | },{ |
igorsk | 0:2a5dccfd318f | 37 | {-10,-10,-10}, |
igorsk | 0:2a5dccfd318f | 38 | { 10,-10,-10}, |
igorsk | 0:2a5dccfd318f | 39 | { 10,-10, 10}, |
igorsk | 0:2a5dccfd318f | 40 | {-10,-10, 10} |
igorsk | 0:2a5dccfd318f | 41 | },{ |
igorsk | 0:2a5dccfd318f | 42 | {-10, 10,-10}, |
igorsk | 0:2a5dccfd318f | 43 | { 10, 10,-10}, |
igorsk | 0:2a5dccfd318f | 44 | { 10, 10, 10}, |
igorsk | 0:2a5dccfd318f | 45 | {-10, 10, 10} |
igorsk | 0:2a5dccfd318f | 46 | },{ |
igorsk | 0:2a5dccfd318f | 47 | {-10,-10,-10}, |
igorsk | 0:2a5dccfd318f | 48 | {-10, 10,-10}, |
igorsk | 0:2a5dccfd318f | 49 | {-10, 10, 10}, |
igorsk | 0:2a5dccfd318f | 50 | {-10,-10, 10} |
igorsk | 0:2a5dccfd318f | 51 | },{ |
igorsk | 0:2a5dccfd318f | 52 | { 10,-10,-10}, |
igorsk | 0:2a5dccfd318f | 53 | { 10, 10,-10}, |
igorsk | 0:2a5dccfd318f | 54 | { 10, 10, 10}, |
igorsk | 0:2a5dccfd318f | 55 | { 10,-10, 10} |
igorsk | 0:2a5dccfd318f | 56 | } |
igorsk | 0:2a5dccfd318f | 57 | }; |
igorsk | 0:2a5dccfd318f | 58 | |
igorsk | 0:2a5dccfd318f | 59 | |
igorsk | 0:2a5dccfd318f | 60 | Cuboid::Cuboid() |
igorsk | 0:2a5dccfd318f | 61 | : Object3D::Object3D() { |
igorsk | 0:2a5dccfd318f | 62 | |
igorsk | 0:2a5dccfd318f | 63 | } |
igorsk | 0:2a5dccfd318f | 64 | |
igorsk | 0:2a5dccfd318f | 65 | void Cuboid::render(Graphics &g) |
igorsk | 0:2a5dccfd318f | 66 | { |
igorsk | 0:2a5dccfd318f | 67 | int side, v; |
igorsk | 0:2a5dccfd318f | 68 | int x[4], y[4], z[4]; |
igorsk | 0:2a5dccfd318f | 69 | |
igorsk | 0:2a5dccfd318f | 70 | for (side = 0; side < 6; side++) |
igorsk | 0:2a5dccfd318f | 71 | { |
igorsk | 0:2a5dccfd318f | 72 | for (v = 0; v < 4; v++) |
igorsk | 0:2a5dccfd318f | 73 | { |
igorsk | 0:2a5dccfd318f | 74 | x[v] = _cube[side][v][0]; |
igorsk | 0:2a5dccfd318f | 75 | y[v] = _cube[side][v][1]; |
igorsk | 0:2a5dccfd318f | 76 | z[v] = _cube[side][v][2]; |
igorsk | 0:2a5dccfd318f | 77 | } |
igorsk | 0:2a5dccfd318f | 78 | rotate3d(x, y, z, _rx, _ry, _rz, 4); |
igorsk | 0:2a5dccfd318f | 79 | for (v = 0; v < 4; v++) |
igorsk | 0:2a5dccfd318f | 80 | { |
igorsk | 0:2a5dccfd318f | 81 | x[v] += _x; |
igorsk | 0:2a5dccfd318f | 82 | y[v] += _y; |
igorsk | 0:2a5dccfd318f | 83 | z[v] += _z; |
igorsk | 0:2a5dccfd318f | 84 | } |
igorsk | 0:2a5dccfd318f | 85 | for (v = 0; v < 4; v++) |
igorsk | 0:2a5dccfd318f | 86 | { |
igorsk | 0:2a5dccfd318f | 87 | g.line3d(x[v], y[v], z[v], x[(v+1)%4], y[(v+1)%4], z[(v+1)%4], _colour); |
igorsk | 0:2a5dccfd318f | 88 | } |
igorsk | 0:2a5dccfd318f | 89 | } |
igorsk | 0:2a5dccfd318f | 90 | |
igorsk | 0:2a5dccfd318f | 91 | /*x0 = _cube[1][0][0]; |
igorsk | 0:2a5dccfd318f | 92 | y0 = _cube[1][0][1]; |
igorsk | 0:2a5dccfd318f | 93 | z0 = _cube[1][0][2]; |
igorsk | 0:2a5dccfd318f | 94 | rotate3d(&x0, &y0, &z0, _rx, _ry, _rz); |
igorsk | 0:2a5dccfd318f | 95 | x1 = _cube[0][0][0]; |
igorsk | 0:2a5dccfd318f | 96 | y1 = _cube[0][0][1]; |
igorsk | 0:2a5dccfd318f | 97 | z1 = _cube[0][0][2]; |
igorsk | 0:2a5dccfd318f | 98 | rotate3d(&x1, &y1, &z1, _rx, _ry, _rz); |
igorsk | 0:2a5dccfd318f | 99 | g.line3d(x0 + _x, y0 + _y, z0 + _z, x1 + _x, y1 + _y, z1 + _z, _colour);*/ |
igorsk | 0:2a5dccfd318f | 100 | } |