1 // Copyright (c) 1999-2014 OPEN CASCADE SAS
3 // This file is part of Open CASCADE Technology software library.
5 // This library is free software; you can redistribute it and/or modify it under
6 // the terms of the GNU Lesser General Public License version 2.1 as published
7 // by the Free Software Foundation, with special exception defined in the file
8 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
9 // distribution for complete text of the license and disclaimer of any warranty.
11 // Alternatively, this file may be used under the terms of Open CASCADE
12 // commercial license or contractual agreement.
16 #include <Vrml_PerspectiveCamera.hxx>
17 #include <Vrml_SFRotation.hxx>
19 Vrml_PerspectiveCamera::Vrml_PerspectiveCamera():
21 myHeightAngle(0.785398)
27 Vrml_SFRotation tmpSFR(0,0,1,0);
28 myOrientation = tmpSFR;
31 Vrml_PerspectiveCamera::Vrml_PerspectiveCamera( const gp_Vec& aPosition,
32 const Vrml_SFRotation& aOrientation,
33 const Standard_Real aFocalDistance,
34 const Standard_Real aHeightAngle)
36 myPosition = aPosition;
37 myOrientation = aOrientation;
38 myFocalDistance = aFocalDistance;
39 myHeightAngle = aHeightAngle;
42 void Vrml_PerspectiveCamera::SetPosition(const gp_Vec& aPosition)
44 myPosition = aPosition;
47 gp_Vec Vrml_PerspectiveCamera::Position() const
52 void Vrml_PerspectiveCamera::SetOrientation(const Vrml_SFRotation& aOrientation)
54 myOrientation = aOrientation;
57 Vrml_SFRotation Vrml_PerspectiveCamera::Orientation() const
62 void Vrml_PerspectiveCamera::SetFocalDistance(const Standard_Real aFocalDistance)
64 myFocalDistance = aFocalDistance;
67 Standard_Real Vrml_PerspectiveCamera::FocalDistance() const
69 return myFocalDistance;
72 void Vrml_PerspectiveCamera::SetAngle(const Standard_Real aHeightAngle)
74 myHeightAngle = aHeightAngle;
77 Standard_Real Vrml_PerspectiveCamera::Angle() const
82 Standard_OStream& Vrml_PerspectiveCamera::Print(Standard_OStream& anOStream) const
84 anOStream << "PerspectiveCamera {\n";
85 if ( Abs(myPosition.X() - 0) > 0.0001 ||
86 Abs(myPosition.Y() - 0) > 0.0001 ||
87 Abs(myPosition.Z() - 1) > 0.0001 )
89 anOStream << " position\t\t";
90 anOStream << myPosition.X() << " " << myPosition.Y() << " " << myPosition.Z() << "\n";
93 if ( Abs(myOrientation.RotationX() - 0) > 0.0001 ||
94 Abs(myOrientation.RotationY() - 0) > 0.0001 ||
95 Abs(myOrientation.RotationZ() - 1) > 0.0001 ||
96 Abs(myOrientation.Angle() - 0) > 0.0001 )
98 anOStream << " orientation\t\t";
99 anOStream << myOrientation.RotationX() << " " << myOrientation.RotationY() << " ";
100 anOStream << myOrientation.RotationZ() << " " << myOrientation.Angle() << "\n";
103 if ( Abs(myFocalDistance - 5) > 0.0001 )
105 anOStream << " focalDistance\t";
106 anOStream << myFocalDistance << "\n";
108 if ( Abs(myHeightAngle - 0.785398) > 0.0000001 )
110 anOStream << " heightAngle\t\t";
111 anOStream << myHeightAngle << "\n";