2002-02-23 21:20:00 +00:00
|
|
|
// model.cxx - manage a 3D aircraft model.
|
|
|
|
// Written by David Megginson, started 2002.
|
|
|
|
//
|
|
|
|
// This file is in the Public Domain, and comes with no warranty.
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include <config.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <plib/sg.h>
|
|
|
|
#include <plib/ssg.h>
|
|
|
|
|
|
|
|
#include <simgear/compiler.h>
|
|
|
|
#include <simgear/debug/logstream.hxx>
|
|
|
|
#include <simgear/misc/exception.hxx>
|
2002-02-25 20:07:34 +00:00
|
|
|
#include <simgear/misc/sg_path.hxx>
|
2002-02-23 21:20:00 +00:00
|
|
|
|
|
|
|
#include "globals.hxx"
|
|
|
|
#include "fg_props.hxx"
|
|
|
|
#include "viewmgr.hxx"
|
|
|
|
#include "model.hxx"
|
|
|
|
|
|
|
|
extern unsigned long int fgSimTime; // FIXME: this is ugly
|
|
|
|
|
|
|
|
extern ssgRoot * scene; // FIXME: from main.cxx
|
|
|
|
|
|
|
|
FGAircraftModel current_model; // FIXME: add to globals
|
|
|
|
|
|
|
|
|
|
|
|
static ssgEntity *
|
|
|
|
find_named_node (ssgEntity * node, const string &name)
|
|
|
|
{
|
|
|
|
char * node_name = node->getName();
|
|
|
|
if (node_name != 0 && name == node_name)
|
|
|
|
return node;
|
|
|
|
else if (node->isAKindOf(ssgTypeBranch())) {
|
|
|
|
int nKids = node->getNumKids();
|
|
|
|
for (int i = 0; i < nKids; i++) {
|
|
|
|
ssgEntity * result =
|
|
|
|
find_named_node(((ssgBranch*)node)->getKid(i), name);
|
|
|
|
if (result != 0)
|
|
|
|
return result;
|
|
|
|
}
|
2002-02-24 21:14:38 +00:00
|
|
|
}
|
|
|
|
return 0;
|
2002-02-23 21:20:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
FGAircraftModel::FGAircraftModel ()
|
2002-02-27 12:46:38 +00:00
|
|
|
: _model(0),
|
2002-02-23 21:20:00 +00:00
|
|
|
_selector(new ssgSelector),
|
2002-02-26 00:10:06 +00:00
|
|
|
_position(new ssgTransform)
|
2002-02-23 21:20:00 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
FGAircraftModel::~FGAircraftModel ()
|
|
|
|
{
|
|
|
|
// since the nodes are attached to the scene graph, they'll be
|
|
|
|
// deleted automatically
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
FGAircraftModel::init ()
|
|
|
|
{
|
|
|
|
// TODO: optionally load an XML file with a pointer to the 3D object
|
|
|
|
// and placement and animation info
|
|
|
|
|
2002-02-27 12:46:38 +00:00
|
|
|
SGPropertyNode props;
|
|
|
|
|
2002-02-26 00:10:06 +00:00
|
|
|
SG_LOG(SG_INPUT, SG_INFO, "Initializing aircraft 3D model");
|
|
|
|
|
2002-02-23 21:20:00 +00:00
|
|
|
// Load the 3D aircraft object itself
|
2002-03-20 22:40:11 +00:00
|
|
|
// DCL - the xml parser requires the full path but the ssgLoader doesn't
|
|
|
|
// so lets have two paths.
|
|
|
|
SGPath xmlpath = globals->get_fg_root();
|
|
|
|
SGPath modelpath = (string)fgGetString("/sim/model/path", "Models/Geometry/glider.ac");
|
|
|
|
xmlpath.append(modelpath.str());
|
|
|
|
|
|
|
|
if (xmlpath.str().substr(xmlpath.str().size() - 4, 4) == ".xml") {
|
|
|
|
readProperties(xmlpath.str(), &props);
|
2002-02-27 12:46:38 +00:00
|
|
|
if (props.hasValue("/path")) {
|
2002-03-20 22:40:11 +00:00
|
|
|
modelpath = modelpath.dir();
|
|
|
|
modelpath.append(props.getStringValue("/path"));
|
2002-02-25 20:07:34 +00:00
|
|
|
} else {
|
2002-03-20 22:40:11 +00:00
|
|
|
modelpath = "Models/Geometry/glider.ac";
|
2002-02-25 20:07:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-03-20 22:40:11 +00:00
|
|
|
ssgTexturePath((char *)xmlpath.dir().c_str());
|
|
|
|
_model = ssgLoad((char *)modelpath.c_str());
|
2002-02-26 00:10:06 +00:00
|
|
|
if (_model == 0) {
|
|
|
|
_model = ssgLoad((char *)"Models/Geometry/glider.ac");
|
|
|
|
if (_model == 0)
|
2002-02-23 21:20:00 +00:00
|
|
|
throw sg_exception("Failed to load an aircraft model");
|
|
|
|
}
|
|
|
|
|
2002-02-26 00:10:06 +00:00
|
|
|
// Load animations
|
|
|
|
vector<SGPropertyNode *> animation_nodes =
|
2002-02-27 12:46:38 +00:00
|
|
|
props.getChildren("animation");
|
2002-03-04 15:46:44 +00:00
|
|
|
for (unsigned int i = 0; i < animation_nodes.size(); i++) {
|
2002-02-27 20:32:24 +00:00
|
|
|
vector<SGPropertyNode *> name_nodes =
|
|
|
|
animation_nodes[i]->getChildren("object-name");
|
|
|
|
if (name_nodes.size() < 1) {
|
|
|
|
SG_LOG(SG_INPUT, SG_ALERT, "No object-name given for transformation");
|
|
|
|
} else {
|
2002-03-04 15:46:44 +00:00
|
|
|
for (unsigned int j = 0; j < name_nodes.size(); j++) {
|
2002-02-27 20:32:24 +00:00
|
|
|
_animations.push_back(read_animation(name_nodes[j]->getStringValue(),
|
|
|
|
animation_nodes[i]));
|
|
|
|
}
|
|
|
|
}
|
2002-02-23 21:20:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Set up the alignment node
|
|
|
|
ssgTransform * align = new ssgTransform;
|
2002-02-26 00:10:06 +00:00
|
|
|
align->addKid(_model);
|
2002-02-23 21:20:00 +00:00
|
|
|
sgMat4 rot_matrix;
|
|
|
|
sgMat4 off_matrix;
|
|
|
|
sgMat4 res_matrix;
|
2002-02-27 12:46:38 +00:00
|
|
|
float h_rot = props.getFloatValue("/offsets/heading-deg", 0.0);
|
|
|
|
float p_rot = props.getFloatValue("/offsets/roll-deg", 0.0);
|
|
|
|
float r_rot = props.getFloatValue("/offsets/pitch-deg", 0.0);
|
|
|
|
float x_off = props.getFloatValue("/offsets/x-m", 0.0);
|
|
|
|
float y_off = props.getFloatValue("/offsets/y-m", 0.0);
|
|
|
|
float z_off = props.getFloatValue("/offsets/z-m", 0.0);
|
2002-02-23 21:20:00 +00:00
|
|
|
sgMakeRotMat4(rot_matrix, h_rot, p_rot, r_rot);
|
|
|
|
sgMakeTransMat4(off_matrix, x_off, y_off, z_off);
|
|
|
|
sgMultMat4(res_matrix, off_matrix, rot_matrix);
|
|
|
|
align->setTransform(res_matrix);
|
|
|
|
|
|
|
|
// Set up the position node
|
|
|
|
_position->addKid(align);
|
|
|
|
|
|
|
|
// Set up the selector node
|
|
|
|
_selector->addKid(_position);
|
|
|
|
_selector->clrTraversalMaskBits(SSGTRAV_HOT);
|
|
|
|
scene->addKid(_selector);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
FGAircraftModel::bind ()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
FGAircraftModel::unbind ()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
FGAircraftModel::update (int dt)
|
|
|
|
{
|
2002-03-25 14:32:13 +00:00
|
|
|
sgMat4 VIEW_ROT;
|
|
|
|
|
2002-02-23 21:20:00 +00:00
|
|
|
_current_timestamp.stamp();
|
2002-02-26 00:10:06 +00:00
|
|
|
long elapsed_ms = (_current_timestamp - _last_timestamp) / 1000;
|
2002-02-23 21:20:00 +00:00
|
|
|
_last_timestamp.stamp();
|
|
|
|
|
2002-03-05 13:39:45 +00:00
|
|
|
int view_number = globals->get_viewmgr()->get_current();
|
|
|
|
|
2002-03-15 21:50:14 +00:00
|
|
|
if (view_number == 0 && !fgGetBool("/sim/view/internal")) {
|
2002-02-23 21:20:00 +00:00
|
|
|
_selector->select(false);
|
|
|
|
} else {
|
2002-03-04 15:46:44 +00:00
|
|
|
for (unsigned int i = 0; i < _animations.size(); i++)
|
2002-02-26 00:10:06 +00:00
|
|
|
do_animation(_animations[i], elapsed_ms);
|
|
|
|
|
2002-02-23 21:20:00 +00:00
|
|
|
_selector->select(true);
|
Major viewer-code overhaul from Jim Wilson:
Description:
This update includes the new viewer interface as proposed by David M. and
a first pass at cleaning up the viewer/view manager code by Jim W.
Note that I have dropped Main/viewer_lookat.?xx and Main/viewer_rph.?xx and
modified the Makefile.am accordingly.
Detail of work:
Overall:
The code reads a little easier. There are still some unnecessary bits in
there and I'd like to supplement the comments in the viewer.hxx with a tiny
bit on each interface group and what the groupings mean (similar but briefer
than what you emailed me the other day). I tried not to mess up the style,
but there is an occasional inconsistency. In general I wouldn't call it done
(especially since there's no tower yet! :)), but I'd like to get this out
there so others can comment, and test.
In Viewer:
The interface as you suggested has been implemented. Basically everything
seems to work as it did visually. There is no difference that I can see in
performance, although some things might be a tiny bit faster.
I've merged the lookat and rph (pilot view) code into the recalc for the
viewer. There is still some redundancy between the two, but a lot has been
removed. In some cases I've taken some code that we'd likely want to inline
anyway and left it in there in duplicate. You'll see that the code for both
looks a little cleaner. I need to take a closer look at the rotations in
particular. I've cleaned up a little there, but I suspect more can be done
to streamline this.
The external declaration to the Quat_mat in mouse.cxx has been removed. IMHO
the quat doesn't serve any intrinsic purpose in mouse.cxx, but I'm not about
to rip it out. It would seem that there more conventional ways to get
spherical data that are just as fast. In any case all the viewer was pulling
from the quat matrix was the pitch value so I modified mouse.cxx to output to
our pitchOffset input and that works fine.
I've changed the native values to degrees from radians where appropriate.
This required a conversion from degrees to radians in a couple modules that
access the interface. Perhaps we should add interface calls that do the
conversion, e.g. a getHeadingOffset_rad() to go along with the
getHeadingOffset_deg().
On the view_offset (now headingOffset) thing there are two entry points
because of the ability to instantly switch views or to scroll to a new view
angle (by hitting the numeric keys for example). This leaves an anomaly in
the interface which should be resolved by adding "goal" settings to the
interface, e.g. a setGoalHeadingOffset_deg(), setGoalPitchOffset_deg(), etc.
Other than these two issues, the next step here will be to look at some
further optimizations, and to write support code for a tower view. That
should be fairly simple at this point. I was considering creating a
"simulated tower view" or "pedestrian view" that defaulted to a position off
to the right of whereever the plane is at the moment you switch to the tower
view. This could be a fall back when we don't have an actual tower location
at hand (as would be the case with rural airports).
ViewManager:
Basically all I did here was neaten things up by ripping out excess crap and
made it compatible as is with the new interface.
The result is that viewmanager is now ready to be developed. The two
preexisting views are still hardcoded into the view manager. The next step
would be to design configuration xml (eg /sim/view[x]/config/blahblah) that
could be used to set up as many views as we want. If we want to take the easy
way out, we might want to insist that view[0] be a pilot-view and have
viewmanager check for that.
2002-03-20 17:43:28 +00:00
|
|
|
FGViewer *pilot_view =
|
|
|
|
(FGViewer *)globals->get_viewmgr()->get_view( 0 );
|
2002-02-23 21:20:00 +00:00
|
|
|
|
|
|
|
sgMat4 sgTRANS;
|
2002-03-25 14:32:13 +00:00
|
|
|
// FIXME: this needs to be unlinked from the viewer
|
|
|
|
// The lon/lat/alt should come from properties and the
|
|
|
|
// calculation for relative position should probably be
|
|
|
|
// added to SimGear.
|
|
|
|
sgMakeTransMat4( sgTRANS, pilot_view->getRelativeViewPos() );
|
2002-02-23 21:20:00 +00:00
|
|
|
|
|
|
|
sgVec3 ownship_up;
|
|
|
|
sgSetVec3( ownship_up, 0.0, 0.0, 1.0);
|
|
|
|
|
|
|
|
sgMat4 sgROT;
|
|
|
|
sgMakeRotMat4( sgROT, -90.0, ownship_up );
|
|
|
|
|
|
|
|
sgMat4 sgTUX;
|
|
|
|
sgCopyMat4( sgTUX, sgROT );
|
2002-03-25 14:32:13 +00:00
|
|
|
|
2002-03-05 13:39:45 +00:00
|
|
|
if (view_number == 0) {
|
2002-03-25 14:32:13 +00:00
|
|
|
|
|
|
|
// FIXME: This needs to be unlinked from the viewer
|
|
|
|
// The lon/lat/alt should come from properties and the
|
|
|
|
// calculation for relative position should probably be
|
|
|
|
// added to SimGear.
|
|
|
|
// Note that the function for building the LOCAL matrix
|
|
|
|
// or redone using plib. Should probably be moved to Simgear.
|
|
|
|
// (cockpit_ROT = LOCAL from viewer).
|
|
|
|
sgMat4 tmpROT;
|
|
|
|
sgCopyMat4( tmpROT, pilot_view->get_COCKPIT_ROT() );
|
|
|
|
sgMat4 cockpit_ROT;
|
|
|
|
sgCopyMat4( cockpit_ROT, tmpROT );
|
|
|
|
|
|
|
|
// Make the Cockpit rotation matrix (just juggling the vectors).
|
|
|
|
cockpit_ROT[0][0] = tmpROT[1][0]; // right
|
|
|
|
cockpit_ROT[0][1] = tmpROT[1][1];
|
|
|
|
cockpit_ROT[0][2] = tmpROT[1][2];
|
|
|
|
cockpit_ROT[1][0] = tmpROT[2][0]; // forward
|
|
|
|
cockpit_ROT[1][1] = tmpROT[2][1];
|
|
|
|
cockpit_ROT[1][2] = tmpROT[2][2];
|
|
|
|
cockpit_ROT[2][0] = tmpROT[0][0]; // view_up
|
|
|
|
cockpit_ROT[2][1] = tmpROT[0][1];
|
|
|
|
cockpit_ROT[2][2] = tmpROT[0][2];
|
|
|
|
|
|
|
|
sgPostMultMat4( sgTUX, cockpit_ROT );
|
2002-03-13 04:58:08 +00:00
|
|
|
sgPostMultMat4( sgTUX, sgTRANS );
|
|
|
|
|
|
|
|
} else {
|
2002-03-25 14:32:13 +00:00
|
|
|
// FIXME: Model rotation need to be unlinked from the viewer.
|
|
|
|
// When the cockpit rotation gets removed from viewer
|
|
|
|
// then it'll be easy to apply offsets and get the equivelant
|
|
|
|
// of this "VIEW_ROT" thing.
|
|
|
|
sgCopyMat4( VIEW_ROT, pilot_view->get_VIEW_ROT());
|
2002-03-13 04:58:08 +00:00
|
|
|
sgPostMultMat4( sgTUX, VIEW_ROT );
|
|
|
|
sgPostMultMat4( sgTUX, sgTRANS );
|
2002-03-05 13:39:45 +00:00
|
|
|
}
|
2002-03-13 04:58:08 +00:00
|
|
|
|
2002-02-23 21:20:00 +00:00
|
|
|
sgCoord tuxpos;
|
|
|
|
sgSetCoord( &tuxpos, sgTUX );
|
|
|
|
_position->setTransform( &tuxpos );
|
2002-02-26 00:10:06 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
FGAircraftModel::Animation
|
2002-02-27 20:32:24 +00:00
|
|
|
FGAircraftModel::read_animation (const string &object_name,
|
|
|
|
const SGPropertyNode * node)
|
2002-02-26 00:10:06 +00:00
|
|
|
{
|
|
|
|
Animation animation;
|
|
|
|
|
2002-02-27 20:32:24 +00:00
|
|
|
// Find the object to be animated
|
|
|
|
ssgEntity * target = find_named_node(_model, object_name);
|
|
|
|
if (target != 0) {
|
|
|
|
SG_LOG(SG_INPUT, SG_INFO, " Target object is " << object_name);
|
|
|
|
} else {
|
|
|
|
animation.type = Animation::None;
|
|
|
|
SG_LOG(SG_INPUT, SG_ALERT, "Object " << object_name
|
|
|
|
<< " not found in model");
|
|
|
|
return animation;
|
|
|
|
}
|
|
|
|
|
2002-02-26 00:10:06 +00:00
|
|
|
// Figure out the animation type
|
|
|
|
string type_name = node->getStringValue("type");
|
|
|
|
if (type_name == "spin") {
|
|
|
|
SG_LOG(SG_INPUT, SG_INFO, "Reading spin animation");
|
|
|
|
animation.type = Animation::Spin;
|
2002-02-26 14:30:04 +00:00
|
|
|
} else if (type_name == "rotate") {
|
|
|
|
SG_LOG(SG_INPUT, SG_INFO, "Reading rotate animation");
|
|
|
|
animation.type = Animation::Rotate;
|
|
|
|
} else if (type_name == "none") {
|
|
|
|
SG_LOG(SG_INPUT, SG_INFO, "Reading disabled animation");
|
|
|
|
animation.type = Animation::None;
|
|
|
|
return animation;
|
2002-02-26 00:10:06 +00:00
|
|
|
} else {
|
|
|
|
animation.type = Animation::None;
|
|
|
|
SG_LOG(SG_INPUT, SG_ALERT, "Unknown animation type " << type_name);
|
|
|
|
return animation;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Splice a transform node into the tree
|
|
|
|
animation.transform = new ssgTransform;
|
|
|
|
int nParents = target->getNumParents();
|
|
|
|
animation.transform->addKid(target);
|
|
|
|
for (int i = 0; i < nParents; i++) {
|
|
|
|
ssgBranch * parent = target->getParent(i);
|
|
|
|
parent->replaceKid(target, animation.transform);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Get the node
|
|
|
|
animation.prop =
|
|
|
|
fgGetNode(node->getStringValue("property", "/null"), true);
|
|
|
|
|
2002-02-26 14:30:04 +00:00
|
|
|
animation.position = node->getFloatValue("initial-position", 0);
|
2002-02-27 12:46:38 +00:00
|
|
|
animation.offset = node->getFloatValue("offset", 0);
|
2002-03-02 16:07:42 +00:00
|
|
|
if (node->hasValue("min")) {
|
|
|
|
animation.has_min = true;
|
|
|
|
animation.min = node->getFloatValue("min");
|
|
|
|
} else {
|
|
|
|
animation.has_min = false;
|
|
|
|
}
|
|
|
|
if (node->hasValue("max")) {
|
|
|
|
animation.has_max = true;
|
|
|
|
animation.max = node->getFloatValue("max");
|
|
|
|
} else {
|
|
|
|
animation.has_max = false;
|
|
|
|
}
|
2002-02-26 14:30:04 +00:00
|
|
|
animation.factor = node->getFloatValue("factor", 1);
|
|
|
|
|
2002-02-26 00:10:06 +00:00
|
|
|
// Get the center and axis
|
2002-02-27 12:46:38 +00:00
|
|
|
animation.center[0] = node->getFloatValue("center/x-m", 0);
|
|
|
|
animation.center[1] = node->getFloatValue("center/y-m", 0);
|
|
|
|
animation.center[2] = node->getFloatValue("center/z-m", 0);
|
|
|
|
animation.axis[0] = node->getFloatValue("axis/x", 0);
|
2002-03-02 16:07:42 +00:00
|
|
|
animation.axis[1] = node->getFloatValue("axis/y", 0);
|
2002-02-27 12:46:38 +00:00
|
|
|
animation.axis[2] = node->getFloatValue("axis/z", 0);
|
|
|
|
|
|
|
|
sgNormalizeVec3(animation.axis);
|
2002-02-26 00:10:06 +00:00
|
|
|
|
|
|
|
return animation;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
FGAircraftModel::do_animation (Animation &animation, long elapsed_ms)
|
|
|
|
{
|
|
|
|
switch (animation.type) {
|
|
|
|
case Animation::None:
|
|
|
|
return;
|
2002-02-27 12:46:38 +00:00
|
|
|
case Animation::Spin:
|
|
|
|
{
|
|
|
|
float velocity_rpms = (animation.prop->getDoubleValue()
|
|
|
|
* animation.factor / 60000.0);
|
2002-02-26 00:10:06 +00:00
|
|
|
animation.position += (elapsed_ms * velocity_rpms * 360);
|
2002-02-27 12:46:38 +00:00
|
|
|
animation.setRotation();
|
2002-02-26 00:10:06 +00:00
|
|
|
return;
|
|
|
|
}
|
2002-02-26 14:30:04 +00:00
|
|
|
case Animation::Rotate: {
|
2002-02-27 12:46:38 +00:00
|
|
|
animation.position = ((animation.prop->getFloatValue()
|
|
|
|
+ animation.offset)
|
|
|
|
* animation.factor);
|
2002-03-02 16:07:42 +00:00
|
|
|
if (animation.has_min && animation.position < animation.min)
|
|
|
|
animation.position = animation.min;
|
|
|
|
if (animation.has_max && animation.position > animation.max)
|
|
|
|
animation.position = animation.max;
|
2002-02-27 12:46:38 +00:00
|
|
|
animation.setRotation();
|
2002-02-26 14:30:04 +00:00
|
|
|
return;
|
|
|
|
}
|
2002-02-26 00:10:06 +00:00
|
|
|
default:
|
|
|
|
return;
|
2002-02-23 21:20:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-02-27 12:46:38 +00:00
|
|
|
/*
|
|
|
|
* Transform to rotate an object around its local axis
|
|
|
|
* from a relative frame of reference at center -- NHV
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
FGAircraftModel::Animation::setRotation()
|
|
|
|
{
|
|
|
|
float temp_angle = -position * SG_DEGREES_TO_RADIANS ;
|
|
|
|
|
|
|
|
float s = (float) sin ( temp_angle ) ;
|
|
|
|
float c = (float) cos ( temp_angle ) ;
|
|
|
|
float t = SG_ONE - c ;
|
|
|
|
|
|
|
|
// axis was normalized at load time
|
|
|
|
// hint to the compiler to put these into FP registers
|
|
|
|
float x = axis[0];
|
|
|
|
float y = axis[1];
|
|
|
|
float z = axis[2];
|
|
|
|
|
|
|
|
sgMat4 matrix;
|
|
|
|
matrix[0][0] = t * x * x + c ;
|
|
|
|
matrix[0][1] = t * y * x - s * z ;
|
|
|
|
matrix[0][2] = t * z * x + s * y ;
|
|
|
|
matrix[0][3] = SG_ZERO;
|
|
|
|
|
|
|
|
matrix[1][0] = t * x * y + s * z ;
|
|
|
|
matrix[1][1] = t * y * y + c ;
|
|
|
|
matrix[1][2] = t * z * y - s * x ;
|
|
|
|
matrix[1][3] = SG_ZERO;
|
|
|
|
|
|
|
|
matrix[2][0] = t * x * z - s * y ;
|
|
|
|
matrix[2][1] = t * y * z + s * x ;
|
|
|
|
matrix[2][2] = t * z * z + c ;
|
|
|
|
matrix[2][3] = SG_ZERO;
|
|
|
|
|
|
|
|
// hint to the compiler to put these into FP registers
|
|
|
|
x = center[0];
|
|
|
|
y = center[1];
|
|
|
|
z = center[2];
|
|
|
|
|
|
|
|
matrix[3][0] = x - x*matrix[0][0] - y*matrix[1][0] - z*matrix[2][0];
|
|
|
|
matrix[3][1] = y - x*matrix[0][1] - y*matrix[1][1] - z*matrix[2][1];
|
|
|
|
matrix[3][2] = z - x*matrix[0][2] - y*matrix[1][2] - z*matrix[2][2];
|
|
|
|
matrix[3][3] = SG_ONE;
|
|
|
|
|
|
|
|
transform->setTransform(matrix);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-02-23 21:20:00 +00:00
|
|
|
// end of model.cxx
|
2002-03-25 14:32:13 +00:00
|
|
|
|