This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Backface Culling in Object Space | |
Hamburg (Germany), the 3rd June 1997. Written by Nils Pipenbrinck aka Submissive/Cubic & $eeN | |
Introduction | |
Ok, I guess it's now time to start working on the 3D section of my tutorial pages. 3D backface culling in object space is a topic which is easy to implement but can reduce some of the calculation costs. Backface culling is used in 3D rendering. It helps you to sort out those polygons in your scene database that won't be visible, since you want to remove them as fast as possible. Please note that in the age of pentiums and other fast processors the overhead of doing this stuff might be higher than the time you can save. I implemented it and found out that it's not really faster than normal backface culling. However, the results are much more accurate. One note before we start: Whenever I speak about tranformations I mean linear transformations. A tranformation may be built out of any number of the following actions, in any order or combination: Rotation, Scaling, Sheari |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define WIN32_LEAN_AND_MEAN | |
#define WIN32_EXTRA_LEAN | |
#include <windows.h> | |
#include <iostream> | |
using std::cout; | |
HWND hwnd; | |
HINSTANCE hinstance; | |
#pragma comment(linker,"/SUBSYSTEM:CONSOLE") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//http://www.flipcode.com/archives/Fast_Trigonometry_Functions_Using_Lookup_Tables.shtml | |
#include <stdio.h> | |
#include <assert.h> | |
#include <math.h> | |
#include <conio.h> | |
#include <time.h> | |
#define MAX_CIRCLE_ANGLE 512 | |
#define HALF_MAX_CIRCLE_ANGLE (MAX_CIRCLE_ANGLE/2) | |
#define QUARTER_MAX_CIRCLE_ANGLE (MAX_CIRCLE_ANGLE/4) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "Matrix.h" | |
#include <string.h> | |
#include <cmath> | |
#define MATRIXELEMENT(mat, row, col) mat[row * 4 + col] | |
const Matrix Matrix::zero; | |
const Matrix Matrix::identity(1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f ); | |
Matrix::Matrix() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "Vector.h" | |
#include <cmath> | |
const Vector Vector::zero(0.0f, 0.0f, 0.0f); | |
const Vector Vector::one(1.0f, 1.0f, 1.0f); | |
const Vector Vector::forward(0.0f, 0.0f, 1.0f); | |
const Vector Vector::up(0.0f, 1.0f, 0.0f); | |
const Vector Vector::right(1.0f, 0.0f, 0.0f); | |
Vector::Vector(float X, float Y, float Z) : x(X), y(Y), z(Z), w(0.0f) {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Generates a trail that is always facing upwards using the scriptable mesh interface. | |
vertex colors and uv's are generated similar to the builtin Trail Renderer. | |
To use it | |
1. create an empty game object | |
2. attach this script and a MeshRenderer | |
3. Then assign a particle material to the mesh renderer | |
*/ | |
var height = 2.0; | |
var time = 2.0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "Quaternion.h" | |
#include <cmath> | |
// http://content.gpwiki.org/index.php/OpenGL:Tutorials:Using_Quaternions_to_represent_rotation | |
// http://www.flipcode.com/documents/matrfaq.html | |
// http://db-in.com/blog/2011/04/cameras-on-opengl-es-2-x/ | |
// http://wiki.beyondunreal.com/Legacy:Quaternion | |
// http://clb.demon.fi/MathGeoLib/docs/float3x3.cpp_code.html#612 | |
// http://clb.demon.fi/MathGeoLib/docs/Quat_summary.php | |
// http://www.euclideanspace.com/maths/geometry/rotations/conversions/matrixToQuaternion/index.htm |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define WIN32_LEAN_AND_MEAN | |
#define WIN32_EXTRA_LEAN | |
#include <windows.h> | |
#include <process.h> | |
#include <stdlib.h> | |
#include <gl/gl.h> | |
#include <cmath> | |
#pragma comment(lib, "opengl32.lib") | |
#define OGL_NEAR float(0.1f) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// http://www.3dbuzz.com/vbforum/showthread.php?118279-Quick-solution-for-making-a-sphere-in-OpenGL | |
#include <math.h> | |
#define X .525731112119133606 | |
#define Z .850650808352039932 | |
static GLfloat vdata[12][3] = { | |
{-X, 0.0, Z}, {X, 0.0, Z}, {-X, 0.0, -Z}, {X, 0.0, -Z}, | |
{0.0, Z, X}, {0.0, Z, -X}, {0.0, -Z, X}, {0.0, -Z, -X}, | |
{Z, X, 0.0}, {-Z, X, 0.0}, {Z, -X, 0.0}, {-Z, -X, 0.0} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <windows.h> | |
#include <string> | |
#include <vector> | |
#include <stack> | |
#include <iostream> | |
using namespace std; | |
// Recursive directory traversal using the Win32 API | |
bool ListFiles(wstring path, wstring mask, vector<wstring>& files) |