1 // placementtrans.hxx -- class for carrying transforms for placing models in the world
3 // Written by Mathias Froehlich, started April 2005.
5 // Copyright (C) 2005 Mathias Froehlich
7 // This program is free software; you can redistribute it and/or
8 // modify it under the terms of the GNU General Public License as
9 // published by the Free Software Foundation; either version 2 of the
10 // License, or (at your option) any later version.
12 // This program is distributed in the hope that it will be useful, but
13 // WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 // General Public License for more details.
17 // You should have received a copy of the GNU General Public License
18 // along with this program; if not, write to the Free Software
19 // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 # error This library requires C++
27 #include <simgear/compiler.h>
28 #include <simgear/constants.h>
33 #include "placementtrans.hxx"
35 ssgPlacementTransform::ssgPlacementTransform(void)
39 ssgPlacementTransform::~ssgPlacementTransform(void)
43 ssgBase *ssgPlacementTransform::clone(int clone_flags)
45 ssgPlacementTransform *b = new ssgPlacementTransform;
46 b->copy_from(this, clone_flags);
51 ssgPlacementTransform::copy_from(ssgPlacementTransform *src, int clone_flags)
53 ssgBaseTransform::copy_from(src, clone_flags);
54 sgdCopyVec3(_placement_offset, src->_placement_offset);
55 sgdCopyVec3(_scenery_center, src->_scenery_center);
58 void ssgPlacementTransform::setTransform(sgdVec3 off)
60 sgdCopyVec3(_placement_offset, off);
62 sgdSubVec3(tmp, _placement_offset, _scenery_center);
70 sgSetVec3(tmat[3], tmp);
72 ssgTransform::setTransform(tmat);
75 void ssgPlacementTransform::setTransform(sgdVec3 off, sgMat4 rot)
77 sgdCopyVec3(_placement_offset, off);
79 sgdSubVec3(tmp, _placement_offset, _scenery_center);
81 sgCopyVec4(tmat[0], rot[0]);
82 sgCopyVec4(tmat[1], rot[1]);
83 sgCopyVec4(tmat[2], rot[2]);
84 sgSetVec3(tmat[3], tmp);
86 ssgTransform::setTransform(tmat);
89 void ssgPlacementTransform::setSceneryCenter(sgdVec3 xyz)
91 sgdCopyVec3(_scenery_center, xyz);
93 sgdSubVec3(tmp, _placement_offset, _scenery_center);
96 sgSetVec3(tmat[3], tmp);
97 ssgTransform::setTransform(tmat);