2007-01-15 12:09:25 -08:00
|
|
|
/*
|
|
|
|
This file is part of Warzone 2100.
|
|
|
|
Copyright (C) 1999-2004 Eidos Interactive
|
2009-02-10 10:01:48 -08:00
|
|
|
Copyright (C) 2005-2009 Warzone Resurrection Project
|
2007-01-15 12:09:25 -08:00
|
|
|
|
|
|
|
Warzone 2100 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.
|
|
|
|
|
|
|
|
Warzone 2100 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 Warzone 2100; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
*/
|
2007-06-28 10:47:08 -07:00
|
|
|
/***************************************************************************/
|
|
|
|
/*
|
|
|
|
* pieMatrix.h
|
|
|
|
*
|
|
|
|
* matrix functions for pumpkin image library.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
/***************************************************************************/
|
|
|
|
#ifndef _pieMatrix_h
|
|
|
|
#define _pieMatrix_h
|
|
|
|
|
2006-05-27 09:37:17 -07:00
|
|
|
#include "lib/ivis_common/piedef.h"
|
2007-06-28 10:47:08 -07:00
|
|
|
|
2007-04-27 03:21:17 -07:00
|
|
|
// FIXME DUPLICATE CODE! Already present in trig.c!
|
2008-03-07 07:09:03 -08:00
|
|
|
#define SC_TABLESIZE 4096
|
2007-05-20 04:05:28 -07:00
|
|
|
#define SIN(X) aSinTable[(Uint16)(X) >> 4]
|
2008-03-07 07:09:03 -08:00
|
|
|
#define COS(X) aSinTable[((Uint16)(X) >> 4) + (SC_TABLESIZE/4)]
|
2007-06-28 10:47:08 -07:00
|
|
|
|
2008-03-07 07:09:03 -08:00
|
|
|
extern SDWORD aSinTable[];
|
2007-06-28 10:47:08 -07:00
|
|
|
|
|
|
|
//*************************************************************************
|
|
|
|
|
2007-05-20 04:05:28 -07:00
|
|
|
/*!
|
|
|
|
* Rotate and translate v with the worldmatrix. Store the result in s
|
2008-05-14 14:15:59 -07:00
|
|
|
* int variant
|
2007-05-20 04:05:28 -07:00
|
|
|
* \param[in] v Vector to translate
|
|
|
|
* \param[out] s Resulting vector
|
|
|
|
*/
|
2008-01-27 13:05:30 -08:00
|
|
|
void pie_RotateTranslate3iv(const Vector3i *v, Vector3i *s);
|
2007-06-28 10:47:08 -07:00
|
|
|
|
2007-05-21 11:25:46 -07:00
|
|
|
|
2008-05-14 14:15:59 -07:00
|
|
|
/*!
|
|
|
|
* Rotate and translate v with the worldmatrix. Store the result in s
|
|
|
|
* Float variant
|
|
|
|
* \param[in] v Vector to translate
|
|
|
|
* \param[out] s Resulting vector
|
|
|
|
*/
|
|
|
|
void pie_RotateTranslate3f(const Vector3f *v, Vector3f *s);
|
|
|
|
|
|
|
|
|
2007-05-21 11:57:11 -07:00
|
|
|
/*!
|
2008-01-27 17:29:20 -08:00
|
|
|
* Calculate surface normal
|
|
|
|
* Eg. if a polygon (with n points in clockwise order) normal is required,
|
|
|
|
* \c p1 = point 0, \c p2 = point 1, \c p3 = point n-1
|
|
|
|
* \param p1,p2,p3 Points for forming 2 vector for cross product
|
|
|
|
* \return Normal vector
|
2007-05-21 11:57:11 -07:00
|
|
|
*/
|
2008-01-27 17:29:20 -08:00
|
|
|
static inline WZ_DECL_CONST WZ_DECL_WARN_UNUSED_RESULT
|
|
|
|
Vector3f pie_SurfaceNormal3fv(const Vector3f p1, const Vector3f p2, const Vector3f p3)
|
2007-05-21 11:57:11 -07:00
|
|
|
{
|
2008-01-27 17:29:20 -08:00
|
|
|
Vector3f
|
|
|
|
a = {
|
|
|
|
p3.x - p1.x,
|
|
|
|
p3.y - p1.y,
|
|
|
|
p3.z - p1.z
|
|
|
|
},
|
|
|
|
b = {
|
|
|
|
p2.x - p1.x,
|
|
|
|
p2.y - p1.y,
|
|
|
|
p2.z - p1.z
|
|
|
|
};
|
|
|
|
|
|
|
|
a = Vector3f_Normalise(a);
|
|
|
|
b = Vector3f_Normalise(b);
|
|
|
|
|
2008-05-14 14:15:59 -07:00
|
|
|
{ // MSVC HACK
|
2008-01-27 17:29:20 -08:00
|
|
|
Vector3f
|
|
|
|
v = {
|
|
|
|
(a.y * b.z) - (a.z * b.y),
|
|
|
|
(a.z * b.x) - (a.x * b.z),
|
|
|
|
(a.x * b.y) - (a.y * b.x)
|
|
|
|
};
|
|
|
|
|
|
|
|
return Vector3f_Normalise(v);
|
|
|
|
}
|
2007-05-21 11:57:11 -07:00
|
|
|
}
|
|
|
|
|
2007-06-28 10:47:08 -07:00
|
|
|
//*************************************************************************
|
|
|
|
|
|
|
|
|
|
|
|
extern void pie_MatInit(void);
|
|
|
|
|
|
|
|
|
|
|
|
//*************************************************************************
|
|
|
|
|
|
|
|
extern void pie_MatBegin(void);
|
|
|
|
extern void pie_MatEnd(void);
|
2007-05-20 04:05:28 -07:00
|
|
|
extern void pie_MATTRANS(int x, int y, int z);
|
2007-06-28 10:47:08 -07:00
|
|
|
extern void pie_TRANSLATE(int x, int y, int z);
|
2008-03-07 07:09:03 -08:00
|
|
|
extern void pie_MatScale( unsigned int percent );
|
2007-06-28 10:47:08 -07:00
|
|
|
extern void pie_MatRotX(int x);
|
|
|
|
extern void pie_MatRotY(int y);
|
|
|
|
extern void pie_MatRotZ(int z);
|
2007-05-29 18:50:01 -07:00
|
|
|
extern Sint32 pie_RotateProject(const Vector3i *src, Vector2i *dest);
|
2007-06-28 10:47:08 -07:00
|
|
|
|
|
|
|
//*************************************************************************
|
|
|
|
|
2006-09-13 02:09:05 -07:00
|
|
|
extern void pie_PerspectiveBegin(void);
|
|
|
|
extern void pie_PerspectiveEnd(void);
|
2007-06-28 10:47:08 -07:00
|
|
|
|
2007-12-01 08:43:28 -08:00
|
|
|
extern void pie_TranslateTextureBegin(Vector2f offset);
|
|
|
|
extern void pie_TranslateTextureEnd(void);
|
|
|
|
|
2007-06-28 10:47:08 -07:00
|
|
|
//*************************************************************************
|
|
|
|
|
2008-01-27 13:05:30 -08:00
|
|
|
extern void pie_VectorInverseRotate0(const Vector3i *v1, Vector3i *v2);
|
2007-06-28 10:47:08 -07:00
|
|
|
extern void pie_SetGeometricOffset(int x, int y);
|
|
|
|
|
2008-01-27 17:29:20 -08:00
|
|
|
extern void pie_Begin3DScene(void);
|
|
|
|
extern void pie_BeginInterface(void);
|
2007-06-28 10:47:08 -07:00
|
|
|
|
|
|
|
#endif
|