JNR
laModel.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 class laModel
39 {
40 protected:
41  M_BOOL _bAddDirectoryPrefix;
42  laRenderer *_pCR;
43 
44  // Material
45  //
46  char _strTex[128];
47  laTexture _nTex;
48 
49  M_BOOL _bEmissive;
50  unsigned _nShininess;
51 
52  // Editing
53  //
54  static M_BOOL _bBend;
55  static double _dBendAng;
56  static double _dBendScale;
57 
58  static M_BOOL _bRotate;
59  static double _dRotAng;
60  static double _dRotTrans;
61 
62  static M_BOOL _bOffset;
63  static laPoint3 _ptOffset;
64 
65 public:
66  laModel(void);
67 
68  // Control
69  //
70  virtual bool load(char* strFile)=0;
71  virtual void discard()=0;
72  virtual void buildCollisionData(class laCollisionDomain* pDomain, class rpgTrap* pTrap=NULL)=0;
73 
74  // Draw
75  //
76  virtual void draw( laRenderer *pr )=0;
77  virtual void drawFx( laRenderer *pr )=0;
78 
79  // Edit geometry
80  // NOTE: These methods are slow and should be used only at loading time
81  //
82  virtual void edScale(laPoint3 sz)=0;
83  virtual void edTranslate(laPoint3 pos)=0;
84  virtual void edNormalize()=0;
85  virtual void edMinaxis()=0;
86  virtual void edMaxaxis()=0;
87  virtual void edCentralize()=0;
88  virtual void edSnap()=0;
89 
90  inline static void edRotate(M_BOOL bRot, double a=0) {
91  _bRotate = bRot;
92  _dRotAng = a;
93  }
94 
95  inline static void edBend(M_BOOL bBend, double a=0, double s=1) {
96  _bBend = bBend;
97  _dBendAng = a;
98  _dBendScale = s;
99  }
100 
101  inline static void edOffset(M_BOOL bBend, laPoint3 offset = laPoint3()) {
102  _bOffset = bBend;
103  _ptOffset = offset;
104  }
105 
106  // Misc
107  //
108  virtual char* strTexture()=0;
109  virtual unsigned vertexCount()=0;
110 
111  virtual laTexture* texture() { return &_nTex; };
112 
113  virtual laPoint3 boundaryMin()=0;
114  virtual laPoint3 boundaryMax()=0;
115 
116  inline void setDirectoryPrefix(M_BOOL bAdd) {
117  _bAddDirectoryPrefix = bAdd;
118  };
119 
120  inline void setTexture(laTexture nTex, M_BOOL bEmissive, unsigned nShininess) {
121  _nTex = nTex;
122  _bEmissive = bEmissive;
123  _nShininess = nShininess;
124  }
125 };
Abstract Interface for 3D Models.
Definition: laModel.h:38
Trap Properties.
Definition: rpgTrap.h:42
2D Texture
Definition: laTexture.h:45
Collision Domain.
Virtual interface for the Engine graphics renderer.
Definition: laRenderer.h:98