JNR
laAnimatedModel.h
1 /*
2 
3 Jump'n'Run Engine
4 http://www.atanaslaskov.com/jnr/
5 
6 BSD LICENSE
7 Copyright (c) 2007-2013, Atanas Laskov
8 All rights reserved.
9 
10 Redistribution and use in source and binary forms, with or without
11 modification, are permitted provided that the following conditions are met:
12 1. Redistributions of source code must retain the above copyright notice,
13 this list of conditions and the following disclaimer.
14 2. Redistributions in binary form must reproduce the above copyright notice,
15 this list of conditions and the following disclaimer in the documentation
16 and/or other materials provided with the distribution.
17 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
18 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20 DISCLAIMED. IN NO EVENT SHALL ATANAS LASKOV BE LIABLE FOR ANY
21 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 
28 */
30 
31 
37 
38 #include "laStaticModel.h"
39 
41  public laModel
42 {
43  // Frames
44  //
45  laStaticModel* _arFrames;
46  unsigned _nFrameCnt;
47  unsigned _nCrFrame;
48 
49  // State
50  double _dSPF;
51  double _dTimeElapsed;
52 
53  laStaticModel _snapshot;
54 
55  // Flags
56  //
57  M_BOOL _bCycle;
58  M_BOOL _bInterpolation;
59  M_BOOL _bTraceEffect;
60 
61 
62 
63 public:
64  laAnimatedModel(void);
65  ~laAnimatedModel(void);
66 
67  // Control
68  //
69  virtual bool load(char* strFile);
70  virtual void discard();
71 
72  virtual void buildCollisionData(class laCollisionDomain* pDomain, rpgTrap* pTrap=NULL);
73 
74  inline void cycle(M_BOOL bCycle) {_bCycle = bCycle;};
75  inline void toggleInterpolate(M_BOOL bEnable) {_bInterpolation = bEnable;};
76  inline void toggleTraceFx(M_BOOL bEnable) {_bTraceEffect = bEnable; }
77 
78  // Draw
79  //
80  virtual void draw(laRenderer *pr);
81  virtual void drawFx(laRenderer *pr) {};
82 
83  // Animate
84  //
85  void animate(laTimer &t);
86 
87  void blend(laStaticModel *pPose1, laStaticModel *pPose2, double dSec = 0.15);
88  void snapshot(laStaticModel* pm);
89  laPoint3 sample(unsigned nVertexIndex);
90 
91  // Edit geometry
92  // NOTE: These methods are slow and should be used only at loading time
93  //
94  virtual void edScale(laPoint3 sz);
95  virtual void edTranslate(laPoint3 pos);
96  virtual void edNormalize();
97  virtual void edMinaxis();
98  virtual void edMaxaxis();
99  virtual void edCentralize();
100  virtual void edSnap();
101 
102  virtual void edInvertAnimation();
103 
104  // Misc
105  //
106  inline unsigned frameCount() const { return _nFrameCnt; }
107  inline unsigned frameIndex() const { return _nCrFrame; }
108  inline void frameIndex(unsigned i) {_nCrFrame = i;}
109  inline laStaticModel* framePtr() { return _arFrames + _nCrFrame; }
110 
111  inline double duration() const { return _nFrameCnt*_dSPF; } //< duration in seconds
112 
113  M_BOOL bIsSolid;
114  inline M_BOOL isSolid() const { return bIsSolid; }
115 
116  virtual char* strTexture();
117  virtual unsigned vertexCount();
118 
119  virtual laPoint3 boundaryMin();
120  virtual laPoint3 boundaryMax();
121 };
Animated 3D Model.
Abstract Interface for 3D Models.
Definition: laModel.h:38
Trap Properties.
Definition: rpgTrap.h:42
Collision Domain.
Virtual interface for the Engine graphics renderer.
Definition: laRenderer.h:98
Static 3D Model.
Definition: laStaticModel.h:44