Compare commits
4 Commits
temp-unity
...
temp_bge_m
Author | SHA1 | Date | |
---|---|---|---|
5c1f4beb63 | |||
a501eb51e2 | |||
5f903a5edd | |||
d54e71c8bf |
@@ -257,7 +257,7 @@ void IK_QJacobianSolver::ConstrainPoleVector(IK_QSegment *root, std::list<IK_QTa
|
||||
// desired rotation based on the pole vector constraint. we use
|
||||
// transpose instead of inverse because we have orthogonal matrices
|
||||
// anyway, and in case of a singular matrix we don't get NaN's.
|
||||
MT_Transform trans(MT_Point3(0, 0, 0), polemat.transposed() * mat);
|
||||
MT_Transform trans(MT_Vector3(0, 0, 0), polemat.transposed() * mat);
|
||||
m_rootmatrix = trans * m_rootmatrix;
|
||||
}
|
||||
}
|
||||
|
@@ -117,10 +117,10 @@ public:
|
||||
MT_Vector3 TranslationChange() const;
|
||||
|
||||
// the start and end of the segment
|
||||
const MT_Point3 &GlobalStart() const
|
||||
const MT_Vector3 &GlobalStart() const
|
||||
{ return m_global_start; }
|
||||
|
||||
const MT_Point3 &GlobalEnd() const
|
||||
const MT_Vector3 &GlobalEnd() const
|
||||
{ return m_global_transform.getOrigin(); }
|
||||
|
||||
// the global transformation at the end of the segment
|
||||
@@ -201,7 +201,7 @@ protected:
|
||||
MT_Scalar m_max_extension;
|
||||
|
||||
// accumulated transformations starting from root
|
||||
MT_Point3 m_global_start;
|
||||
MT_Vector3 m_global_start;
|
||||
MT_Transform m_global_transform;
|
||||
|
||||
// number degrees of freedom, (first) id of this segments DOF's
|
||||
|
@@ -184,7 +184,7 @@ private :
|
||||
|
||||
|
||||
MT_Transform seg_t_pre_rot(
|
||||
MT_Point3(
|
||||
MT_Vector3(
|
||||
seg_start->seg_start[0],
|
||||
seg_start->seg_start[1],
|
||||
seg_start->seg_start[2]
|
||||
@@ -196,11 +196,11 @@ private :
|
||||
|
||||
|
||||
|
||||
MT_Transform seg_t_rot(MT_Point3(0,0,0),seg_rot);
|
||||
MT_Transform seg_t_rot(MT_Vector3(0,0,0),seg_rot);
|
||||
MT_Transform seg_local = seg_t_pre_rot * seg_t_rot * translation;
|
||||
|
||||
MT_Vector3 bone_start = global_transform *
|
||||
MT_Point3(
|
||||
MT_Vector3(
|
||||
seg_start->seg_start[0],
|
||||
seg_start->seg_start[1],
|
||||
seg_start->seg_start[2]
|
||||
|
@@ -37,7 +37,6 @@ set(SRC
|
||||
intern/MT_Matrix3x3.cpp
|
||||
intern/MT_Matrix4x4.cpp
|
||||
intern/MT_Plane3.cpp
|
||||
intern/MT_Point3.cpp
|
||||
intern/MT_Quaternion.cpp
|
||||
intern/MT_Transform.cpp
|
||||
intern/MT_Vector2.cpp
|
||||
@@ -53,15 +52,10 @@ set(SRC
|
||||
include/MT_MinMax.h
|
||||
include/MT_Optimize.h
|
||||
include/MT_Plane3.h
|
||||
include/MT_Point2.h
|
||||
include/MT_Point3.h
|
||||
include/MT_Quaternion.h
|
||||
include/MT_Scalar.h
|
||||
include/MT_Stream.h
|
||||
include/MT_Transform.h
|
||||
include/MT_Tuple2.h
|
||||
include/MT_Tuple3.h
|
||||
include/MT_Tuple4.h
|
||||
include/MT_Vector2.h
|
||||
include/MT_Vector3.h
|
||||
include/MT_Vector4.h
|
||||
@@ -71,9 +65,6 @@ set(SRC
|
||||
|
||||
include/MT_Matrix3x3.inl
|
||||
include/MT_Matrix4x4.inl
|
||||
include/MT_Plane3.inl
|
||||
include/MT_Point2.inl
|
||||
include/MT_Point3.inl
|
||||
include/MT_Quaternion.inl
|
||||
include/MT_Vector2.inl
|
||||
include/MT_Vector3.inl
|
||||
|
@@ -46,7 +46,6 @@
|
||||
|
||||
#include "MT_Scalar.h"
|
||||
|
||||
class MT_Point3;
|
||||
class MT_Vector3;
|
||||
|
||||
class MT_CmMatrix4x4
|
||||
@@ -54,24 +53,25 @@ class MT_CmMatrix4x4
|
||||
|
||||
public :
|
||||
|
||||
MT_CmMatrix4x4(
|
||||
const float value[4][4]
|
||||
);
|
||||
template <typename T>
|
||||
MT_CmMatrix4x4(const T value[4][4])
|
||||
{
|
||||
for (int i=0;i<4;i++)
|
||||
{
|
||||
for (int j=0;j<4;j++)
|
||||
m_V[i][j] = (MT_Scalar)value[i][j];
|
||||
}
|
||||
}
|
||||
|
||||
MT_CmMatrix4x4(
|
||||
);
|
||||
|
||||
|
||||
MT_CmMatrix4x4(
|
||||
const double value[16]
|
||||
);
|
||||
|
||||
MT_CmMatrix4x4(
|
||||
const MT_CmMatrix4x4 & other
|
||||
);
|
||||
|
||||
MT_CmMatrix4x4(
|
||||
const MT_Point3& orig,
|
||||
const MT_Vector3& orig,
|
||||
const MT_Vector3& dir,
|
||||
const MT_Vector3 up
|
||||
);
|
||||
@@ -85,20 +85,20 @@ public :
|
||||
const MT_CmMatrix4x4 & other
|
||||
);
|
||||
|
||||
double*
|
||||
MT_Scalar*
|
||||
getPointer(
|
||||
);
|
||||
|
||||
const
|
||||
double*
|
||||
MT_Scalar*
|
||||
getPointer(
|
||||
) const;
|
||||
|
||||
void
|
||||
setElem(
|
||||
int pos,
|
||||
double newvalue
|
||||
);
|
||||
template <typename T>
|
||||
void setElem(int pos, T newvalue)
|
||||
{
|
||||
m_Vflat[pos] = (MT_Scalar)newvalue;
|
||||
}
|
||||
|
||||
MT_Vector3
|
||||
GetRight(
|
||||
@@ -112,7 +112,7 @@ public :
|
||||
GetDir(
|
||||
) const;
|
||||
|
||||
MT_Point3
|
||||
MT_Vector3
|
||||
GetPos(
|
||||
) const;
|
||||
|
||||
@@ -121,7 +121,7 @@ public :
|
||||
const MT_Vector3 & v
|
||||
);
|
||||
|
||||
double&
|
||||
MT_Scalar&
|
||||
operator (
|
||||
) (int row,int col) { return m_V[col][row]; }
|
||||
|
||||
@@ -139,8 +139,8 @@ public :
|
||||
protected:
|
||||
union
|
||||
{
|
||||
double m_V[4][4];
|
||||
double m_Vflat[16];
|
||||
MT_Scalar m_V[4][4];
|
||||
MT_Scalar m_Vflat[16];
|
||||
};
|
||||
};
|
||||
|
||||
|
@@ -55,8 +55,8 @@
|
||||
class MT_Matrix3x3 {
|
||||
public:
|
||||
MT_Matrix3x3() {}
|
||||
MT_Matrix3x3(const float *m) { setValue(m); }
|
||||
MT_Matrix3x3(const double *m) { setValue(m); }
|
||||
template <typename T>
|
||||
MT_Matrix3x3(const T *m) { setValue(m); }
|
||||
MT_Matrix3x3(const MT_Quaternion& q) { setRotation(q); }
|
||||
|
||||
MT_Matrix3x3(const MT_Quaternion& q, const MT_Vector3& s) {
|
||||
@@ -97,28 +97,18 @@ public:
|
||||
m_el[i][2] = v[2];
|
||||
}
|
||||
|
||||
void setValue(const float *m) {
|
||||
template <typename T>
|
||||
void setValue(const T *m) {
|
||||
m_el[0][0] = *m++; m_el[1][0] = *m++; m_el[2][0] = *m++; m++;
|
||||
m_el[0][1] = *m++; m_el[1][1] = *m++; m_el[2][1] = *m++; m++;
|
||||
m_el[0][2] = *m++; m_el[1][2] = *m++; m_el[2][2] = *m;
|
||||
}
|
||||
|
||||
void setValue(const double *m) {
|
||||
m_el[0][0] = *m++; m_el[1][0] = *m++; m_el[2][0] = *m++; m++;
|
||||
m_el[0][1] = *m++; m_el[1][1] = *m++; m_el[2][1] = *m++; m++;
|
||||
m_el[0][2] = *m++; m_el[1][2] = *m++; m_el[2][2] = *m;
|
||||
}
|
||||
|
||||
void setValue3x3(const float *m) {
|
||||
m_el[0][0] = *m++; m_el[1][0] = *m++; m_el[2][0] = *m++;
|
||||
m_el[0][1] = *m++; m_el[1][1] = *m++; m_el[2][1] = *m++;
|
||||
m_el[0][2] = *m++; m_el[1][2] = *m++; m_el[2][2] = *m;
|
||||
}
|
||||
|
||||
void setValue3x3(const double *m) {
|
||||
m_el[0][0] = *m++; m_el[1][0] = *m++; m_el[2][0] = *m++;
|
||||
m_el[0][1] = *m++; m_el[1][1] = *m++; m_el[2][1] = *m++;
|
||||
m_el[0][2] = *m++; m_el[1][2] = *m++; m_el[2][2] = *m;
|
||||
template <typename T>
|
||||
void setValue3x3(const T *m) {
|
||||
m_el[0][0] = (MT_Scalar)*m++; m_el[1][0] = (MT_Scalar)*m++; m_el[2][0] = (MT_Scalar)*m++;
|
||||
m_el[0][1] = (MT_Scalar)*m++; m_el[1][1] = (MT_Scalar)*m++; m_el[2][1] = (MT_Scalar)*m++;
|
||||
m_el[0][2] = (MT_Scalar)*m++; m_el[1][2] = (MT_Scalar)*m++; m_el[2][2] = (MT_Scalar)*m;
|
||||
}
|
||||
|
||||
void setValue(MT_Scalar xx, MT_Scalar xy, MT_Scalar xz,
|
||||
@@ -205,28 +195,18 @@ public:
|
||||
MT_Scalar(0.0), MT_Scalar(0.0), MT_Scalar(1.0));
|
||||
}
|
||||
|
||||
void getValue(float *m) const {
|
||||
*m++ = (float) m_el[0][0]; *m++ = (float) m_el[1][0]; *m++ = (float) m_el[2][0]; *m++ = (float) 0.0;
|
||||
*m++ = (float) m_el[0][1]; *m++ = (float) m_el[1][1]; *m++ = (float) m_el[2][1]; *m++ = (float) 0.0;
|
||||
*m++ = (float) m_el[0][2]; *m++ = (float) m_el[1][2]; *m++ = (float) m_el[2][2]; *m = (float) 0.0;
|
||||
template <typename T>
|
||||
void getValue(T *m) const {
|
||||
*m++ = (T)m_el[0][0]; *m++ = (T)m_el[1][0]; *m++ = (T)m_el[2][0]; *m++ = (T)0;
|
||||
*m++ = (T)m_el[0][1]; *m++ = (T)m_el[1][1]; *m++ = (T)m_el[2][1]; *m++ = (T)0;
|
||||
*m++ = (T)m_el[0][2]; *m++ = (T)m_el[1][2]; *m++ = (T)m_el[2][2]; *m = (T)0;
|
||||
}
|
||||
|
||||
void getValue(double *m) const {
|
||||
*m++ = m_el[0][0]; *m++ = m_el[1][0]; *m++ = m_el[2][0]; *m++ = 0.0;
|
||||
*m++ = m_el[0][1]; *m++ = m_el[1][1]; *m++ = m_el[2][1]; *m++ = 0.0;
|
||||
*m++ = m_el[0][2]; *m++ = m_el[1][2]; *m++ = m_el[2][2]; *m = 0.0;
|
||||
}
|
||||
|
||||
void getValue3x3(float *m) const {
|
||||
*m++ = (float) m_el[0][0]; *m++ = (float) m_el[1][0]; *m++ = (float) m_el[2][0];
|
||||
*m++ = (float) m_el[0][1]; *m++ = (float) m_el[1][1]; *m++ = (float) m_el[2][1];
|
||||
*m++ = (float) m_el[0][2]; *m++ = (float) m_el[1][2]; *m++ = (float) m_el[2][2];
|
||||
}
|
||||
|
||||
void getValue3x3(double *m) const {
|
||||
*m++ = m_el[0][0]; *m++ = m_el[1][0]; *m++ = m_el[2][0];
|
||||
*m++ = m_el[0][1]; *m++ = m_el[1][1]; *m++ = m_el[2][1];
|
||||
*m++ = m_el[0][2]; *m++ = m_el[1][2]; *m++ = m_el[2][2];
|
||||
template <typename T>
|
||||
void getValue3x3(T *m) const {
|
||||
*m++ = (T)m_el[0][0]; *m++ = (T)m_el[1][0]; *m++ = (T)m_el[2][0];
|
||||
*m++ = (T)m_el[0][1]; *m++ = (T)m_el[1][1]; *m++ = (T)m_el[2][1];
|
||||
*m++ = (T)m_el[0][2]; *m++ = (T)m_el[1][2]; *m++ = (T)m_el[2][2];
|
||||
}
|
||||
|
||||
MT_Quaternion getRotation() const;
|
||||
|
@@ -55,11 +55,8 @@ public:
|
||||
/**
|
||||
* Initialize all fields with the values pointed at by m. A
|
||||
* contigous block of 16 values is read. */
|
||||
MT_Matrix4x4(const float *m) { setValue(m); }
|
||||
/**
|
||||
* Initialize all fields with the values pointed at by m. A
|
||||
* contigous block of 16 values is read. */
|
||||
MT_Matrix4x4(const double *m) { setValue(m); }
|
||||
template <typename T>
|
||||
MT_Matrix4x4(const T *m) { setValue(m); }
|
||||
|
||||
/**
|
||||
* Initialise with these 16 explicit values.
|
||||
@@ -101,23 +98,14 @@ public:
|
||||
|
||||
/**
|
||||
* Set the matrix to the values pointer at by m. A contiguous
|
||||
* block of 16 values is copied. */
|
||||
void setValue(const float *m) {
|
||||
m_el[0][0] = *m++; m_el[1][0] = *m++; m_el[2][0] = *m++; m_el[3][0] = *m++;
|
||||
m_el[0][1] = *m++; m_el[1][1] = *m++; m_el[2][1] = *m++; m_el[3][1] = *m++;
|
||||
m_el[0][2] = *m++; m_el[1][2] = *m++; m_el[2][2] = *m++; m_el[3][2] = *m++;
|
||||
m_el[0][3] = *m++; m_el[1][3] = *m++; m_el[2][3] = *m++; m_el[3][3] = *m;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the matrix to the values pointer at by m. A contiguous
|
||||
* block of 16 values is copied.
|
||||
* block of 16 values is copied.
|
||||
*/
|
||||
void setValue(const double *m) {
|
||||
m_el[0][0] = *m++; m_el[1][0] = *m++; m_el[2][0] = *m++; m_el[3][0] = *m++;
|
||||
m_el[0][1] = *m++; m_el[1][1] = *m++; m_el[2][1] = *m++; m_el[3][1] = *m++;
|
||||
m_el[0][2] = *m++; m_el[1][2] = *m++; m_el[2][2] = *m++; m_el[3][2] = *m++;
|
||||
m_el[0][3] = *m++; m_el[1][3] = *m++; m_el[2][3] = *m++; m_el[3][3] = *m;
|
||||
template <typename T>
|
||||
void setValue(const T *m) {
|
||||
m_el[0][0] = (MT_Scalar)*m++; m_el[1][0] = (MT_Scalar)*m++; m_el[2][0] = (MT_Scalar)*m++; m_el[3][0] = (MT_Scalar)*m++;
|
||||
m_el[0][1] = (MT_Scalar)*m++; m_el[1][1] = (MT_Scalar)*m++; m_el[2][1] = (MT_Scalar)*m++; m_el[3][1] = (MT_Scalar)*m++;
|
||||
m_el[0][2] = (MT_Scalar)*m++; m_el[1][2] = (MT_Scalar)*m++; m_el[2][2] = (MT_Scalar)*m++; m_el[3][2] = (MT_Scalar)*m++;
|
||||
m_el[0][3] = (MT_Scalar)*m++; m_el[1][3] = (MT_Scalar)*m++; m_el[2][3] = (MT_Scalar)*m++; m_el[3][3] = (MT_Scalar)*m;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -166,28 +154,20 @@ public:
|
||||
/**
|
||||
* Read the element from row i, column j.
|
||||
*/
|
||||
float getElement(int i, int j) {
|
||||
return (float) m_el[i][j];
|
||||
template <typename T>
|
||||
T getElement(int i, int j) {
|
||||
return (T)m_el[i][j];
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy the contents to a contiguous block of 16 floats.
|
||||
*/
|
||||
void getValue(float *m) const {
|
||||
*m++ = (float) m_el[0][0]; *m++ = (float) m_el[1][0]; *m++ = (float) m_el[2][0]; *m++ = (float) m_el[3][0];
|
||||
*m++ = (float) m_el[0][1]; *m++ = (float) m_el[1][1]; *m++ = (float) m_el[2][1]; *m++ = (float) m_el[3][1];
|
||||
*m++ = (float) m_el[0][2]; *m++ = (float) m_el[1][2]; *m++ = (float) m_el[2][2]; *m++ = (float) m_el[3][2];
|
||||
*m++ = (float) m_el[0][3]; *m++ = (float) m_el[1][3]; *m++ = (float) m_el[2][3]; *m = (float) m_el[3][3];
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy the contents to a contiguous block of 16 doubles.
|
||||
*/
|
||||
void getValue(double *m) const {
|
||||
*m++ = m_el[0][0]; *m++ = m_el[1][0]; *m++ = m_el[2][0]; *m++ = m_el[3][0];
|
||||
*m++ = m_el[0][1]; *m++ = m_el[1][1]; *m++ = m_el[2][1]; *m++ = m_el[3][1];
|
||||
*m++ = m_el[0][2]; *m++ = m_el[1][2]; *m++ = m_el[2][2]; *m++ = m_el[3][2];
|
||||
*m++ = m_el[0][3]; *m++ = m_el[1][3]; *m++ = m_el[2][3]; *m = m_el[3][3];
|
||||
template <typename T>
|
||||
void getValue(T *m) const {
|
||||
*m++ = (T)m_el[0][0]; *m++ = (T)m_el[1][0]; *m++ = (T)m_el[2][0]; *m++ = (T)m_el[3][0];
|
||||
*m++ = (T)m_el[0][1]; *m++ = (T)m_el[1][1]; *m++ = (T)m_el[2][1]; *m++ = (T)m_el[3][1];
|
||||
*m++ = (T)m_el[0][2]; *m++ = (T)m_el[1][2]; *m++ = (T)m_el[2][2]; *m++ = (T)m_el[3][2];
|
||||
*m++ = (T)m_el[0][3]; *m++ = (T)m_el[1][3]; *m++ = (T)m_el[2][3]; *m = (T)m_el[3][3];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -33,8 +33,8 @@
|
||||
#ifndef MT_PLANE3
|
||||
#define MT_PLANE3
|
||||
|
||||
#include "MT_Tuple4.h"
|
||||
#include "MT_Point3.h"
|
||||
#include "MT_Vector4.h"
|
||||
#include "MT_Vector3.h"
|
||||
|
||||
/**
|
||||
* A simple 3d plane class.
|
||||
@@ -42,12 +42,12 @@
|
||||
* This class represents a plane in 3d. The internal parameterization used
|
||||
* is n.x + d =0 where n is a unit vector and d is a scalar.
|
||||
*
|
||||
* It inherits data from MT_Tuple4 please see this class for low level
|
||||
* It inherits data from MT_Vector4 please see this class for low level
|
||||
* access to the internal representation.
|
||||
*
|
||||
*/
|
||||
|
||||
class MT_Plane3 : public MT_Tuple4
|
||||
class MT_Plane3 : public MT_Vector4
|
||||
{
|
||||
public :
|
||||
/**
|
||||
@@ -81,7 +81,7 @@ public :
|
||||
MT_Plane3(
|
||||
const MT_Plane3 & p
|
||||
):
|
||||
MT_Tuple4(p)
|
||||
MT_Vector4(p)
|
||||
{
|
||||
}
|
||||
|
||||
|
@@ -48,7 +48,7 @@ GEN_INLINE
|
||||
MT_Plane3::
|
||||
MT_Plane3(
|
||||
):
|
||||
MT_Tuple4()
|
||||
MT_Vector4()
|
||||
{
|
||||
m_co[0] = MT_Scalar(1);
|
||||
m_co[1] = MT_Scalar(0);
|
||||
|
@@ -1,83 +0,0 @@
|
||||
/*
|
||||
* ***** BEGIN GPL LICENSE BLOCK *****
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*
|
||||
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
|
||||
* All rights reserved.
|
||||
*
|
||||
* The Original Code is: all of this file.
|
||||
*
|
||||
* Contributor(s): none yet.
|
||||
*
|
||||
* ***** END GPL LICENSE BLOCK *****
|
||||
*/
|
||||
|
||||
/** \file moto/include/MT_Point2.h
|
||||
* \ingroup moto
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
|
||||
* Copyright (c) 2000 Gino van den Bergen <gino@acm.org>
|
||||
*
|
||||
* Permission to use, copy, modify, distribute and sell this software
|
||||
* and its documentation for any purpose is hereby granted without fee,
|
||||
* provided that the above copyright notice appear in all copies and
|
||||
* that both that copyright notice and this permission notice appear
|
||||
* in supporting documentation. Gino van den Bergen makes no
|
||||
* representations about the suitability of this software for any
|
||||
* purpose. It is provided "as is" without express or implied warranty.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef MT_POINT2_H
|
||||
#define MT_POINT2_H
|
||||
|
||||
#include "MT_Vector2.h"
|
||||
|
||||
class MT_Point2 : public MT_Vector2 {
|
||||
public:
|
||||
MT_Point2() {}
|
||||
MT_Point2(const float *v2) : MT_Vector2(v2) {}
|
||||
MT_Point2(const double *v2) : MT_Vector2(v2) {}
|
||||
MT_Point2(MT_Scalar x2, MT_Scalar y2) : MT_Vector2(x2, y2) {}
|
||||
|
||||
MT_Point2& operator+=(const MT_Vector2& v);
|
||||
MT_Point2& operator-=(const MT_Vector2& v);
|
||||
MT_Point2& operator=(const MT_Vector2& v);
|
||||
|
||||
MT_Scalar distance(const MT_Point2& p) const;
|
||||
MT_Scalar distance2(const MT_Point2& p) const;
|
||||
|
||||
MT_Point2 lerp(const MT_Point2& p, MT_Scalar t) const;
|
||||
};
|
||||
|
||||
MT_Point2 operator+(const MT_Point2& p, const MT_Vector2& v);
|
||||
MT_Point2 operator-(const MT_Point2& p, const MT_Vector2& v);
|
||||
MT_Vector2 operator-(const MT_Point2& p1, const MT_Point2& p2);
|
||||
|
||||
MT_Scalar MT_distance(const MT_Point2& p1, const MT_Point2& p2);
|
||||
MT_Scalar MT_distance2(const MT_Point2& p1, const MT_Point2& p2);
|
||||
|
||||
MT_Point2 MT_lerp(const MT_Point2& p1, const MT_Point2& p2, MT_Scalar t);
|
||||
|
||||
#ifdef GEN_INLINED
|
||||
#include "MT_Point2.inl"
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
@@ -1,54 +0,0 @@
|
||||
#include "MT_Optimize.h"
|
||||
|
||||
GEN_INLINE MT_Point2& MT_Point2::operator+=(const MT_Vector2& v) {
|
||||
m_co[0] += v[0]; m_co[1] += v[1];
|
||||
return *this;
|
||||
}
|
||||
|
||||
GEN_INLINE MT_Point2& MT_Point2::operator-=(const MT_Vector2& v) {
|
||||
m_co[0] -= v[0]; m_co[1] -= v[1];
|
||||
return *this;
|
||||
}
|
||||
|
||||
GEN_INLINE MT_Point2& MT_Point2::operator=(const MT_Vector2& v) {
|
||||
m_co[0] = v[0]; m_co[1] = v[1];
|
||||
return *this;
|
||||
}
|
||||
|
||||
GEN_INLINE MT_Scalar MT_Point2::distance(const MT_Point2& p) const {
|
||||
return (p - *this).length();
|
||||
}
|
||||
|
||||
GEN_INLINE MT_Scalar MT_Point2::distance2(const MT_Point2& p) const {
|
||||
return (p - *this).length2();
|
||||
}
|
||||
|
||||
GEN_INLINE MT_Point2 MT_Point2::lerp(const MT_Point2& p, MT_Scalar t) const {
|
||||
return MT_Point2(m_co[0] + (p[0] - m_co[0]) * t,
|
||||
m_co[1] + (p[1] - m_co[1]) * t);
|
||||
}
|
||||
|
||||
GEN_INLINE MT_Point2 operator+(const MT_Point2& p, const MT_Vector2& v) {
|
||||
return MT_Point2(p[0] + v[0], p[1] + v[1]);
|
||||
}
|
||||
|
||||
GEN_INLINE MT_Point2 operator-(const MT_Point2& p, const MT_Vector2& v) {
|
||||
return MT_Point2(p[0] - v[0], p[1] - v[1]);
|
||||
}
|
||||
|
||||
GEN_INLINE MT_Vector2 operator-(const MT_Point2& p1, const MT_Point2& p2) {
|
||||
return MT_Vector2(p1[0] - p2[0], p1[1] - p2[1]);
|
||||
}
|
||||
|
||||
GEN_INLINE MT_Scalar MT_distance(const MT_Point2& p1, const MT_Point2& p2) {
|
||||
return p1.distance(p2);
|
||||
}
|
||||
|
||||
GEN_INLINE MT_Scalar MT_distance2(const MT_Point2& p1, const MT_Point2& p2) {
|
||||
return p1.distance2(p2);
|
||||
}
|
||||
|
||||
GEN_INLINE MT_Point2 MT_lerp(const MT_Point2& p1, const MT_Point2& p2, MT_Scalar t) {
|
||||
return p1.lerp(p2, t);
|
||||
}
|
||||
|
@@ -1,84 +0,0 @@
|
||||
/*
|
||||
* ***** BEGIN GPL LICENSE BLOCK *****
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*
|
||||
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
|
||||
* All rights reserved.
|
||||
*
|
||||
* The Original Code is: all of this file.
|
||||
*
|
||||
* Contributor(s): none yet.
|
||||
*
|
||||
* ***** END GPL LICENSE BLOCK *****
|
||||
*/
|
||||
|
||||
/** \file moto/include/MT_Point3.h
|
||||
* \ingroup moto
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
|
||||
* Copyright (c) 2000 Gino van den Bergen <gino@acm.org>
|
||||
*
|
||||
* Permission to use, copy, modify, distribute and sell this software
|
||||
* and its documentation for any purpose is hereby granted without fee,
|
||||
* provided that the above copyright notice appear in all copies and
|
||||
* that both that copyright notice and this permission notice appear
|
||||
* in supporting documentation. Gino van den Bergen makes no
|
||||
* representations about the suitability of this software for any
|
||||
* purpose. It is provided "as is" without express or implied warranty.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef MT_POINT_H
|
||||
#define MT_POINT_H
|
||||
|
||||
#include "MT_Vector3.h"
|
||||
|
||||
class MT_Point3 : public MT_Vector3 {
|
||||
public:
|
||||
MT_Point3() {}
|
||||
MT_Point3(const float *v) : MT_Vector3(v) {}
|
||||
MT_Point3(const double *v) : MT_Vector3(v) {}
|
||||
MT_Point3(MT_Scalar xx, MT_Scalar yy, MT_Scalar zz) : MT_Vector3(xx, yy, zz) {}
|
||||
|
||||
MT_Point3& operator+=(const MT_Vector3& v);
|
||||
MT_Point3& operator-=(const MT_Vector3& v);
|
||||
MT_Point3& operator=(const MT_Vector3& v);
|
||||
MT_Point3& operator=(const MT_Point3& v);
|
||||
|
||||
MT_Scalar distance(const MT_Point3& p) const;
|
||||
MT_Scalar distance2(const MT_Point3& p) const;
|
||||
|
||||
MT_Point3 lerp(const MT_Point3& p, MT_Scalar t) const;
|
||||
};
|
||||
|
||||
MT_Point3 operator+(const MT_Point3& p, const MT_Vector3& v);
|
||||
MT_Point3 operator-(const MT_Point3& p, const MT_Vector3& v);
|
||||
MT_Vector3 operator-(const MT_Point3& p1, const MT_Point3& p2);
|
||||
|
||||
MT_Scalar MT_distance(const MT_Point3& p1, const MT_Point3& p2);
|
||||
MT_Scalar MT_distance2(const MT_Point3& p1, const MT_Point3& p2);
|
||||
|
||||
MT_Point3 MT_lerp(const MT_Point3& p1, const MT_Point3& p2, MT_Scalar t);
|
||||
|
||||
#ifdef GEN_INLINED
|
||||
#include "MT_Point3.inl"
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
@@ -1,59 +0,0 @@
|
||||
#include "MT_Optimize.h"
|
||||
|
||||
GEN_INLINE MT_Point3& MT_Point3::operator+=(const MT_Vector3& v) {
|
||||
m_co[0] += v[0]; m_co[1] += v[1]; m_co[2] += v[2];
|
||||
return *this;
|
||||
}
|
||||
|
||||
GEN_INLINE MT_Point3& MT_Point3::operator-=(const MT_Vector3& v) {
|
||||
m_co[0] -= v[0]; m_co[1] -= v[1]; m_co[2] -= v[2];
|
||||
return *this;
|
||||
}
|
||||
|
||||
GEN_INLINE MT_Point3& MT_Point3::operator=(const MT_Vector3& v) {
|
||||
m_co[0] = v[0]; m_co[1] = v[1]; m_co[2] = v[2];
|
||||
return *this;
|
||||
}
|
||||
|
||||
GEN_INLINE MT_Point3& MT_Point3::operator=(const MT_Point3& v) {
|
||||
m_co[0] = v[0]; m_co[1] = v[1]; m_co[2] = v[2];
|
||||
return *this;
|
||||
}
|
||||
|
||||
GEN_INLINE MT_Scalar MT_Point3::distance(const MT_Point3& p) const {
|
||||
return (p - *this).length();
|
||||
}
|
||||
|
||||
GEN_INLINE MT_Scalar MT_Point3::distance2(const MT_Point3& p) const {
|
||||
return (p - *this).length2();
|
||||
}
|
||||
|
||||
GEN_INLINE MT_Point3 MT_Point3::lerp(const MT_Point3& p, MT_Scalar t) const {
|
||||
return MT_Point3(m_co[0] + (p[0] - m_co[0]) * t,
|
||||
m_co[1] + (p[1] - m_co[1]) * t,
|
||||
m_co[2] + (p[2] - m_co[2]) * t);
|
||||
}
|
||||
|
||||
GEN_INLINE MT_Point3 operator+(const MT_Point3& p, const MT_Vector3& v) {
|
||||
return MT_Point3(p[0] + v[0], p[1] + v[1], p[2] + v[2]);
|
||||
}
|
||||
|
||||
GEN_INLINE MT_Point3 operator-(const MT_Point3& p, const MT_Vector3& v) {
|
||||
return MT_Point3(p[0] - v[0], p[1] - v[1], p[2] - v[2]);
|
||||
}
|
||||
|
||||
GEN_INLINE MT_Vector3 operator-(const MT_Point3& p1, const MT_Point3& p2) {
|
||||
return MT_Vector3(p1[0] - p2[0], p1[1] - p2[1], p1[2] - p2[2]);
|
||||
}
|
||||
|
||||
GEN_INLINE MT_Scalar MT_distance(const MT_Point3& p1, const MT_Point3& p2) {
|
||||
return p1.distance(p2);
|
||||
}
|
||||
|
||||
GEN_INLINE MT_Scalar MT_distance2(const MT_Point3& p1, const MT_Point3& p2) {
|
||||
return p1.distance2(p2);
|
||||
}
|
||||
|
||||
GEN_INLINE MT_Point3 MT_lerp(const MT_Point3& p1, const MT_Point3& p2, MT_Scalar t) {
|
||||
return p1.lerp(p2, t);
|
||||
}
|
@@ -56,8 +56,8 @@ class MT_Quaternion : public MT_Vector4 {
|
||||
public:
|
||||
MT_Quaternion() {}
|
||||
MT_Quaternion(const MT_Vector4& v) : MT_Vector4(v) {}
|
||||
MT_Quaternion(const float v[4]) : MT_Vector4(v) {}
|
||||
MT_Quaternion(const double v[4]) : MT_Vector4(v) {}
|
||||
template <typename T>
|
||||
MT_Quaternion(const T v[4]) : MT_Vector4(v) {}
|
||||
MT_Quaternion(MT_Scalar xx, MT_Scalar yy, MT_Scalar zz, MT_Scalar ww) :
|
||||
MT_Vector4(xx, yy, zz, ww) {}
|
||||
MT_Quaternion(const MT_Vector3& axis, MT_Scalar mt_angle) {
|
||||
|
@@ -53,7 +53,7 @@
|
||||
#include "MT_random.h"
|
||||
#include "NM_Scalar.h"
|
||||
|
||||
typedef double MT_Scalar; //this should be float !
|
||||
typedef float MT_Scalar;
|
||||
|
||||
|
||||
const MT_Scalar MT_DEGS_PER_RAD(57.29577951308232286465);
|
||||
|
@@ -54,22 +54,22 @@
|
||||
#ifndef MT_TRANSFORM_H
|
||||
#define MT_TRANSFORM_H
|
||||
|
||||
#include "MT_Point3.h"
|
||||
#include "MT_Vector3.h"
|
||||
#include "MT_Matrix3x3.h"
|
||||
|
||||
class MT_Transform {
|
||||
public:
|
||||
MT_Transform() {}
|
||||
MT_Transform(const float *m) { setValue(m); }
|
||||
MT_Transform(const double *m) { setValue(m); }
|
||||
MT_Transform(const MT_Point3& p, const MT_Quaternion& q)
|
||||
template <typename T>
|
||||
MT_Transform(const T *m) { setValue(m); }
|
||||
MT_Transform(const MT_Vector3& p, const MT_Quaternion& q)
|
||||
: m_type(IDENTITY)
|
||||
{
|
||||
setOrigin(p);
|
||||
setRotation(q);
|
||||
}
|
||||
|
||||
MT_Transform(const MT_Point3& p, const MT_Matrix3x3& m)
|
||||
MT_Transform(const MT_Vector3& p, const MT_Matrix3x3& m)
|
||||
: m_type(IDENTITY)
|
||||
{
|
||||
setOrigin(p);
|
||||
@@ -84,22 +84,12 @@ public:
|
||||
}
|
||||
|
||||
|
||||
MT_Point3 operator()(const MT_Point3& p) const {
|
||||
return MT_Point3(MT_dot(m_basis[0], p) + m_origin[0],
|
||||
MT_dot(m_basis[1], p) + m_origin[1],
|
||||
MT_dot(m_basis[2], p) + m_origin[2]);
|
||||
}
|
||||
|
||||
MT_Vector3 operator()(const MT_Vector3& p) const {
|
||||
return MT_Vector3(MT_dot(m_basis[0], p) + m_origin[0],
|
||||
MT_dot(m_basis[1], p) + m_origin[1],
|
||||
MT_dot(m_basis[2], p) + m_origin[2]);
|
||||
}
|
||||
|
||||
MT_Point3 operator*(const MT_Point3& p) const {
|
||||
return (*this)(p);
|
||||
}
|
||||
|
||||
MT_Vector3 operator*(const MT_Vector3& p) const {
|
||||
return (*this)(p);
|
||||
}
|
||||
@@ -107,14 +97,19 @@ public:
|
||||
|
||||
MT_Matrix3x3& getBasis() { return m_basis; }
|
||||
const MT_Matrix3x3& getBasis() const { return m_basis; }
|
||||
MT_Point3& getOrigin() { return m_origin; }
|
||||
const MT_Point3& getOrigin() const { return m_origin; }
|
||||
MT_Vector3& getOrigin() { return m_origin; }
|
||||
const MT_Vector3& getOrigin() const { return m_origin; }
|
||||
MT_Quaternion getRotation() const { return m_basis.getRotation(); }
|
||||
|
||||
void setValue(const float *m);
|
||||
void setValue(const double *m);
|
||||
template <typename T>
|
||||
void setValue(const T *m)
|
||||
{
|
||||
m_basis.setValue(m);
|
||||
m_origin.setValue(&m[12]);
|
||||
m_type = AFFINE;
|
||||
}
|
||||
|
||||
void setOrigin(const MT_Point3& origin) {
|
||||
void setOrigin(const MT_Vector3& origin) {
|
||||
m_origin = origin;
|
||||
m_type |= TRANSLATION;
|
||||
}
|
||||
@@ -129,9 +124,14 @@ public:
|
||||
m_type &= ~SCALING;
|
||||
m_type |= ROTATION;
|
||||
}
|
||||
|
||||
void getValue(float *m) const;
|
||||
void getValue(double *m) const;
|
||||
|
||||
template <typename T>
|
||||
void getValue(T *m) const
|
||||
{
|
||||
m_basis.getValue(m);
|
||||
m_origin.getValue(&m[12]);
|
||||
m[15] = 1.0;
|
||||
}
|
||||
|
||||
void setIdentity();
|
||||
|
||||
@@ -161,12 +161,12 @@ private:
|
||||
AFFINE = TRANSLATION | LINEAR
|
||||
};
|
||||
|
||||
MT_Transform(const MT_Matrix3x3& basis, const MT_Point3& origin,
|
||||
MT_Transform(const MT_Matrix3x3& basis, const MT_Vector3& origin,
|
||||
unsigned int type) {
|
||||
setValue(basis, origin, type);
|
||||
}
|
||||
|
||||
void setValue(const MT_Matrix3x3& basis, const MT_Point3& origin,
|
||||
void setValue(const MT_Matrix3x3& basis, const MT_Vector3& origin,
|
||||
unsigned int type) {
|
||||
m_basis = basis;
|
||||
m_origin = origin;
|
||||
@@ -176,7 +176,7 @@ private:
|
||||
friend MT_Transform operator*(const MT_Transform& t1, const MT_Transform& t2);
|
||||
|
||||
MT_Matrix3x3 m_basis;
|
||||
MT_Point3 m_origin;
|
||||
MT_Vector3 m_origin;
|
||||
unsigned int m_type;
|
||||
};
|
||||
|
||||
|
@@ -1,111 +0,0 @@
|
||||
/*
|
||||
* ***** BEGIN GPL LICENSE BLOCK *****
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*
|
||||
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
|
||||
* All rights reserved.
|
||||
*
|
||||
* The Original Code is: all of this file.
|
||||
*
|
||||
* Contributor(s): none yet.
|
||||
*
|
||||
* ***** END GPL LICENSE BLOCK *****
|
||||
*/
|
||||
|
||||
/** \file moto/include/MT_Tuple2.h
|
||||
* \ingroup moto
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
|
||||
* Copyright (c) 2000 Gino van den Bergen <gino@acm.org>
|
||||
*
|
||||
* Permission to use, copy, modify, distribute and sell this software
|
||||
* and its documentation for any purpose is hereby granted without fee,
|
||||
* provided that the above copyright notice appear in all copies and
|
||||
* that both that copyright notice and this permission notice appear
|
||||
* in supporting documentation. Gino van den Bergen makes no
|
||||
* representations about the suitability of this software for any
|
||||
* purpose. It is provided "as is" without express or implied warranty.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef MT_Tuple2_H
|
||||
#define MT_Tuple2_H
|
||||
|
||||
#include "MT_Stream.h"
|
||||
#include "MT_Scalar.h"
|
||||
|
||||
class MT_Tuple2 {
|
||||
public:
|
||||
MT_Tuple2() {}
|
||||
MT_Tuple2(const float *vv) { setValue(vv); }
|
||||
MT_Tuple2(const double *vv) { setValue(vv); }
|
||||
MT_Tuple2(MT_Scalar xx, MT_Scalar yy) { setValue(xx, yy); }
|
||||
|
||||
MT_Scalar& operator[](int i) { return m_co[i]; }
|
||||
const MT_Scalar& operator[](int i) const { return m_co[i]; }
|
||||
|
||||
MT_Scalar& x() { return m_co[0]; }
|
||||
const MT_Scalar& x() const { return m_co[0]; }
|
||||
|
||||
MT_Scalar& y() { return m_co[1]; }
|
||||
const MT_Scalar& y() const { return m_co[1]; }
|
||||
|
||||
MT_Scalar& u() { return m_co[0]; }
|
||||
const MT_Scalar& u() const { return m_co[0]; }
|
||||
|
||||
MT_Scalar& v() { return m_co[1]; }
|
||||
const MT_Scalar& v() const { return m_co[1]; }
|
||||
|
||||
MT_Scalar *getValue() { return m_co; }
|
||||
const MT_Scalar *getValue() const { return m_co; }
|
||||
|
||||
void getValue(float *vv) const {
|
||||
vv[0] = (float) m_co[0]; vv[1] = (float) m_co[1];
|
||||
}
|
||||
|
||||
void getValue(double *vv) const {
|
||||
vv[0] = m_co[0]; vv[1] = m_co[1];
|
||||
}
|
||||
|
||||
void setValue(const float *vv) {
|
||||
m_co[0] = vv[0]; m_co[1] = vv[1];
|
||||
}
|
||||
|
||||
void setValue(const double *vv) {
|
||||
m_co[0] = vv[0]; m_co[1] = vv[1];
|
||||
}
|
||||
|
||||
void setValue(MT_Scalar xx, MT_Scalar yy) {
|
||||
m_co[0] = xx; m_co[1] = yy;
|
||||
}
|
||||
|
||||
protected:
|
||||
MT_Scalar m_co[2];
|
||||
};
|
||||
|
||||
inline bool operator==(const MT_Tuple2& t1, const MT_Tuple2& t2) {
|
||||
return t1[0] == t2[0] && t1[1] == t2[1];
|
||||
}
|
||||
|
||||
inline MT_OStream& operator<<(MT_OStream& os, const MT_Tuple2& t) {
|
||||
return os << t[0] << ' ' << t[1];
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@@ -1,116 +0,0 @@
|
||||
/*
|
||||
* ***** BEGIN GPL LICENSE BLOCK *****
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*
|
||||
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
|
||||
* All rights reserved.
|
||||
*
|
||||
* The Original Code is: all of this file.
|
||||
*
|
||||
* Contributor(s): none yet.
|
||||
*
|
||||
* ***** END GPL LICENSE BLOCK *****
|
||||
*/
|
||||
|
||||
/** \file moto/include/MT_Tuple3.h
|
||||
* \ingroup moto
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
|
||||
* Copyright (c) 2000 Gino van den Bergen <gino@acm.org>
|
||||
*
|
||||
* Permission to use, copy, modify, distribute and sell this software
|
||||
* and its documentation for any purpose is hereby granted without fee,
|
||||
* provided that the above copyright notice appear in all copies and
|
||||
* that both that copyright notice and this permission notice appear
|
||||
* in supporting documentation. Gino van den Bergen makes no
|
||||
* representations about the suitability of this software for any
|
||||
* purpose. It is provided "as is" without express or implied warranty.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef MT_TUPLE3_H
|
||||
#define MT_TUPLE3_H
|
||||
|
||||
#include "MT_Stream.h"
|
||||
#include "MT_Scalar.h"
|
||||
|
||||
class MT_Tuple3 {
|
||||
public:
|
||||
MT_Tuple3() {}
|
||||
MT_Tuple3(const float *v) { setValue(v); }
|
||||
MT_Tuple3(const double *v) { setValue(v); }
|
||||
MT_Tuple3(MT_Scalar xx, MT_Scalar yy, MT_Scalar zz) { setValue(xx, yy, zz); }
|
||||
|
||||
MT_Scalar& operator[](int i) { return m_co[i]; }
|
||||
const MT_Scalar& operator[](int i) const { return m_co[i]; }
|
||||
|
||||
MT_Scalar& x() { return m_co[0]; }
|
||||
const MT_Scalar& x() const { return m_co[0]; }
|
||||
|
||||
MT_Scalar& y() { return m_co[1]; }
|
||||
const MT_Scalar& y() const { return m_co[1]; }
|
||||
|
||||
MT_Scalar& z() { return m_co[2]; }
|
||||
const MT_Scalar& z() const { return m_co[2]; }
|
||||
|
||||
MT_Scalar *getValue() { return m_co; }
|
||||
const MT_Scalar *getValue() const { return m_co; }
|
||||
|
||||
void getValue(float *v) const {
|
||||
v[0] = float(m_co[0]);
|
||||
v[1] = float(m_co[1]);
|
||||
v[2] = float(m_co[2]);
|
||||
}
|
||||
|
||||
void getValue(double *v) const {
|
||||
v[0] = double(m_co[0]);
|
||||
v[1] = double(m_co[1]);
|
||||
v[2] = double(m_co[2]);
|
||||
}
|
||||
|
||||
void setValue(const float *v) {
|
||||
m_co[0] = MT_Scalar(v[0]);
|
||||
m_co[1] = MT_Scalar(v[1]);
|
||||
m_co[2] = MT_Scalar(v[2]);
|
||||
}
|
||||
|
||||
void setValue(const double *v) {
|
||||
m_co[0] = MT_Scalar(v[0]);
|
||||
m_co[1] = MT_Scalar(v[1]);
|
||||
m_co[2] = MT_Scalar(v[2]);
|
||||
}
|
||||
|
||||
void setValue(MT_Scalar xx, MT_Scalar yy, MT_Scalar zz) {
|
||||
m_co[0] = xx; m_co[1] = yy; m_co[2] = zz;
|
||||
}
|
||||
|
||||
protected:
|
||||
MT_Scalar m_co[3];
|
||||
};
|
||||
|
||||
inline bool operator==(const MT_Tuple3& t1, const MT_Tuple3& t2) {
|
||||
return t1[0] == t2[0] && t1[1] == t2[1] && t1[2] == t2[2];
|
||||
}
|
||||
|
||||
inline MT_OStream& operator<<(MT_OStream& os, const MT_Tuple3& t) {
|
||||
return os << t[0] << ' ' << t[1] << ' ' << t[2];
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@@ -1,126 +0,0 @@
|
||||
/*
|
||||
* ***** BEGIN GPL LICENSE BLOCK *****
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*
|
||||
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
|
||||
* All rights reserved.
|
||||
*
|
||||
* The Original Code is: all of this file.
|
||||
*
|
||||
* Contributor(s): none yet.
|
||||
*
|
||||
* ***** END GPL LICENSE BLOCK *****
|
||||
*/
|
||||
|
||||
/** \file moto/include/MT_Tuple4.h
|
||||
* \ingroup moto
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
|
||||
* Copyright (c) 2000 Gino van den Bergen <gino@acm.org>
|
||||
*
|
||||
* Permission to use, copy, modify, distribute and sell this software
|
||||
* and its documentation for any purpose is hereby granted without fee,
|
||||
* provided that the above copyright notice appear in all copies and
|
||||
* that both that copyright notice and this permission notice appear
|
||||
* in supporting documentation. Gino van den Bergen makes no
|
||||
* representations about the suitability of this software for any
|
||||
* purpose. It is provided "as is" without express or implied warranty.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef MT_TUPLE4_H
|
||||
#define MT_TUPLE4_H
|
||||
|
||||
#include "MT_Stream.h"
|
||||
#include "MT_Scalar.h"
|
||||
|
||||
class MT_Tuple4 {
|
||||
public:
|
||||
MT_Tuple4() {}
|
||||
MT_Tuple4(const float *v) { setValue(v); }
|
||||
MT_Tuple4(const double *v) { setValue(v); }
|
||||
MT_Tuple4(MT_Scalar xx, MT_Scalar yy, MT_Scalar zz, MT_Scalar ww) {
|
||||
setValue(xx, yy, zz, ww);
|
||||
}
|
||||
|
||||
MT_Scalar& operator[](int i) { return m_co[i]; }
|
||||
const MT_Scalar& operator[](int i) const { return m_co[i]; }
|
||||
|
||||
MT_Scalar& x() { return m_co[0]; }
|
||||
const MT_Scalar& x() const { return m_co[0]; }
|
||||
|
||||
MT_Scalar& y() { return m_co[1]; }
|
||||
const MT_Scalar& y() const { return m_co[1]; }
|
||||
|
||||
MT_Scalar& z() { return m_co[2]; }
|
||||
const MT_Scalar& z() const { return m_co[2]; }
|
||||
|
||||
MT_Scalar& w() { return m_co[3]; }
|
||||
const MT_Scalar& w() const { return m_co[3]; }
|
||||
|
||||
MT_Scalar *getValue() { return m_co; }
|
||||
const MT_Scalar *getValue() const { return m_co; }
|
||||
|
||||
|
||||
void getValue(float *v) const {
|
||||
v[0] = float(m_co[0]);
|
||||
v[1] = float(m_co[1]);
|
||||
v[2] = float(m_co[2]);
|
||||
v[3] = float(m_co[3]);
|
||||
}
|
||||
|
||||
void getValue(double *v) const {
|
||||
v[0] = double(m_co[0]);
|
||||
v[1] = double(m_co[1]);
|
||||
v[2] = double(m_co[2]);
|
||||
v[3] = double(m_co[3]);
|
||||
}
|
||||
|
||||
void setValue(const float *v) {
|
||||
m_co[0] = MT_Scalar(v[0]);
|
||||
m_co[1] = MT_Scalar(v[1]);
|
||||
m_co[2] = MT_Scalar(v[2]);
|
||||
m_co[3] = MT_Scalar(v[3]);
|
||||
}
|
||||
|
||||
void setValue(const double *v) {
|
||||
m_co[0] = MT_Scalar(v[0]);
|
||||
m_co[1] = MT_Scalar(v[1]);
|
||||
m_co[2] = MT_Scalar(v[2]);
|
||||
m_co[3] = MT_Scalar(v[3]);
|
||||
}
|
||||
|
||||
void setValue(MT_Scalar xx, MT_Scalar yy, MT_Scalar zz, MT_Scalar ww) {
|
||||
m_co[0] = xx; m_co[1] = yy; m_co[2] = zz; m_co[3] = ww;
|
||||
}
|
||||
|
||||
protected:
|
||||
MT_Scalar m_co[4];
|
||||
};
|
||||
|
||||
inline bool operator==(const MT_Tuple4& t1, const MT_Tuple4& t2) {
|
||||
return t1[0] == t2[0] && t1[1] == t2[1] && t1[2] == t2[2] && t1[3] == t2[3];
|
||||
}
|
||||
|
||||
inline MT_OStream& operator<<(MT_OStream& os, const MT_Tuple4& t) {
|
||||
return os << t[0] << ' ' << t[1] << ' ' << t[2] << ' ' << t[3];
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@@ -47,16 +47,55 @@
|
||||
#ifndef MT_VECTOR2_H
|
||||
#define MT_VECTOR2_H
|
||||
|
||||
#include <MT_assert.h>
|
||||
#include "MT_Tuple2.h"
|
||||
#include "MT_Stream.h"
|
||||
#include "MT_Scalar.h"
|
||||
#include "MT_assert.h"
|
||||
|
||||
class MT_Vector2 : public MT_Tuple2 {
|
||||
class MT_Vector2 {
|
||||
public:
|
||||
MT_Vector2() {}
|
||||
MT_Vector2(const float *v2) : MT_Tuple2(v2) {}
|
||||
MT_Vector2(const double *v2) : MT_Tuple2(v2) {}
|
||||
MT_Vector2(MT_Scalar xx, MT_Scalar yy) : MT_Tuple2(xx, yy) {}
|
||||
|
||||
template <typename T>
|
||||
MT_Vector2(const T *vv) { setValue(vv); }
|
||||
MT_Vector2(MT_Scalar xx, MT_Scalar yy) { setValue(xx, yy); }
|
||||
|
||||
MT_Scalar& operator[](int i) { return m_co[i]; }
|
||||
const MT_Scalar& operator[](int i) const { return m_co[i]; }
|
||||
|
||||
MT_Scalar& x() { return m_co[0]; }
|
||||
const MT_Scalar& x() const { return m_co[0]; }
|
||||
|
||||
MT_Scalar& y() { return m_co[1]; }
|
||||
const MT_Scalar& y() const { return m_co[1]; }
|
||||
|
||||
MT_Scalar& u() { return m_co[0]; }
|
||||
const MT_Scalar& u() const { return m_co[0]; }
|
||||
|
||||
MT_Scalar& v() { return m_co[1]; }
|
||||
const MT_Scalar& v() const { return m_co[1]; }
|
||||
|
||||
MT_Scalar *getValue() { return m_co; }
|
||||
const MT_Scalar *getValue() const { return m_co; }
|
||||
|
||||
template <typename T>
|
||||
void getValue(T *vv) const {
|
||||
vv[0] = (T)m_co[0]; vv[1] = (T)m_co[1];
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void setValue(const T *vv) {
|
||||
m_co[0] = (MT_Scalar)vv[0]; m_co[1] = (MT_Scalar)vv[1];
|
||||
}
|
||||
|
||||
void setValue(MT_Scalar xx, MT_Scalar yy) {
|
||||
m_co[0] = xx; m_co[1] = yy;
|
||||
}
|
||||
|
||||
MT_Scalar distance(const MT_Vector2& p) const;
|
||||
MT_Scalar distance2(const MT_Vector2& p) const;
|
||||
|
||||
MT_Vector2 lerp(const MT_Vector2& p, MT_Scalar t) const;
|
||||
|
||||
MT_Vector2& operator=(const MT_Vector2& v);
|
||||
MT_Vector2& operator+=(const MT_Vector2& v);
|
||||
MT_Vector2& operator-=(const MT_Vector2& v);
|
||||
MT_Vector2& operator*=(MT_Scalar s);
|
||||
@@ -84,8 +123,24 @@ public:
|
||||
int closestAxis() const;
|
||||
|
||||
static MT_Vector2 random();
|
||||
|
||||
protected:
|
||||
MT_Scalar m_co[2];
|
||||
};
|
||||
|
||||
inline bool operator==(const MT_Vector2& t1, const MT_Vector2& t2) {
|
||||
return t1[0] == t2[0] && t1[1] == t2[1];
|
||||
}
|
||||
|
||||
inline MT_OStream& operator<<(MT_OStream& os, const MT_Vector2& t) {
|
||||
return os << t[0] << ' ' << t[1];
|
||||
}
|
||||
|
||||
MT_Scalar MT_distance(const MT_Vector2& p1, const MT_Vector2& p2);
|
||||
MT_Scalar MT_distance2(const MT_Vector2& p1, const MT_Vector2& p2);
|
||||
|
||||
MT_Vector2 MT_lerp(const MT_Vector2& p1, const MT_Vector2& p2, MT_Scalar t);
|
||||
|
||||
MT_Vector2 operator+(const MT_Vector2& v1, const MT_Vector2& v2);
|
||||
MT_Vector2 operator-(const MT_Vector2& v1, const MT_Vector2& v2);
|
||||
MT_Vector2 operator-(const MT_Vector2& v);
|
||||
|
@@ -1,5 +1,36 @@
|
||||
#include "MT_Optimize.h"
|
||||
|
||||
GEN_INLINE MT_Vector2& MT_Vector2::operator=(const MT_Vector2& v) {
|
||||
m_co[0] = v[0]; m_co[1] = v[1];
|
||||
return *this;
|
||||
}
|
||||
|
||||
GEN_INLINE MT_Scalar MT_Vector2::distance(const MT_Vector2& p) const {
|
||||
return (p - *this).length();
|
||||
}
|
||||
|
||||
GEN_INLINE MT_Scalar MT_Vector2::distance2(const MT_Vector2& p) const {
|
||||
return (p - *this).length2();
|
||||
}
|
||||
|
||||
GEN_INLINE MT_Vector2 MT_Vector2::lerp(const MT_Vector2& p, MT_Scalar t) const {
|
||||
return MT_Vector2(m_co[0] + (p[0] - m_co[0]) * t,
|
||||
m_co[1] + (p[1] - m_co[1]) * t);
|
||||
}
|
||||
|
||||
GEN_INLINE MT_Scalar MT_distance(const MT_Vector2& p1, const MT_Vector2& p2) {
|
||||
return p1.distance(p2);
|
||||
}
|
||||
|
||||
GEN_INLINE MT_Scalar MT_distance2(const MT_Vector2& p1, const MT_Vector2& p2) {
|
||||
return p1.distance2(p2);
|
||||
}
|
||||
|
||||
GEN_INLINE MT_Vector2 MT_lerp(const MT_Vector2& p1, const MT_Vector2& p2, MT_Scalar t) {
|
||||
return p1.lerp(p2, t);
|
||||
}
|
||||
|
||||
|
||||
GEN_INLINE MT_Vector2& MT_Vector2::operator+=(const MT_Vector2& vv) {
|
||||
m_co[0] += vv[0]; m_co[1] += vv[1];
|
||||
return *this;
|
||||
|
@@ -47,17 +47,57 @@
|
||||
#ifndef MT_VECTOR3_H
|
||||
#define MT_VECTOR3_H
|
||||
|
||||
#include <MT_assert.h>
|
||||
#include "MT_Tuple3.h"
|
||||
#include "MT_Stream.h"
|
||||
#include "MT_Scalar.h"
|
||||
#include "MT_assert.h"
|
||||
|
||||
class MT_Vector3 : public MT_Tuple3 {
|
||||
class MT_Vector3 {
|
||||
public:
|
||||
virtual ~MT_Vector3() {}
|
||||
MT_Vector3() {}
|
||||
MT_Vector3(const float *v) : MT_Tuple3(v) {}
|
||||
MT_Vector3(const double *v) : MT_Tuple3(v) {}
|
||||
MT_Vector3(MT_Scalar xx, MT_Scalar yy, MT_Scalar zz) : MT_Tuple3(xx, yy, zz) {}
|
||||
|
||||
template <typename T>
|
||||
MT_Vector3(const T *v) { setValue(v); }
|
||||
MT_Vector3(MT_Scalar xx, MT_Scalar yy, MT_Scalar zz) { setValue(xx, yy, zz); }
|
||||
|
||||
MT_Scalar& operator[](int i) { return m_co[i]; }
|
||||
const MT_Scalar& operator[](int i) const { return m_co[i]; }
|
||||
|
||||
MT_Scalar& x() { return m_co[0]; }
|
||||
const MT_Scalar& x() const { return m_co[0]; }
|
||||
|
||||
MT_Scalar& y() { return m_co[1]; }
|
||||
const MT_Scalar& y() const { return m_co[1]; }
|
||||
|
||||
MT_Scalar& z() { return m_co[2]; }
|
||||
const MT_Scalar& z() const { return m_co[2]; }
|
||||
|
||||
MT_Scalar *getValue() { return m_co; }
|
||||
const MT_Scalar *getValue() const { return m_co; }
|
||||
|
||||
template <typename T>
|
||||
void getValue(T *v) const {
|
||||
v[0] = (T)m_co[0];
|
||||
v[1] = (T)m_co[1];
|
||||
v[2] = (T)m_co[2];
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void setValue(const T *v) {
|
||||
m_co[0] = (MT_Scalar)v[0];
|
||||
m_co[1] = (MT_Scalar)v[1];
|
||||
m_co[2] = (MT_Scalar)v[2];
|
||||
}
|
||||
|
||||
void setValue(MT_Scalar xx, MT_Scalar yy, MT_Scalar zz) {
|
||||
m_co[0] = xx; m_co[1] = yy; m_co[2] = zz;
|
||||
}
|
||||
|
||||
|
||||
MT_Scalar distance(const MT_Vector3& p) const;
|
||||
MT_Scalar distance2(const MT_Vector3& p) const;
|
||||
|
||||
MT_Vector3 lerp(const MT_Vector3& p, MT_Scalar t) const;
|
||||
|
||||
MT_Vector3& operator=(const MT_Vector3& v);
|
||||
MT_Vector3& operator+=(const MT_Vector3& v);
|
||||
MT_Vector3& operator-=(const MT_Vector3& v);
|
||||
MT_Vector3& operator*=(MT_Scalar s);
|
||||
@@ -89,8 +129,24 @@ public:
|
||||
int closestAxis() const;
|
||||
|
||||
static MT_Vector3 random();
|
||||
|
||||
protected:
|
||||
MT_Scalar m_co[3];
|
||||
};
|
||||
|
||||
inline bool operator==(const MT_Vector3& t1, const MT_Vector3& t2) {
|
||||
return t1[0] == t2[0] && t1[1] == t2[1] && t1[2] == t2[2];
|
||||
}
|
||||
|
||||
inline MT_OStream& operator<<(MT_OStream& os, const MT_Vector3& t) {
|
||||
return os << t[0] << ' ' << t[1] << ' ' << t[2];
|
||||
}
|
||||
|
||||
MT_Scalar MT_distance(const MT_Vector3& p1, const MT_Vector3& p2);
|
||||
MT_Scalar MT_distance2(const MT_Vector3& p1, const MT_Vector3& p2);
|
||||
|
||||
MT_Vector3 MT_lerp(const MT_Vector3& p1, const MT_Vector3& p2, MT_Scalar t);
|
||||
|
||||
MT_Vector3 operator+(const MT_Vector3& v1, const MT_Vector3& v2);
|
||||
MT_Vector3 operator-(const MT_Vector3& v1, const MT_Vector3& v2);
|
||||
MT_Vector3 operator-(const MT_Vector3& v);
|
||||
@@ -113,6 +169,7 @@ MT_Vector3 MT_cross(const MT_Vector3& v1, const MT_Vector3& v2);
|
||||
MT_Scalar MT_triple(const MT_Vector3& v1, const MT_Vector3& v2,
|
||||
const MT_Vector3& v3);
|
||||
|
||||
|
||||
#ifdef GEN_INLINED
|
||||
#include "MT_Vector3.inl"
|
||||
#endif
|
||||
|
@@ -1,5 +1,36 @@
|
||||
#include "MT_Optimize.h"
|
||||
|
||||
GEN_INLINE MT_Vector3& MT_Vector3::operator=(const MT_Vector3& v) {
|
||||
m_co[0] = v[0]; m_co[1] = v[1]; m_co[2] = v[2];
|
||||
return *this;
|
||||
}
|
||||
|
||||
GEN_INLINE MT_Scalar MT_Vector3::distance(const MT_Vector3& p) const {
|
||||
return (p - *this).length();
|
||||
}
|
||||
|
||||
GEN_INLINE MT_Scalar MT_Vector3::distance2(const MT_Vector3& p) const {
|
||||
return (p - *this).length2();
|
||||
}
|
||||
|
||||
GEN_INLINE MT_Vector3 MT_Vector3::lerp(const MT_Vector3& p, MT_Scalar t) const {
|
||||
return MT_Vector3(m_co[0] + (p[0] - m_co[0]) * t,
|
||||
m_co[1] + (p[1] - m_co[1]) * t,
|
||||
m_co[2] + (p[2] - m_co[2]) * t);
|
||||
}
|
||||
|
||||
GEN_INLINE MT_Scalar MT_distance(const MT_Vector3& p1, const MT_Vector3& p2) {
|
||||
return p1.distance(p2);
|
||||
}
|
||||
|
||||
GEN_INLINE MT_Scalar MT_distance2(const MT_Vector3& p1, const MT_Vector3& p2) {
|
||||
return p1.distance2(p2);
|
||||
}
|
||||
|
||||
GEN_INLINE MT_Vector3 MT_lerp(const MT_Vector3& p1, const MT_Vector3& p2, MT_Scalar t) {
|
||||
return p1.lerp(p2, t);
|
||||
}
|
||||
|
||||
GEN_INLINE MT_Vector3& MT_Vector3::operator+=(const MT_Vector3& v) {
|
||||
m_co[0] += v[0]; m_co[1] += v[1]; m_co[2] += v[2];
|
||||
return *this;
|
||||
|
@@ -47,19 +47,58 @@
|
||||
#ifndef MT_VECTOR4_H
|
||||
#define MT_VECTOR4_H
|
||||
|
||||
#include <MT_assert.h>
|
||||
#include "MT_Stream.h"
|
||||
#include "MT_Scalar.h"
|
||||
#include "MT_assert.h"
|
||||
|
||||
#include "MT_Tuple4.h"
|
||||
|
||||
class MT_Vector4 : public MT_Tuple4 {
|
||||
class MT_Vector4 {
|
||||
public:
|
||||
virtual ~MT_Vector4() {}
|
||||
MT_Vector4() {}
|
||||
MT_Vector4(const float *v) : MT_Tuple4(v) {}
|
||||
MT_Vector4(const double *v) : MT_Tuple4(v) {}
|
||||
MT_Vector4(MT_Scalar xx, MT_Scalar yy, MT_Scalar zz, MT_Scalar ww) :
|
||||
MT_Tuple4(xx, yy, zz, ww) {}
|
||||
|
||||
template <typename T>
|
||||
MT_Vector4(const T *v) { setValue(v); }
|
||||
MT_Vector4(MT_Scalar xx, MT_Scalar yy, MT_Scalar zz, MT_Scalar ww) {
|
||||
setValue(xx, yy, zz, ww);
|
||||
}
|
||||
|
||||
MT_Scalar& operator[](int i) { return m_co[i]; }
|
||||
const MT_Scalar& operator[](int i) const { return m_co[i]; }
|
||||
|
||||
MT_Scalar& x() { return m_co[0]; }
|
||||
const MT_Scalar& x() const { return m_co[0]; }
|
||||
|
||||
MT_Scalar& y() { return m_co[1]; }
|
||||
const MT_Scalar& y() const { return m_co[1]; }
|
||||
|
||||
MT_Scalar& z() { return m_co[2]; }
|
||||
const MT_Scalar& z() const { return m_co[2]; }
|
||||
|
||||
MT_Scalar& w() { return m_co[3]; }
|
||||
const MT_Scalar& w() const { return m_co[3]; }
|
||||
|
||||
MT_Scalar *getValue() { return m_co; }
|
||||
const MT_Scalar *getValue() const { return m_co; }
|
||||
|
||||
|
||||
template <typename T>
|
||||
void getValue(T *v) const {
|
||||
v[0] = (T)m_co[0];
|
||||
v[1] = (T)m_co[1];
|
||||
v[2] = (T)m_co[2];
|
||||
v[3] = (T)m_co[3];
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void setValue(const T *v) {
|
||||
m_co[0] = (MT_Scalar)v[0];
|
||||
m_co[1] = (MT_Scalar)v[1];
|
||||
m_co[2] = (MT_Scalar)v[2];
|
||||
m_co[3] = (MT_Scalar)v[3];
|
||||
}
|
||||
|
||||
void setValue(MT_Scalar xx, MT_Scalar yy, MT_Scalar zz, MT_Scalar ww) {
|
||||
m_co[0] = xx; m_co[1] = yy; m_co[2] = zz; m_co[3] = ww;
|
||||
}
|
||||
|
||||
MT_Vector4& operator+=(const MT_Vector4& v);
|
||||
MT_Vector4& operator-=(const MT_Vector4& v);
|
||||
MT_Vector4& operator*=(MT_Scalar s);
|
||||
@@ -79,8 +118,20 @@ public:
|
||||
MT_Vector4 scaled(MT_Scalar x, MT_Scalar y, MT_Scalar z, MT_Scalar w) const;
|
||||
|
||||
bool fuzzyZero() const;
|
||||
|
||||
protected:
|
||||
MT_Scalar m_co[4];
|
||||
};
|
||||
|
||||
inline bool operator==(const MT_Vector4& t1, const MT_Vector4& t2) {
|
||||
return t1[0] == t2[0] && t1[1] == t2[1] && t1[2] == t2[2] && t1[3] == t2[3];
|
||||
}
|
||||
|
||||
inline MT_OStream& operator<<(MT_OStream& os, const MT_Vector4& t) {
|
||||
return os << t[0] << ' ' << t[1] << ' ' << t[2] << ' ' << t[3];
|
||||
}
|
||||
|
||||
|
||||
MT_Vector4 operator+(const MT_Vector4& v1, const MT_Vector4& v2);
|
||||
MT_Vector4 operator-(const MT_Vector4& v1, const MT_Vector4& v2);
|
||||
MT_Vector4 operator-(const MT_Vector4& v);
|
||||
|
@@ -32,7 +32,6 @@
|
||||
|
||||
#include "MT_CmMatrix4x4.h"
|
||||
#include "MT_Vector3.h"
|
||||
#include "MT_Point3.h"
|
||||
|
||||
|
||||
MT_CmMatrix4x4::MT_CmMatrix4x4()
|
||||
@@ -40,27 +39,6 @@ MT_CmMatrix4x4::MT_CmMatrix4x4()
|
||||
Identity();
|
||||
}
|
||||
|
||||
|
||||
|
||||
MT_CmMatrix4x4::MT_CmMatrix4x4(const float value[4][4])
|
||||
{
|
||||
for (int i=0;i<4;i++)
|
||||
{
|
||||
for (int j=0;j<4;j++)
|
||||
m_V[i][j] = value[i][j];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
MT_CmMatrix4x4::MT_CmMatrix4x4(const double value[16])
|
||||
{
|
||||
for (int i=0;i<16;i++)
|
||||
m_Vflat[i] = value[i];
|
||||
}
|
||||
|
||||
|
||||
|
||||
MT_CmMatrix4x4::MT_CmMatrix4x4(const MT_CmMatrix4x4& other)
|
||||
{
|
||||
SetMatrix(other);
|
||||
@@ -68,7 +46,7 @@ MT_CmMatrix4x4::MT_CmMatrix4x4(const MT_CmMatrix4x4& other)
|
||||
|
||||
|
||||
|
||||
MT_CmMatrix4x4::MT_CmMatrix4x4(const MT_Point3& orig,
|
||||
MT_CmMatrix4x4::MT_CmMatrix4x4(const MT_Vector3& orig,
|
||||
const MT_Vector3& dir,
|
||||
const MT_Vector3 up)
|
||||
{
|
||||
@@ -122,9 +100,9 @@ MT_Vector3 MT_CmMatrix4x4::GetDir() const
|
||||
|
||||
|
||||
|
||||
MT_Point3 MT_CmMatrix4x4::GetPos() const
|
||||
MT_Vector3 MT_CmMatrix4x4::GetPos() const
|
||||
{
|
||||
return MT_Point3(m_V[3][0], m_V[3][1], m_V[3][2]);
|
||||
return MT_Vector3(m_V[3][0], m_V[3][1], m_V[3][2]);
|
||||
}
|
||||
|
||||
|
||||
@@ -148,25 +126,18 @@ void MT_CmMatrix4x4::SetMatrix(const MT_CmMatrix4x4& other)
|
||||
|
||||
|
||||
|
||||
double* MT_CmMatrix4x4::getPointer()
|
||||
MT_Scalar* MT_CmMatrix4x4::getPointer()
|
||||
{
|
||||
return &m_V[0][0];
|
||||
}
|
||||
|
||||
|
||||
|
||||
const double* MT_CmMatrix4x4::getPointer() const
|
||||
const MT_Scalar* MT_CmMatrix4x4::getPointer() const
|
||||
{
|
||||
return &m_V[0][0];
|
||||
}
|
||||
|
||||
|
||||
|
||||
void MT_CmMatrix4x4::setElem(int pos,double newvalue)
|
||||
{
|
||||
m_Vflat[pos] = newvalue;
|
||||
}
|
||||
|
||||
MT_CmMatrix4x4 MT_CmMatrix4x4::Perspective(
|
||||
MT_Scalar inLeft,
|
||||
MT_Scalar inRight,
|
||||
|
@@ -1,38 +0,0 @@
|
||||
/*
|
||||
* ***** BEGIN GPL LICENSE BLOCK *****
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*
|
||||
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
|
||||
* All rights reserved.
|
||||
*
|
||||
* The Original Code is: all of this file.
|
||||
*
|
||||
* Contributor(s): none yet.
|
||||
*
|
||||
* ***** END GPL LICENSE BLOCK *****
|
||||
*/
|
||||
|
||||
/** \file moto/intern/MT_Point3.cpp
|
||||
* \ingroup moto
|
||||
*/
|
||||
|
||||
|
||||
#include "MT_Point3.h"
|
||||
|
||||
|
||||
#ifndef GEN_INLINED
|
||||
#include "MT_Point3.inl"
|
||||
#endif
|
@@ -53,30 +53,6 @@
|
||||
|
||||
#include "MT_Transform.h"
|
||||
|
||||
void MT_Transform::setValue(const float *m) {
|
||||
m_basis.setValue(m);
|
||||
m_origin.setValue(&m[12]);
|
||||
m_type = AFFINE;
|
||||
}
|
||||
|
||||
void MT_Transform::setValue(const double *m) {
|
||||
m_basis.setValue(m);
|
||||
m_origin.setValue(&m[12]);
|
||||
m_type = AFFINE;
|
||||
}
|
||||
|
||||
void MT_Transform::getValue(float *m) const {
|
||||
m_basis.getValue(m);
|
||||
m_origin.getValue(&m[12]);
|
||||
m[15] = 1.0;
|
||||
}
|
||||
|
||||
void MT_Transform::getValue(double *m) const {
|
||||
m_basis.getValue(m);
|
||||
m_origin.getValue(&m[12]);
|
||||
m[15] = 1.0;
|
||||
}
|
||||
|
||||
MT_Transform& MT_Transform::operator*=(const MT_Transform& t) {
|
||||
m_origin += m_basis * t.m_origin;
|
||||
m_basis *= t.m_basis;
|
||||
|
@@ -35,7 +35,7 @@
|
||||
#include "CTR_HashedPtr.h"
|
||||
#include "SCA_IActuator.h"
|
||||
#include "DNA_actuator_types.h"
|
||||
#include "MT_Point3.h"
|
||||
#include "MT_Vector3.h"
|
||||
|
||||
class BL_ActionActuator : public SCA_IActuator
|
||||
{
|
||||
@@ -114,7 +114,7 @@ public:
|
||||
#endif /* WITH_PYTHON */
|
||||
|
||||
protected:
|
||||
MT_Point3 m_lastpos;
|
||||
MT_Vector3 m_lastpos;
|
||||
float m_blendframe;
|
||||
int m_flag;
|
||||
/** The frame this action starts */
|
||||
|
@@ -573,7 +573,7 @@ bool BL_ArmatureObject::GetBoneMatrix(Bone* bone, MT_Matrix4x4& matrix)
|
||||
|
||||
float BL_ArmatureObject::GetBoneLength(Bone* bone) const
|
||||
{
|
||||
return (float)(MT_Point3(bone->head) - MT_Point3(bone->tail)).length();
|
||||
return (float)(MT_Vector3(bone->head) - MT_Vector3(bone->tail)).length();
|
||||
}
|
||||
|
||||
#ifdef WITH_PYTHON
|
||||
|
@@ -491,7 +491,7 @@ typedef struct MTF_localLayer {
|
||||
const char *name;
|
||||
} MTF_localLayer;
|
||||
|
||||
static void GetUVs(BL_Material *material, MTF_localLayer *layers, MFace *mface, MTFace *tface, MT_Point2 uvs[4][MAXTEX])
|
||||
static void GetUVs(BL_Material *material, MTF_localLayer *layers, MFace *mface, MTFace *tface, MT_Vector2 uvs[4][MAXTEX])
|
||||
{
|
||||
int unit = 0;
|
||||
if (tface)
|
||||
@@ -506,7 +506,7 @@ static void GetUVs(BL_Material *material, MTF_localLayer *layers, MFace *mface,
|
||||
}
|
||||
else
|
||||
{
|
||||
uvs[0][0] = uvs[1][0] = uvs[2][0] = uvs[3][0] = MT_Point2(0.f, 0.f);
|
||||
uvs[0][0] = uvs[1][0] = uvs[2][0] = uvs[3][0] = MT_Vector2(0.f, 0.f);
|
||||
}
|
||||
|
||||
vector<STR_String> found_layers;
|
||||
@@ -889,7 +889,7 @@ static bool ConvertMaterial(
|
||||
return true;
|
||||
}
|
||||
|
||||
static RAS_MaterialBucket *material_from_mesh(Material *ma, MFace *mface, MTFace *tface, MCol *mcol, MTF_localLayer *layers, int lightlayer, unsigned int *rgb, MT_Point2 uvs[4][RAS_TexVert::MAX_UNIT], const char *tfaceName, KX_Scene* scene, KX_BlenderSceneConverter *converter)
|
||||
static RAS_MaterialBucket *material_from_mesh(Material *ma, MFace *mface, MTFace *tface, MCol *mcol, MTF_localLayer *layers, int lightlayer, unsigned int *rgb, MT_Vector2 uvs[4][RAS_TexVert::MAX_UNIT], const char *tfaceName, KX_Scene* scene, KX_BlenderSceneConverter *converter)
|
||||
{
|
||||
RAS_IPolyMaterial* polymat = converter->FindCachedPolyMaterial(scene, ma);
|
||||
BL_Material* bl_mat = converter->FindCachedBlenderMaterial(scene, ma);
|
||||
@@ -1011,10 +1011,10 @@ RAS_MeshObject* BL_ConvertMesh(Mesh* mesh, Object* blenderobj, KX_Scene* scene,
|
||||
meshobj->m_sharedvertex_map.resize(totvert);
|
||||
|
||||
Material* ma = 0;
|
||||
MT_Point2 uvs[4][RAS_TexVert::MAX_UNIT];
|
||||
MT_Vector2 uvs[4][RAS_TexVert::MAX_UNIT];
|
||||
unsigned int rgb[4] = {0};
|
||||
|
||||
MT_Point3 pt[4];
|
||||
MT_Vector3 pt[4];
|
||||
MT_Vector3 no[4];
|
||||
MT_Vector4 tan[4];
|
||||
|
||||
@@ -1030,7 +1030,7 @@ RAS_MeshObject* BL_ConvertMesh(Mesh* mesh, Object* blenderobj, KX_Scene* scene,
|
||||
|
||||
/* we need to manually initialize the uvs (MoTo doesn't do that) [#34550] */
|
||||
for (unsigned int i = 0; i < RAS_TexVert::MAX_UNIT; i++) {
|
||||
uvs[0][i] = uvs[1][i] = uvs[2][i] = uvs[3][i] = MT_Point2(0.f, 0.f);
|
||||
uvs[0][i] = uvs[1][i] = uvs[2][i] = uvs[3][i] = MT_Vector2(0.f, 0.f);
|
||||
}
|
||||
|
||||
for (int f=0;f<totface;f++,mface++)
|
||||
@@ -1299,8 +1299,8 @@ static float my_boundbox_mesh(Mesh *me, float *loc, float *size)
|
||||
|
||||
|
||||
static void BL_CreateGraphicObjectNew(KX_GameObject* gameobj,
|
||||
const MT_Point3& localAabbMin,
|
||||
const MT_Point3& localAabbMax,
|
||||
const MT_Vector3& localAabbMin,
|
||||
const MT_Vector3& localAabbMax,
|
||||
KX_Scene* kxscene,
|
||||
bool isActive,
|
||||
e_PhysicsEngine physics_engine)
|
||||
@@ -1617,8 +1617,8 @@ static KX_GameObject *gameobject_from_blenderobject(
|
||||
#endif
|
||||
}
|
||||
|
||||
MT_Point3 min = MT_Point3(center) - MT_Vector3(extents);
|
||||
MT_Point3 max = MT_Point3(center) + MT_Vector3(extents);
|
||||
MT_Vector3 min = MT_Vector3(center) - MT_Vector3(extents);
|
||||
MT_Vector3 max = MT_Vector3(center) + MT_Vector3(extents);
|
||||
SG_BBox bbox = SG_BBox(min, max);
|
||||
gameobj->GetSGNode()->SetBBox(bbox);
|
||||
gameobj->GetSGNode()->SetRadius(radius);
|
||||
@@ -1778,7 +1778,7 @@ static void bl_ConvertBlenderObject_Single(
|
||||
bool isInActiveLayer
|
||||
)
|
||||
{
|
||||
MT_Point3 pos(
|
||||
MT_Vector3 pos(
|
||||
blenderobject->loc[0]+blenderobject->dloc[0],
|
||||
blenderobject->loc[1]+blenderobject->dloc[1],
|
||||
blenderobject->loc[2]+blenderobject->dloc[2]
|
||||
@@ -2225,7 +2225,7 @@ void BL_ConvertBlenderObjects(struct Main* maggie,
|
||||
KX_GameObject* gameobj = (KX_GameObject*) sumolist->GetValue(i);
|
||||
if (gameobj->GetMeshCount() > 0)
|
||||
{
|
||||
MT_Point3 box[2];
|
||||
MT_Vector3 box[2];
|
||||
gameobj->GetSGNode()->BBox().getmm(box, MT_Transform::Identity());
|
||||
// box[0] is the min, box[1] is the max
|
||||
bool isactive = objectlist->SearchValue(gameobj);
|
||||
|
@@ -35,7 +35,7 @@
|
||||
#include "RAS_Deformer.h"
|
||||
#include "DNA_object_types.h"
|
||||
#include "DNA_key_types.h"
|
||||
#include "MT_Point3.h"
|
||||
#include "MT_Vector3.h"
|
||||
#include <stdlib.h>
|
||||
|
||||
#ifdef _MSC_VER
|
||||
|
@@ -55,7 +55,7 @@
|
||||
#include "BKE_action.h"
|
||||
#include "BKE_key.h"
|
||||
#include "BKE_ipo.h"
|
||||
#include "MT_Point3.h"
|
||||
#include "MT_Vector3.h"
|
||||
|
||||
extern "C"{
|
||||
#include "BKE_customdata.h"
|
||||
|
@@ -306,8 +306,8 @@ bool BL_ShapeActionActuator::Update(double curtime, bool frame)
|
||||
/* Perform increment */
|
||||
if (keepgoing) {
|
||||
if (m_playtype == ACT_ACTION_MOTION) {
|
||||
MT_Point3 newpos;
|
||||
MT_Point3 deltapos;
|
||||
MT_Vector3 newpos;
|
||||
MT_Vector3 deltapos;
|
||||
|
||||
newpos = obj->NodeGetWorldPosition();
|
||||
|
||||
|
@@ -35,7 +35,7 @@
|
||||
#include "CTR_HashedPtr.h"
|
||||
#include "SCA_IActuator.h"
|
||||
#include "BL_ActionActuator.h"
|
||||
#include "MT_Point3.h"
|
||||
#include "MT_Vector3.h"
|
||||
#include <vector>
|
||||
|
||||
struct Key;
|
||||
@@ -116,7 +116,7 @@ protected:
|
||||
void SetLocalTime(float curtime);
|
||||
bool ClampLocalTime();
|
||||
|
||||
MT_Point3 m_lastpos;
|
||||
MT_Vector3 m_lastpos;
|
||||
float m_blendframe;
|
||||
int m_flag;
|
||||
/** The frame this action starts */
|
||||
|
@@ -54,7 +54,7 @@
|
||||
#include "BKE_fcurve.h"
|
||||
#include "BKE_ipo.h"
|
||||
#include "BKE_library.h"
|
||||
#include "MT_Point3.h"
|
||||
#include "MT_Vector3.h"
|
||||
|
||||
extern "C"{
|
||||
#include "BKE_lattice.h"
|
||||
|
@@ -52,7 +52,7 @@
|
||||
#include "BLI_utildefines.h"
|
||||
#include "BKE_armature.h"
|
||||
#include "BKE_action.h"
|
||||
#include "MT_Point3.h"
|
||||
#include "MT_Vector3.h"
|
||||
|
||||
extern "C"{
|
||||
#include "BKE_lattice.h"
|
||||
|
@@ -617,7 +617,7 @@ void KX_BlenderSceneConverter::WritePhysicsObjectToAnimationIpo(int frameNumber)
|
||||
BKE_animdata_add_id(&blenderObject->id);
|
||||
|
||||
if (blenderObject->adt) {
|
||||
const MT_Point3 &position = gameObj->NodeGetWorldPosition();
|
||||
const MT_Vector3 &position = gameObj->NodeGetWorldPosition();
|
||||
//const MT_Vector3& scale = gameObj->NodeGetWorldScaling();
|
||||
const MT_Matrix3x3 &orn = gameObj->NodeGetWorldOrientation();
|
||||
|
||||
@@ -634,7 +634,7 @@ void KX_BlenderSceneConverter::WritePhysicsObjectToAnimationIpo(int frameNumber)
|
||||
insert_keyframe(NULL, &blenderObject->id, NULL, NULL, "rotation_euler", -1, (float)frameNumber, INSERTKEY_FAST);
|
||||
|
||||
#if 0
|
||||
const MT_Point3& position = gameObj->NodeGetWorldPosition();
|
||||
const MT_Vector3& position = gameObj->NodeGetWorldPosition();
|
||||
//const MT_Vector3& scale = gameObj->NodeGetWorldScaling();
|
||||
const MT_Matrix3x3& orn = gameObj->NodeGetWorldOrientation();
|
||||
|
||||
|
@@ -101,7 +101,7 @@ bool KX_SoftBodyDeformer::Apply(class RAS_IPolyMaterial *polymat)
|
||||
RAS_TexVert& v = it.vertex[i];
|
||||
btAssert(v.getSoftBodyIndex() >= 0);
|
||||
|
||||
MT_Point3 pt (
|
||||
MT_Vector3 pt (
|
||||
nodes[v.getSoftBodyIndex()].m_x.getX(),
|
||||
nodes[v.getSoftBodyIndex()].m_x.getY(),
|
||||
nodes[v.getSoftBodyIndex()].m_x.getZ());
|
||||
|
@@ -36,10 +36,10 @@
|
||||
#include "SCA_ISensor.h"
|
||||
#include "SCA_IController.h"
|
||||
#include "SCA_IActuator.h"
|
||||
#include "MT_Point3.h"
|
||||
#include "MT_Vector3.h"
|
||||
#include "EXP_ListValue.h"
|
||||
|
||||
MT_Point3 SCA_IObject::m_sDummy=MT_Point3(0,0,0);
|
||||
MT_Vector3 SCA_IObject::m_sDummy=MT_Vector3(0,0,0);
|
||||
SG_QList SCA_IObject::m_activeBookmarkedControllers;
|
||||
|
||||
SCA_IObject::SCA_IObject():
|
||||
|
@@ -82,7 +82,7 @@ protected:
|
||||
// Elements: SCA_IController with bookmark option
|
||||
static SG_QList m_activeBookmarkedControllers;
|
||||
|
||||
static class MT_Point3 m_sDummy;
|
||||
static class MT_Vector3 m_sDummy;
|
||||
|
||||
/**
|
||||
* Ignore activity culling requests?
|
||||
@@ -213,7 +213,7 @@ public:
|
||||
*/
|
||||
unsigned int GetState(void) { return m_state; }
|
||||
|
||||
// const class MT_Point3& ConvertPythonPylist(PyObject *pylist);
|
||||
// const class MT_Vector3& ConvertPythonPylist(PyObject *pylist);
|
||||
|
||||
virtual int GetGameObjectType() {return -1;}
|
||||
|
||||
|
@@ -36,9 +36,9 @@
|
||||
|
||||
#include "MT_Matrix4x4.h"
|
||||
#include "MT_Matrix3x3.h"
|
||||
#include "MT_Tuple2.h"
|
||||
#include "MT_Tuple3.h"
|
||||
#include "MT_Tuple4.h"
|
||||
#include "MT_Vector2.h"
|
||||
#include "MT_Vector3.h"
|
||||
#include "MT_Vector4.h"
|
||||
|
||||
#include "RAS_IPolygonMaterial.h"
|
||||
|
||||
|
@@ -7,7 +7,7 @@
|
||||
#define __BL_MATERIAL_H__
|
||||
|
||||
#include "STR_String.h"
|
||||
#include "MT_Point2.h"
|
||||
#include "MT_Vector2.h"
|
||||
#include "DNA_meshdata_types.h"
|
||||
|
||||
#ifdef WITH_CXX_GUARDEDALLOC
|
||||
|
@@ -556,7 +556,7 @@ void BL_Shader::Update(const RAS_MeshSlot &ms, RAS_IRasterizer *rasty)
|
||||
}
|
||||
case CAM_POS:
|
||||
{
|
||||
MT_Point3 pos(rasty->GetCameraPosition());
|
||||
MT_Vector3 pos(rasty->GetCameraPosition());
|
||||
SetUniform(uni->mLoc, pos);
|
||||
break;
|
||||
}
|
||||
@@ -627,7 +627,7 @@ int BL_Shader::GetUniformLocation(const char *name)
|
||||
return -1;
|
||||
}
|
||||
|
||||
void BL_Shader::SetUniform(int uniform, const MT_Tuple2 &vec)
|
||||
void BL_Shader::SetUniform(int uniform, const MT_Vector2 &vec)
|
||||
{
|
||||
if (GLEW_ARB_fragment_shader && GLEW_ARB_vertex_shader && GLEW_ARB_shader_objects) {
|
||||
float value[2];
|
||||
@@ -636,7 +636,7 @@ void BL_Shader::SetUniform(int uniform, const MT_Tuple2 &vec)
|
||||
}
|
||||
}
|
||||
|
||||
void BL_Shader::SetUniform(int uniform, const MT_Tuple3 &vec)
|
||||
void BL_Shader::SetUniform(int uniform, const MT_Vector3 &vec)
|
||||
{
|
||||
if (GLEW_ARB_fragment_shader && GLEW_ARB_vertex_shader && GLEW_ARB_shader_objects) {
|
||||
float value[3];
|
||||
@@ -645,7 +645,7 @@ void BL_Shader::SetUniform(int uniform, const MT_Tuple3 &vec)
|
||||
}
|
||||
}
|
||||
|
||||
void BL_Shader::SetUniform(int uniform, const MT_Tuple4 &vec)
|
||||
void BL_Shader::SetUniform(int uniform, const MT_Vector4 &vec)
|
||||
{
|
||||
if (GLEW_ARB_fragment_shader && GLEW_ARB_vertex_shader && GLEW_ARB_shader_objects) {
|
||||
float value[4];
|
||||
|
@@ -11,9 +11,9 @@
|
||||
#include "BL_Texture.h"
|
||||
#include "MT_Matrix4x4.h"
|
||||
#include "MT_Matrix3x3.h"
|
||||
#include "MT_Tuple2.h"
|
||||
#include "MT_Tuple3.h"
|
||||
#include "MT_Tuple4.h"
|
||||
#include "MT_Vector2.h"
|
||||
#include "MT_Vector3.h"
|
||||
#include "MT_Vector4.h"
|
||||
|
||||
/**
|
||||
* BL_Sampler
|
||||
@@ -190,9 +190,9 @@ public:
|
||||
int GetAttribLocation(const char *name);
|
||||
void BindAttribute(const char *attr, int loc);
|
||||
int GetUniformLocation(const char *name);
|
||||
void SetUniform(int uniform, const MT_Tuple2 &vec);
|
||||
void SetUniform(int uniform, const MT_Tuple3 &vec);
|
||||
void SetUniform(int uniform, const MT_Tuple4 &vec);
|
||||
void SetUniform(int uniform, const MT_Vector2 &vec);
|
||||
void SetUniform(int uniform, const MT_Vector3 &vec);
|
||||
void SetUniform(int uniform, const MT_Vector4 &vec);
|
||||
void SetUniform(int uniform, const MT_Matrix4x4 &vec, bool transpose = false);
|
||||
void SetUniform(int uniform, const MT_Matrix3x3 &vec, bool transpose = false);
|
||||
void SetUniform(int uniform, const float &val);
|
||||
|
@@ -802,7 +802,7 @@ void KX_BlenderMaterial::setObjectMatrixData(int i, RAS_IRasterizer *ras)
|
||||
mMaterial->mapping[i].scale[2]
|
||||
);
|
||||
|
||||
MT_Point3 pos = obj->NodeGetWorldPosition();
|
||||
MT_Vector3 pos = obj->NodeGetWorldPosition();
|
||||
MT_Vector4 matmul = MT_Vector4(pos[0], pos[1], pos[2], 1.f);
|
||||
MT_Vector4 t = mvmat*matmul;
|
||||
|
||||
|
@@ -113,11 +113,11 @@ void KX_Camera::CorrectLookUp(MT_Scalar speed)
|
||||
|
||||
|
||||
|
||||
const MT_Point3 KX_Camera::GetCameraLocation() const
|
||||
const MT_Vector3 KX_Camera::GetCameraLocation() const
|
||||
{
|
||||
/* this is the camera locatio in cam coords... */
|
||||
//return m_trans1.getOrigin();
|
||||
//return MT_Point3(0,0,0); <-----
|
||||
//return MT_Vector3(0,0,0); <-----
|
||||
/* .... I want it in world coords */
|
||||
//MT_Transform trans;
|
||||
//trans.setBasis(NodeGetWorldOrientation());
|
||||
@@ -323,9 +323,9 @@ void KX_Camera::ExtractFrustumSphere()
|
||||
// frustrum projection
|
||||
// detect which of the corner of the far clipping plane is the farthest to the origin
|
||||
MT_Vector4 nfar; // far point in device normalized coordinate
|
||||
MT_Point3 farpoint; // most extreme far point in camera coordinate
|
||||
MT_Point3 nearpoint;// most extreme near point in camera coordinate
|
||||
MT_Point3 farcenter(0.0, 0.0, 0.0);// center of far cliping plane in camera coordinate
|
||||
MT_Vector3 farpoint; // most extreme far point in camera coordinate
|
||||
MT_Vector3 nearpoint;// most extreme near point in camera coordinate
|
||||
MT_Vector3 farcenter(0.0, 0.0, 0.0);// center of far cliping plane in camera coordinate
|
||||
MT_Scalar F=-1.0, N; // square distance of far and near point to origin
|
||||
MT_Scalar f, n; // distance of far and near point to z axis. f is always > 0 but n can be < 0
|
||||
MT_Scalar e, s; // far and near clipping distance (<0)
|
||||
@@ -334,7 +334,7 @@ void KX_Camera::ExtractFrustumSphere()
|
||||
// tmp value
|
||||
MT_Vector4 npoint(1.0, 1.0, 1.0, 1.0);
|
||||
MT_Vector4 hpoint;
|
||||
MT_Point3 point;
|
||||
MT_Vector3 point;
|
||||
MT_Scalar len;
|
||||
for (int i=0; i<4; i++)
|
||||
{
|
||||
@@ -364,17 +364,17 @@ void KX_Camera::ExtractFrustumSphere()
|
||||
e = farpoint[2];
|
||||
s = nearpoint[2];
|
||||
// projection on XY plane for distance to axis computation
|
||||
MT_Point2 farxy(farpoint[0], farpoint[1]);
|
||||
MT_Vector2 farxy(farpoint[0], farpoint[1]);
|
||||
// f is forced positive by construction
|
||||
f = farxy.length();
|
||||
// get corresponding point on the near plane
|
||||
farxy *= s/e;
|
||||
// this formula preserve the sign of n
|
||||
n = f*s/e - MT_Point2(nearpoint[0]-farxy[0], nearpoint[1]-farxy[1]).length();
|
||||
c = MT_Point2(farcenter[0], farcenter[1]).length()/e;
|
||||
n = f*s/e - MT_Vector2(nearpoint[0]-farxy[0], nearpoint[1]-farxy[1]).length();
|
||||
c = MT_Vector2(farcenter[0], farcenter[1]).length()/e;
|
||||
// the big formula, it simplifies to (F-N)/(2(e-s)) for the symmetric case
|
||||
z = (F-N)/(2.0*(e-s+c*(f-n)));
|
||||
m_frustum_center = MT_Point3(farcenter[0]*z/e, farcenter[1]*z/e, z);
|
||||
m_frustum_center = MT_Vector3(farcenter[0]*z/e, farcenter[1]*z/e, z);
|
||||
m_frustum_radius = m_frustum_center.distance(farpoint);
|
||||
}
|
||||
else
|
||||
@@ -388,8 +388,8 @@ void KX_Camera::ExtractFrustumSphere()
|
||||
hfar = clip_camcs_matrix*hfar;
|
||||
|
||||
// Tranform to 3d camera local space.
|
||||
MT_Point3 nearpoint(hnear[0]/hnear[3], hnear[1]/hnear[3], hnear[2]/hnear[3]);
|
||||
MT_Point3 farpoint(hfar[0]/hfar[3], hfar[1]/hfar[3], hfar[2]/hfar[3]);
|
||||
MT_Vector3 nearpoint(hnear[0]/hnear[3], hnear[1]/hnear[3], hnear[2]/hnear[3]);
|
||||
MT_Vector3 farpoint(hfar[0]/hfar[3], hfar[1]/hfar[3], hfar[2]/hfar[3]);
|
||||
|
||||
// just use mediant point
|
||||
m_frustum_center = (farpoint + nearpoint)*0.5;
|
||||
@@ -402,7 +402,7 @@ void KX_Camera::ExtractFrustumSphere()
|
||||
m_set_frustum_center = true;
|
||||
}
|
||||
|
||||
bool KX_Camera::PointInsideFrustum(const MT_Point3& x)
|
||||
bool KX_Camera::PointInsideFrustum(const MT_Vector3& x)
|
||||
{
|
||||
ExtractClipPlanes();
|
||||
|
||||
@@ -414,7 +414,7 @@ bool KX_Camera::PointInsideFrustum(const MT_Point3& x)
|
||||
return true;
|
||||
}
|
||||
|
||||
int KX_Camera::BoxInsideFrustum(const MT_Point3 *box)
|
||||
int KX_Camera::BoxInsideFrustum(const MT_Vector3 *box)
|
||||
{
|
||||
ExtractClipPlanes();
|
||||
|
||||
@@ -446,7 +446,7 @@ int KX_Camera::BoxInsideFrustum(const MT_Point3 *box)
|
||||
return INTERSECT;
|
||||
}
|
||||
|
||||
int KX_Camera::SphereInsideFrustum(const MT_Point3& center, const MT_Scalar &radius)
|
||||
int KX_Camera::SphereInsideFrustum(const MT_Vector3& center, const MT_Scalar &radius)
|
||||
{
|
||||
ExtractFrustumSphere();
|
||||
if (center.distance2(m_frustum_center) > (radius + m_frustum_radius)*(radius + m_frustum_radius))
|
||||
@@ -613,7 +613,7 @@ KX_PYMETHODDEF_DOC_VARARGS(KX_Camera, sphereInsideFrustum,
|
||||
float radius;
|
||||
if (PyArg_ParseTuple(args, "Of:sphereInsideFrustum", &pycenter, &radius))
|
||||
{
|
||||
MT_Point3 center;
|
||||
MT_Vector3 center;
|
||||
if (PyVecTo(pycenter, center))
|
||||
{
|
||||
return PyLong_FromLong(SphereInsideFrustum(center, radius)); /* new ref */
|
||||
@@ -657,7 +657,7 @@ KX_PYMETHODDEF_DOC_O(KX_Camera, boxInsideFrustum,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
MT_Point3 box[8];
|
||||
MT_Vector3 box[8];
|
||||
for (unsigned int p = 0; p < 8 ; p++)
|
||||
{
|
||||
PyObject *item = PySequence_GetItem(value, p); /* new ref */
|
||||
@@ -686,7 +686,7 @@ KX_PYMETHODDEF_DOC_O(KX_Camera, pointInsideFrustum,
|
||||
"\t\t# Box is outside the frustum !\n"
|
||||
)
|
||||
{
|
||||
MT_Point3 point;
|
||||
MT_Vector3 point;
|
||||
if (PyVecTo(value, point))
|
||||
{
|
||||
return PyLong_FromLong(PointInsideFrustum(point)); /* new ref */
|
||||
@@ -1088,7 +1088,7 @@ KX_PYMETHODDEF_DOC_VARARGS(KX_Camera, getScreenVect,
|
||||
y = 1.0 - y; //to follow Blender window coordinate system (Top-Down)
|
||||
|
||||
MT_Vector3 vect;
|
||||
MT_Point3 campos, screenpos;
|
||||
MT_Vector3 campos, screenpos;
|
||||
|
||||
const GLint *viewport;
|
||||
GLdouble win[3];
|
||||
@@ -1114,7 +1114,7 @@ KX_PYMETHODDEF_DOC_VARARGS(KX_Camera, getScreenVect,
|
||||
gluUnProject(vect[0], vect[1], vect[2], modelmatrix, projmatrix, viewport, &win[0], &win[1], &win[2]);
|
||||
|
||||
campos = this->GetCameraLocation();
|
||||
screenpos = MT_Point3(win[0], win[1], win[2]);
|
||||
screenpos = MT_Vector3(win[0], win[1], win[2]);
|
||||
vect = campos-screenpos;
|
||||
|
||||
vect.normalize();
|
||||
|
@@ -38,7 +38,7 @@
|
||||
#include "MT_Matrix3x3.h"
|
||||
#include "MT_Matrix4x4.h"
|
||||
#include "MT_Vector3.h"
|
||||
#include "MT_Point3.h"
|
||||
#include "MT_Vector3.h"
|
||||
#include "KX_GameObject.h"
|
||||
#include "EXP_IntValue.h"
|
||||
#include "RAS_CameraData.h"
|
||||
@@ -61,7 +61,7 @@ protected:
|
||||
RAS_CameraData m_camdata;
|
||||
|
||||
// Never used, I think...
|
||||
// void MoveTo(const MT_Point3& movevec)
|
||||
// void MoveTo(const MT_Vector3& movevec)
|
||||
// {
|
||||
#if 0
|
||||
MT_Transform camtrans;
|
||||
@@ -113,7 +113,7 @@ protected:
|
||||
/**
|
||||
* The center point of the frustum.
|
||||
*/
|
||||
MT_Point3 m_frustum_center;
|
||||
MT_Vector3 m_frustum_center;
|
||||
MT_Scalar m_frustum_radius;
|
||||
bool m_set_frustum_center;
|
||||
|
||||
@@ -168,7 +168,7 @@ public:
|
||||
* Not implemented.
|
||||
*/
|
||||
void CorrectLookUp(MT_Scalar speed);
|
||||
const MT_Point3 GetCameraLocation() const;
|
||||
const MT_Vector3 GetCameraLocation() const;
|
||||
|
||||
/* I want the camera orientation as well. */
|
||||
const MT_Quaternion GetCameraOrientation() const;
|
||||
@@ -226,19 +226,19 @@ public:
|
||||
* \param radius The radius of the sphere.
|
||||
* \return INSIDE, INTERSECT, or OUTSIDE depending on the sphere's relation to the frustum.
|
||||
*/
|
||||
int SphereInsideFrustum(const MT_Point3& center, const MT_Scalar &radius);
|
||||
int SphereInsideFrustum(const MT_Vector3& center, const MT_Scalar &radius);
|
||||
/**
|
||||
* Tests the given eight corners of a box with the view frustum.
|
||||
*
|
||||
* \param box a pointer to eight MT_Point3 representing the world coordinates of the corners of the box.
|
||||
* \param box a pointer to eight MT_Vector3 representing the world coordinates of the corners of the box.
|
||||
* \return INSIDE, INTERSECT, or OUTSIDE depending on the box's relation to the frustum.
|
||||
*/
|
||||
int BoxInsideFrustum(const MT_Point3 *box);
|
||||
int BoxInsideFrustum(const MT_Vector3 *box);
|
||||
/**
|
||||
* Tests the given point against the view frustum.
|
||||
* \return true if the given point is inside or on the view frustum; false if it is outside.
|
||||
*/
|
||||
bool PointInsideFrustum(const MT_Point3& x);
|
||||
bool PointInsideFrustum(const MT_Vector3& x);
|
||||
|
||||
/**
|
||||
* Gets this camera's culling status.
|
||||
|
@@ -190,10 +190,10 @@ bool KX_CameraActuator::Update(double curtime, bool frame)
|
||||
return false;
|
||||
|
||||
KX_GameObject *obj = (KX_GameObject*) GetParent();
|
||||
MT_Point3 from = obj->NodeGetWorldPosition();
|
||||
MT_Vector3 from = obj->NodeGetWorldPosition();
|
||||
MT_Matrix3x3 frommat = obj->NodeGetWorldOrientation();
|
||||
/* These casts are _very_ dangerous!!! */
|
||||
MT_Point3 lookat = ((KX_GameObject*)m_ob)->NodeGetWorldPosition();
|
||||
MT_Vector3 lookat = ((KX_GameObject*)m_ob)->NodeGetWorldPosition();
|
||||
MT_Matrix3x3 actormat = ((KX_GameObject*)m_ob)->NodeGetWorldOrientation();
|
||||
|
||||
float fp1[3]={0}, fp2[3]={0}, rc[3];
|
||||
|
@@ -36,7 +36,7 @@
|
||||
#include "SCA_IActuator.h"
|
||||
#include "KX_ConstraintActuator.h"
|
||||
#include "SCA_IObject.h"
|
||||
#include "MT_Point3.h"
|
||||
#include "MT_Vector3.h"
|
||||
#include "MT_Matrix3x3.h"
|
||||
#include "KX_GameObject.h"
|
||||
#include "KX_RayCast.h"
|
||||
@@ -180,8 +180,8 @@ bool KX_ConstraintActuator::Update(double curtime, bool frame)
|
||||
/* Having to retrieve location/rotation and setting it afterwards may not */
|
||||
/* be efficient enough... Something to look at later. */
|
||||
KX_GameObject *obj = (KX_GameObject*) GetParent();
|
||||
MT_Point3 position = obj->NodeGetWorldPosition();
|
||||
MT_Point3 newposition;
|
||||
MT_Vector3 position = obj->NodeGetWorldPosition();
|
||||
MT_Vector3 newposition;
|
||||
MT_Vector3 normal, direction, refDirection;
|
||||
MT_Matrix3x3 rotation = obj->NodeGetWorldOrientation();
|
||||
MT_Scalar filter, newdistance, cosangle;
|
||||
@@ -332,7 +332,7 @@ bool KX_ConstraintActuator::Update(double curtime, bool frame)
|
||||
}
|
||||
}
|
||||
{
|
||||
MT_Point3 topoint = position + (m_maximumBound) * direction;
|
||||
MT_Vector3 topoint = position + (m_maximumBound) * direction;
|
||||
PHY_IPhysicsEnvironment* pe = KX_GetActiveScene()->GetPhysicsEnvironment();
|
||||
PHY_IPhysicsController *spc = obj->GetPhysicsController();
|
||||
|
||||
@@ -458,7 +458,7 @@ bool KX_ConstraintActuator::Update(double curtime, bool frame)
|
||||
}
|
||||
m_hitObject = NULL;
|
||||
// distance of Fh area is stored in m_minimum
|
||||
MT_Point3 topoint = position + (m_minimumBound+spc->GetRadius()) * direction;
|
||||
MT_Vector3 topoint = position + (m_minimumBound+spc->GetRadius()) * direction;
|
||||
KX_RayCast::Callback<KX_ConstraintActuator, void> callback(this, spc);
|
||||
result = KX_RayCast::RayTest(pe, position, topoint, callback);
|
||||
// we expect a hit object
|
||||
@@ -470,7 +470,7 @@ bool KX_ConstraintActuator::Update(double curtime, bool frame)
|
||||
// compute new position & orientation
|
||||
MT_Scalar distance = (callback.m_hitPoint-position).length()-spc->GetRadius();
|
||||
// estimate the velocity of the hit point
|
||||
MT_Point3 relativeHitPoint;
|
||||
MT_Vector3 relativeHitPoint;
|
||||
relativeHitPoint = (callback.m_hitPoint-m_hitObject->NodeGetWorldPosition());
|
||||
MT_Vector3 velocityHitPoint = m_hitObject->GetVelocity(relativeHitPoint);
|
||||
MT_Vector3 relativeVelocity = spc->GetLinearVelocity() - velocityHitPoint;
|
||||
|
@@ -194,7 +194,9 @@ void KX_FontObject::DrawFontText()
|
||||
|
||||
/* Get a working copy of the OpenGLMatrix to use */
|
||||
double mat[16];
|
||||
memcpy(mat, this->GetOpenGLMatrix(), sizeof(double)*16);
|
||||
for (unsigned short i = 0; i < 16; ++i) {
|
||||
mat[i] = m_OpenGL_4x4Matrix.getPointer()[i];
|
||||
}
|
||||
|
||||
/* Account for offset */
|
||||
MT_Vector3 offset = this->NodeGetWorldOrientation() * m_offset * this->NodeGetWorldScaling();
|
||||
|
@@ -83,7 +83,7 @@
|
||||
|
||||
#include "BLI_math.h"
|
||||
|
||||
static MT_Point3 dummy_point= MT_Point3(0.0, 0.0, 0.0);
|
||||
static MT_Vector3 dummy_point= MT_Vector3(0.0, 0.0, 0.0);
|
||||
static MT_Vector3 dummy_scaling = MT_Vector3(1.0, 1.0, 1.0);
|
||||
static MT_Matrix3x3 dummy_orientation = MT_Matrix3x3(1.0, 0.0, 0.0,
|
||||
0.0, 1.0, 0.0,
|
||||
@@ -362,7 +362,7 @@ void KX_GameObject::SetParent(KX_Scene *scene, KX_GameObject* obj, bool addToCom
|
||||
MT_Vector3 newpos = invori*(NodeGetWorldPosition()-obj->NodeGetWorldPosition())*scale2;
|
||||
|
||||
NodeSetLocalScale(scale1);
|
||||
NodeSetLocalPosition(MT_Point3(newpos[0],newpos[1],newpos[2]));
|
||||
NodeSetLocalPosition(MT_Vector3(newpos[0],newpos[1],newpos[2]));
|
||||
NodeSetLocalOrientation(invori*NodeGetWorldOrientation());
|
||||
NodeUpdateGS(0.f);
|
||||
// object will now be a child, it must be removed from the parent list
|
||||
@@ -421,9 +421,9 @@ void KX_GameObject::RemoveParent(KX_Scene *scene)
|
||||
if (m_pPhysicsController->IsDynamic() && (rootobj != NULL && rootobj->m_pPhysicsController))
|
||||
{
|
||||
// dynamic object should remember the velocity they had while being parented
|
||||
MT_Point3 childPoint = GetSGNode()->GetWorldPosition();
|
||||
MT_Point3 rootPoint = rootobj->GetSGNode()->GetWorldPosition();
|
||||
MT_Point3 relPoint;
|
||||
MT_Vector3 childPoint = GetSGNode()->GetWorldPosition();
|
||||
MT_Vector3 rootPoint = rootobj->GetSGNode()->GetWorldPosition();
|
||||
MT_Vector3 relPoint;
|
||||
relPoint = (childPoint-rootPoint);
|
||||
MT_Vector3 linVel = rootobj->m_pPhysicsController->GetVelocity(relPoint);
|
||||
MT_Vector3 angVel = rootobj->m_pPhysicsController->GetAngularVelocity();
|
||||
@@ -700,10 +700,10 @@ void KX_GameObject::ApplyRotation(const MT_Vector3& drot,bool local)
|
||||
/**
|
||||
* GetOpenGL Matrix, returns an OpenGL 'compatible' matrix
|
||||
*/
|
||||
double* KX_GameObject::GetOpenGLMatrix()
|
||||
float* KX_GameObject::GetOpenGLMatrix()
|
||||
{
|
||||
// todo: optimize and only update if necessary
|
||||
double* fl = m_OpenGL_4x4Matrix.getPointer();
|
||||
float* fl = m_OpenGL_4x4Matrix.getPointer();
|
||||
if (GetSGNode()) {
|
||||
MT_Transform trans;
|
||||
|
||||
@@ -742,7 +742,7 @@ void KX_GameObject::AddMeshUser()
|
||||
m_meshes[i]->AddMeshUser(this, &m_meshSlots, GetDeformer());
|
||||
}
|
||||
// set the part of the mesh slot that never change
|
||||
double* fl = GetOpenGLMatrixPtr()->getPointer();
|
||||
float* fl = GetOpenGLMatrixPtr()->getPointer();
|
||||
|
||||
SG_QList::iterator<RAS_MeshSlot> mit(m_meshSlots);
|
||||
// RAS_MeshSlot* ms;
|
||||
@@ -1335,7 +1335,7 @@ MT_Vector3 KX_GameObject::GetAngularVelocity(bool local)
|
||||
return velocity;
|
||||
}
|
||||
|
||||
MT_Vector3 KX_GameObject::GetVelocity(const MT_Point3& point)
|
||||
MT_Vector3 KX_GameObject::GetVelocity(const MT_Vector3& point)
|
||||
{
|
||||
if (m_pPhysicsController)
|
||||
{
|
||||
@@ -1346,7 +1346,7 @@ MT_Vector3 KX_GameObject::GetVelocity(const MT_Point3& point)
|
||||
|
||||
// scenegraph node stuff
|
||||
|
||||
void KX_GameObject::NodeSetLocalPosition(const MT_Point3& trans)
|
||||
void KX_GameObject::NodeSetLocalPosition(const MT_Vector3& trans)
|
||||
{
|
||||
// check on valid node in case a python controller holds a reference to a deleted object
|
||||
if (!GetSGNode())
|
||||
@@ -1453,7 +1453,7 @@ void KX_GameObject::NodeSetWorldScale(const MT_Vector3& scale)
|
||||
}
|
||||
}
|
||||
|
||||
void KX_GameObject::NodeSetWorldPosition(const MT_Point3& trans)
|
||||
void KX_GameObject::NodeSetWorldPosition(const MT_Vector3& trans)
|
||||
{
|
||||
if (!GetSGNode())
|
||||
return;
|
||||
@@ -1473,7 +1473,7 @@ void KX_GameObject::NodeSetWorldPosition(const MT_Point3& trans)
|
||||
scale[2] = 1.0/scale[2];
|
||||
MT_Matrix3x3 invori = parent->GetWorldOrientation().inverse();
|
||||
MT_Vector3 newpos = invori*(trans-parent->GetWorldPosition())*scale;
|
||||
NodeSetLocalPosition(MT_Point3(newpos[0],newpos[1],newpos[2]));
|
||||
NodeSetLocalPosition(MT_Vector3(newpos[0],newpos[1],newpos[2]));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1524,7 +1524,7 @@ const MT_Vector3& KX_GameObject::NodeGetLocalScaling() const
|
||||
return GetSGNode()->GetLocalScale();
|
||||
}
|
||||
|
||||
const MT_Point3& KX_GameObject::NodeGetWorldPosition() const
|
||||
const MT_Vector3& KX_GameObject::NodeGetWorldPosition() const
|
||||
{
|
||||
// check on valid node in case a python controller holds a reference to a deleted object
|
||||
if (GetSGNode())
|
||||
@@ -1533,7 +1533,7 @@ const MT_Point3& KX_GameObject::NodeGetWorldPosition() const
|
||||
return dummy_point;
|
||||
}
|
||||
|
||||
const MT_Point3& KX_GameObject::NodeGetLocalPosition() const
|
||||
const MT_Vector3& KX_GameObject::NodeGetLocalPosition() const
|
||||
{
|
||||
// check on valid node in case a python controller holds a reference to a deleted object
|
||||
if (GetSGNode())
|
||||
@@ -1789,15 +1789,15 @@ static int mathutils_kxgameob_vector_set(BaseMathObject *bmo, int subtype)
|
||||
|
||||
switch (subtype) {
|
||||
case MATHUTILS_VEC_CB_POS_LOCAL:
|
||||
self->NodeSetLocalPosition(MT_Point3(bmo->data));
|
||||
self->NodeSetLocalPosition(MT_Vector3(bmo->data));
|
||||
self->NodeUpdateGS(0.f);
|
||||
break;
|
||||
case MATHUTILS_VEC_CB_POS_GLOBAL:
|
||||
self->NodeSetWorldPosition(MT_Point3(bmo->data));
|
||||
self->NodeSetWorldPosition(MT_Vector3(bmo->data));
|
||||
self->NodeUpdateGS(0.f);
|
||||
break;
|
||||
case MATHUTILS_VEC_CB_SCALE_LOCAL:
|
||||
self->NodeSetLocalScale(MT_Point3(bmo->data));
|
||||
self->NodeSetLocalScale(MT_Vector3(bmo->data));
|
||||
self->NodeUpdateGS(0.f);
|
||||
break;
|
||||
case MATHUTILS_VEC_CB_SCALE_GLOBAL:
|
||||
@@ -1810,16 +1810,16 @@ static int mathutils_kxgameob_vector_set(BaseMathObject *bmo, int subtype)
|
||||
self->SetObjectColor(MT_Vector4(bmo->data));
|
||||
break;
|
||||
case MATHUTILS_VEC_CB_LINVEL_LOCAL:
|
||||
self->setLinearVelocity(MT_Point3(bmo->data),true);
|
||||
self->setLinearVelocity(MT_Vector3(bmo->data),true);
|
||||
break;
|
||||
case MATHUTILS_VEC_CB_LINVEL_GLOBAL:
|
||||
self->setLinearVelocity(MT_Point3(bmo->data),false);
|
||||
self->setLinearVelocity(MT_Vector3(bmo->data),false);
|
||||
break;
|
||||
case MATHUTILS_VEC_CB_ANGVEL_LOCAL:
|
||||
self->setAngularVelocity(MT_Point3(bmo->data),true);
|
||||
self->setAngularVelocity(MT_Vector3(bmo->data),true);
|
||||
break;
|
||||
case MATHUTILS_VEC_CB_ANGVEL_GLOBAL:
|
||||
self->setAngularVelocity(MT_Point3(bmo->data),false);
|
||||
self->setAngularVelocity(MT_Vector3(bmo->data),false);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -2616,7 +2616,7 @@ PyObject *KX_GameObject::pyattr_get_worldPosition(void *self_v, const KX_PYATTRI
|
||||
int KX_GameObject::pyattr_set_worldPosition(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
|
||||
{
|
||||
KX_GameObject* self = static_cast<KX_GameObject*>(self_v);
|
||||
MT_Point3 pos;
|
||||
MT_Vector3 pos;
|
||||
if (!PyVecTo(value, pos))
|
||||
return PY_SET_ATTR_FAIL;
|
||||
|
||||
@@ -2640,7 +2640,7 @@ PyObject *KX_GameObject::pyattr_get_localPosition(void *self_v, const KX_PYATTRI
|
||||
int KX_GameObject::pyattr_set_localPosition(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
|
||||
{
|
||||
KX_GameObject* self = static_cast<KX_GameObject*>(self_v);
|
||||
MT_Point3 pos;
|
||||
MT_Vector3 pos;
|
||||
if (!PyVecTo(value, pos))
|
||||
return PY_SET_ATTR_FAIL;
|
||||
|
||||
@@ -2768,7 +2768,7 @@ PyObject *KX_GameObject::pyattr_get_localTransform(void *self_v, const KX_PYATTR
|
||||
{
|
||||
KX_GameObject* self = static_cast<KX_GameObject*>(self_v);
|
||||
|
||||
double mat[16];
|
||||
float mat[16];
|
||||
|
||||
MT_Transform trans;
|
||||
|
||||
@@ -2798,7 +2798,7 @@ int KX_GameObject::pyattr_set_localTransform(void *self_v, const KX_PYATTRIBUTE_
|
||||
temp.getValue(*transform);
|
||||
mat4_to_loc_rot_size(loc, rot, size, transform);
|
||||
|
||||
self->NodeSetLocalPosition(MT_Point3(loc));
|
||||
self->NodeSetLocalPosition(MT_Vector3(loc));
|
||||
|
||||
//MT_Matrix3x3's constructor expects a 4x4 matrix
|
||||
orientation = MT_Matrix3x3();
|
||||
@@ -2832,7 +2832,7 @@ int KX_GameObject::pyattr_set_worldTransform(void *self_v, const KX_PYATTRIBUTE_
|
||||
temp.getValue(*transform);
|
||||
mat4_to_loc_rot_size(loc, rot, size, transform);
|
||||
|
||||
self->NodeSetWorldPosition(MT_Point3(loc));
|
||||
self->NodeSetWorldPosition(MT_Vector3(loc));
|
||||
|
||||
//MT_Matrix3x3's constructor expects a 4x4 matrix
|
||||
orientation = MT_Matrix3x3();
|
||||
@@ -3366,7 +3366,7 @@ PyObject *KX_GameObject::PySetOcclusion(PyObject *args)
|
||||
PyObject *KX_GameObject::PyGetVelocity(PyObject *args)
|
||||
{
|
||||
// only can get the velocity if we have a physics object connected to us...
|
||||
MT_Point3 point(0.0,0.0,0.0);
|
||||
MT_Vector3 point(0.0,0.0,0.0);
|
||||
PyObject *pypos = NULL;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "|O:getVelocity", &pypos) || (pypos && !PyVecTo(pypos, point)))
|
||||
@@ -3470,7 +3470,7 @@ PyObject *KX_GameObject::PyApplyImpulse(PyObject *args)
|
||||
|
||||
if (PyArg_ParseTuple(args, "OO|i:applyImpulse", &pyattach, &pyimpulse, &local))
|
||||
{
|
||||
MT_Point3 attach;
|
||||
MT_Vector3 attach;
|
||||
MT_Vector3 impulse;
|
||||
if (PyVecTo(pyattach, attach) && PyVecTo(pyimpulse, impulse))
|
||||
{
|
||||
@@ -3571,7 +3571,7 @@ PyObject *KX_GameObject::PyGetPropertyNames()
|
||||
KX_PYMETHODDEF_DOC_O(KX_GameObject, getDistanceTo,
|
||||
"getDistanceTo(other): get distance to another point/KX_GameObject")
|
||||
{
|
||||
MT_Point3 b;
|
||||
MT_Vector3 b;
|
||||
if (PyVecTo(value, b))
|
||||
{
|
||||
return PyFloat_FromDouble(NodeGetWorldPosition().distance(b));
|
||||
@@ -3591,7 +3591,7 @@ KX_PYMETHODDEF_DOC_O(KX_GameObject, getVectTo,
|
||||
"getVectTo(other): get vector and the distance to another point/KX_GameObject\n"
|
||||
"Returns a 3-tuple with (distance,worldVector,localVector)\n")
|
||||
{
|
||||
MT_Point3 toPoint, fromPoint;
|
||||
MT_Vector3 toPoint, fromPoint;
|
||||
MT_Vector3 toDir, locToDir;
|
||||
MT_Scalar distance;
|
||||
|
||||
@@ -3700,7 +3700,7 @@ KX_PYMETHODDEF_DOC(KX_GameObject, rayCastTo,
|
||||
" dist = max distance to look (can be negative => look behind); 0 or omitted => detect up to other\n"
|
||||
" other = 3-tuple or object reference")
|
||||
{
|
||||
MT_Point3 toPoint;
|
||||
MT_Vector3 toPoint;
|
||||
PyObject *pyarg;
|
||||
float dist = 0.0f;
|
||||
char *propName = NULL;
|
||||
@@ -3723,7 +3723,7 @@ KX_PYMETHODDEF_DOC(KX_GameObject, rayCastTo,
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
MT_Point3 fromPoint = NodeGetWorldPosition();
|
||||
MT_Vector3 fromPoint = NodeGetWorldPosition();
|
||||
|
||||
if (dist != 0.0f)
|
||||
toPoint = fromPoint + dist * (toPoint-fromPoint).safe_normalized();
|
||||
@@ -3810,8 +3810,8 @@ KX_PYMETHODDEF_DOC(KX_GameObject, rayCast,
|
||||
" prop on, xray off: return closest hit if it matches prop, no hit otherwise\n"
|
||||
" prop on, xray on : return closest hit matching prop or no hit if there is no object matching prop on the full extend of the ray\n")
|
||||
{
|
||||
MT_Point3 toPoint;
|
||||
MT_Point3 fromPoint;
|
||||
MT_Vector3 toPoint;
|
||||
MT_Vector3 fromPoint;
|
||||
PyObject *pyto;
|
||||
PyObject *pyfrom = NULL;
|
||||
float dist = 0.0f;
|
||||
|
@@ -175,7 +175,7 @@ public:
|
||||
* side effect of storing the result internally. The
|
||||
* memory for the matrix remains the property of this class.
|
||||
*/
|
||||
double *
|
||||
float *
|
||||
GetOpenGLMatrix(
|
||||
);
|
||||
|
||||
@@ -435,7 +435,7 @@ public:
|
||||
*/
|
||||
MT_Vector3
|
||||
GetVelocity(
|
||||
const MT_Point3& position
|
||||
const MT_Vector3& position
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -547,7 +547,7 @@ public:
|
||||
* \section Coordinate system manipulation functions
|
||||
*/
|
||||
|
||||
void NodeSetLocalPosition(const MT_Point3& trans );
|
||||
void NodeSetLocalPosition(const MT_Vector3& trans );
|
||||
|
||||
void NodeSetLocalOrientation(const MT_Matrix3x3& rot );
|
||||
void NodeSetGlobalOrientation(const MT_Matrix3x3& rot );
|
||||
@@ -558,7 +558,7 @@ public:
|
||||
void NodeSetRelativeScale( const MT_Vector3& scale );
|
||||
|
||||
// adapt local position so that world position is set to desired position
|
||||
void NodeSetWorldPosition(const MT_Point3& trans);
|
||||
void NodeSetWorldPosition(const MT_Vector3& trans);
|
||||
|
||||
void
|
||||
NodeUpdateGS(
|
||||
@@ -567,11 +567,11 @@ public:
|
||||
|
||||
const MT_Matrix3x3& NodeGetWorldOrientation( ) const;
|
||||
const MT_Vector3& NodeGetWorldScaling( ) const;
|
||||
const MT_Point3& NodeGetWorldPosition( ) const;
|
||||
const MT_Vector3& NodeGetWorldPosition( ) const;
|
||||
|
||||
const MT_Matrix3x3& NodeGetLocalOrientation( ) const;
|
||||
const MT_Vector3& NodeGetLocalScaling( ) const;
|
||||
const MT_Point3& NodeGetLocalPosition( ) const;
|
||||
const MT_Vector3& NodeGetLocalPosition( ) const;
|
||||
|
||||
/**
|
||||
* \section scene graph node accessor functions.
|
||||
|
@@ -52,11 +52,11 @@ public:
|
||||
m_scaling + m_deltaScaling));
|
||||
}
|
||||
|
||||
MT_Point3& GetPosition() { return m_position; }
|
||||
MT_Vector3& GetPosition() { return m_position; }
|
||||
MT_Vector3& GetEulerAngles() { return m_eulerAngles; }
|
||||
MT_Vector3& GetScaling() { return m_scaling; }
|
||||
|
||||
const MT_Point3& GetPosition() const { return m_position; }
|
||||
const MT_Vector3& GetPosition() const { return m_position; }
|
||||
const MT_Vector3& GetEulerAngles() const { return m_eulerAngles; }
|
||||
const MT_Vector3& GetScaling() const { return m_scaling; }
|
||||
|
||||
@@ -64,7 +64,7 @@ public:
|
||||
MT_Vector3& GetDeltaEulerAngles() { return m_deltaEulerAngles; }
|
||||
MT_Vector3& GetDeltaScaling() { return m_deltaScaling; }
|
||||
|
||||
void SetPosition(const MT_Point3& pos) { m_position = pos; }
|
||||
void SetPosition(const MT_Vector3& pos) { m_position = pos; }
|
||||
void SetEulerAngles(const MT_Vector3& eul) { m_eulerAngles = eul; }
|
||||
void SetScaling(const MT_Vector3& scaling) { m_scaling = scaling; }
|
||||
|
||||
@@ -75,7 +75,7 @@ public:
|
||||
}
|
||||
|
||||
protected:
|
||||
MT_Point3 m_position;
|
||||
MT_Vector3 m_position;
|
||||
MT_Vector3 m_eulerAngles;
|
||||
MT_Vector3 m_scaling;
|
||||
MT_Vector3 m_deltaPosition;
|
||||
|
@@ -151,7 +151,7 @@ bool KX_IpoSGController::Update(double currentTime)
|
||||
else {
|
||||
// Local ipo should be defined with the object position at (0,0,0)
|
||||
// Local transform is applied to the object based on initial position
|
||||
MT_Point3 newPosition(0.0f, 0.0f, 0.0f);
|
||||
MT_Vector3 newPosition(0.0f, 0.0f, 0.0f);
|
||||
|
||||
if (!m_ipo_add)
|
||||
newPosition = ob->GetLocalPosition();
|
||||
|
@@ -64,7 +64,7 @@ class KX_IpoSGController : public SG_Controller
|
||||
double m_ipotime;
|
||||
|
||||
/** Location of the object when the IPO is first fired (for local transformations) */
|
||||
MT_Point3 m_ipo_start_point;
|
||||
MT_Vector3 m_ipo_start_point;
|
||||
|
||||
/** Orientation of the object when the IPO is first fired (for local transformations) */
|
||||
MT_Matrix3x3 m_ipo_start_orient;
|
||||
|
@@ -90,7 +90,7 @@ SG_Controller *BL_CreateIPO(struct bAction *action, KX_GameObject* gameobj, KX_B
|
||||
|
||||
Object* blenderobject = gameobj->GetBlenderObject();
|
||||
|
||||
ipocontr->GetIPOTransform().SetPosition(MT_Point3(blenderobject->loc));
|
||||
ipocontr->GetIPOTransform().SetPosition(MT_Vector3(blenderobject->loc));
|
||||
ipocontr->GetIPOTransform().SetEulerAngles(MT_Vector3(blenderobject->rot));
|
||||
ipocontr->GetIPOTransform().SetScaling(MT_Vector3(blenderobject->size));
|
||||
|
||||
|
@@ -1346,7 +1346,7 @@ void KX_KetsjiEngine::PostProcessScene(KX_Scene* scene)
|
||||
activecam->NodeSetLocalOrientation(camtrans.getBasis());
|
||||
activecam->NodeUpdateGS(0);
|
||||
} else {
|
||||
activecam->NodeSetLocalPosition(MT_Point3(0.0, 0.0, 0.0));
|
||||
activecam->NodeSetLocalPosition(MT_Vector3(0.0, 0.0, 0.0));
|
||||
activecam->NodeSetLocalOrientation(MT_Vector3(0.0, 0.0, 0.0));
|
||||
activecam->NodeUpdateGS(0);
|
||||
}
|
||||
|
@@ -43,7 +43,7 @@ KX_MotionState::~KX_MotionState()
|
||||
|
||||
void KX_MotionState::GetWorldPosition(float& posX,float& posY,float& posZ)
|
||||
{
|
||||
const MT_Point3& pos = m_node->GetWorldPosition();
|
||||
const MT_Vector3& pos = m_node->GetWorldPosition();
|
||||
posX = pos[0];
|
||||
posY = pos[1];
|
||||
posZ = pos[2];
|
||||
@@ -79,8 +79,8 @@ void KX_MotionState::SetWorldOrientation(const float* ori)
|
||||
|
||||
void KX_MotionState::SetWorldPosition(float posX,float posY,float posZ)
|
||||
{
|
||||
m_node->SetLocalPosition(MT_Point3(posX,posY,posZ));
|
||||
//m_node->SetWorldPosition(MT_Point3(posX,posY,posZ));
|
||||
m_node->SetLocalPosition(MT_Vector3(posX,posY,posZ));
|
||||
//m_node->SetWorldPosition(MT_Vector3(posX,posY,posZ));
|
||||
}
|
||||
|
||||
void KX_MotionState::SetWorldOrientation(float quatIma0,float quatIma1,float quatIma2,float quatReal)
|
||||
|
@@ -38,7 +38,7 @@
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "MT_Point3.h"
|
||||
#include "MT_Vector3.h"
|
||||
#include "RAS_FramingManager.h"
|
||||
#include "RAS_ICanvas.h"
|
||||
#include "RAS_IRasterizer.h"
|
||||
@@ -391,17 +391,17 @@ bool KX_MouseFocusSensor::ParentObjectHasFocus()
|
||||
return false;
|
||||
}
|
||||
|
||||
const MT_Point3& KX_MouseFocusSensor::RaySource() const
|
||||
const MT_Vector3& KX_MouseFocusSensor::RaySource() const
|
||||
{
|
||||
return m_prevSourcePoint;
|
||||
}
|
||||
|
||||
const MT_Point3& KX_MouseFocusSensor::RayTarget() const
|
||||
const MT_Vector3& KX_MouseFocusSensor::RayTarget() const
|
||||
{
|
||||
return m_prevTargetPoint;
|
||||
}
|
||||
|
||||
const MT_Point3& KX_MouseFocusSensor::HitPosition() const
|
||||
const MT_Vector3& KX_MouseFocusSensor::HitPosition() const
|
||||
{
|
||||
return m_hitPosition;
|
||||
}
|
||||
|
@@ -97,9 +97,9 @@ class KX_MouseFocusSensor : public SCA_MouseSensor
|
||||
/// \see KX_RayCast
|
||||
bool NeedRayCast(KX_ClientObjectInfo *client, void *UNUSED(data));
|
||||
|
||||
const MT_Point3& RaySource() const;
|
||||
const MT_Point3& RayTarget() const;
|
||||
const MT_Point3& HitPosition() const;
|
||||
const MT_Vector3& RaySource() const;
|
||||
const MT_Vector3& RayTarget() const;
|
||||
const MT_Vector3& HitPosition() const;
|
||||
const MT_Vector3& HitNormal() const;
|
||||
const MT_Vector2& HitUV() const;
|
||||
|
||||
@@ -173,17 +173,17 @@ class KX_MouseFocusSensor : public SCA_MouseSensor
|
||||
/**
|
||||
* (in game world coordinates) the place where the object was hit.
|
||||
*/
|
||||
MT_Point3 m_hitPosition;
|
||||
MT_Vector3 m_hitPosition;
|
||||
|
||||
/**
|
||||
* (in game world coordinates) the position to which to shoot the ray.
|
||||
*/
|
||||
MT_Point3 m_prevTargetPoint;
|
||||
MT_Vector3 m_prevTargetPoint;
|
||||
|
||||
/**
|
||||
* (in game world coordinates) the position from which to shoot the ray.
|
||||
*/
|
||||
MT_Point3 m_prevSourcePoint;
|
||||
MT_Vector3 m_prevSourcePoint;
|
||||
|
||||
/**
|
||||
* (in game world coordinates) the face normal of the vertex where
|
||||
|
@@ -310,7 +310,7 @@ bool KX_NavMeshObject::BuildNavMesh()
|
||||
return false;
|
||||
}
|
||||
|
||||
MT_Point3 pos;
|
||||
MT_Vector3 pos;
|
||||
if (dmeshes==NULL)
|
||||
{
|
||||
for (int i=0; i<nverts; i++)
|
||||
@@ -506,8 +506,8 @@ void KX_NavMeshObject::DrawNavMesh(NavMeshRenderMode renderMode)
|
||||
continue;
|
||||
const float* vif = m_navMesh->getVertex(poly->v[i]);
|
||||
const float* vjf = m_navMesh->getVertex(poly->v[j]);
|
||||
MT_Point3 vi(vif[0], vif[2], vif[1]);
|
||||
MT_Point3 vj(vjf[0], vjf[2], vjf[1]);
|
||||
MT_Vector3 vi(vif[0], vif[2], vif[1]);
|
||||
MT_Vector3 vj(vjf[0], vjf[2], vjf[1]);
|
||||
vi = TransformToWorldCoords(vi);
|
||||
vj = TransformToWorldCoords(vj);
|
||||
KX_RasterizerDrawDebugLine(vi, vj, color);
|
||||
@@ -523,7 +523,7 @@ void KX_NavMeshObject::DrawNavMesh(NavMeshRenderMode renderMode)
|
||||
for (int j = 0; j < pd->ntris; ++j)
|
||||
{
|
||||
const unsigned char* t = m_navMesh->getDetailTri(pd->tbase+j);
|
||||
MT_Point3 tri[3];
|
||||
MT_Vector3 tri[3];
|
||||
for (int k = 0; k < 3; ++k)
|
||||
{
|
||||
const float* v;
|
||||
@@ -551,7 +551,7 @@ void KX_NavMeshObject::DrawNavMesh(NavMeshRenderMode renderMode)
|
||||
}
|
||||
}
|
||||
|
||||
MT_Point3 KX_NavMeshObject::TransformToLocalCoords(const MT_Point3& wpos)
|
||||
MT_Vector3 KX_NavMeshObject::TransformToLocalCoords(const MT_Vector3& wpos)
|
||||
{
|
||||
MT_Matrix3x3 orientation = NodeGetWorldOrientation();
|
||||
const MT_Vector3& scaling = NodeGetWorldScaling();
|
||||
@@ -559,26 +559,26 @@ MT_Point3 KX_NavMeshObject::TransformToLocalCoords(const MT_Point3& wpos)
|
||||
MT_Transform worldtr(NodeGetWorldPosition(), orientation);
|
||||
MT_Transform invworldtr;
|
||||
invworldtr.invert(worldtr);
|
||||
MT_Point3 lpos = invworldtr(wpos);
|
||||
MT_Vector3 lpos = invworldtr(wpos);
|
||||
return lpos;
|
||||
}
|
||||
|
||||
MT_Point3 KX_NavMeshObject::TransformToWorldCoords(const MT_Point3& lpos)
|
||||
MT_Vector3 KX_NavMeshObject::TransformToWorldCoords(const MT_Vector3& lpos)
|
||||
{
|
||||
MT_Matrix3x3 orientation = NodeGetWorldOrientation();
|
||||
const MT_Vector3& scaling = NodeGetWorldScaling();
|
||||
orientation.scale(scaling[0], scaling[1], scaling[2]);
|
||||
MT_Transform worldtr(NodeGetWorldPosition(), orientation);
|
||||
MT_Point3 wpos = worldtr(lpos);
|
||||
MT_Vector3 wpos = worldtr(lpos);
|
||||
return wpos;
|
||||
}
|
||||
|
||||
int KX_NavMeshObject::FindPath(const MT_Point3& from, const MT_Point3& to, float* path, int maxPathLen)
|
||||
int KX_NavMeshObject::FindPath(const MT_Vector3& from, const MT_Vector3& to, float* path, int maxPathLen)
|
||||
{
|
||||
if (!m_navMesh)
|
||||
return 0;
|
||||
MT_Point3 localfrom = TransformToLocalCoords(from);
|
||||
MT_Point3 localto = TransformToLocalCoords(to);
|
||||
MT_Vector3 localfrom = TransformToLocalCoords(from);
|
||||
MT_Vector3 localto = TransformToLocalCoords(to);
|
||||
float spos[3], epos[3];
|
||||
localfrom.getValue(spos); flipAxes(spos);
|
||||
localto.getValue(epos); flipAxes(epos);
|
||||
@@ -597,7 +597,7 @@ int KX_NavMeshObject::FindPath(const MT_Point3& from, const MT_Point3& to, float
|
||||
for (int i=0; i<pathLen; i++)
|
||||
{
|
||||
flipAxes(&path[i*3]);
|
||||
MT_Point3 waypoint(&path[i*3]);
|
||||
MT_Vector3 waypoint(&path[i*3]);
|
||||
waypoint = TransformToWorldCoords(waypoint);
|
||||
waypoint.getValue(&path[i*3]);
|
||||
}
|
||||
@@ -609,12 +609,12 @@ int KX_NavMeshObject::FindPath(const MT_Point3& from, const MT_Point3& to, float
|
||||
return pathLen;
|
||||
}
|
||||
|
||||
float KX_NavMeshObject::Raycast(const MT_Point3& from, const MT_Point3& to)
|
||||
float KX_NavMeshObject::Raycast(const MT_Vector3& from, const MT_Vector3& to)
|
||||
{
|
||||
if (!m_navMesh)
|
||||
return 0.f;
|
||||
MT_Point3 localfrom = TransformToLocalCoords(from);
|
||||
MT_Point3 localto = TransformToLocalCoords(to);
|
||||
MT_Vector3 localfrom = TransformToLocalCoords(from);
|
||||
MT_Vector3 localto = TransformToLocalCoords(to);
|
||||
float spos[3], epos[3];
|
||||
localfrom.getValue(spos); flipAxes(spos);
|
||||
localto.getValue(epos); flipAxes(epos);
|
||||
@@ -686,7 +686,7 @@ KX_PYMETHODDEF_DOC(KX_NavMeshObject, findPath,
|
||||
PyObject *ob_from, *ob_to;
|
||||
if (!PyArg_ParseTuple(args,"OO:getPath",&ob_from,&ob_to))
|
||||
return NULL;
|
||||
MT_Point3 from, to;
|
||||
MT_Vector3 from, to;
|
||||
if (!PyVecTo(ob_from, from) || !PyVecTo(ob_to, to))
|
||||
return NULL;
|
||||
|
||||
@@ -695,7 +695,7 @@ KX_PYMETHODDEF_DOC(KX_NavMeshObject, findPath,
|
||||
PyObject *pathList = PyList_New( pathLen );
|
||||
for (int i=0; i<pathLen; i++)
|
||||
{
|
||||
MT_Point3 point(&path[3*i]);
|
||||
MT_Vector3 point(&path[3*i]);
|
||||
PyList_SET_ITEM(pathList, i, PyObjectFrom(point));
|
||||
}
|
||||
|
||||
@@ -709,7 +709,7 @@ KX_PYMETHODDEF_DOC(KX_NavMeshObject, raycast,
|
||||
PyObject *ob_from, *ob_to;
|
||||
if (!PyArg_ParseTuple(args,"OO:getPath",&ob_from,&ob_to))
|
||||
return NULL;
|
||||
MT_Point3 from, to;
|
||||
MT_Vector3 from, to;
|
||||
if (!PyVecTo(ob_from, from) || !PyVecTo(ob_to, to))
|
||||
return NULL;
|
||||
float hit = Raycast(from, to);
|
||||
|
@@ -56,15 +56,15 @@ public:
|
||||
|
||||
bool BuildNavMesh();
|
||||
dtStatNavMesh* GetNavMesh();
|
||||
int FindPath(const MT_Point3& from, const MT_Point3& to, float* path, int maxPathLen);
|
||||
float Raycast(const MT_Point3& from, const MT_Point3& to);
|
||||
int FindPath(const MT_Vector3& from, const MT_Vector3& to, float* path, int maxPathLen);
|
||||
float Raycast(const MT_Vector3& from, const MT_Vector3& to);
|
||||
|
||||
enum NavMeshRenderMode {RM_WALLS, RM_POLYS, RM_TRIS, RM_MAX};
|
||||
void DrawNavMesh(NavMeshRenderMode mode);
|
||||
void DrawPath(const float *path, int pathLen, const MT_Vector3& color);
|
||||
|
||||
MT_Point3 TransformToLocalCoords(const MT_Point3& wpos);
|
||||
MT_Point3 TransformToWorldCoords(const MT_Point3& lpos);
|
||||
MT_Vector3 TransformToLocalCoords(const MT_Vector3& wpos);
|
||||
MT_Vector3 TransformToWorldCoords(const MT_Vector3& lpos);
|
||||
#ifdef WITH_PYTHON
|
||||
/* --------------------------------------------------------------------- */
|
||||
/* Python interface ---------------------------------------------------- */
|
||||
|
@@ -81,7 +81,7 @@ void KX_NearSensor::SynchronizeTransform()
|
||||
{
|
||||
PHY_IMotionState* motionState = m_physCtrl->GetMotionState();
|
||||
KX_GameObject* parent = ((KX_GameObject*)GetParent());
|
||||
const MT_Point3& pos = parent->NodeGetWorldPosition();
|
||||
const MT_Vector3& pos = parent->NodeGetWorldPosition();
|
||||
float ori[12];
|
||||
parent->NodeGetWorldOrientation().getValue(ori);
|
||||
motionState->SetWorldPosition(pos[0], pos[1], pos[2]);
|
||||
|
@@ -165,9 +165,9 @@ bool KX_ObjectActuator::Update()
|
||||
MT_Vector3 v = parent->GetLinearVelocity(m_bitLocalFlag.LinearVelocity);
|
||||
if (m_reference)
|
||||
{
|
||||
const MT_Point3& mypos = parent->NodeGetWorldPosition();
|
||||
const MT_Point3& refpos = m_reference->NodeGetWorldPosition();
|
||||
MT_Point3 relpos;
|
||||
const MT_Vector3& mypos = parent->NodeGetWorldPosition();
|
||||
const MT_Vector3& refpos = m_reference->NodeGetWorldPosition();
|
||||
MT_Vector3 relpos;
|
||||
relpos = (mypos-refpos);
|
||||
MT_Vector3 vel= m_reference->GetVelocity(relpos);
|
||||
if (m_bitLocalFlag.LinearVelocity)
|
||||
|
@@ -234,8 +234,8 @@ void KX_ObstacleSimulation::AddObstaclesForNavMesh(KX_NavMeshObject* navmeshobj)
|
||||
KX_Obstacle* obstacle = CreateObstacle(navmeshobj);
|
||||
obstacle->m_type = KX_OBSTACLE_NAV_MESH;
|
||||
obstacle->m_shape = KX_OBSTACLE_SEGMENT;
|
||||
obstacle->m_pos = MT_Point3(vj[0], vj[2], vj[1]);
|
||||
obstacle->m_pos2 = MT_Point3(vi[0], vi[2], vi[1]);
|
||||
obstacle->m_pos = MT_Vector3(vj[0], vj[2], vj[1]);
|
||||
obstacle->m_pos2 = MT_Vector3(vi[0], vi[2], vi[1]);
|
||||
obstacle->m_rad = 0;
|
||||
}
|
||||
}
|
||||
@@ -308,8 +308,8 @@ void KX_ObstacleSimulation::DrawObstacles()
|
||||
{
|
||||
if (m_obstacles[i]->m_shape==KX_OBSTACLE_SEGMENT)
|
||||
{
|
||||
MT_Point3 p1 = m_obstacles[i]->m_pos;
|
||||
MT_Point3 p2 = m_obstacles[i]->m_pos2;
|
||||
MT_Vector3 p1 = m_obstacles[i]->m_pos;
|
||||
MT_Vector3 p2 = m_obstacles[i]->m_pos2;
|
||||
//apply world transform
|
||||
if (m_obstacles[i]->m_type == KX_OBSTACLE_NAV_MESH)
|
||||
{
|
||||
@@ -328,7 +328,7 @@ void KX_ObstacleSimulation::DrawObstacles()
|
||||
}
|
||||
}
|
||||
|
||||
static MT_Point3 nearestPointToObstacle(MT_Point3& pos ,KX_Obstacle* obstacle)
|
||||
static MT_Vector3 nearestPointToObstacle(MT_Vector3& pos ,KX_Obstacle* obstacle)
|
||||
{
|
||||
switch (obstacle->m_shape)
|
||||
{
|
||||
@@ -342,7 +342,7 @@ static MT_Point3 nearestPointToObstacle(MT_Point3& pos ,KX_Obstacle* obstacle)
|
||||
MT_Vector3 v = pos - obstacle->m_pos;
|
||||
MT_Scalar proj = abdir.dot(v);
|
||||
CLAMP(proj, 0, dist);
|
||||
MT_Point3 res = obstacle->m_pos + abdir*proj;
|
||||
MT_Vector3 res = obstacle->m_pos + abdir*proj;
|
||||
return res;
|
||||
}
|
||||
}
|
||||
@@ -361,7 +361,7 @@ static bool filterObstacle(KX_Obstacle* activeObst, KX_NavMeshObject* activeNavM
|
||||
return false;
|
||||
|
||||
//filter obstacles by position
|
||||
MT_Point3 p = nearestPointToObstacle(activeObst->m_pos, otherObst);
|
||||
MT_Vector3 p = nearestPointToObstacle(activeObst->m_pos, otherObst);
|
||||
if ( fabs(activeObst->m_pos.z() - p.z()) > levelHeight)
|
||||
return false;
|
||||
|
||||
@@ -497,8 +497,8 @@ void KX_ObstacleSimulationTOI_rays::sampleRVO(KX_Obstacle* activeObst, KX_NavMes
|
||||
}
|
||||
else if (ob->m_shape == KX_OBSTACLE_SEGMENT)
|
||||
{
|
||||
MT_Point3 p1 = ob->m_pos;
|
||||
MT_Point3 p2 = ob->m_pos2;
|
||||
MT_Vector3 p1 = ob->m_pos;
|
||||
MT_Vector3 p2 = ob->m_pos2;
|
||||
//apply world transform
|
||||
if (ob->m_type == KX_OBSTACLE_NAV_MESH)
|
||||
{
|
||||
@@ -669,8 +669,8 @@ static void processSamples(KX_Obstacle* activeObst, KX_NavMeshObject* activeNavM
|
||||
}
|
||||
else if (ob->m_shape == KX_OBSTACLE_SEGMENT)
|
||||
{
|
||||
MT_Point3 p1 = ob->m_pos;
|
||||
MT_Point3 p2 = ob->m_pos2;
|
||||
MT_Vector3 p1 = ob->m_pos;
|
||||
MT_Vector3 p2 = ob->m_pos2;
|
||||
//apply world transform
|
||||
if (ob->m_type == KX_OBSTACLE_NAV_MESH)
|
||||
{
|
||||
|
@@ -27,8 +27,8 @@
|
||||
#define __KX_OBSTACLESIMULATION_H__
|
||||
|
||||
#include <vector>
|
||||
#include "MT_Point2.h"
|
||||
#include "MT_Point3.h"
|
||||
#include "MT_Vector2.h"
|
||||
#include "MT_Vector3.h"
|
||||
|
||||
class KX_GameObject;
|
||||
class KX_NavMeshObject;
|
||||
@@ -50,8 +50,8 @@ struct KX_Obstacle
|
||||
{
|
||||
KX_OBSTACLE_TYPE m_type;
|
||||
KX_OBSTACLE_SHAPE m_shape;
|
||||
MT_Point3 m_pos;
|
||||
MT_Point3 m_pos2;
|
||||
MT_Vector3 m_pos;
|
||||
MT_Vector3 m_pos2;
|
||||
MT_Scalar m_rad;
|
||||
|
||||
float vel[2];
|
||||
|
@@ -31,7 +31,7 @@
|
||||
|
||||
|
||||
#include "KX_PositionInterpolator.h"
|
||||
#include "MT_Point3.h"
|
||||
#include "MT_Vector3.h"
|
||||
#include "KX_IScalarInterpolator.h"
|
||||
|
||||
void KX_PositionInterpolator::Execute(float currentTime) const
|
||||
|
@@ -34,12 +34,12 @@
|
||||
|
||||
#include "KX_IInterpolator.h"
|
||||
|
||||
class MT_Point3;
|
||||
class MT_Vector3;
|
||||
class KX_IScalarInterpolator;
|
||||
|
||||
class KX_PositionInterpolator : public KX_IInterpolator {
|
||||
public:
|
||||
KX_PositionInterpolator(MT_Point3& target,
|
||||
KX_PositionInterpolator(MT_Vector3& target,
|
||||
KX_IScalarInterpolator *ipos[]) :
|
||||
m_target(target)
|
||||
{
|
||||
@@ -51,7 +51,7 @@ public:
|
||||
virtual void Execute(float currentTime) const;
|
||||
|
||||
private:
|
||||
MT_Point3& m_target;
|
||||
MT_Vector3& m_target;
|
||||
KX_IScalarInterpolator *m_ipos[3];
|
||||
|
||||
|
||||
|
@@ -40,7 +40,7 @@
|
||||
#include "MT_Vector3.h"
|
||||
#include "MT_Vector4.h"
|
||||
#include "MT_Matrix4x4.h"
|
||||
#include "MT_Point2.h"
|
||||
#include "MT_Vector2.h"
|
||||
|
||||
#include "EXP_ListValue.h"
|
||||
|
||||
@@ -152,7 +152,7 @@ PyObject *PyObjectFrom(const MT_Quaternion &qrot)
|
||||
}
|
||||
#endif
|
||||
|
||||
PyObject *PyObjectFrom(const MT_Tuple4 &vec)
|
||||
PyObject *PyObjectFrom(const MT_Vector4 &vec)
|
||||
{
|
||||
#ifdef USE_MATHUTILS
|
||||
float fvec[4];
|
||||
@@ -168,7 +168,7 @@ PyObject *PyObjectFrom(const MT_Tuple4 &vec)
|
||||
#endif
|
||||
}
|
||||
|
||||
PyObject *PyObjectFrom(const MT_Tuple3 &vec)
|
||||
PyObject *PyObjectFrom(const MT_Vector3 &vec)
|
||||
{
|
||||
#ifdef USE_MATHUTILS
|
||||
float fvec[3];
|
||||
@@ -183,7 +183,7 @@ PyObject *PyObjectFrom(const MT_Tuple3 &vec)
|
||||
#endif
|
||||
}
|
||||
|
||||
PyObject *PyObjectFrom(const MT_Tuple2 &vec)
|
||||
PyObject *PyObjectFrom(const MT_Vector2 &vec)
|
||||
{
|
||||
#ifdef USE_MATHUTILS
|
||||
float fvec[2];
|
||||
|
@@ -33,8 +33,8 @@
|
||||
#ifndef __KX_PYMATH_H__
|
||||
#define __KX_PYMATH_H__
|
||||
|
||||
#include "MT_Point2.h"
|
||||
#include "MT_Point3.h"
|
||||
#include "MT_Vector2.h"
|
||||
#include "MT_Vector3.h"
|
||||
#include "MT_Vector2.h"
|
||||
#include "MT_Vector3.h"
|
||||
#include "MT_Vector4.h"
|
||||
@@ -53,9 +53,9 @@ extern "C" {
|
||||
|
||||
inline unsigned int Size(const MT_Matrix4x4&) { return 4; }
|
||||
inline unsigned int Size(const MT_Matrix3x3&) { return 3; }
|
||||
inline unsigned int Size(const MT_Tuple2&) { return 2; }
|
||||
inline unsigned int Size(const MT_Tuple3&) { return 3; }
|
||||
inline unsigned int Size(const MT_Tuple4&) { return 4; }
|
||||
inline unsigned int Size(const MT_Vector2&) { return 2; }
|
||||
inline unsigned int Size(const MT_Vector3&) { return 3; }
|
||||
inline unsigned int Size(const MT_Vector4&) { return 4; }
|
||||
|
||||
/**
|
||||
* Converts the given python matrix (column-major) to an MT class (row-major).
|
||||
@@ -250,14 +250,14 @@ PyObject *PyObjectFrom(const MT_Matrix4x4 &mat);
|
||||
PyObject *PyObjectFrom(const MT_Matrix3x3 &mat);
|
||||
|
||||
/**
|
||||
* Converts an MT_Tuple2 to a python object.
|
||||
* Converts an MT_Vector2 to a python object.
|
||||
*/
|
||||
PyObject *PyObjectFrom(const MT_Tuple2 &vec);
|
||||
PyObject *PyObjectFrom(const MT_Vector2 &vec);
|
||||
|
||||
/**
|
||||
* Converts an MT_Tuple3 to a python object
|
||||
* Converts an MT_Vector3 to a python object
|
||||
*/
|
||||
PyObject *PyObjectFrom(const MT_Tuple3 &vec);
|
||||
PyObject *PyObjectFrom(const MT_Vector3 &vec);
|
||||
|
||||
#ifdef USE_MATHUTILS
|
||||
/**
|
||||
@@ -267,9 +267,9 @@ PyObject *PyObjectFrom(const MT_Quaternion &qrot);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Converts an MT_Tuple4 to a python object.
|
||||
* Converts an MT_Vector4 to a python object.
|
||||
*/
|
||||
PyObject *PyObjectFrom(const MT_Tuple4 &pos);
|
||||
PyObject *PyObjectFrom(const MT_Vector4 &pos);
|
||||
|
||||
#endif
|
||||
|
||||
|
@@ -108,7 +108,7 @@ extern "C" {
|
||||
#include "RAS_BucketManager.h"
|
||||
#include "RAS_2DFilterManager.h"
|
||||
#include "MT_Vector3.h"
|
||||
#include "MT_Point3.h"
|
||||
#include "MT_Vector3.h"
|
||||
#include "EXP_ListValue.h"
|
||||
#include "EXP_InputParser.h"
|
||||
#include "KX_Scene.h"
|
||||
|
@@ -147,14 +147,14 @@ void KX_RadarSensor::SynchronizeTransform()
|
||||
}
|
||||
}
|
||||
|
||||
//Using a temp variable to translate MT_Point3 to float[3].
|
||||
//Using a temp variable to translate MT_Vector3 to float[3].
|
||||
//float[3] works better for the Python interface.
|
||||
MT_Point3 temp = trans.getOrigin();
|
||||
MT_Vector3 temp = trans.getOrigin();
|
||||
m_cone_origin[0] = temp[0];
|
||||
m_cone_origin[1] = temp[1];
|
||||
m_cone_origin[2] = temp[2];
|
||||
|
||||
temp = trans(MT_Point3(0, -m_coneheight/2.0, 0));
|
||||
temp = trans(MT_Vector3(0, -m_coneheight/2.0, 0));
|
||||
m_cone_target[0] = temp[0];
|
||||
m_cone_target[1] = temp[1];
|
||||
m_cone_target[2] = temp[2];
|
||||
@@ -163,7 +163,7 @@ void KX_RadarSensor::SynchronizeTransform()
|
||||
if (m_physCtrl)
|
||||
{
|
||||
PHY_IMotionState* motionState = m_physCtrl->GetMotionState();
|
||||
const MT_Point3& pos = trans.getOrigin();
|
||||
const MT_Vector3& pos = trans.getOrigin();
|
||||
float ori[12];
|
||||
trans.getBasis().getValue(ori);
|
||||
motionState->SetWorldPosition(pos[0], pos[1], pos[2]);
|
||||
|
@@ -33,7 +33,7 @@
|
||||
#define __KX_RADARSENSOR_H__
|
||||
|
||||
#include "KX_NearSensor.h"
|
||||
#include "MT_Point3.h"
|
||||
#include "MT_Vector3.h"
|
||||
|
||||
/**
|
||||
* Radar 'cone' sensor. Very similar to a near-sensor, but instead of a sphere, a cone is used.
|
||||
|
@@ -36,7 +36,7 @@
|
||||
|
||||
#include "KX_RayCast.h"
|
||||
|
||||
#include "MT_Point3.h"
|
||||
#include "MT_Vector3.h"
|
||||
#include "MT_Vector3.h"
|
||||
|
||||
#include "PHY_IPhysicsEnvironment.h"
|
||||
@@ -58,7 +58,7 @@ void KX_RayCast::reportHit(PHY_RayCastResult* result)
|
||||
m_hitPolygon = result->m_polygon;
|
||||
}
|
||||
|
||||
bool KX_RayCast::RayTest(PHY_IPhysicsEnvironment* physics_environment, const MT_Point3& _frompoint, const MT_Point3& topoint, KX_RayCast& callback)
|
||||
bool KX_RayCast::RayTest(PHY_IPhysicsEnvironment* physics_environment, const MT_Vector3& _frompoint, const MT_Vector3& topoint, KX_RayCast& callback)
|
||||
{
|
||||
if (physics_environment==NULL) return false; /* prevents crashing in some cases */
|
||||
|
||||
@@ -69,9 +69,9 @@ bool KX_RayCast::RayTest(PHY_IPhysicsEnvironment* physics_environment, const MT_
|
||||
//
|
||||
// returns true if an object was found, false if not.
|
||||
|
||||
MT_Point3 frompoint(_frompoint);
|
||||
MT_Vector3 frompoint(_frompoint);
|
||||
const MT_Vector3 todir( (topoint - frompoint).safe_normalized() );
|
||||
MT_Point3 prevpoint(_frompoint+todir*(-1.f));
|
||||
MT_Vector3 prevpoint(_frompoint+todir*(-1.f));
|
||||
|
||||
PHY_IPhysicsController* hit_controller;
|
||||
|
||||
|
@@ -35,7 +35,7 @@
|
||||
#include "PHY_IPhysicsEnvironment.h"
|
||||
#include "PHY_IPhysicsController.h"
|
||||
#include "MT_Vector2.h"
|
||||
#include "MT_Point3.h"
|
||||
#include "MT_Vector3.h"
|
||||
#include "MT_Vector3.h"
|
||||
|
||||
class RAS_MeshObject;
|
||||
@@ -60,7 +60,7 @@ class KX_RayCast : public PHY_IRayCastFilterCallback
|
||||
{
|
||||
public:
|
||||
bool m_hitFound;
|
||||
MT_Point3 m_hitPoint;
|
||||
MT_Vector3 m_hitPoint;
|
||||
MT_Vector3 m_hitNormal;
|
||||
const RAS_MeshObject* m_hitMesh;
|
||||
int m_hitPolygon;
|
||||
@@ -92,8 +92,8 @@ public:
|
||||
/// Implement bool RayHit in your class to receive ray callbacks.
|
||||
static bool RayTest(
|
||||
PHY_IPhysicsEnvironment* physics_environment,
|
||||
const MT_Point3& frompoint,
|
||||
const MT_Point3& topoint,
|
||||
const MT_Vector3& frompoint,
|
||||
const MT_Vector3& topoint,
|
||||
KX_RayCast& callback);
|
||||
|
||||
|
||||
|
@@ -207,7 +207,7 @@ bool KX_RaySensor::Evaluate()
|
||||
m_hitNormal[2] = 0;
|
||||
|
||||
KX_GameObject* obj = (KX_GameObject*)GetParent();
|
||||
MT_Point3 frompoint = obj->NodeGetWorldPosition();
|
||||
MT_Vector3 frompoint = obj->NodeGetWorldPosition();
|
||||
MT_Matrix3x3 matje = obj->NodeGetWorldOrientation();
|
||||
MT_Matrix3x3 invmat = matje.inverse();
|
||||
|
||||
@@ -263,7 +263,7 @@ bool KX_RaySensor::Evaluate()
|
||||
m_rayDirection[1] = todir[1];
|
||||
m_rayDirection[2] = todir[2];
|
||||
|
||||
MT_Point3 topoint = frompoint + (m_distance) * todir;
|
||||
MT_Vector3 topoint = frompoint + (m_distance) * todir;
|
||||
PHY_IPhysicsEnvironment* pe = m_scene->GetPhysicsEnvironment();
|
||||
|
||||
if (!pe)
|
||||
|
@@ -34,7 +34,7 @@
|
||||
#define __KX_RAYSENSOR_H__
|
||||
|
||||
#include "SCA_ISensor.h"
|
||||
#include "MT_Point3.h"
|
||||
#include "MT_Vector3.h"
|
||||
#include "SCA_IScene.h" /* only for scene replace */
|
||||
#include "KX_Scene.h" /* only for scene replace */
|
||||
|
||||
|
@@ -66,7 +66,7 @@ UpdateChildCoordinates(
|
||||
// be nice to have non constant reference access to these values.
|
||||
|
||||
const MT_Vector3 & child_scale = child->GetLocalScale();
|
||||
const MT_Point3 & child_pos = child->GetLocalPosition();
|
||||
const MT_Vector3 & child_pos = child->GetLocalPosition();
|
||||
const MT_Matrix3x3 & child_rotation = child->GetLocalOrientation();
|
||||
// we don't know if the armature has been updated or not, assume yes
|
||||
parentUpdated = true;
|
||||
@@ -74,7 +74,7 @@ UpdateChildCoordinates(
|
||||
// the childs world locations which we will update.
|
||||
|
||||
MT_Vector3 child_w_scale;
|
||||
MT_Point3 child_w_pos;
|
||||
MT_Vector3 child_w_pos;
|
||||
MT_Matrix3x3 child_w_rotation;
|
||||
|
||||
bool valid_parent_transform = false;
|
||||
@@ -109,7 +109,7 @@ UpdateChildCoordinates(
|
||||
child_transform[2][0], child_transform[2][1], child_transform[2][2]);
|
||||
child_w_rotation.scale(1.0/child_w_scale[0], 1.0/child_w_scale[1], 1.0/child_w_scale[2]);
|
||||
|
||||
child_w_pos = MT_Point3(child_transform[0][3], child_transform[1][3], child_transform[2][3]);
|
||||
child_w_pos = MT_Vector3(child_transform[0][3], child_transform[1][3], child_transform[2][3]);
|
||||
|
||||
valid_parent_transform = true;
|
||||
}
|
||||
|
@@ -69,7 +69,7 @@ UpdateChildCoordinates(
|
||||
else {
|
||||
// the childs world locations which we will update.
|
||||
const MT_Vector3 & p_world_scale = parent->GetWorldScaling();
|
||||
const MT_Point3 & p_world_pos = parent->GetWorldPosition();
|
||||
const MT_Vector3 & p_world_pos = parent->GetWorldPosition();
|
||||
const MT_Matrix3x3 & p_world_rotation = parent->GetWorldOrientation();
|
||||
|
||||
child->SetWorldScale(p_world_scale * child->GetLocalScale());
|
||||
@@ -195,13 +195,13 @@ UpdateChildCoordinates(
|
||||
parentUpdated = true;
|
||||
|
||||
const MT_Vector3 & child_scale = child->GetLocalScale();
|
||||
const MT_Point3 & child_pos = child->GetLocalPosition();
|
||||
const MT_Vector3 & child_pos = child->GetLocalPosition();
|
||||
const MT_Matrix3x3 & child_rotation = child->GetLocalOrientation();
|
||||
|
||||
// the childs world locations which we will update.
|
||||
|
||||
MT_Vector3 child_w_scale;
|
||||
MT_Point3 child_w_pos;
|
||||
MT_Vector3 child_w_pos;
|
||||
MT_Matrix3x3 child_w_rotation;
|
||||
|
||||
if (parent) {
|
||||
@@ -210,11 +210,11 @@ UpdateChildCoordinates(
|
||||
// first compute the normal child world coordinates.
|
||||
|
||||
MT_Vector3 child_n_scale;
|
||||
MT_Point3 child_n_pos;
|
||||
MT_Vector3 child_n_pos;
|
||||
MT_Matrix3x3 child_n_rotation;
|
||||
|
||||
const MT_Vector3 & p_world_scale = parent->GetWorldScaling();
|
||||
const MT_Point3 & p_world_pos = parent->GetWorldPosition();
|
||||
const MT_Vector3 & p_world_pos = parent->GetWorldPosition();
|
||||
const MT_Matrix3x3 & p_world_rotation = parent->GetWorldOrientation();
|
||||
|
||||
child_n_scale = p_world_scale * child_scale;
|
||||
|
@@ -802,8 +802,8 @@ void KX_Scene::DupliGroupRecurse(CValue* obj, int level)
|
||||
// set the replica's relative scale with the rootnode's scale
|
||||
replica->NodeSetRelativeScale(newscale);
|
||||
|
||||
MT_Point3 offset(group->dupli_ofs);
|
||||
MT_Point3 newpos = groupobj->NodeGetWorldPosition() +
|
||||
MT_Vector3 offset(group->dupli_ofs);
|
||||
MT_Vector3 newpos = groupobj->NodeGetWorldPosition() +
|
||||
newscale*(groupobj->NodeGetWorldOrientation() * (gameobj->NodeGetWorldPosition()-offset));
|
||||
replica->NodeSetLocalPosition(newpos);
|
||||
// set the orientation after position for softbody!
|
||||
@@ -922,7 +922,7 @@ SCA_IObject* KX_Scene::AddReplicaObject(class CValue* originalobject,
|
||||
if (referenceobj) {
|
||||
// At this stage all the objects in the hierarchy have been duplicated,
|
||||
// we can update the scenegraph, we need it for the duplication of logic
|
||||
MT_Point3 newpos = referenceobj->NodeGetWorldPosition();
|
||||
MT_Vector3 newpos = referenceobj->NodeGetWorldPosition();
|
||||
replica->NodeSetLocalPosition(newpos);
|
||||
|
||||
MT_Matrix3x3 newori = referenceobj->NodeGetWorldOrientation();
|
||||
@@ -1395,13 +1395,13 @@ void KX_Scene::MarkVisible(SG_Tree *node, RAS_IRasterizer* rasty, KX_Camera* cam
|
||||
if (dotest && !node->inside( cam->NodeGetWorldPosition()))
|
||||
{
|
||||
MT_Scalar radius = node->Radius();
|
||||
MT_Point3 center = node->Center();
|
||||
MT_Vector3 center = node->Center();
|
||||
|
||||
intersect = cam->SphereInsideFrustum(center, radius);
|
||||
|
||||
if (intersect == KX_Camera::INTERSECT)
|
||||
{
|
||||
MT_Point3 box[8];
|
||||
MT_Vector3 box[8];
|
||||
node->get(box);
|
||||
intersect = cam->BoxInsideFrustum(box);
|
||||
}
|
||||
@@ -1489,7 +1489,7 @@ void KX_Scene::MarkVisible(RAS_IRasterizer* rasty, KX_GameObject* gameobj,KX_Cam
|
||||
break;
|
||||
case KX_Camera::INTERSECT:
|
||||
// Test the object's bound box against the view frustum.
|
||||
MT_Point3 box[8];
|
||||
MT_Vector3 box[8];
|
||||
gameobj->GetSGNode()->getBBox(box);
|
||||
vis = cam->BoxInsideFrustum(box) != KX_Camera::OUTSIDE;
|
||||
break;
|
||||
@@ -1557,9 +1557,9 @@ void KX_Scene::CalculateVisibleMeshes(RAS_IRasterizer* rasty,KX_Camera* cam, int
|
||||
planes[5].setValue(cplanes[3].getValue()); // bottom
|
||||
CullingInfo info(layer);
|
||||
|
||||
double mvmat[16] = {0};
|
||||
float mvmat[16] = {0};
|
||||
cam->GetModelviewMatrix().getValue(mvmat);
|
||||
double pmat[16] = {0};
|
||||
float pmat[16] = {0};
|
||||
cam->GetProjectionMatrix().getValue(pmat);
|
||||
|
||||
dbvt_culling = m_physicsEnvironment->CullingTest(PhysicsCullingCallback,&info,planes,5,m_dbvt_occlusion_res,
|
||||
@@ -1816,7 +1816,7 @@ void KX_Scene::UpdateObjectActivity(void)
|
||||
/* determine the activity criterium and set objects accordingly */
|
||||
int i=0;
|
||||
|
||||
MT_Point3 camloc = GetActiveCamera()->NodeGetWorldPosition(); //GetCameraLocation();
|
||||
MT_Vector3 camloc = GetActiveCamera()->NodeGetWorldPosition(); //GetCameraLocation();
|
||||
|
||||
for (i=0;i<GetObjectList()->GetCount();i++)
|
||||
{
|
||||
@@ -1825,7 +1825,7 @@ void KX_Scene::UpdateObjectActivity(void)
|
||||
if (!ob->GetIgnoreActivityCulling()) {
|
||||
/* Simple test: more than 10 away from the camera, count
|
||||
* Manhattan distance. */
|
||||
MT_Point3 obpos = ob->NodeGetWorldPosition();
|
||||
MT_Vector3 obpos = ob->NodeGetWorldPosition();
|
||||
|
||||
if ((fabs(camloc[0] - obpos[0]) > m_activity_box_radius) ||
|
||||
(fabs(camloc[1] - obpos[1]) > m_activity_box_radius) ||
|
||||
|
@@ -252,7 +252,7 @@ bool KX_SoundActuator::Update(double curtime, bool frame)
|
||||
if (cam)
|
||||
{
|
||||
KX_GameObject* obj = (KX_GameObject*)this->GetParent();
|
||||
MT_Point3 p;
|
||||
MT_Vector3 p;
|
||||
MT_Matrix3x3 Mo;
|
||||
float data[4];
|
||||
|
||||
|
@@ -187,8 +187,8 @@ bool KX_SteeringActuator::Update(double curtime, bool frame)
|
||||
return false; // do nothing on negative events
|
||||
|
||||
KX_GameObject *obj = (KX_GameObject*) GetParent();
|
||||
const MT_Point3& mypos = obj->NodeGetWorldPosition();
|
||||
const MT_Point3& targpos = m_target->NodeGetWorldPosition();
|
||||
const MT_Vector3& mypos = obj->NodeGetWorldPosition();
|
||||
const MT_Vector3& targpos = m_target->NodeGetWorldPosition();
|
||||
MT_Vector3 vectotarg = targpos - mypos;
|
||||
MT_Vector3 vectotarg2d = vectotarg;
|
||||
vectotarg2d.z() = 0;
|
||||
@@ -499,7 +499,7 @@ void KX_SteeringActuator::HandleActorFace(MT_Vector3& velocity)
|
||||
KX_GameObject* parentObject = curobj->GetParent();
|
||||
if (parentObject)
|
||||
{
|
||||
MT_Point3 localpos;
|
||||
MT_Vector3 localpos;
|
||||
localpos = curobj->GetSGNode()->GetLocalPosition();
|
||||
MT_Matrix3x3 parentmatinv;
|
||||
parentmatinv = parentObject->NodeGetWorldOrientation ().inverse ();
|
||||
|
@@ -329,7 +329,7 @@ bool KX_TrackToActuator::Update(double curtime, bool frame)
|
||||
/* check if the model is parented and calculate the child transform */
|
||||
if (m_parentobj) {
|
||||
|
||||
MT_Point3 localpos;
|
||||
MT_Vector3 localpos;
|
||||
localpos = curobj->GetSGNode()->GetLocalPosition();
|
||||
// Get the inverse of the parent matrix
|
||||
MT_Matrix3x3 parentmatinv;
|
||||
|
@@ -177,7 +177,7 @@ PyObject *KX_VertexProxy::pyattr_get_XYZ(void *self_v, const KX_PYATTRIBUTE_DEF
|
||||
PyObject *KX_VertexProxy::pyattr_get_UV(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
|
||||
{
|
||||
KX_VertexProxy* self = static_cast<KX_VertexProxy*>(self_v);
|
||||
return PyObjectFrom(MT_Point2(self->m_vertex->getUV(0)));
|
||||
return PyObjectFrom(MT_Vector2(self->m_vertex->getUV(0)));
|
||||
}
|
||||
|
||||
PyObject *KX_VertexProxy::pyattr_get_uvs(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
|
||||
@@ -187,7 +187,7 @@ PyObject *KX_VertexProxy::pyattr_get_uvs(void *self_v, const KX_PYATTRIBUTE_DEF
|
||||
PyObject* uvlist = PyList_New(RAS_TexVert::MAX_UNIT);
|
||||
for (int i=0; i<RAS_TexVert::MAX_UNIT; ++i)
|
||||
{
|
||||
PyList_SET_ITEM(uvlist, i, PyObjectFrom(MT_Point2(self->m_vertex->getUV(i))));
|
||||
PyList_SET_ITEM(uvlist, i, PyObjectFrom(MT_Vector2(self->m_vertex->getUV(i))));
|
||||
}
|
||||
|
||||
return uvlist;
|
||||
@@ -214,7 +214,7 @@ int KX_VertexProxy::pyattr_set_x(void *self_v, const struct KX_PYATTRIBUTE_DEF *
|
||||
if (PyFloat_Check(value))
|
||||
{
|
||||
float val = PyFloat_AsDouble(value);
|
||||
MT_Point3 pos(self->m_vertex->getXYZ());
|
||||
MT_Vector3 pos(self->m_vertex->getXYZ());
|
||||
pos.x() = val;
|
||||
self->m_vertex->SetXYZ(pos);
|
||||
self->m_mesh->SetMeshModified(true);
|
||||
@@ -229,7 +229,7 @@ int KX_VertexProxy::pyattr_set_y(void *self_v, const struct KX_PYATTRIBUTE_DEF *
|
||||
if (PyFloat_Check(value))
|
||||
{
|
||||
float val = PyFloat_AsDouble(value);
|
||||
MT_Point3 pos(self->m_vertex->getXYZ());
|
||||
MT_Vector3 pos(self->m_vertex->getXYZ());
|
||||
pos.y() = val;
|
||||
self->m_vertex->SetXYZ(pos);
|
||||
self->m_mesh->SetMeshModified(true);
|
||||
@@ -244,7 +244,7 @@ int KX_VertexProxy::pyattr_set_z(void *self_v, const struct KX_PYATTRIBUTE_DEF *
|
||||
if (PyFloat_Check(value))
|
||||
{
|
||||
float val = PyFloat_AsDouble(value);
|
||||
MT_Point3 pos(self->m_vertex->getXYZ());
|
||||
MT_Vector3 pos(self->m_vertex->getXYZ());
|
||||
pos.z() = val;
|
||||
self->m_vertex->SetXYZ(pos);
|
||||
self->m_mesh->SetMeshModified(true);
|
||||
@@ -259,7 +259,7 @@ int KX_VertexProxy::pyattr_set_u(void *self_v, const struct KX_PYATTRIBUTE_DEF *
|
||||
if (PyFloat_Check(value))
|
||||
{
|
||||
float val = PyFloat_AsDouble(value);
|
||||
MT_Point2 uv = self->m_vertex->getUV(0);
|
||||
MT_Vector2 uv = self->m_vertex->getUV(0);
|
||||
uv[0] = val;
|
||||
self->m_vertex->SetUV(0, uv);
|
||||
self->m_mesh->SetMeshModified(true);
|
||||
@@ -274,7 +274,7 @@ int KX_VertexProxy::pyattr_set_v(void *self_v, const struct KX_PYATTRIBUTE_DEF *
|
||||
if (PyFloat_Check(value))
|
||||
{
|
||||
float val = PyFloat_AsDouble(value);
|
||||
MT_Point2 uv = self->m_vertex->getUV(0);
|
||||
MT_Vector2 uv = self->m_vertex->getUV(0);
|
||||
uv[1] = val;
|
||||
self->m_vertex->SetUV(0, uv);
|
||||
self->m_mesh->SetMeshModified(true);
|
||||
@@ -289,7 +289,7 @@ int KX_VertexProxy::pyattr_set_u2(void *self_v, const struct KX_PYATTRIBUTE_DEF
|
||||
if (PyFloat_Check(value))
|
||||
{
|
||||
float val = PyFloat_AsDouble(value);
|
||||
MT_Point2 uv = self->m_vertex->getUV(1);
|
||||
MT_Vector2 uv = self->m_vertex->getUV(1);
|
||||
uv[0] = val;
|
||||
self->m_vertex->SetUV(1, uv);
|
||||
self->m_mesh->SetMeshModified(true);
|
||||
@@ -304,7 +304,7 @@ int KX_VertexProxy::pyattr_set_v2(void *self_v, const struct KX_PYATTRIBUTE_DEF
|
||||
if (PyFloat_Check(value))
|
||||
{
|
||||
float val = PyFloat_AsDouble(value);
|
||||
MT_Point2 uv = self->m_vertex->getUV(1);
|
||||
MT_Vector2 uv = self->m_vertex->getUV(1);
|
||||
uv[1] = val;
|
||||
self->m_vertex->SetUV(1, uv);
|
||||
self->m_mesh->SetMeshModified(true);
|
||||
@@ -386,7 +386,7 @@ int KX_VertexProxy::pyattr_set_XYZ(void *self_v, const struct KX_PYATTRIBUTE_DEF
|
||||
KX_VertexProxy* self = static_cast<KX_VertexProxy*>(self_v);
|
||||
if (PySequence_Check(value))
|
||||
{
|
||||
MT_Point3 vec;
|
||||
MT_Vector3 vec;
|
||||
if (PyVecTo(value, vec))
|
||||
{
|
||||
self->m_vertex->SetXYZ(vec);
|
||||
@@ -402,7 +402,7 @@ int KX_VertexProxy::pyattr_set_UV(void *self_v, const struct KX_PYATTRIBUTE_DEF
|
||||
KX_VertexProxy* self = static_cast<KX_VertexProxy*>(self_v);
|
||||
if (PySequence_Check(value))
|
||||
{
|
||||
MT_Point2 vec;
|
||||
MT_Vector2 vec;
|
||||
if (PyVecTo(value, vec)) {
|
||||
self->m_vertex->SetUV(0, vec);
|
||||
self->m_mesh->SetMeshModified(true);
|
||||
@@ -417,7 +417,7 @@ int KX_VertexProxy::pyattr_set_uvs(void *self_v, const struct KX_PYATTRIBUTE_DEF
|
||||
KX_VertexProxy* self= static_cast<KX_VertexProxy*>(self_v);
|
||||
if (PySequence_Check(value))
|
||||
{
|
||||
MT_Point2 vec;
|
||||
MT_Vector2 vec;
|
||||
for (int i=0; i<PySequence_Size(value) && i<RAS_TexVert::MAX_UNIT; ++i)
|
||||
{
|
||||
if (PyVecTo(PySequence_GetItem(value, i), vec))
|
||||
@@ -500,12 +500,12 @@ CValue* KX_VertexProxy::GetReplica() { return NULL;}
|
||||
|
||||
PyObject *KX_VertexProxy::PyGetXYZ()
|
||||
{
|
||||
return PyObjectFrom(MT_Point3(m_vertex->getXYZ()));
|
||||
return PyObjectFrom(MT_Vector3(m_vertex->getXYZ()));
|
||||
}
|
||||
|
||||
PyObject *KX_VertexProxy::PySetXYZ(PyObject *value)
|
||||
{
|
||||
MT_Point3 vec;
|
||||
MT_Vector3 vec;
|
||||
if (!PyVecTo(value, vec))
|
||||
return NULL;
|
||||
|
||||
@@ -567,7 +567,7 @@ PyObject *KX_VertexProxy::PyGetUV1()
|
||||
|
||||
PyObject *KX_VertexProxy::PySetUV1(PyObject *value)
|
||||
{
|
||||
MT_Point2 vec;
|
||||
MT_Vector2 vec;
|
||||
if (!PyVecTo(value, vec))
|
||||
return NULL;
|
||||
|
||||
@@ -583,7 +583,7 @@ PyObject *KX_VertexProxy::PyGetUV2()
|
||||
|
||||
PyObject *KX_VertexProxy::PySetUV2(PyObject *args)
|
||||
{
|
||||
MT_Point2 vec;
|
||||
MT_Vector2 vec;
|
||||
if (!PyVecTo(args, vec))
|
||||
return NULL;
|
||||
|
||||
|
@@ -19,7 +19,7 @@ subject to the following restrictions:
|
||||
#include "CcdPhysicsEnvironment.h"
|
||||
#include "CcdGraphicController.h"
|
||||
#include "btBulletDynamicsCommon.h"
|
||||
#include "MT_Point3.h"
|
||||
#include "MT_Vector3.h"
|
||||
|
||||
|
||||
CcdGraphicController::CcdGraphicController (CcdPhysicsEnvironment* phyEnv, PHY_IMotionState* motionState) :
|
||||
@@ -48,13 +48,6 @@ void CcdGraphicController::SetLocalAabb(const btVector3& aabbMin,const btVector3
|
||||
SetGraphicTransform();
|
||||
}
|
||||
|
||||
void CcdGraphicController::SetLocalAabb(const MT_Point3& aabbMin,const MT_Point3& aabbMax)
|
||||
{
|
||||
m_localAabbMin.setValue(aabbMin[0],aabbMin[1],aabbMin[2]);
|
||||
m_localAabbMax.setValue(aabbMax[0],aabbMax[1],aabbMax[2]);
|
||||
SetGraphicTransform();
|
||||
}
|
||||
|
||||
void CcdGraphicController::SetLocalAabb(const MT_Vector3& aabbMin,const MT_Vector3& aabbMax)
|
||||
{
|
||||
m_localAabbMin.setValue(aabbMin[0],aabbMin[1],aabbMin[2]);
|
||||
|
@@ -27,7 +27,7 @@ subject to the following restrictions:
|
||||
#include "LinearMath/btTransform.h"
|
||||
|
||||
#include "PHY_IMotionState.h"
|
||||
#include "MT_Point3.h"
|
||||
#include "MT_Vector3.h"
|
||||
|
||||
class CcdPhysicsEnvironment;
|
||||
class btCollisionObject;
|
||||
@@ -41,7 +41,6 @@ public:
|
||||
virtual ~CcdGraphicController();
|
||||
|
||||
void SetLocalAabb(const btVector3& aabbMin,const btVector3& aabbMax);
|
||||
void SetLocalAabb(const MT_Point3& aabbMin,const MT_Point3& aabbMax);
|
||||
virtual void SetLocalAabb(const MT_Vector3& aabbMin,const MT_Vector3& aabbMax);
|
||||
virtual void SetLocalAabb(const float aabbMin[3],const float aabbMax[3]);
|
||||
|
||||
|
@@ -1346,7 +1346,7 @@ void CcdPhysicsController::SetLinearVelocity(const MT_Vector3& lin_vel,bool loc
|
||||
}
|
||||
}
|
||||
}
|
||||
void CcdPhysicsController::ApplyImpulse(const MT_Point3& attach, const MT_Vector3& impulsein, bool local)
|
||||
void CcdPhysicsController::ApplyImpulse(const MT_Vector3& attach, const MT_Vector3& impulsein, bool local)
|
||||
{
|
||||
btVector3 pos;
|
||||
btVector3 impulse(impulsein.x(), impulsein.y(), impulsein.z());
|
||||
@@ -1452,7 +1452,7 @@ MT_Vector3 CcdPhysicsController::GetAngularVelocity()
|
||||
return MT_Vector3(0.f, 0.f, 0.f);
|
||||
}
|
||||
|
||||
MT_Vector3 CcdPhysicsController::GetVelocity(const MT_Point3 &posin)
|
||||
MT_Vector3 CcdPhysicsController::GetVelocity(const MT_Vector3 &posin)
|
||||
{
|
||||
btVector3 pos(posin.x(), posin.y(), posin.z());
|
||||
btRigidBody* body = GetRigidBody();
|
||||
|
@@ -616,7 +616,7 @@ protected:
|
||||
virtual void SetMass(MT_Scalar newmass);
|
||||
|
||||
// physics methods
|
||||
virtual void ApplyImpulse(const MT_Point3& attach, const MT_Vector3& impulsein, bool local);
|
||||
virtual void ApplyImpulse(const MT_Vector3& attach, const MT_Vector3& impulsein, bool local);
|
||||
virtual void ApplyTorque(const MT_Vector3& torque,bool local);
|
||||
virtual void ApplyForce(const MT_Vector3& force,bool local);
|
||||
virtual void SetAngularVelocity(const MT_Vector3& ang_vel,bool local);
|
||||
@@ -633,7 +633,7 @@ protected:
|
||||
// reading out information from physics
|
||||
virtual MT_Vector3 GetLinearVelocity();
|
||||
virtual MT_Vector3 GetAngularVelocity();
|
||||
virtual MT_Vector3 GetVelocity(const MT_Point3& posin);
|
||||
virtual MT_Vector3 GetVelocity(const MT_Vector3& posin);
|
||||
virtual MT_Vector3 GetLocalInertia();
|
||||
|
||||
// dyna's that are rigidbody are free in orientation, dyna's with non-rigidbody are restricted
|
||||
|
@@ -1455,7 +1455,7 @@ struct OcclusionBuffer
|
||||
m[14] = btScalar(m1[ 2]*m2[12]+m1[ 6]*m2[13]+m1[10]*m2[14]+m1[14]*m2[15]);
|
||||
m[15] = btScalar(m1[ 3]*m2[12]+m1[ 7]*m2[13]+m1[11]*m2[14]+m1[15]*m2[15]);
|
||||
}
|
||||
void setup(int size, const int *view, double modelview[16], double projection[16])
|
||||
void setup(int size, const int *view, float modelview[16], float projection[16])
|
||||
{
|
||||
m_initialized=false;
|
||||
m_occlusion=false;
|
||||
@@ -1505,7 +1505,7 @@ struct OcclusionBuffer
|
||||
m_initialized = true;
|
||||
m_occlusion = false;
|
||||
}
|
||||
void SetModelMatrix(double *fl)
|
||||
void SetModelMatrix(float *fl)
|
||||
{
|
||||
CMmat4mul(m_mtc,m_wtc,fl);
|
||||
if (!m_initialized)
|
||||
@@ -1896,7 +1896,7 @@ struct DbvtCullingCallback : btDbvt::ICollide
|
||||
KX_GameObject* gameobj = KX_GameObject::GetClientObject(info);
|
||||
if (gameobj && gameobj->GetOccluder())
|
||||
{
|
||||
double* fl = gameobj->GetOpenGLMatrixPtr()->getPointer();
|
||||
float* fl = gameobj->GetOpenGLMatrixPtr()->getPointer();
|
||||
// this will create the occlusion buffer if not already done
|
||||
// and compute the transformation from model local space to clip space
|
||||
m_ocb->SetModelMatrix(fl);
|
||||
@@ -1937,7 +1937,7 @@ struct DbvtCullingCallback : btDbvt::ICollide
|
||||
};
|
||||
|
||||
static OcclusionBuffer gOcb;
|
||||
bool CcdPhysicsEnvironment::CullingTest(PHY_CullingCallback callback, void* userData, MT_Vector4 *planes, int nplanes, int occlusionRes, const int *viewport, double modelview[16], double projection[16])
|
||||
bool CcdPhysicsEnvironment::CullingTest(PHY_CullingCallback callback, void* userData, MT_Vector4 *planes, int nplanes, int occlusionRes, const int *viewport, float modelview[16], float projection[16])
|
||||
{
|
||||
if (!m_cullingTree)
|
||||
return false;
|
||||
|
@@ -211,7 +211,7 @@ protected:
|
||||
btTypedConstraint* GetConstraintById(int constraintId);
|
||||
|
||||
virtual PHY_IPhysicsController* RayTest(PHY_IRayCastFilterCallback &filterCallback, float fromX,float fromY,float fromZ, float toX,float toY,float toZ);
|
||||
virtual bool CullingTest(PHY_CullingCallback callback, void* userData, MT_Vector4* planes, int nplanes, int occlusionRes, const int *viewport, double modelview[16], double projection[16]);
|
||||
virtual bool CullingTest(PHY_CullingCallback callback, void* userData, MT_Vector4* planes, int nplanes, int occlusionRes, const int *viewport, float modelview[16], float projection[16]);
|
||||
|
||||
|
||||
//Methods for gamelogic collision/physics callbacks
|
||||
|
@@ -83,7 +83,7 @@ public:
|
||||
}
|
||||
|
||||
virtual PHY_IPhysicsController* RayTest(PHY_IRayCastFilterCallback &filterCallback, float fromX,float fromY,float fromZ, float toX,float toY,float toZ);
|
||||
virtual bool CullingTest(PHY_CullingCallback callback, void* userData, class MT_Vector4* planes, int nplanes, int occlusionRes, const int *viewport, double modelview[16], double projection[16]) { return false; }
|
||||
virtual bool CullingTest(PHY_CullingCallback callback, void* userData, class MT_Vector4* planes, int nplanes, int occlusionRes, const int *viewport, float modelview[16], float projection[16]) { return false; }
|
||||
|
||||
|
||||
//gamelogic callbacks
|
||||
|
@@ -39,7 +39,7 @@ class PHY_IMotionState;
|
||||
class PHY_IPhysicsEnvironment;
|
||||
|
||||
class MT_Vector3;
|
||||
class MT_Point3;
|
||||
class MT_Vector3;
|
||||
class MT_Matrix3x3;
|
||||
|
||||
class KX_GameObject;
|
||||
@@ -83,7 +83,7 @@ class PHY_IPhysicsController : public PHY_IController
|
||||
virtual void SetMass(MT_Scalar newmass)=0;
|
||||
|
||||
// physics methods
|
||||
virtual void ApplyImpulse(const MT_Point3& attach, const MT_Vector3& impulse,bool local)=0;
|
||||
virtual void ApplyImpulse(const MT_Vector3& attach, const MT_Vector3& impulse,bool local)=0;
|
||||
virtual void ApplyTorque(const MT_Vector3& torque,bool local)=0;
|
||||
virtual void ApplyForce(const MT_Vector3& force,bool local)=0;
|
||||
virtual void SetAngularVelocity(const MT_Vector3& ang_vel,bool local)=0;
|
||||
@@ -105,7 +105,7 @@ class PHY_IPhysicsController : public PHY_IController
|
||||
// reading out information from physics
|
||||
virtual MT_Vector3 GetLinearVelocity()=0;
|
||||
virtual MT_Vector3 GetAngularVelocity()=0;
|
||||
virtual MT_Vector3 GetVelocity(const MT_Point3& pos)=0;
|
||||
virtual MT_Vector3 GetVelocity(const MT_Vector3& pos)=0;
|
||||
virtual MT_Vector3 GetLocalInertia()=0;
|
||||
|
||||
// dyna's that are rigidbody are free in orientation, dyna's with non-rigidbody are restricted
|
||||
|
@@ -183,7 +183,7 @@ class PHY_IPhysicsEnvironment
|
||||
//culling based on physical broad phase
|
||||
// the plane number must be set as follow: near, far, left, right, top, botton
|
||||
// the near plane must be the first one and must always be present, it is used to get the direction of the view
|
||||
virtual bool CullingTest(PHY_CullingCallback callback, void *userData, MT_Vector4* planeNormals, int planeNumber, int occlusionRes, const int *viewport, double modelview[16], double projection[16]) = 0;
|
||||
virtual bool CullingTest(PHY_CullingCallback callback, void *userData, MT_Vector4* planeNormals, int planeNumber, int occlusionRes, const int *viewport, float modelview[16], float projection[16]) = 0;
|
||||
|
||||
//Methods for gamelogic collision/physics callbacks
|
||||
//todo:
|
||||
|
@@ -57,7 +57,7 @@ public:
|
||||
void set(RAS_MeshSlot *ms, RAS_MaterialBucket *bucket, const MT_Vector3& pnorm)
|
||||
{
|
||||
// would be good to use the actual bounding box center instead
|
||||
MT_Point3 pos(ms->m_OpenGLMatrix[12], ms->m_OpenGLMatrix[13], ms->m_OpenGLMatrix[14]);
|
||||
MT_Vector3 pos(ms->m_OpenGLMatrix[12], ms->m_OpenGLMatrix[13], ms->m_OpenGLMatrix[14]);
|
||||
|
||||
m_z = MT_dot(pnorm, pos);
|
||||
m_ms = ms;
|
||||
|
@@ -288,11 +288,11 @@ public:
|
||||
* Sets the modelview matrix.
|
||||
*/
|
||||
virtual void SetViewMatrix(const MT_Matrix4x4 &mat, const MT_Matrix3x3 &ori,
|
||||
const MT_Point3 &pos, bool perspective) = 0;
|
||||
const MT_Vector3 &pos, bool perspective) = 0;
|
||||
|
||||
/**
|
||||
*/
|
||||
virtual const MT_Point3& GetCameraPosition() = 0;
|
||||
virtual const MT_Vector3& GetCameraPosition() = 0;
|
||||
virtual bool GetCameraOrtho() = 0;
|
||||
|
||||
/**
|
||||
@@ -423,7 +423,7 @@ public:
|
||||
/**
|
||||
* Render Tools
|
||||
*/
|
||||
virtual void applyTransform(double *oglmatrix, int drawingmode) = 0;
|
||||
virtual void applyTransform(float *oglmatrix, int drawingmode) = 0;
|
||||
|
||||
/**
|
||||
* Renders 2D boxes.
|
||||
|
@@ -128,7 +128,7 @@ public:
|
||||
void* m_clientObj;
|
||||
RAS_Deformer* m_pDeformer;
|
||||
DerivedMesh* m_pDerivedMesh;
|
||||
double* m_OpenGLMatrix;
|
||||
float* m_OpenGLMatrix;
|
||||
// visibility
|
||||
bool m_bVisible;
|
||||
bool m_bCulled;
|
||||
|
@@ -38,7 +38,7 @@
|
||||
#include "RAS_Polygon.h"
|
||||
#include "RAS_IPolygonMaterial.h"
|
||||
#include "RAS_Deformer.h"
|
||||
#include "MT_Point3.h"
|
||||
#include "MT_Vector3.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
@@ -308,8 +308,8 @@ void RAS_MeshObject::SetVertexColor(RAS_IPolyMaterial* mat,MT_Vector4 rgba)
|
||||
}
|
||||
|
||||
void RAS_MeshObject::AddVertex(RAS_Polygon *poly, int i,
|
||||
const MT_Point3& xyz,
|
||||
const MT_Point2 uvs[RAS_TexVert::MAX_UNIT],
|
||||
const MT_Vector3& xyz,
|
||||
const MT_Vector2 uvs[RAS_TexVert::MAX_UNIT],
|
||||
const MT_Vector4& tangent,
|
||||
const unsigned int rgba,
|
||||
const MT_Vector3& normal,
|
||||
|
@@ -110,8 +110,8 @@ public:
|
||||
|
||||
virtual RAS_Polygon* AddPolygon(RAS_MaterialBucket *bucket, int numverts);
|
||||
virtual void AddVertex(RAS_Polygon *poly, int i,
|
||||
const MT_Point3& xyz,
|
||||
const MT_Point2 uvs[RAS_TexVert::MAX_UNIT],
|
||||
const MT_Vector3& xyz,
|
||||
const MT_Vector2 uvs[RAS_TexVert::MAX_UNIT],
|
||||
const MT_Vector4& tangent,
|
||||
const unsigned int rgbacolor,
|
||||
const MT_Vector3& normal,
|
||||
|
@@ -262,7 +262,7 @@ void RAS_OpenGLLight::Update()
|
||||
// lights don't get their openGL matrix updated, do it now
|
||||
if (kxlight->GetSGNode()->IsDirty())
|
||||
kxlight->GetOpenGLMatrix();
|
||||
double *dobmat = kxlight->GetOpenGLMatrixPtr()->getPointer();
|
||||
float *dobmat = kxlight->GetOpenGLMatrixPtr()->getPointer();
|
||||
|
||||
for (int i=0; i<4; i++)
|
||||
for (int j=0; j<4; j++, dobmat++)
|
||||
|
@@ -379,8 +379,8 @@ void RAS_OpenGLRasterizer::FlushDebugShapes(SCA_IScene *scene)
|
||||
glColor4f(debugShapes[i].m_color[0], debugShapes[i].m_color[1], debugShapes[i].m_color[2], 1.0f);
|
||||
const MT_Scalar *fromPtr = &debugShapes[i].m_pos.x();
|
||||
const MT_Scalar *toPtr= &debugShapes[i].m_param.x();
|
||||
glVertex3dv(fromPtr);
|
||||
glVertex3dv(toPtr);
|
||||
glVertex3fv(fromPtr);
|
||||
glVertex3fv(toPtr);
|
||||
}
|
||||
glEnd();
|
||||
|
||||
@@ -416,7 +416,7 @@ void RAS_OpenGLRasterizer::FlushDebugShapes(SCA_IScene *scene)
|
||||
pos = pos*tr;
|
||||
pos += debugShapes[i].m_pos;
|
||||
const MT_Scalar* posPtr = &pos.x();
|
||||
glVertex3dv(posPtr);
|
||||
glVertex3fv(posPtr);
|
||||
}
|
||||
glEnd();
|
||||
}
|
||||
@@ -751,8 +751,8 @@ void RAS_OpenGLRasterizer::IndexPrimitivesMulti(RAS_MeshSlot& ms)
|
||||
void RAS_OpenGLRasterizer::SetProjectionMatrix(MT_CmMatrix4x4 &mat)
|
||||
{
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
double* matrix = &mat(0, 0);
|
||||
glLoadMatrixd(matrix);
|
||||
float* matrix = &mat(0, 0);
|
||||
glLoadMatrixf(matrix);
|
||||
|
||||
m_camortho = (mat(3, 3) != 0.0);
|
||||
}
|
||||
@@ -760,11 +760,11 @@ void RAS_OpenGLRasterizer::SetProjectionMatrix(MT_CmMatrix4x4 &mat)
|
||||
void RAS_OpenGLRasterizer::SetProjectionMatrix(const MT_Matrix4x4 & mat)
|
||||
{
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
double matrix[16];
|
||||
float matrix[16];
|
||||
/* Get into argument. Looks a bit dodgy, but it's ok. */
|
||||
mat.getValue(matrix);
|
||||
/* Internally, MT_Matrix4x4 uses doubles (MT_Scalar). */
|
||||
glLoadMatrixd(matrix);
|
||||
glLoadMatrixf(matrix);
|
||||
|
||||
m_camortho= (mat[3][3] != 0.0);
|
||||
}
|
||||
@@ -780,7 +780,7 @@ MT_Matrix4x4 RAS_OpenGLRasterizer::GetFrustumMatrix(
|
||||
bool
|
||||
) {
|
||||
MT_Matrix4x4 result;
|
||||
double mat[16];
|
||||
float mat[16];
|
||||
|
||||
// correction for stereo
|
||||
if (Stereo())
|
||||
@@ -819,7 +819,7 @@ MT_Matrix4x4 RAS_OpenGLRasterizer::GetFrustumMatrix(
|
||||
glLoadIdentity();
|
||||
glFrustum(left, right, bottom, top, frustnear, frustfar);
|
||||
|
||||
glGetDoublev(GL_PROJECTION_MATRIX, mat);
|
||||
glGetFloatv(GL_PROJECTION_MATRIX, mat);
|
||||
result.setValue(mat);
|
||||
|
||||
return result;
|
||||
@@ -834,14 +834,14 @@ MT_Matrix4x4 RAS_OpenGLRasterizer::GetOrthoMatrix(
|
||||
float frustfar
|
||||
) {
|
||||
MT_Matrix4x4 result;
|
||||
double mat[16];
|
||||
float mat[16];
|
||||
|
||||
// stereo is meaning less for orthographic, disable it
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
glOrtho(left, right, bottom, top, frustnear, frustfar);
|
||||
|
||||
glGetDoublev(GL_PROJECTION_MATRIX, mat);
|
||||
glGetFloatv(GL_PROJECTION_MATRIX, mat);
|
||||
result.setValue(mat);
|
||||
|
||||
return result;
|
||||
@@ -851,7 +851,7 @@ MT_Matrix4x4 RAS_OpenGLRasterizer::GetOrthoMatrix(
|
||||
// next arguments probably contain redundant info, for later...
|
||||
void RAS_OpenGLRasterizer::SetViewMatrix(const MT_Matrix4x4 &mat,
|
||||
const MT_Matrix3x3 & camOrientMat3x3,
|
||||
const MT_Point3 & pos,
|
||||
const MT_Vector3 & pos,
|
||||
bool perspective)
|
||||
{
|
||||
m_viewmatrix = mat;
|
||||
@@ -902,12 +902,12 @@ void RAS_OpenGLRasterizer::SetViewMatrix(const MT_Matrix4x4 &mat,
|
||||
m_viewmatrix.getValue(glviewmat);
|
||||
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glLoadMatrixd(glviewmat);
|
||||
glLoadMatrixf(glviewmat);
|
||||
m_campos = pos;
|
||||
}
|
||||
|
||||
|
||||
const MT_Point3& RAS_OpenGLRasterizer::GetCameraPosition()
|
||||
const MT_Vector3& RAS_OpenGLRasterizer::GetCameraPosition()
|
||||
{
|
||||
return m_campos;
|
||||
}
|
||||
@@ -1215,7 +1215,7 @@ void RAS_OpenGLRasterizer::RemoveLight(RAS_ILightObject* lightobject)
|
||||
m_lights.erase(lit);
|
||||
}
|
||||
|
||||
bool RAS_OpenGLRasterizer::RayHit(struct KX_ClientObjectInfo *client, KX_RayCast *result, double *oglmatrix)
|
||||
bool RAS_OpenGLRasterizer::RayHit(struct KX_ClientObjectInfo *client, KX_RayCast *result, float *oglmatrix)
|
||||
{
|
||||
if (result->m_hitMesh) {
|
||||
|
||||
@@ -1229,14 +1229,14 @@ bool RAS_OpenGLRasterizer::RayHit(struct KX_ClientObjectInfo *client, KX_RayCast
|
||||
left = (dir.cross(resultnormal)).safe_normalized();
|
||||
// for the up vector, we take the 'resultnormal' returned by the physics
|
||||
|
||||
double maat[16] = {left[0], left[1], left[2], 0,
|
||||
float maat[16] = {left[0], left[1], left[2], 0,
|
||||
dir[0], dir[1], dir[2], 0,
|
||||
resultnormal[0], resultnormal[1], resultnormal[2], 0,
|
||||
0, 0, 0, 1};
|
||||
|
||||
glTranslated(oglmatrix[12],oglmatrix[13],oglmatrix[14]);
|
||||
glTranslatef(oglmatrix[12],oglmatrix[13],oglmatrix[14]);
|
||||
//glMultMatrixd(oglmatrix);
|
||||
glMultMatrixd(maat);
|
||||
glMultMatrixf(maat);
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
@@ -1244,7 +1244,7 @@ bool RAS_OpenGLRasterizer::RayHit(struct KX_ClientObjectInfo *client, KX_RayCast
|
||||
}
|
||||
}
|
||||
|
||||
void RAS_OpenGLRasterizer::applyTransform(double* oglmatrix,int objectdrawmode )
|
||||
void RAS_OpenGLRasterizer::applyTransform(float* oglmatrix,int objectdrawmode )
|
||||
{
|
||||
/* FIXME:
|
||||
blender: intern/moto/include/MT_Vector3.inl:42: MT_Vector3 operator/(const
|
||||
@@ -1269,8 +1269,8 @@ void RAS_OpenGLRasterizer::applyTransform(double* oglmatrix,int objectdrawmode )
|
||||
// when new parenting for objects is done, this rotation
|
||||
// will be moved into the object
|
||||
|
||||
MT_Point3 objpos (oglmatrix[12],oglmatrix[13],oglmatrix[14]);
|
||||
MT_Point3 campos = GetCameraPosition();
|
||||
MT_Vector3 objpos (oglmatrix[12],oglmatrix[13],oglmatrix[14]);
|
||||
MT_Vector3 campos = GetCameraPosition();
|
||||
MT_Vector3 dir = (campos - objpos).safe_normalized();
|
||||
MT_Vector3 up(0,0,1.0);
|
||||
|
||||
@@ -1297,27 +1297,27 @@ void RAS_OpenGLRasterizer::applyTransform(double* oglmatrix,int objectdrawmode )
|
||||
dir *= size[1];
|
||||
up *= size[2];
|
||||
|
||||
double maat[16] = {left[0], left[1], left[2], 0,
|
||||
float maat[16] = {left[0], left[1], left[2], 0,
|
||||
dir[0], dir[1], dir[2], 0,
|
||||
up[0], up[1], up[2], 0,
|
||||
0, 0, 0, 1};
|
||||
|
||||
glTranslatef(objpos[0],objpos[1],objpos[2]);
|
||||
glMultMatrixd(maat);
|
||||
glMultMatrixf(maat);
|
||||
|
||||
}
|
||||
else {
|
||||
if (objectdrawmode & RAS_IPolyMaterial::SHADOW)
|
||||
{
|
||||
// shadow must be cast to the ground, physics system needed here!
|
||||
MT_Point3 frompoint(oglmatrix[12],oglmatrix[13],oglmatrix[14]);
|
||||
MT_Vector3 frompoint(oglmatrix[12],oglmatrix[13],oglmatrix[14]);
|
||||
KX_GameObject *gameobj = (KX_GameObject*)m_clientobject;
|
||||
MT_Vector3 direction = MT_Vector3(0,0,-1);
|
||||
|
||||
direction.normalize();
|
||||
direction *= 100000;
|
||||
|
||||
MT_Point3 topoint = frompoint + direction;
|
||||
MT_Vector3 topoint = frompoint + direction;
|
||||
|
||||
KX_Scene* kxscene = (KX_Scene*) m_auxilaryClientInfo;
|
||||
PHY_IPhysicsEnvironment* physics_environment = kxscene->GetPhysicsEnvironment();
|
||||
@@ -1327,11 +1327,11 @@ void RAS_OpenGLRasterizer::applyTransform(double* oglmatrix,int objectdrawmode )
|
||||
if (!physics_controller && parent)
|
||||
physics_controller = parent->GetPhysicsController();
|
||||
|
||||
KX_RayCast::Callback<RAS_OpenGLRasterizer, double> callback(this, physics_controller, oglmatrix);
|
||||
KX_RayCast::Callback<RAS_OpenGLRasterizer, float> callback(this, physics_controller, oglmatrix);
|
||||
if (!KX_RayCast::RayTest(physics_environment, frompoint, topoint, callback))
|
||||
{
|
||||
// couldn't find something to cast the shadow on...
|
||||
glMultMatrixd(oglmatrix);
|
||||
glMultMatrixf(oglmatrix);
|
||||
}
|
||||
else
|
||||
{ // we found the "ground", but the cast matrix doesn't take
|
||||
@@ -1343,7 +1343,7 @@ void RAS_OpenGLRasterizer::applyTransform(double* oglmatrix,int objectdrawmode )
|
||||
{
|
||||
|
||||
// 'normal' object
|
||||
glMultMatrixd(oglmatrix);
|
||||
glMultMatrixf(oglmatrix);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user