Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
falcon4ever committed Apr 1, 2013
0 parents commit 7516b4a
Show file tree
Hide file tree
Showing 3,279 changed files with 1,382,147 additions and 0 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
12 changes: 12 additions & 0 deletions addons/.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>addons</name>
<comment></comment>
<projects>
<project>openFrameworks</project>
</projects>
<buildSpec>
</buildSpec>
<natures>
</natures>
</projectDescription>
33 changes: 33 additions & 0 deletions addons/ofx3DModelLoader/install.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<install>
<name>ofx3DModelLoader</name>

<version>0.01</version>
<author>theo watson</author>
<url></url>

<add>
<!-- ===================================================================== -->
<!-- ========================== add per project using this addon ========= -->
<!-- ===================================================================== -->

<src>
<folder name="addons/ofxDirList/src">
<file>../../../addons/ofx3DModelLoader/src/ofx3DBaseLoader.h</file>
<file>../../../addons/ofx3DModelLoader/src/ofx3dModelLoader.cpp</file>
<file>../../../addons/ofx3DModelLoader/src/ofx3DModelLoader.h</file>
<file>../../../addons/ofx3DModelLoader/src/3DS/model3DS.cpp</file>
<file>../../../addons/ofx3DModelLoader/src/3DS/model3DS.h</file>
<file>../../../addons/ofx3DModelLoader/src/3DS/texture3DS.cpp</file>
<file>../../../addons/ofx3DModelLoader/src/3DS/texture3DS.h</file>
<file>../../../addons/ofx3DModelLoader/src/3DS/Vector3DS.h</file>
</folder>
</src>

<include>
<path>../../../addons/ofx3DModelLoader/src/3DS/</path>
<path>../../../addons/ofx3DModelLoader/src/</path>
</include>

</add>

</install>
189 changes: 189 additions & 0 deletions addons/ofx3DModelLoader/src/3DS/Vector3DS.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,189 @@
/*
Vector3DS class
© Keith O'Conor 2004
keith.oconor @ {cs.tcd.ie, gmail.com}
*/

#ifndef VECTOR_H
#define VECTOR_H

#include <math.h>
#include <iostream>

class Vector3DS{
public:
float x;
float y;
float z;

/*
Vector3DS();
Vector3DS(float a, float b, float c);
Vector3DS(Vector3DS& copy);
Vector3DS& operator=(const Vector3DS &other);
int operator== (const Vector3DS &other);
int operator!= (const Vector3DS &other);
Vector3DS operator+(const Vector3DS &other);
Vector3DS operator-(const Vector3DS &other);
Vector3DS operator*(const float &value);
Vector3DS operator/(const float &value);
Vector3DS& operator+=(const Vector3DS &other);
Vector3DS& operator-=(const Vector3DS &other);
Vector3DS& operator*=(const float& other);
Vector3DS& operator/=(const float& other);
float operator[](unsigned i);
float length();
float lengthSq();
float dotProduct(const Vector3DS &other);
Vector3DS crossProduct(const Vector3DS &other);
void normalize();
float distance(const Vector3DS &other);
float distanceSq(const Vector3DS &other);
void set(float newX, float newY, float newZ);
void zero();
*/

/////////////////
// Constructors
/////////////////

inline Vector3DS():x(0),y(0),z(0){}
inline Vector3DS(const float a, const float b, const float c):x(a),y(b),z(c){}
inline Vector3DS(const Vector3DS& copy):x(copy.x),y(copy.y),z(copy.z){}

//////////////
// Operators
//////////////

inline Vector3DS& operator= (const Vector3DS &other){
x=other.x;y=other.y;z=other.z;
return *this;
}

inline int operator== (const Vector3DS &other) const{
return (x==other.x && y==other.y && z==other.z);
}
inline int operator!= (const Vector3DS &other) const{
return (x!=other.x || y!=other.y || z!=other.z);
}

inline Vector3DS operator+ (const Vector3DS &other) const{
return Vector3DS(x+other.x, y+other.y, z+other.z);
}

inline Vector3DS operator- (const Vector3DS &other) const{
return Vector3DS(x-other.x, y-other.y, z-other.z);
}

inline Vector3DS operator* (const float &value) const{
return Vector3DS(x*value, y*value, z*value);
}

inline Vector3DS operator/ (const float &value) const{
return Vector3DS(x/value, y/value, z/value);
}

inline Vector3DS& operator+= (const Vector3DS &other){
x+=other.x;
y+=other.y;
z+=other.z;
return *this;
}
inline Vector3DS& operator-= (const Vector3DS &other){
x-=other.x;
y-=other.y;
z-=other.z;
return *this;
}

inline Vector3DS& operator*= (const float &value){
x*=value;
y*=value;
z*=value;
return *this;
}

inline Vector3DS& operator/= (const float &value){
x/=value;
y/=value;
z/=value;
return *this;
}

inline float operator[] (unsigned i) const{
switch(i){
case 0:return x;
case 1:return y;
case 2:return z;
}
}

/////////////////////
// Other operations
/////////////////////

inline float length() const{
float len=(x*x)+(y*y)+(z*z);
return (float)sqrt(len);
}

inline float lengthSq() const{
return (x*x)+(y*y)+(z*z);
}

inline float dotProduct(const Vector3DS &other) const{
//this[dot]other
return (x*other.x) + (y*other.y) + (z*other.z);
}

inline Vector3DS crossProduct(const Vector3DS &other) const{
//(x1,y1,z1)◊(x2,y2,z2) = (y1z2-y2z1, x2z1-x1z2, x1y2-x2y1).
return Vector3DS(
(y*other.z) - (z*other.y),
(z*other.x) - (x*other.z),
(x*other.y) - (y*other.x)
);
}

inline void normalize(){
float len=length();
if(len==0)return;
len=1.0f/len;
x*=len;
y*=len;
z*=len;
}

inline float distance(const Vector3DS &other) const{
return (Vector3DS(other.x-x,other.y-y,other.z-z)).length();
}

inline float distanceSq(const Vector3DS &other) const{
return (Vector3DS(other.x-x,other.y-y,other.z-z)).lengthSq();
}

inline void set(float newX, float newY, float newZ){
x=newX;y=newY;z=newZ;
}

inline void zero(){
x=y=z=0;
}

};

typedef Vector3DS Vertex;

const Vector3DS vZero=Vector3DS(0,0,0);

/////////////////////////////
// Global stream operators
//////////////////////////////
inline std::ostream& operator<<(std::ostream &str, const Vector3DS &v){
str<<v.x<<", "<<v.y<<", "<<v.z;
return str;
}

#endif //VECTOR_H
Loading

0 comments on commit 7516b4a

Please sign in to comment.