* Fix many style issues. Quaternion and Vector3 still show some of their foreign
origin. Yes.. shame on me, i had even imported their non unix line endings :) Will make them BCitizens soon. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33890 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -15,43 +15,47 @@
|
|||||||
|
|
||||||
|
|
||||||
float
|
float
|
||||||
MathUtils::EaseInOutCubic(float t /*time*/, float b /*begin*/, float c /*distance*/, float d /*duration*/)
|
MathUtils::EaseInOutCubic(float time, float start, float distance,
|
||||||
|
float duration)
|
||||||
{
|
{
|
||||||
t /= d / 2.0;
|
time /= duration / 2.0;
|
||||||
if (t < 1.0)
|
if (time < 1.0)
|
||||||
return c / 2.0 * t * t * t + b;
|
return distance / 2.0 * time * time * time + start;
|
||||||
t -= 2.0;
|
time -= 2.0;
|
||||||
return c / 2.0 * (t * t * t + 2.0) + b;
|
return distance / 2.0 * (time * time * time + 2.0) + start;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
float
|
float
|
||||||
MathUtils::EaseInOutQuart(float t /*time*/, float b /*begin*/, float c /*distance*/, float d /*duration*/)
|
MathUtils::EaseInOutQuart(float time, float start, float distance,
|
||||||
|
float duration)
|
||||||
{
|
{
|
||||||
t /= d / 2;
|
time /= duration / 2;
|
||||||
|
|
||||||
if (t < 1)
|
if (time < 1)
|
||||||
return c / 2 * t * t * t * t + b;
|
return distance / 2 * time * time * time * time + start;
|
||||||
|
|
||||||
t -= 2;
|
time -= 2;
|
||||||
|
|
||||||
return -c / 2 * (t * t * t * t - 2) + b;
|
return -distance / 2 * (time * time * time * time - 2) + start;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
float
|
float
|
||||||
MathUtils::EaseInOutQuint(float t /*time*/, float b /*begin*/, float c /*distance*/, float d /*duration*/)
|
MathUtils::EaseInOutQuint(float time, float start, float distance,
|
||||||
|
float duration)
|
||||||
{
|
{
|
||||||
t /= d / 2;
|
time /= duration / 2;
|
||||||
if (t < 1)
|
if (time < 1)
|
||||||
return c / 2 * t * t * t * t * t + b;
|
return distance / 2 * time * time * time * time * time + start;
|
||||||
t -= 2;
|
time -= 2;
|
||||||
return c / 2 *(t * t * t * t * t + 2) + b;
|
return distance / 2 *(time * time * time * time * time + 2) + start;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
float
|
float
|
||||||
MathUtils::EaseInOutSine(float t /*time*/, float b /*begin*/, float c /*distance*/, float d /*duration*/)
|
MathUtils::EaseInOutSine(float time, float start, float distance,
|
||||||
|
float duration)
|
||||||
{
|
{
|
||||||
return -c / 2 * (cos(3.14159 * t / d) - 1) + b;
|
return -distance / 2 * (cos(3.14159 * time / distance) - 1) + start;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,10 +12,14 @@
|
|||||||
class MathUtils
|
class MathUtils
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static float EaseInOutCubic(float time, float begin, float distance, float duration);
|
static float EaseInOutCubic(float time, float begin, float distance,
|
||||||
static float EaseInOutQuart(float time, float begin, float distance, float duration);
|
float duration);
|
||||||
static float EaseInOutQuint(float time, float begin, float distance, float duration);
|
static float EaseInOutQuart(float time, float begin, float distance,
|
||||||
static float EaseInOutSine(float time, float begin, float distance, float duration);
|
float duration);
|
||||||
|
static float EaseInOutQuint(float time, float begin, float distance,
|
||||||
|
float duration);
|
||||||
|
static float EaseInOutSine(float time, float begin, float distance,
|
||||||
|
float duration);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* _MATH_UTILS_H */
|
#endif /* _MATH_UTILS_H */
|
||||||
|
|||||||
@@ -76,9 +76,8 @@ MeshInstance::Render()
|
|||||||
glBindTexture(GL_TEXTURE_2D, fTextureReference->Id());
|
glBindTexture(GL_TEXTURE_2D, fTextureReference->Id());
|
||||||
|
|
||||||
int lastVertexCount = 0;
|
int lastVertexCount = 0;
|
||||||
//int batchCount = 0;
|
|
||||||
|
|
||||||
for(uint32 i = 0; i < fMeshReference->FaceCount(); i++) {
|
for (uint32 i = 0; i < fMeshReference->FaceCount(); i++) {
|
||||||
|
|
||||||
const Face& face = fMeshReference->GetFace(i);
|
const Face& face = fMeshReference->GetFace(i);
|
||||||
|
|
||||||
@@ -91,8 +90,6 @@ MeshInstance::Render()
|
|||||||
glBegin(GL_TRIANGLES);
|
glBegin(GL_TRIANGLES);
|
||||||
else
|
else
|
||||||
glBegin(GL_QUADS);
|
glBegin(GL_QUADS);
|
||||||
|
|
||||||
//batchCount++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// calculate normal
|
// calculate normal
|
||||||
@@ -144,11 +141,10 @@ MeshInstance::Render()
|
|||||||
lastVertexCount = face.vertexCount;
|
lastVertexCount = face.vertexCount;
|
||||||
}
|
}
|
||||||
glEnd();
|
glEnd();
|
||||||
//printf("batchCount %d\n", batchCount);
|
|
||||||
|
|
||||||
if (fDrawNormals) {
|
if (fDrawNormals) {
|
||||||
glBegin(GL_LINES);
|
glBegin(GL_LINES);
|
||||||
for(uint32 i = 0; i < fMeshReference->FaceCount(); i++) {
|
for (uint32 i = 0; i < fMeshReference->FaceCount(); i++) {
|
||||||
|
|
||||||
const Face& face = fMeshReference->GetFace(i);
|
const Face& face = fMeshReference->GetFace(i);
|
||||||
|
|
||||||
|
|||||||
@@ -9,30 +9,38 @@
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
*
|
*
|
||||||
* This is a refactored and stripped down version of bullet-2.66 src\LinearMath\btQuaternion.h
|
* This is a refactored and stripped down version of
|
||||||
* The dependancies on base class btQuadWord have been removed for simplification.
|
* bullet-2.66 src\LinearMath\btQuaternion.h
|
||||||
|
* The dependancies on base class btQuadWord have been removed for
|
||||||
|
* simplification.
|
||||||
* Added gl matrix conversion method.
|
* Added gl matrix conversion method.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Copyright (c) 2003-2006 Gino van den Bergen / Erwin Coumans http://continuousphysics.com/Bullet/
|
Copyright (c) 2003-2006 Gino van den Bergen / Erwin Coumans
|
||||||
|
http://continuousphysics.com/Bullet/
|
||||||
|
|
||||||
This software is provided 'as-is', without any express or implied warranty.
|
This software is provided 'as-is', without any express or implied warranty.
|
||||||
In no event will the authors be held liable for any damages arising from the use of this software.
|
In no event will the authors be held liable for any damages arising from the
|
||||||
|
use of this software.
|
||||||
Permission is granted to anyone to use this software for any purpose,
|
Permission is granted to anyone to use this software for any purpose,
|
||||||
including commercial applications, and to alter it and redistribute it freely,
|
including commercial applications, and to alter it and redistribute it freely,
|
||||||
subject to the following restrictions:
|
subject to the following restrictions:
|
||||||
|
|
||||||
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
|
1. The origin of this software must not be misrepresented; you must not claim
|
||||||
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
|
that you wrote the original software. If you use this software in a product,
|
||||||
|
an acknowledgment in the product documentation would be appreciated but is
|
||||||
|
not required.
|
||||||
|
2. Altered source versions must be plainly marked as such, and must not be
|
||||||
|
misrepresented as being the original software.
|
||||||
3. This notice may not be removed or altered from any source distribution.
|
3. This notice may not be removed or altered from any source distribution.
|
||||||
*/
|
*/
|
||||||
#ifndef __QUATERNION_H__
|
#ifndef __QUATERNION_H__
|
||||||
#define __QUATERNION_H__
|
#define __QUATERNION_H__
|
||||||
|
|
||||||
#include "Vector3.h"
|
#include "Vector3.h"
|
||||||
#include <SupportDefs.h> //pout FLT_EPSILON
|
#include <SupportDefs.h>
|
||||||
|
|
||||||
class Quaternion {
|
class Quaternion {
|
||||||
protected:
|
protected:
|
||||||
@@ -48,7 +56,7 @@ public:
|
|||||||
*((Quaternion*)this) = q;
|
*((Quaternion*)this) = q;
|
||||||
}
|
}
|
||||||
|
|
||||||
Quaternion(const float& x, const float& y, const float& z,const float& w)
|
Quaternion(const float& x, const float& y, const float& z, const float& w)
|
||||||
{
|
{
|
||||||
m_x = x, m_y = y, m_z = z, m_w = w;
|
m_x = x, m_y = y, m_z = z, m_w = w;
|
||||||
}
|
}
|
||||||
@@ -77,19 +85,19 @@ public:
|
|||||||
|
|
||||||
void setValue(const float& x, const float& y, const float& z)
|
void setValue(const float& x, const float& y, const float& z)
|
||||||
{
|
{
|
||||||
m_x=x;
|
m_x = x;
|
||||||
m_y=y;
|
m_y = y;
|
||||||
m_z=z;
|
m_z = z;
|
||||||
m_w = 0.f;
|
m_w = 0.f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void setValue(const float& x, const float& y, const float& z,const float& w)
|
void setValue(const float& x, const float& y, const float& z, const float& w)
|
||||||
{
|
{
|
||||||
m_x=x;
|
m_x = x;
|
||||||
m_y=y;
|
m_y = y;
|
||||||
m_z=z;
|
m_z = z;
|
||||||
m_w=w;
|
m_w = w;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -228,7 +236,8 @@ public:
|
|||||||
operator+(const Quaternion& q2) const
|
operator+(const Quaternion& q2) const
|
||||||
{
|
{
|
||||||
const Quaternion& q1 = *this;
|
const Quaternion& q1 = *this;
|
||||||
return Quaternion(q1.x() + q2.x(), q1.y() + q2.y(), q1.z() + q2.z(), q1.m_w + q2.m_w);
|
return Quaternion(q1.x() + q2.x(), q1.y() + q2.y(), q1.z() + q2.z(),
|
||||||
|
q1.m_w + q2.m_w);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -236,7 +245,8 @@ public:
|
|||||||
operator-(const Quaternion& q2) const
|
operator-(const Quaternion& q2) const
|
||||||
{
|
{
|
||||||
const Quaternion& q1 = *this;
|
const Quaternion& q1 = *this;
|
||||||
return Quaternion(q1.x() - q2.x(), q1.y() - q2.y(), q1.z() - q2.z(), q1.m_w - q2.m_w);
|
return Quaternion(q1.x() - q2.x(), q1.y() - q2.y(), q1.z() - q2.z(),
|
||||||
|
q1.m_w - q2.m_w);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -249,10 +259,10 @@ public:
|
|||||||
|
|
||||||
inline Quaternion farthest( const Quaternion& qd) const
|
inline Quaternion farthest( const Quaternion& qd) const
|
||||||
{
|
{
|
||||||
Quaternion diff,sum;
|
Quaternion diff, sum;
|
||||||
diff = *this - qd;
|
diff = *this - qd;
|
||||||
sum = *this + qd;
|
sum = *this + qd;
|
||||||
if( diff.dot(diff) > sum.dot(sum) )
|
if (diff.dot(diff) > sum.dot(sum))
|
||||||
return qd;
|
return qd;
|
||||||
return (-qd);
|
return (-qd);
|
||||||
}
|
}
|
||||||
@@ -261,8 +271,7 @@ public:
|
|||||||
Quaternion slerp(const Quaternion& q, const float& t) const
|
Quaternion slerp(const Quaternion& q, const float& t) const
|
||||||
{
|
{
|
||||||
float theta = angle(q);
|
float theta = angle(q);
|
||||||
if (theta != 0.0f)
|
if (theta != 0.0f) {
|
||||||
{
|
|
||||||
float d = 1.0f / sin(theta);
|
float d = 1.0f / sin(theta);
|
||||||
float s0 = sin((1.0f - t) * theta);
|
float s0 = sin((1.0f - t) * theta);
|
||||||
float s1 = sin(t * theta);
|
float s1 = sin(t * theta);
|
||||||
@@ -270,16 +279,14 @@ public:
|
|||||||
(m_y * s0 + q.y() * s1) * d,
|
(m_y * s0 + q.y() * s1) * d,
|
||||||
(m_z * s0 + q.z() * s1) * d,
|
(m_z * s0 + q.z() * s1) * d,
|
||||||
(m_w * s0 + q.m_w * s1) * d);
|
(m_w * s0 + q.m_w * s1) * d);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void toOpenGLMatrix(float m[4][4]){
|
void toOpenGLMatrix(float m[4][4])
|
||||||
|
{
|
||||||
float wx, wy, wz, xx, yy, yz, xy, xz, zz, x2, y2, z2;
|
float wx, wy, wz, xx, yy, yz, xy, xz, zz, x2, y2, z2;
|
||||||
|
|
||||||
// calculate coefficients
|
// calculate coefficients
|
||||||
@@ -316,7 +323,8 @@ operator-(const Quaternion& q)
|
|||||||
|
|
||||||
inline Quaternion
|
inline Quaternion
|
||||||
operator*(const Quaternion& q1, const Quaternion& q2) {
|
operator*(const Quaternion& q1, const Quaternion& q2) {
|
||||||
return Quaternion(q1.w() * q2.x() + q1.x() * q2.w() + q1.y() * q2.z() - q1.z() * q2.y(),
|
return Quaternion(
|
||||||
|
q1.w() * q2.x() + q1.x() * q2.w() + q1.y() * q2.z() - q1.z() * q2.y(),
|
||||||
q1.w() * q2.y() + q1.y() * q2.w() + q1.z() * q2.x() - q1.x() * q2.z(),
|
q1.w() * q2.y() + q1.y() * q2.w() + q1.z() * q2.x() - q1.x() * q2.z(),
|
||||||
q1.w() * q2.z() + q1.z() * q2.w() + q1.x() * q2.y() - q1.y() * q2.x(),
|
q1.w() * q2.z() + q1.z() * q2.w() + q1.x() * q2.y() - q1.y() * q2.x(),
|
||||||
q1.w() * q2.w() - q1.x() * q2.x() - q1.y() * q2.y() - q1.z() * q2.z());
|
q1.w() * q2.w() - q1.x() * q2.x() - q1.y() * q2.y() - q1.z() * q2.z());
|
||||||
@@ -378,8 +386,9 @@ slerp(const Quaternion& q1, const Quaternion& q2, const float& t)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Game Programming Gems 2.10. make sure v0,v1 are normalized
|
||||||
inline Quaternion
|
inline Quaternion
|
||||||
shortestArcQuat(const Vector3& v0, const Vector3& v1) // Game Programming Gems 2.10. make sure v0,v1 are normalized
|
shortestArcQuat(const Vector3& v0, const Vector3& v1)
|
||||||
{
|
{
|
||||||
Vector3 c = v0.cross(v1);
|
Vector3 c = v0.cross(v1);
|
||||||
float d = v0.dot(v1);
|
float d = v0.dot(v1);
|
||||||
|
|||||||
@@ -186,7 +186,7 @@ void
|
|||||||
RenderView::_DeleteScene()
|
RenderView::_DeleteScene()
|
||||||
{
|
{
|
||||||
MeshInstanceList::iterator it = fMeshInstances.begin();
|
MeshInstanceList::iterator it = fMeshInstances.begin();
|
||||||
for(; it != fMeshInstances.end(); it++) {
|
for (; it != fMeshInstances.end(); it++) {
|
||||||
delete (*it);
|
delete (*it);
|
||||||
}
|
}
|
||||||
fMeshInstances.clear();
|
fMeshInstances.clear();
|
||||||
@@ -231,7 +231,7 @@ RenderView::_Render()
|
|||||||
fLastFrameTime = time;
|
fLastFrameTime = time;
|
||||||
|
|
||||||
MeshInstanceList::iterator it = fMeshInstances.begin();
|
MeshInstanceList::iterator it = fMeshInstances.begin();
|
||||||
for(; it != fMeshInstances.end(); it++) {
|
for (; it != fMeshInstances.end(); it++) {
|
||||||
(*it)->Update(deltaTime);
|
(*it)->Update(deltaTime);
|
||||||
(*it)->Render();
|
(*it)->Render();
|
||||||
}
|
}
|
||||||
|
|||||||
+49
-18
@@ -9,22 +9,30 @@
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
*
|
*
|
||||||
* This is a refactored and stripped down version of bullet-2.66 src\LinearMath\btVector3.h
|
* This is a refactored and stripped down version of bullet-2.66
|
||||||
* The dependancies on base class btQuadWord have been removed for simplification.
|
* src\LinearMath\btVector3.h
|
||||||
|
* The dependancies on base class btQuadWord have been removed for
|
||||||
|
* simplification.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Copyright (c) 2003-2006 Gino van den Bergen / Erwin Coumans http://continuousphysics.com/Bullet/
|
Copyright (c) 2003-2006 Gino van den Bergen / Erwin Coumans
|
||||||
|
http://continuousphysics.com/Bullet/
|
||||||
|
|
||||||
This software is provided 'as-is', without any express or implied warranty.
|
This software is provided 'as-is', without any express or implied warranty.
|
||||||
In no event will the authors be held liable for any damages arising from the use of this software.
|
In no event will the authors be held liable for any damages arising from the
|
||||||
|
use of this software.
|
||||||
Permission is granted to anyone to use this software for any purpose,
|
Permission is granted to anyone to use this software for any purpose,
|
||||||
including commercial applications, and to alter it and redistribute it freely,
|
including commercial applications, and to alter it and redistribute it freely,
|
||||||
subject to the following restrictions:
|
subject to the following restrictions:
|
||||||
|
|
||||||
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
|
1. The origin of this software must not be misrepresented; you must not claim
|
||||||
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
|
that you wrote the original software. If you use this software in a product,
|
||||||
|
an acknowledgment in the product documentation would be appreciated but is
|
||||||
|
not required.
|
||||||
|
2. Altered source versions must be plainly marked as such, and must not be
|
||||||
|
misrepresented as being the original software.
|
||||||
3. This notice may not be removed or altered from any source distribution.
|
3. This notice may not be removed or altered from any source distribution.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -70,9 +78,9 @@ public:
|
|||||||
|
|
||||||
inline void setValue(const float& x, const float& y, const float& z)
|
inline void setValue(const float& x, const float& y, const float& z)
|
||||||
{
|
{
|
||||||
m_x=x;
|
m_x = x;
|
||||||
m_y=y;
|
m_y = y;
|
||||||
m_z=z;
|
m_z = z;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline Vector3& operator+=(const Vector3& v)
|
inline Vector3& operator+=(const Vector3& v)
|
||||||
@@ -167,9 +175,9 @@ public:
|
|||||||
|
|
||||||
inline float triple(const Vector3& v1, const Vector3& v2) const
|
inline float triple(const Vector3& v1, const Vector3& v2) const
|
||||||
{
|
{
|
||||||
return m_x * (v1.y() * v2.z() - v1.z() * v2.y()) +
|
return m_x * (v1.y() * v2.z() - v1.z() * v2.y())
|
||||||
m_y * (v1.z() * v2.x() - v1.x() * v2.z()) +
|
+ m_y * (v1.z() * v2.x() - v1.x() * v2.z())
|
||||||
m_z * (v1.x() * v2.y() - v1.y() * v2.x());
|
+ m_z * (v1.x() * v2.y() - v1.y() * v2.x());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -203,7 +211,7 @@ public:
|
|||||||
m_x = s * v0.x() + rt * v1.x();
|
m_x = s * v0.x() + rt * v1.x();
|
||||||
m_y = s * v0.y() + rt * v1.y();
|
m_y = s * v0.y() + rt * v1.y();
|
||||||
m_z = s * v0.z() + rt * v1.z();
|
m_z = s * v0.z() + rt * v1.z();
|
||||||
//don't do the unused w component
|
// don't do the unused w component
|
||||||
// m_co[3] = s * v0[3] + rt * v1[3];
|
// m_co[3] = s * v0[3] + rt * v1[3];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -224,42 +232,49 @@ public:
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
inline Vector3
|
inline Vector3
|
||||||
operator+(const Vector3& v1, const Vector3& v2)
|
operator+(const Vector3& v1, const Vector3& v2)
|
||||||
{
|
{
|
||||||
return Vector3(v1.x() + v2.x(), v1.y() + v2.y(), v1.z() + v2.z());
|
return Vector3(v1.x() + v2.x(), v1.y() + v2.y(), v1.z() + v2.z());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline Vector3
|
inline Vector3
|
||||||
operator*(const Vector3& v1, const Vector3& v2)
|
operator*(const Vector3& v1, const Vector3& v2)
|
||||||
{
|
{
|
||||||
return Vector3(v1.x() * v2.x(), v1.y() * v2.y(), v1.z() * v2.z());
|
return Vector3(v1.x() * v2.x(), v1.y() * v2.y(), v1.z() * v2.z());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline Vector3
|
inline Vector3
|
||||||
operator-(const Vector3& v1, const Vector3& v2)
|
operator-(const Vector3& v1, const Vector3& v2)
|
||||||
{
|
{
|
||||||
return Vector3(v1.x() - v2.x(), v1.y() - v2.y(), v1.z() - v2.z());
|
return Vector3(v1.x() - v2.x(), v1.y() - v2.y(), v1.z() - v2.z());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline Vector3
|
inline Vector3
|
||||||
operator-(const Vector3& v)
|
operator-(const Vector3& v)
|
||||||
{
|
{
|
||||||
return Vector3(-v.x(), -v.y(), -v.z());
|
return Vector3(-v.x(), -v.y(), -v.z());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline Vector3
|
inline Vector3
|
||||||
operator*(const Vector3& v, const float& s)
|
operator*(const Vector3& v, const float& s)
|
||||||
{
|
{
|
||||||
return Vector3(v.x() * s, v.y() * s, v.z() * s);
|
return Vector3(v.x() * s, v.y() * s, v.z() * s);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline Vector3
|
inline Vector3
|
||||||
operator*(const float& s, const Vector3& v)
|
operator*(const float& s, const Vector3& v)
|
||||||
{
|
{
|
||||||
return v * s;
|
return v * s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline Vector3
|
inline Vector3
|
||||||
operator/(const Vector3& v, const float& s)
|
operator/(const Vector3& v, const float& s)
|
||||||
{
|
{
|
||||||
@@ -267,18 +282,21 @@ operator/(const Vector3& v, const float& s)
|
|||||||
return v * (1.0f / s);
|
return v * (1.0f / s);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline Vector3
|
inline Vector3
|
||||||
operator/(const Vector3& v1, const Vector3& v2)
|
operator/(const Vector3& v1, const Vector3& v2)
|
||||||
{
|
{
|
||||||
return Vector3(v1.x() / v2.x(),v1.y() / v2.y(),v1.z() / v2.z());
|
return Vector3(v1.x() / v2.x(),v1.y() / v2.y(),v1.z() / v2.z());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline float
|
inline float
|
||||||
dot(const Vector3& v1, const Vector3& v2)
|
dot(const Vector3& v1, const Vector3& v2)
|
||||||
{
|
{
|
||||||
return v1.dot(v2);
|
return v1.dot(v2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline float
|
inline float
|
||||||
distance2(const Vector3& v1, const Vector3& v2)
|
distance2(const Vector3& v1, const Vector3& v2)
|
||||||
{
|
{
|
||||||
@@ -292,24 +310,28 @@ distance(const Vector3& v1, const Vector3& v2)
|
|||||||
return v1.distance(v2);
|
return v1.distance(v2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline float
|
inline float
|
||||||
angle(const Vector3& v1, const Vector3& v2)
|
angle(const Vector3& v1, const Vector3& v2)
|
||||||
{
|
{
|
||||||
return v1.angle(v2);
|
return v1.angle(v2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline Vector3
|
inline Vector3
|
||||||
cross(const Vector3& v1, const Vector3& v2)
|
cross(const Vector3& v1, const Vector3& v2)
|
||||||
{
|
{
|
||||||
return v1.cross(v2);
|
return v1.cross(v2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline float
|
inline float
|
||||||
triple(const Vector3& v1, const Vector3& v2, const Vector3& v3)
|
triple(const Vector3& v1, const Vector3& v2, const Vector3& v3)
|
||||||
{
|
{
|
||||||
return v1.triple(v2, v3);
|
return v1.triple(v2, v3);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline Vector3
|
inline Vector3
|
||||||
lerp(const Vector3& v1, const Vector3& v2, const float& t)
|
lerp(const Vector3& v1, const Vector3& v2, const float& t)
|
||||||
{
|
{
|
||||||
@@ -317,27 +339,36 @@ lerp(const Vector3& v1, const Vector3& v2, const float& t)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline bool operator==(const Vector3& p1, const Vector3& p2)
|
inline bool
|
||||||
|
operator==(const Vector3& p1, const Vector3& p2)
|
||||||
{
|
{
|
||||||
return p1.x() == p2.x() && p1.y() == p2.y() && p1.z() == p2.z();
|
return p1.x() == p2.x() && p1.y() == p2.y() && p1.z() == p2.z();
|
||||||
}
|
}
|
||||||
|
|
||||||
inline float Vector3::distance2(const Vector3& v) const
|
|
||||||
|
inline float
|
||||||
|
Vector3::distance2(const Vector3& v) const
|
||||||
{
|
{
|
||||||
return (v - *this).length2();
|
return (v - *this).length2();
|
||||||
}
|
}
|
||||||
|
|
||||||
inline float Vector3::distance(const Vector3& v) const
|
|
||||||
|
inline float
|
||||||
|
Vector3::distance(const Vector3& v) const
|
||||||
{
|
{
|
||||||
return (v - *this).length();
|
return (v - *this).length();
|
||||||
}
|
}
|
||||||
|
|
||||||
inline Vector3 Vector3::normalized() const
|
|
||||||
|
inline Vector3
|
||||||
|
Vector3::normalized() const
|
||||||
{
|
{
|
||||||
return *this / length();
|
return *this / length();
|
||||||
}
|
}
|
||||||
|
|
||||||
inline Vector3 Vector3::rotate( const Vector3& wAxis, const float angle )
|
|
||||||
|
inline Vector3
|
||||||
|
Vector3::rotate( const Vector3& wAxis, const float angle )
|
||||||
{
|
{
|
||||||
// wAxis must be a unit lenght vector
|
// wAxis must be a unit lenght vector
|
||||||
|
|
||||||
|
|||||||
@@ -91,8 +91,8 @@ VideoFileTexture::_Load(const char* fileName)
|
|||||||
format.u.raw_video.display.format = fVideoBitmap->ColorSpace();
|
format.u.raw_video.display.format = fVideoBitmap->ColorSpace();
|
||||||
format.u.raw_video.display.line_width = (int32) bounds.Width();
|
format.u.raw_video.display.line_width = (int32) bounds.Width();
|
||||||
format.u.raw_video.display.line_count = (int32) bounds.Height();
|
format.u.raw_video.display.line_count = (int32) bounds.Height();
|
||||||
format.u.raw_video.display.bytes_per_row =
|
format.u.raw_video.display.bytes_per_row
|
||||||
fVideoBitmap->BytesPerRow();
|
= fVideoBitmap->BytesPerRow();
|
||||||
|
|
||||||
err = fVideoTrack->DecodedFormat(&format);
|
err = fVideoTrack->DecodedFormat(&format);
|
||||||
if (err != B_OK) {
|
if (err != B_OK) {
|
||||||
@@ -120,8 +120,8 @@ VideoFileTexture::Update(float /*dt*/) {
|
|||||||
// TODO loop
|
// TODO loop
|
||||||
int64 frameCount = 0;
|
int64 frameCount = 0;
|
||||||
media_header mh;
|
media_header mh;
|
||||||
status_t err =
|
status_t err
|
||||||
fVideoTrack->ReadFrames(fVideoBitmap->Bits(), &frameCount, &mh);
|
= fVideoTrack->ReadFrames(fVideoBitmap->Bits(), &frameCount, &mh);
|
||||||
if (err) {
|
if (err) {
|
||||||
printf("BMediaTrack::ReadFrames error -- %s\n", strerror(err));
|
printf("BMediaTrack::ReadFrames error -- %s\n", strerror(err));
|
||||||
return;
|
return;
|
||||||
|
|||||||
Reference in New Issue
Block a user