Torque3D Documentation / _generateds / decalInstance.h

decalInstance.h

Engine/source/T3D/decal/decalInstance.h

More...

Classes:

class

DecalInstance represents a rendering decal in the scene.

Detailed Description

 1
 2//-----------------------------------------------------------------------------
 3// Copyright (c) 2012 GarageGames, LLC
 4//
 5// Permission is hereby granted, free of charge, to any person obtaining a copy
 6// of this software and associated documentation files (the "Software"), to
 7// deal in the Software without restriction, including without limitation the
 8// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
 9// sell copies of the Software, and to permit persons to whom the Software is
10// furnished to do so, subject to the following conditions:
11//
12// The above copyright notice and this permission notice shall be included in
13// all copies or substantial portions of the Software.
14//
15// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21// IN THE SOFTWARE.
22//-----------------------------------------------------------------------------
23
24#ifndef _DECALINSTANCE_H_
25#define _DECALINSTANCE_H_
26
27#ifndef _GFXVERTEXBUFFER_H_
28#include "gfx/gfxVertexBuffer.h"
29#endif
30
31#ifndef _DECALDATA_H_
32#include "T3D/decal/decalData.h"
33#endif
34
35struct DecalVertex;
36class SceneRenderState;
37
38/// DecalInstance represents a rendering decal in the scene.
39/// You should not allocate this yourself, add new decals to the scene
40/// via the DecalManager.
41/// All data is public, change it if you wish, but be sure to inform
42/// the DecalManager.
43class DecalInstance
44{
45   public:
46
47      DecalData *mDataBlock;
48
49      Point3F mPosition;
50      Point3F mNormal;
51      Point3F mTangent;
52      F32 mRotAroundNormal;   
53      F32 mSize;
54
55      U32 mCreateTime;
56      F32 mVisibility;
57
58      F32 mLastAlpha;
59
60      U32 mTextureRectIdx;      
61
62      DecalVertex *mVerts;
63      U16 *mIndices;
64
65      U32 mVertCount;
66      U32 mIndxCount;
67
68      U8 mFlags;
69
70      U8 mRenderPriority;
71
72      S32 mId;
73
74      GFXTexHandle *mCustomTex;
75
76      void getWorldMatrix( MatrixF *outMat, bool flip = false );
77      
78      Box3F getWorldBox() const
79      {
80         return Box3F( mPosition - Point3F( mSize / 2.f ), mPosition + Point3F( mSize / 2.f ) );
81      }
82
83      U8 getRenderPriority() const
84      {
85         return mRenderPriority == 0 ? mDataBlock->renderPriority : mRenderPriority;
86      }
87
88      /// Calculates the size of this decal onscreen in pixels, used for LOD.
89      F32 calcPixelSize( U32 viewportHeight, const Point3F &cameraPos, F32 worldToScreenScaleY ) const;
90         
91      DecalInstance();
92};
93
94#endif // _DECALINSTANCE_H_
95