00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef TOXIC_RENDERER_UTILITIES_H
00024 #define TOXIC_RENDERER_UTILITIES_H
00025
00026 #include "common/math/real.h"
00027 #include "common/math/vector3.h"
00028 #include "common/misc/types.h"
00029 #include "globals.h"
00030
00031 #include <cassert>
00032 #include <cmath>
00033
00034 namespace toxic {
00035
00036 int IntSquareRoot(int n);
00037 bool IsSquare(int n);
00038
00039 struct ConversionTables {
00040 static sheep::Real m_cos_phi[256];
00041 static sheep::Real m_sin_phi[256];
00042 static sheep::Real m_cos_theta[256];
00043 static sheep::Real m_sin_theta[256];
00044 static sheep::Vector3 m_direction[256];
00045
00046 ConversionTables();
00047 };
00048
00049
00050
00051
00052 void VectorToSphericalCoords(
00053 const sheep::Vector3 &v,
00054 sheep::Real *phi,
00055 sheep::Real *theta);
00056
00057
00058
00059 sheep::Vector3 SphericalCoordsToVector(sheep::Real phi, sheep::Real theta);
00060
00061
00062
00063 void PackSphericalCoords(
00064 sheep::Real phi, sheep::Real theta,
00065 sheep::uint8 *qphi, sheep::uint8 *qtheta);
00066
00067
00068
00069 void UnpackSphericalCoords(
00070 sheep::uint8 qphi, sheep::uint8 qtheta,
00071 sheep::Real *phi, sheep::Real *theta);
00072
00073
00074
00075 void PackSphericalCoords(
00076 sheep::Real phi, sheep::Real theta,
00077 sheep::uint8 *q);
00078
00079
00080
00081 void UnpackSphericalCoords(
00082 sheep::uint8 q,
00083 sheep::Real *phi, sheep::Real *theta);
00084
00085
00086 void PackDirection(
00087 const sheep::Vector3 &v,
00088 sheep::uint8 *qphi, sheep::uint8 *qtheta);
00089
00090
00091 void PackDirection(const sheep::Vector3 &v, sheep::uint8 *q);
00092
00093
00094
00095 sheep::Vector3 UnpackDirection(sheep::uint8 qphi, sheep::uint8 qtheta);
00096
00097
00098
00099 sheep::Vector3 UnpackDirection(sheep::uint8 q);
00100
00101 #include "utilities.inl"
00102
00103 }
00104
00105 #endif // !TOXIC_RENDERER_UTILITIES_H