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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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)
37 sgdSetVec3(_placement_offset, 0, 0, 0);
38 sgdSetVec3(_scenery_center, 0, 0, 0);
41 ssgPlacementTransform::~ssgPlacementTransform(void)
45 ssgBase *ssgPlacementTransform::clone(int clone_flags)
47 ssgPlacementTransform *b = new ssgPlacementTransform;
48 b->copy_from(this, clone_flags);
53 ssgPlacementTransform::copy_from(ssgPlacementTransform *src, int clone_flags)
55 ssgBaseTransform::copy_from(src, clone_flags);
56 sgdCopyVec3(_placement_offset, src->_placement_offset);
57 sgdCopyVec3(_scenery_center, src->_scenery_center);
60 void ssgPlacementTransform::setTransform(sgdVec3 off)
62 sgdCopyVec3(_placement_offset, off);
64 sgdSubVec3(tmp, _placement_offset, _scenery_center);
72 sgSetVec3(tmat[3], tmp);
74 ssgTransform::setTransform(tmat);
77 void ssgPlacementTransform::setTransform(sgdVec3 off, sgMat4 rot)
79 sgdCopyVec3(_placement_offset, off);
81 sgdSubVec3(tmp, _placement_offset, _scenery_center);
83 sgCopyVec4(tmat[0], rot[0]);
84 sgCopyVec4(tmat[1], rot[1]);
85 sgCopyVec4(tmat[2], rot[2]);
86 sgSetVec3(tmat[3], tmp);
88 ssgTransform::setTransform(tmat);
91 void ssgPlacementTransform::setSceneryCenter(sgdVec3 xyz)
93 sgdCopyVec3(_scenery_center, xyz);
95 sgdSubVec3(tmp, _placement_offset, _scenery_center);
98 sgSetVec3(tmat[3], tmp);
99 ssgTransform::setTransform(tmat);