/* * PVVMUD a 3D MUD * Copyright (C) 1998-1999 Programvareverkstedet (pvv@pvv.org) * * This program 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. * * 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 * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ #include "pvvmud.H" #include "beam.H" CBeam::CBeam(){ } CBeam::CBeam(const CVector & point,const CVector & direction){ m_point = point; m_direction = direction; } CBeam::CBeam(const CVertex & point,const CVector & direction){ m_point = CVector(point.getX(),point.getY(),point.getZ()); m_direction = direction; } CBeam::CBeam(const CPosition & point,const CVector & direction){ m_point = CVector(point.getX(),point.getY(),point.getZ()); m_direction = direction; } const CVector & CBeam::getPoint() const{ return m_point; } const CVector & CBeam::getDirection() const{ return m_direction; } CBeam CBeam::operator+ (const CPosition& position) const{ CBeam result; result = *this; CVector pos(position.getX(),position.getY(),position.getZ()); result.m_point += pos; return result; } void CBeam::transform(const CMatrix & transformation){ CVector p2 = m_point + m_direction; m_point.transform(transformation); p2.transform(transformation); m_direction = p2 - m_point; } /////////////////////////////////////////////////////////////////////////////// // CBeam::intersect // Info : Check intersection between beam and a bBox // Return : Return true if beam intersect with bBox // Implementation: HACK only check if point inside in XY plane /////////////////////////////////////////////////////////////////////////////// int CBeam::intersect(const CBBox & bBox) const { // cdebug << "CBeam::intersect : Hack impl.\n"; return bBox.insideXY(m_point); } ostream& operator<<(ostream&s,const CBeam& b){ return s << "( P: " << b.getPoint() << ", D: " << b.getDirection() << " )"; }