misc.cpp

Sat, 16 Mar 2013 03:11:19 +0200

author
Santeri Piippo <crimsondusk64@gmail.com>
date
Sat, 16 Mar 2013 03:11:19 +0200
changeset 14
6d9d8efae2f8
parent 13
3955ff2a7d72
child 18
a6732098fed8
permissions
-rw-r--r--

this thing got its own reinterpret_cast now. :P Added SetContents action for altering an object by contents and reinterpreting it.

#include "common.h"
#include <math.h>

double GetWordFloat (str& s, const ushort n) {
	return atof ((s / " ")[n]);
}

long GetWordInt (str& s, const ushort n) {
	return atol ((s / " ")[n]);
}

vertex ParseVertex (str& s, const ushort n) {
	vertex v;
	v.x = GetWordFloat (s, n);
	v.y = GetWordFloat (s, n + 1);
	v.z = GetWordFloat (s, n + 2);
	
	return v;
}

void StripWhitespace (str& s) {
	str other;
	
	for (size_t i = 0; i < ~s; i++)
		if (s[i] > 32 && s[i] < 127)
			other += s[i];
}

vertex bearing::project (vertex& vSource, ulong ulLength) {
	vertex vDest = vSource;
	
	vDest.x += (cos (fAngle) * ulLength);
	vDest.y += (sin (fAngle) * ulLength);
	vDest.x += (cos (fPitch) * ulLength);
	vDest.z += (sin (fPitch) * ulLength);
	return vDest;
}

mercurial