Click here to Skip to main content
15,884,099 members
Articles / Multimedia / GDI+

Overhauser (Catmull-Rom) Splines for Camera Animation

Rate me:
Please Sign up or sign in to vote.
4.85/5 (26 votes)
10 Nov 2008CPOL5 min read 112.6K   3.7K   40  
An introduction to Overhauser splines from the perspective of a game writer, with C++ sample code
#ifndef vec3HPP
#define vec3HPP

/// Minimal 3-dimensional vector abstraction
class vec3
{
public:

    // Constructors
    vec3() : x(0), y(0), z(0)
	{}
	
	vec3(float vx, float vy, float vz)
	{
		x = vx;
		y = vy;
		z = vz;
	}

	vec3(const vec3& v)
	{
		x = v.x;
		y = v.y;
		z = v.z;
	}

	// Destructor
	~vec3() {}

	// A minimal set of vector operations
	vec3 operator * (float mult) const // result = this * arg
	{
		return vec3(x * mult, y * mult, z * mult);
	}

	vec3 operator + (const vec3& v) const // result = this + arg
	{
		return vec3(x + v.x, y + v.y, z + v.z);
	}

	vec3 operator - (const vec3& v) const // result = this - arg
	{
		return vec3(x - v.x, y - v.y, z - v.z);
	}

	float x, y, z;
};

#endif

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior) Microsoft
United States United States
Software engineering manager at Microsoft (Seattle area).

Comments and Discussions