Skip to content

Commit

Permalink
Initial commit.
Browse files Browse the repository at this point in the history
  • Loading branch information
Donatas committed Oct 13, 2012
0 parents commit 121f9c5
Show file tree
Hide file tree
Showing 131 changed files with 8,352 additions and 0 deletions.
166 changes: 166 additions & 0 deletions anorms.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,166 @@
/*
* anorms.h - header file
*/

{ -0.525731f, 0.000000f, 0.850651f },
{ -0.442863f, 0.238856f, 0.864188f },
{ -0.295242f, 0.000000f, 0.955423f },
{ -0.309017f, 0.500000f, 0.809017f },
{ -0.162460f, 0.262866f, 0.951056f },
{ 0.000000f, 0.000000f, 1.000000f },
{ 0.000000f, 0.850651f, 0.525731f },
{ -0.147621f, 0.716567f, 0.681718f },
{ 0.147621f, 0.716567f, 0.681718f },
{ 0.000000f, 0.525731f, 0.850651f },
{ 0.309017f, 0.500000f, 0.809017f },
{ 0.525731f, 0.000000f, 0.850651f },
{ 0.295242f, 0.000000f, 0.955423f },
{ 0.442863f, 0.238856f, 0.864188f },
{ 0.162460f, 0.262866f, 0.951056f },
{ -0.681718f, 0.147621f, 0.716567f },
{ -0.809017f, 0.309017f, 0.500000f },
{ -0.587785f, 0.425325f, 0.688191f },
{ -0.850651f, 0.525731f, 0.000000f },
{ -0.864188f, 0.442863f, 0.238856f },
{ -0.716567f, 0.681718f, 0.147621f },
{ -0.688191f, 0.587785f, 0.425325f },
{ -0.500000f, 0.809017f, 0.309017f },
{ -0.238856f, 0.864188f, 0.442863f },
{ -0.425325f, 0.688191f, 0.587785f },
{ -0.716567f, 0.681718f, -0.147621f },
{ -0.500000f, 0.809017f, -0.309017f },
{ -0.525731f, 0.850651f, 0.000000f },
{ 0.000000f, 0.850651f, -0.525731f },
{ -0.238856f, 0.864188f, -0.442863f },
{ 0.000000f, 0.955423f, -0.295242f },
{ -0.262866f, 0.951056f, -0.162460f },
{ 0.000000f, 1.000000f, 0.000000f },
{ 0.000000f, 0.955423f, 0.295242f },
{ -0.262866f, 0.951056f, 0.162460f },
{ 0.238856f, 0.864188f, 0.442863f },
{ 0.262866f, 0.951056f, 0.162460f },
{ 0.500000f, 0.809017f, 0.309017f },
{ 0.238856f, 0.864188f, -0.442863f },
{ 0.262866f, 0.951056f, -0.162460f },
{ 0.500000f, 0.809017f, -0.309017f },
{ 0.850651f, 0.525731f, 0.000000f },
{ 0.716567f, 0.681718f, 0.147621f },
{ 0.716567f, 0.681718f, -0.147621f },
{ 0.525731f, 0.850651f, 0.000000f },
{ 0.425325f, 0.688191f, 0.587785f },
{ 0.864188f, 0.442863f, 0.238856f },
{ 0.688191f, 0.587785f, 0.425325f },
{ 0.809017f, 0.309017f, 0.500000f },
{ 0.681718f, 0.147621f, 0.716567f },
{ 0.587785f, 0.425325f, 0.688191f },
{ 0.955423f, 0.295242f, 0.000000f },
{ 1.000000f, 0.000000f, 0.000000f },
{ 0.951056f, 0.162460f, 0.262866f },
{ 0.850651f, -0.525731f, 0.000000f },
{ 0.955423f, -0.295242f, 0.000000f },
{ 0.864188f, -0.442863f, 0.238856f },
{ 0.951056f, -0.162460f, 0.262866f },
{ 0.809017f, -0.309017f, 0.500000f },
{ 0.681718f, -0.147621f, 0.716567f },
{ 0.850651f, 0.000000f, 0.525731f },
{ 0.864188f, 0.442863f, -0.238856f },
{ 0.809017f, 0.309017f, -0.500000f },
{ 0.951056f, 0.162460f, -0.262866f },
{ 0.525731f, 0.000000f, -0.850651f },
{ 0.681718f, 0.147621f, -0.716567f },
{ 0.681718f, -0.147621f, -0.716567f },
{ 0.850651f, 0.000000f, -0.525731f },
{ 0.809017f, -0.309017f, -0.500000f },
{ 0.864188f, -0.442863f, -0.238856f },
{ 0.951056f, -0.162460f, -0.262866f },
{ 0.147621f, 0.716567f, -0.681718f },
{ 0.309017f, 0.500000f, -0.809017f },
{ 0.425325f, 0.688191f, -0.587785f },
{ 0.442863f, 0.238856f, -0.864188f },
{ 0.587785f, 0.425325f, -0.688191f },
{ 0.688191f, 0.587785f, -0.425325f },
{ -0.147621f, 0.716567f, -0.681718f },
{ -0.309017f, 0.500000f, -0.809017f },
{ 0.000000f, 0.525731f, -0.850651f },
{ -0.525731f, 0.000000f, -0.850651f },
{ -0.442863f, 0.238856f, -0.864188f },
{ -0.295242f, 0.000000f, -0.955423f },
{ -0.162460f, 0.262866f, -0.951056f },
{ 0.000000f, 0.000000f, -1.000000f },
{ 0.295242f, 0.000000f, -0.955423f },
{ 0.162460f, 0.262866f, -0.951056f },
{ -0.442863f, -0.238856f, -0.864188f },
{ -0.309017f, -0.500000f, -0.809017f },
{ -0.162460f, -0.262866f, -0.951056f },
{ 0.000000f, -0.850651f, -0.525731f },
{ -0.147621f, -0.716567f, -0.681718f },
{ 0.147621f, -0.716567f, -0.681718f },
{ 0.000000f, -0.525731f, -0.850651f },
{ 0.309017f, -0.500000f, -0.809017f },
{ 0.442863f, -0.238856f, -0.864188f },
{ 0.162460f, -0.262866f, -0.951056f },
{ 0.238856f, -0.864188f, -0.442863f },
{ 0.500000f, -0.809017f, -0.309017f },
{ 0.425325f, -0.688191f, -0.587785f },
{ 0.716567f, -0.681718f, -0.147621f },
{ 0.688191f, -0.587785f, -0.425325f },
{ 0.587785f, -0.425325f, -0.688191f },
{ 0.000000f, -0.955423f, -0.295242f },
{ 0.000000f, -1.000000f, 0.000000f },
{ 0.262866f, -0.951056f, -0.162460f },
{ 0.000000f, -0.850651f, 0.525731f },
{ 0.000000f, -0.955423f, 0.295242f },
{ 0.238856f, -0.864188f, 0.442863f },
{ 0.262866f, -0.951056f, 0.162460f },
{ 0.500000f, -0.809017f, 0.309017f },
{ 0.716567f, -0.681718f, 0.147621f },
{ 0.525731f, -0.850651f, 0.000000f },
{ -0.238856f, -0.864188f, -0.442863f },
{ -0.500000f, -0.809017f, -0.309017f },
{ -0.262866f, -0.951056f, -0.162460f },
{ -0.850651f, -0.525731f, 0.000000f },
{ -0.716567f, -0.681718f, -0.147621f },
{ -0.716567f, -0.681718f, 0.147621f },
{ -0.525731f, -0.850651f, 0.000000f },
{ -0.500000f, -0.809017f, 0.309017f },
{ -0.238856f, -0.864188f, 0.442863f },
{ -0.262866f, -0.951056f, 0.162460f },
{ -0.864188f, -0.442863f, 0.238856f },
{ -0.809017f, -0.309017f, 0.500000f },
{ -0.688191f, -0.587785f, 0.425325f },
{ -0.681718f, -0.147621f, 0.716567f },
{ -0.442863f, -0.238856f, 0.864188f },
{ -0.587785f, -0.425325f, 0.688191f },
{ -0.309017f, -0.500000f, 0.809017f },
{ -0.147621f, -0.716567f, 0.681718f },
{ -0.425325f, -0.688191f, 0.587785f },
{ -0.162460f, -0.262866f, 0.951056f },
{ 0.442863f, -0.238856f, 0.864188f },
{ 0.162460f, -0.262866f, 0.951056f },
{ 0.309017f, -0.500000f, 0.809017f },
{ 0.147621f, -0.716567f, 0.681718f },
{ 0.000000f, -0.525731f, 0.850651f },
{ 0.425325f, -0.688191f, 0.587785f },
{ 0.587785f, -0.425325f, 0.688191f },
{ 0.688191f, -0.587785f, 0.425325f },
{ -0.955423f, 0.295242f, 0.000000f },
{ -0.951056f, 0.162460f, 0.262866f },
{ -1.000000f, 0.000000f, 0.000000f },
{ -0.850651f, 0.000000f, 0.525731f },
{ -0.955423f, -0.295242f, 0.000000f },
{ -0.951056f, -0.162460f, 0.262866f },
{ -0.864188f, 0.442863f, -0.238856f },
{ -0.951056f, 0.162460f, -0.262866f },
{ -0.809017f, 0.309017f, -0.500000f },
{ -0.864188f, -0.442863f, -0.238856f },
{ -0.951056f, -0.162460f, -0.262866f },
{ -0.809017f, -0.309017f, -0.500000f },
{ -0.681718f, 0.147621f, -0.716567f },
{ -0.681718f, -0.147621f, -0.716567f },
{ -0.850651f, 0.000000f, -0.525731f },
{ -0.688191f, 0.587785f, -0.425325f },
{ -0.587785f, 0.425325f, -0.688191f },
{ -0.425325f, 0.688191f, -0.587785f },
{ -0.425325f, -0.688191f, -0.587785f },
{ -0.587785f, -0.425325f, -0.688191f },
{ -0.688191f, -0.587785f, -0.425325f }
27 changes: 27 additions & 0 deletions average.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#include "average.h"


average::average()
{
t = 0;
av = 0;
}

void average::Add(double value, double time)
{
now = value;
if (t + time)
av = ((av * t) + (now * time)) / (t + time);
t += time;
}

double average::GetAverage()
{
return av;
}

double average::GetNow()
{
return now;
}

24 changes: 24 additions & 0 deletions average.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#ifndef INC_AVERAGE_H
#define INC_AVERAGE_H


class average {

public:
average();

double GetAverage();
double GetNow();

void Add(double value, double time);
private:

double t;//time
double av;//average

double now;

};


#endif
37 changes: 37 additions & 0 deletions bModels.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#include "bModels.h"



void bModels::Load(char *filename)
{
std::ifstream f(filename);

std::string name;
//double length;

//int n;
f >> n;
bM = new bModel[n];

//model *tempM;


for (int i = 0; i < n; i++)
{
f >> bM[i].length;
f.ignore();
f >> name;

//tempM = new model;

std::string s = "buildings/" + name + "/";


bM[i].m.Open(s.c_str());
//bModels.push_back(*tempM);
//delete tempM;
}


f.close();
}
26 changes: 26 additions & 0 deletions bModels.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#ifndef INC_BMODELS_H
#define INC_BMODELS_H

#include "model.h"


class bModel {
public:
double length;

model m;

};


class bModels {
public:
int n;
bModel *bM;

void Load(char *filename);

};


#endif
77 changes: 77 additions & 0 deletions bmp.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
//--------------------------------------------------------------
#include <windows.h> // Header File For Windows - has structures for BMP format
#include <stdio.h> // Header File For Standard Input/Output
#include <stdlib.h>
#include "BMP.h"

/*------------------------------------------------------------------
BMP Loader - a quick and dirty substitute for GLaux
if you only use GLaux to load BMP files will load any format of a
windows DIB BMP format graphics file Only works on a windows box
Caution! memory for the data is allocated using 'new'.
In the NeHe tutorials the memory is reclaimed using 'free'.
For the small tutorials its not a big deal but not a good practice in
larger projects (heap trashing not good). J.M. Doyle : 12 Jan 2003
------------------------------------------------------------------*/

AUX_RGBImageRec *auxDIBImageLoad(const char *FileName)
{
return new AUX_RGBImageRec(FileName);
}


void AUX_RGBImageRec::convertBGRtoRGB()
{
const DWORD BitmapLength = sizeX * sizeY * 3;
byte Temp; // not quick but it works
for(DWORD i=0; i< BitmapLength; i += 3)
{
Temp = data[i];
data[i] = data[i+2];
data[i+2] = Temp;
}
}

AUX_RGBImageRec::AUX_RGBImageRec(const char *FileName): data(0), NoErrors(false)
{
loadFile(FileName);
}

AUX_RGBImageRec::~AUX_RGBImageRec()
{
if (data != 0) delete data;
data = 0;
}

bool AUX_RGBImageRec::loadFile(const char* Filename)
{
BITMAPINFO BMInfo; // need the current OpenGL device contexts in order to make use of windows DIB utilities
const HDC gldc = wglGetCurrentDC(); // a handle for the current OpenGL Device Contexts
// assume there are errors until file is loaded successfully into memory
NoErrors = false; // release old data since this object could be used to load multiple Textures
if(data != 0) delete data; // windows needs this info to determine what header info we are looking for
BMInfo.bmiHeader.biSize = sizeof(BITMAPINFOHEADER); // Get windows to determine color bit depth in the file for us
BMInfo.bmiHeader.biBitCount = 0; // Get windows to open and load the BMP file and handle the messy decompression if the file is compressed
// assume perfect world and no errors in reading file, Ha Ha
HANDLE DIBHandle = LoadImage(0,Filename, IMAGE_BITMAP, 0, 0,LR_DEFAULTCOLOR | LR_CREATEDIBSECTION | LR_LOADFROMFILE); // use windows to get header info of bitmap - assume no errors in header format

GetDIBits(gldc, (HBITMAP)DIBHandle, 0,0, 0, &BMInfo, DIB_RGB_COLORS);
sizeX = BMInfo.bmiHeader.biWidth;
sizeY = BMInfo.bmiHeader.biHeight; // change color depth to 24 bits (3 bytes (BGR) / pixel)
BMInfo.bmiHeader.biBitCount = 24; // don't want the data compressed
BMInfo.bmiHeader.biCompression = BI_RGB;
const DWORD BitmapLength = sizeX * sizeY * 3; // 3 bytes (BGR) per pixel (24bp)
// allocate enough memory to hold the pixel data in client memory
data = new byte[BitmapLength]; // Get windows to do the dirty work of converting the BMP into the format needed by OpenGL
// if file is already 24 bit color then this is a waste of time but makes for short code
// Get the actual Texel data from the BMP object

if (GetDIBits(gldc, (HBITMAP)DIBHandle, 0, sizeY, data, &BMInfo, DIB_RGB_COLORS))
{
NoErrors = true;
convertBGRtoRGB(); // NOTE: BMP is in BGR format but OpenGL needs RGB unless you use GL_BGR_EXT
}

DeleteObject(DIBHandle); // don't need the BMP Object anymore
return NoErrors;
}
23 changes: 23 additions & 0 deletions bmp.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@

#ifndef INC_BMP_H
#define INC_BMP_H

//---------------------------------------------------------------------------

class AUX_RGBImageRec {
void convertBGRtoRGB();
public:
byte *data;
DWORD sizeX;
DWORD sizeY;
bool NoErrors;
AUX_RGBImageRec(): NoErrors(false), data(0) {};
AUX_RGBImageRec(const char *FileName);
~AUX_RGBImageRec();
bool loadFile(const char *FileName);
friend AUX_RGBImageRec *auxDIBImageLoad(const char *FileName);
};



#endif
Loading

0 comments on commit 121f9c5

Please sign in to comment.