Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Object3D.h
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 #ifndef MBED_OBJECT3D_H 00023 #define MBED_OBJECT3D_H 00024 00025 #include "Graphics.h" 00026 00027 /* Class: Object3D 00028 * General purpose 3D base object, new 3D objects should inherit 00029 * from this class. 00030 */ 00031 class Object3D { 00032 00033 public: 00034 Object3D(); 00035 00036 /* Function: position 00037 * Specify the position of the object in 3D space. 00038 * 00039 * Parameters: 00040 * x - X co-ordinate of the point that the centre of the object should be placed at. 00041 * y - Y co-ordinate of the point that the centre of the object should be placed at. 00042 * z - Z co-ordinate of the point that the centre of the object should be placed at. 00043 */ 00044 void position(int x, int y, int z); 00045 00046 /* Function: rotate 00047 * Rotate the object about it's centre point. 00048 * 00049 * Parameters: 00050 * rx - Component of the rotation along the x-axis in radians. 00051 * ry - Component of the rotation along the y-axis in radians. 00052 * rz - Component of the rotation along the z-axis in radians. 00053 */ 00054 void rotate(float rx, float ry, float rz); 00055 00056 /* Function: scale 00057 * Modify the size of the object. 00058 * 00059 * Parameters: 00060 * sx - Proportion to change the object's size by along the x axis. 00061 * sy - Proportion to change the object's size by along the y axis. 00062 * sz - Proportion to change the object's size by along the z axis. 00063 */ 00064 void scale(float sx, float sy, float sz); 00065 00066 /* Function: colour 00067 * Sets the colour of the object. 00068 * 00069 * Parameters: 00070 * colour - The colour of the object. 00071 */ 00072 void colour(int colour); 00073 00074 /* Function: render 00075 * Draws the object on the specified graphical context. 00076 * 00077 * Parameters: 00078 * g - The graphical context to which the object should be rendered. 00079 */ 00080 virtual void render(Graphics &g) = 0; 00081 00082 protected: 00083 int _x, _y, _z; 00084 float _rx, _ry, _rz; 00085 float _sx, _sy, _sz; 00086 int _colour; 00087 }; 00088 00089 00090 /* Function: rotate3d 00091 * Rotates point(s) in 3D space about origin (0,0,0) 00092 * 00093 * Parameters: 00094 * x - Pointer to the x co-ordinate(s) of the point(s) to be rotated. 00095 * y - Pointer to the y co-ordinate(s) of the point(s) to be rotated. 00096 * z - Pointer to the z co-ordinate(s) of the point(s) to be rotated. 00097 * anglex - The angle to rotate the point by around axis x in radians. 00098 * angley - The angle to rotate the point by around axis y in radians. 00099 * anglez - The angle to rotate the point by around axis z in radians. 00100 * count - count of coordinates pointed to by x, y and z 00101 */ 00102 void rotate3d(int *x, int *y, int *z, float anglex, float angley, float anglez, int count = 1); 00103 00104 #endif
Generated on Fri Jul 15 2022 20:49:26 by
1.7.2