Frapper  1.0a
S3DGameNode.h
Go to the documentation of this file.
1 /*
2 -----------------------------------------------------------------------------
3 This source file is part of FRAPPER
4 research.animationsinstitut.de
5 sourceforge.net/projects/frapper
6 
7 Copyright (c) 2008-2009 Filmakademie Baden-Wuerttemberg, Institute of Animation
8 
9 This program is free software; you can redistribute it and/or modify it under
10 the terms of the GNU Lesser General Public License as published by the Free Software
11 Foundation; version 2.1 of the License.
12 
13 This program is distributed in the hope that it will be useful, but WITHOUT
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15 FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
16 
17 You should have received a copy of the GNU Lesser General Public License along with
18 this program; if not, write to the Free Software Foundation, Inc., 59 Temple
19 Place - Suite 330, Boston, MA 02111-1307, USA, or go to
20 http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html
21 -----------------------------------------------------------------------------
22 */
23 
32 
33 #ifndef S3DGAMENODE_H
34 #define S3DGAMENODE_H
35 
36 // OGRE
37 #include <Ogre.h>
38 #if (OGRE_PLATFORM == OGRE_PLATFORM_WIN32)
39 #include <windows.h>
40 #endif
41 
42 // includes, Frapper
43 #include "Log.h"
44 #include "GeometryNode.h"
45 #include "ParameterGroup.h"
46 #include "AbstractParameter.h"
47 #include "ViewNode.h"
48 
49 // Qt
50 #include <QQueue>
51 
52 // Game Engine
53 #include "S3DGameEngine.h"
54 
55 namespace S3DGameNode {
56 using namespace Frapper;
57 
61 class S3DGameNode : public ViewNode
62 {
63  Q_OBJECT
64 
65 
66 public: // constructors and destructors
67 
74  S3DGameNode ( const QString &name, ParameterGroup *parameterRoot );
75 
83  virtual ~S3DGameNode ();
84 
85 
86 public: // functions
87 
94  virtual Ogre::SceneNode * getSceneNode ();
95 
96 
97 private slots:
98 
99  // Common function to update member variables
100  // according to game parameters.
101  //
102  // To add a new game parameter, do the following:
103  // 1) Add parameter to s3dgame.xml
104  // 2) Set change function of parameter to this function in c'tor
105  // 3) Add member variable and update in this function
106  void updateGameParameter();
107 
111  void LoadPlayerCharacter();
112 
116  void LoadPlayerLight();
117 
121  void LoadLevel();
122 
126  void LoadLevel_P1();
127 
131  void LoadLevel_P2();
132 
136  void LoadObjectMarker();
137 
141  void LoadAnimatedObject();
142 
146  void LoadLogic();
147 
151  void ShowGameLogic();
152 
156  void ProcessGeometryOutputP1();
157 
161  void ProcessGeometryOutputP2();
162 
166  void ProcessGeometryOutputBoth();
167 
168  void ResetGameRequest();
169 
170  void ResetSlot();
171 
172 protected: //data
173 
178 
182  Ogre::SceneManager *mSceneManager;
183 
191 
197 
204 
211 
216 
226 
227  // Input action parameter
228  Parameter *mP1ActionParameter, *mP2ActionParameter;
229 
230  // Animation length parameter
231  int mJumpAnimLength,
233  mDeathAnimLength,
234  mFallAnimLength;
235 
236  int mPlatform1Loop, mPlatform2Loop, mPlatform3Loop;
237 
238  // local correspondences to GUI parameters
239  float mScale,
240  mStepSize,
241  mIntervalLength,
242  mAnimScale,
243  mLavaStep;
244 
245  // Output animation number parameter
246  NumberParameter *mJumpStart,
247  *mJumpEnd,
248  *mWalk,
249  *mJump,
250  *mDeath,
251  *mFall,
252  *mDive,
253  *mPlatform1Anim,
254  *mPlatform2Anim,
255  *mPlatform3Anim,
256  *mRings,
257  *mEndScreen;
258 
259  // Output parameter to set loop animations
260  Parameter *mWaitIdle, *mJumpIdle;
261 
262  // Output Camera Parameter, correspond to the position and orientation of the player character
263  Parameter *mPosition, *mOrientation;
264 
265 protected: //functions
266 
267  void UpdateCamera();
268 
269  // create a new input parameter for each animated object in the scene
270  void createInputObjectParameter( const QList<QString>& objectNames );
271 
273  void CopyAnimatedObjects();
274 
275  // process scene nodes
276  void processInputGeometryP1( Ogre::SceneNode * inputGeometryP1 );
277  void processInputGeometryP2( Ogre::SceneNode * inputGeometryP2 );
278  void processObjectMarker( Ogre::SceneNode * inputObjectMarker );
279  void processInputLogic( Ogre::SceneNode * inputLogic );
280 
281  // pure virtual function, used to reset the game on certain events
282  virtual void ResetGame()=0;
283 };
284 
285 } // namespace S3DGameNode
286 #endif