root/juggler/branches/1.0/Kernel/vjSimDisplay.h

Revision 8789, 4.1 kB (checked in by patrickh, 7 years ago)

Copyright update.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1 /*************** <auto-copyright.pl BEGIN do not edit this line> **************
2  *
3  * VR Juggler is (C) Copyright 1998, 1999, 2000, 2001, 2002
4  *   by Iowa State University
5  *
6  * Original Authors:
7  *   Allen Bierbaum, Christopher Just,
8  *   Patrick Hartling, Kevin Meinert,
9  *   Carolina Cruz-Neira, Albert Baker
10  *
11  * This library is free software; you can redistribute it and/or
12  * modify it under the terms of the GNU Library General Public
13  * License as published by the Free Software Foundation; either
14  * version 2 of the License, or (at your option) any later version.
15  *
16  * This library is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
19  * Library General Public License for more details.
20  *
21  * You should have received a copy of the GNU Library General Public
22  * License along with this library; if not, write to the
23  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
24  * Boston, MA 02111-1307, USA.
25  *
26  * -----------------------------------------------------------------
27  * File:          $RCSfile$
28  * Date modified: $Date$
29  * Version:       $Revision$
30  * -----------------------------------------------------------------
31  *
32  *************** <auto-copyright.pl END do not edit this line> ***************/
33
34
35 #ifndef _VJ_SIM_DISPLAY_H_
36 #define _VJ_SIM_DISPLAY_H_
37 //#pragma once
38
39 #include <vjConfig.h>
40 #include <Math/vjMatrix.h>
41 #include <Kernel/vjDebug.h>
42 #include <Input/InputManager/vjPosInterface.h>
43 #include <Kernel/vjDisplay.h>
44 #include <Kernel/vjCameraProjection.h>
45
46 class vjSimDisplay : public vjDisplay
47 {
48 public:
49    vjSimDisplay() {
50       mCameraProj = NULL;
51    }
52
53 public:
54    //: Configure the simulator
55    virtual void config(vjConfigChunk* chunk)
56    {
57       vjASSERT((std::string)chunk->getType() == std::string("simDisplay"));
58
59       vjDisplay::config(chunk);
60
61       mType = SIM;
62       mCameraProj = new vjCameraProjection;
63       mCameraProj->config(chunk);
64
65       std::string camera_proxy_str = chunk->getProperty("cameraPos");
66       std::string wand_proxy_str = chunk->getProperty("wandPos");
67
68       mCamera.init(camera_proxy_str);
69       mWand.init(wand_proxy_str);      // Configure the wand to use
70
71       if(mCamera.getProxyIndex() == -1)
72       {
73          vjDEBUG(vjDBG_ERROR,0)
74             << clrOutNORM(clrRED,"ERROR:")
75             << "vjSimDisplay:: Fatal Error: Camera not found named: "
76             << camera_proxy_str.c_str() << vjDEBUG_FLUSH;
77          exit(1);
78       }
79
80       // Get drawing parameters
81       mDrawProjections = chunk->getProperty("drawProjections");
82       mSurfaceColor[0] = chunk->getProperty("surfaceColor", 0);
83       mSurfaceColor[1] = chunk->getProperty("surfaceColor", 1);
84       mSurfaceColor[2] = chunk->getProperty("surfaceColor", 2);
85    }
86
87    virtual void updateProjections()
88    {
89       updateInternalData();
90       vjMatrix camera_pos = getCameraPos();
91       mCameraProj->calcViewMatrix(camera_pos);
92    }
93
94    vjMatrix getCameraPos()
95    { return mCameraPos; }
96
97    vjMatrix getHeadPos()
98    { return mHeadPos; }
99
100    vjMatrix getWandPos()
101    { return mWandPos; }
102
103    vjProjection* getCameraProj()
104    { return mCameraProj; }
105
106 public// Sim Drawing parameters
107    bool shouldDrawProjections()
108    { return mDrawProjections; }
109
110    vjVec3 getSurfaceColor()
111    { return mSurfaceColor; }
112
113 protected:
114     //: Update internal simulator data
115    void updateInternalData()
116    {
117       mHeadPos = *(mUser->getHeadPos());
118       mWandPos = *(mWand->getData());
119
120       mCameraPos = *(mCamera->getData());
121       mCameraPos.invert(mCameraPos);         // Invert to get viewing version
122    }
123
124 private:
125    // Drawing attributes
126    bool     mDrawProjections;    //: Should we draw projections
127    vjVec3   mSurfaceColor;       //: Color to draw surfaces
128
129    /// Defines the projection for this window. Ex. RIGHT, LEFT, FRONT
130    vjProjection*   mCameraProj;            // Camera projection. (For sim, etc.)
131
132    vjPosInterface mCamera;     // Prosy interfaces to devices needed
133    vjPosInterface mWand;
134
135    vjMatrix    mCameraPos;    // The data about the position of all this stuff
136    vjMatrix    mHeadPos;
137    vjMatrix    mWandPos;
138 };
139
140 #endif
Note: See TracBrowser for help on using the browser.