This Library for DOGS-102 Graphic LCD module. Based on Igor Skochinsky's "DOGLCDDemo" program.

Dependents:   DOGS102_Example1 DOGS102_Example2

Fork of DOGLCDDemo by Igor Skochinsky

Committer:
ban4jp
Date:
Sat May 03 16:04:16 2014 +0000
Revision:
1:2145a74df666
Parent:
0:2a5dccfd318f
Change to library, and Support DOGS-102 Graphic LCD module.

Who changed what in which revision?

UserRevisionLine numberNew 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 "TrimeshObject.h"
igorsk 0:2a5dccfd318f 23
igorsk 0:2a5dccfd318f 24 TrimeshObject::TrimeshObject(int vertices[][3], int faces[][3], int num_faces)
igorsk 0:2a5dccfd318f 25 : Object3D::Object3D() {
igorsk 0:2a5dccfd318f 26 _vertices = vertices;
igorsk 0:2a5dccfd318f 27 _faces = faces;
igorsk 0:2a5dccfd318f 28 _num_faces = num_faces;
igorsk 0:2a5dccfd318f 29 }
igorsk 0:2a5dccfd318f 30
igorsk 0:2a5dccfd318f 31 void TrimeshObject::render(Graphics &g) {
igorsk 0:2a5dccfd318f 32 int face, fv0, fv1, fv2;
igorsk 0:2a5dccfd318f 33 int *v0, *v1, *v2;
igorsk 0:2a5dccfd318f 34 int x[3], y[3], z[3];
igorsk 0:2a5dccfd318f 35 for (face = 0; face < _num_faces; face++) {
igorsk 0:2a5dccfd318f 36 fv0 = _faces[face][0];
igorsk 0:2a5dccfd318f 37 fv1 = _faces[face][1];
igorsk 0:2a5dccfd318f 38 fv2 = _faces[face][2];
igorsk 0:2a5dccfd318f 39 v0 = _vertices[fv0];
igorsk 0:2a5dccfd318f 40 v1 = _vertices[fv1];
igorsk 0:2a5dccfd318f 41 v2 = _vertices[fv2];
igorsk 0:2a5dccfd318f 42
igorsk 0:2a5dccfd318f 43 x[0] = v0[0]; x[1] = v1[0]; x[2] = v2[0];
igorsk 0:2a5dccfd318f 44 y[0] = v0[1]; y[1] = v1[1]; y[2] = v2[1];
igorsk 0:2a5dccfd318f 45 z[0] = v0[2]; z[1] = v1[2]; z[2] = v2[2];
igorsk 0:2a5dccfd318f 46 rotate3d(x, y, z, _rx, _ry, _rz, 3);
igorsk 0:2a5dccfd318f 47
igorsk 0:2a5dccfd318f 48 for ( int i=0; i < 3; i++ )
igorsk 0:2a5dccfd318f 49 {
igorsk 0:2a5dccfd318f 50 x[i] += _x;
igorsk 0:2a5dccfd318f 51 y[i] += _y;
igorsk 0:2a5dccfd318f 52 z[i] += _z;
igorsk 0:2a5dccfd318f 53 }
igorsk 0:2a5dccfd318f 54
igorsk 0:2a5dccfd318f 55 g.line3d(x[0], y[0], z[0], x[1], y[1], z[1], _colour);
igorsk 0:2a5dccfd318f 56 g.line3d(x[1], y[1], z[1], x[2], y[2], z[2], _colour);
igorsk 0:2a5dccfd318f 57 g.line3d(x[2], y[2], z[2], x[0], y[0], z[0], _colour);
igorsk 0:2a5dccfd318f 58 }
igorsk 0:2a5dccfd318f 59 }