Igor Skochinsky
/
DOGLCDDemo
A demo program for DOGL-128 LCD module. Based on Mike Sheldon's 3D Tie Fighter demo.
Embed:
(wiki syntax)
Show/hide line numbers
TrimeshObject.cpp
00001 /* 00002 * libmbed-graphics 2D and wireframe 3D graphics library for the MBED 00003 * microcontroller platform 00004 * Copyright (C) <2009> Michael Sheldon <mike@mikeasoft.com> 00005 * 00006 * This library is free software; you can redistribute it and/or 00007 * modify it under the terms of the GNU Library General Public 00008 * License as published by the Free Software Foundation; either 00009 * version 2 of the License, or (at your option) any later version. 00010 * 00011 * This library is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00014 * Library General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU Library General Public 00017 * License along with this library; if not, write to the 00018 * Free Software Foundation, Inc., 59 Temple Place - Suite 330, 00019 * Boston, MA 02111-1307, USA. 00020 */ 00021 00022 #include "TrimeshObject.h" 00023 00024 TrimeshObject::TrimeshObject(int vertices[][3], int faces[][3], int num_faces) 00025 : Object3D::Object3D() { 00026 _vertices = vertices; 00027 _faces = faces; 00028 _num_faces = num_faces; 00029 } 00030 00031 void TrimeshObject::render(Graphics &g) { 00032 int face, fv0, fv1, fv2; 00033 int *v0, *v1, *v2; 00034 int x[3], y[3], z[3]; 00035 for (face = 0; face < _num_faces; face++) { 00036 fv0 = _faces[face][0]; 00037 fv1 = _faces[face][1]; 00038 fv2 = _faces[face][2]; 00039 v0 = _vertices[fv0]; 00040 v1 = _vertices[fv1]; 00041 v2 = _vertices[fv2]; 00042 00043 x[0] = v0[0]; x[1] = v1[0]; x[2] = v2[0]; 00044 y[0] = v0[1]; y[1] = v1[1]; y[2] = v2[1]; 00045 z[0] = v0[2]; z[1] = v1[2]; z[2] = v2[2]; 00046 rotate3d(x, y, z, _rx, _ry, _rz, 3); 00047 00048 for ( int i=0; i < 3; i++ ) 00049 { 00050 x[i] += _x; 00051 y[i] += _y; 00052 z[i] += _z; 00053 } 00054 00055 g.line3d(x[0], y[0], z[0], x[1], y[1], z[1], _colour); 00056 g.line3d(x[1], y[1], z[1], x[2], y[2], z[2], _colour); 00057 g.line3d(x[2], y[2], z[2], x[0], y[0], z[0], _colour); 00058 } 00059 }
Generated on Fri Jul 15 2022 20:49:26 by 1.7.2