2010-01-06 15:00:08 +01:00
|
|
|
/*
|
|
|
|
OpenMW - The completely unofficial reimplementation of Morrowind
|
|
|
|
Copyright (C) 2008-2010 Nicolay Korslund
|
|
|
|
Email: < korslund@gmail.com >
|
|
|
|
WWW: http://openmw.sourceforge.net/
|
|
|
|
|
|
|
|
This file (nif_types.h) is part of the OpenMW package.
|
|
|
|
|
|
|
|
OpenMW is distributed as free software: you can redistribute it
|
|
|
|
and/or modify it under the terms of the GNU General Public License
|
|
|
|
version 3, as published by the Free Software Foundation.
|
|
|
|
|
|
|
|
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
|
|
|
|
version 3 along with this program. If not, see
|
|
|
|
http://www.gnu.org/licenses/ .
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
2013-02-24 13:51:56 -08:00
|
|
|
#ifndef OPENMW_COMPONENTS_NIF_NIFTYPES_HPP
|
|
|
|
#define OPENMW_COMPONENTS_NIF_NIFTYPES_HPP
|
2010-01-06 15:00:08 +01:00
|
|
|
|
2015-02-17 17:08:55 +01:00
|
|
|
#include <osg/Vec3f>
|
2015-05-07 21:17:15 +02:00
|
|
|
#include <osg/Matrixf>
|
2012-07-10 02:38:35 -07:00
|
|
|
|
2010-01-06 15:00:08 +01:00
|
|
|
// Common types used in NIF files
|
|
|
|
|
|
|
|
namespace Nif
|
|
|
|
{
|
|
|
|
|
2015-02-17 17:08:55 +01:00
|
|
|
struct Matrix3
|
|
|
|
{
|
|
|
|
float mValues[3][3];
|
|
|
|
|
|
|
|
Matrix3()
|
|
|
|
{
|
|
|
|
for (int i=0;i<3;++i)
|
|
|
|
for (int j=0;j<3;++j)
|
2015-02-20 17:56:49 +01:00
|
|
|
mValues[i][j] = (i==j) ? 1.f : 0.f;
|
2015-02-17 17:08:55 +01:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2010-01-06 15:00:08 +01:00
|
|
|
struct Transformation
|
|
|
|
{
|
2015-02-17 17:08:55 +01:00
|
|
|
osg::Vec3f pos;
|
2015-03-22 22:52:44 +01:00
|
|
|
Matrix3 rotation; // this can contain scale components too, including negative and nonuniform scales
|
2012-03-23 22:15:45 +02:00
|
|
|
float scale;
|
|
|
|
|
2015-05-07 21:17:15 +02:00
|
|
|
osg::Matrixf toMatrix() const
|
|
|
|
{
|
|
|
|
osg::Matrixf transform;
|
|
|
|
transform.setTrans(pos);
|
|
|
|
|
|
|
|
for (int i=0;i<3;++i)
|
|
|
|
for (int j=0;j<3;++j)
|
|
|
|
transform(j,i) = rotation.mValues[i][j] * scale; // NB column/row major difference
|
|
|
|
|
|
|
|
return transform;
|
|
|
|
}
|
|
|
|
|
2012-07-09 21:35:36 -07:00
|
|
|
static const Transformation& getIdentity()
|
2012-03-23 22:15:45 +02:00
|
|
|
{
|
2012-07-10 23:13:03 -07:00
|
|
|
static const Transformation identity = {
|
2015-02-17 17:08:55 +01:00
|
|
|
osg::Vec3f(), Matrix3(), 1.0f
|
2012-07-10 23:13:03 -07:00
|
|
|
};
|
2012-07-09 21:35:36 -07:00
|
|
|
return identity;
|
2012-03-23 22:15:45 +02:00
|
|
|
}
|
2010-01-06 15:00:08 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
} // Namespace
|
|
|
|
#endif
|