8 class IBlockModelProvider;
9 class BlockModelManager;
27 :color(0xffffffff), color2(0xffffffff)
31 inline void SetPosition(
float x,
float y,
float z)
38 inline void SetPosition(
const Vector3& vPos)
47 position[0] = r.position[0];
48 position[1] = r.position[1];
49 position[2] = r.position[2];
59 inline void SetNormal(
float x,
float y,
float z)
66 inline void SetNormal(
const Vector3& vNormal)
68 normal[0] = vNormal.x;
69 normal[1] = vNormal.y;
70 normal[2] = vNormal.z;
82 return Vector3(normal[0], normal[1], normal[2]);
85 inline void OffsetPosition(
float dx,
float dy,
float dz)
92 inline void OffsetPosition(
const Vector3& v)
99 inline void SetHeightScale(
float scale)
101 position[1] *= scale;
104 inline void SetTexcoord(
float u,
float v)
110 inline void SetTexcoord(
const Vector2& v)
117 inline void GetTexcoord(
float& u,
float& v)
126 DWORD light = (DWORD)(amount * 255);
127 color = (color&0xff000000) | (light<<16 | light<<8 | light);
133 color = (color&0xff0000ff) | (nSunLight<<16 | nBlockLight<<8);
139 color = (color&0xffffff00) | nBlockID;
147 color = (((byte)(color>>24)-45)<<24) | (color&0x00ffffff);
153 color = (strength<<24) | (color&0x00ffffff);
157 inline void SetBlockColor(DWORD color)
180 evf_topFront = 0x001,
182 evf_topRight = 0x004,
184 evf_LeftFront = 0x010,
185 evf_leftBack = 0x020,
186 evf_rightFont = 0x040,
187 evf_rightBack = 0x080,
188 evf_bottomFront = 0x100,
189 evf_bottomLeft = 0x200,
190 evf_bottomRight = 0x400,
191 evf_bottomBack = 0x800,
202 evf_NxNyNz = 0x80000,
208 void CloneRenderData(
const BlockModel& from_block);
212 void ClearVertices();
220 int AddVertex(
const BlockModel& from_block, int32 nVertexIndex);
221 void CloneVertices(
const BlockModel& from_block);
224 std::vector<BlockVertexCompressed>& Vertices();
226 void SetAOMask(uint32_t edges);
228 void SetVerticalScale(EdgeVertexFlag vertexId,
float scale);
231 void TranslateVertices(
float dx,
float dy,
float dz);
237 m_Vertices[vertexId].SetLightIntensity(value);
246 m_Vertices[vertexId].SetVertexLight(nBlockLight, nSunLight);
254 void GetBoundingBoxVertices(
Vector3 * pVertices,
int* pNumber);
255 static void GetBoundingBoxVertices(
CShapeAABB& aabb,
Vector3 * pVertices,
int* pNumber);
259 void SetIsCubeAABB(
bool bIsCube);
268 void SetUseAmbientOcclusion(
bool bValue){m_bUseAO = bValue;};
272 void SetFaceCount(
int nFaceCount);
273 int IncrementFaceCount(
int nDelta = 1);
275 int GetVerticesCount();
276 void ReserveVertices(
int nReservedSize = 24);
280 void SetDisableFaceCulling(
bool bDisabled){ m_bDisableFaceCulling = bDisabled; };
284 void SetUsingSelfLighting(
bool bEnable) {m_bUseSelfLighting = bEnable;}
288 void SetUniformLighting(
bool val) { m_bUniformLighting = val; }
291 void Transform(
const Matrix4& mat);
293 void Transform(
const Vector3& vOffset,
float fScaling);
296 void RemoveFace(
int nFirstIndex);
303 int GetTextureIndex()
const;
304 void SetTextureIndex(
int val);
306 void SetColor(DWORD
color);
309 void LoadModel(
BlockTemplate* pTemplate,
const std::string& filename,
const Matrix4& mat,
int nTextureIndex = 0);
310 void LoadModelByTexture(int32_t texFaceNum);
311 void LoadCubeModel();
313 void LoadModel(
const std::string& sModelName);
317 void SetVertexShadow(
int nIndex,
unsigned char nShadowLevel);
318 void SetVertexShadowFromAOFlags(
int nIndex,
int nCubeIndex, uint32 aoFlags);
319 void SetVertexColor(
int nIndex, DWORD color);
322 unsigned char CalculateCubeVertexAOShadowLevel(
int nIndex, uint32 aoFlags);
324 void SetVertexHeightScale(
int nIndex,
float scale);
333 static const int32_t g_topLB = 0;
334 static const int32_t g_topLT = 1;
335 static const int32_t g_topRT = 2;
336 static const int32_t g_topRB = 3;
339 static const int32_t g_frtLB = 4;
340 static const int32_t g_frtLT = 5;
341 static const int32_t g_frtRT = 6;
342 static const int32_t g_frtRB = 7;
345 static const int32_t g_btmLB = 8;
346 static const int32_t g_btmLT = 9;
347 static const int32_t g_btmRT = 10;
348 static const int32_t g_btmRB = 11;
351 static const int32_t g_leftLB = 12;
352 static const int32_t g_leftLT = 13;
353 static const int32_t g_leftRT = 14;
354 static const int32_t g_leftRB = 15;
357 static const int32_t g_rightLB = 16;
358 static const int32_t g_rightLT = 17;
359 static const int32_t g_rightRT = 18;
360 static const int32_t g_rightRB = 19;
363 static const int32_t g_bkLB = 20;
364 static const int32_t g_bkLT = 21;
365 static const int32_t g_bkRT = 22;
366 static const int32_t g_bkRB = 23;
370 std::vector<BlockVertexCompressed> m_Vertices;
375 bool m_bDisableFaceCulling;
378 bool m_bUseSelfLighting;
380 bool m_bUniformLighting;
int GetFaceCount()
get face count.
Definition: BlockModel.h:271
void SetLightIntensity(float amount)
only used for fixed function rendering
Definition: BlockModel.h:124
void SetCategoryID(DWORD nBlockID)
used for shader rendering
Definition: BlockModel.h:137
Definition: BlockModel.h:163
void SetVertexLight(uint32_t vertexId, uint8_t nBlockLight, uint8_t nSunLight)
Definition: BlockModel.h:244
void SetShadow()
make it darker, each time this function is called.
Definition: BlockModel.h:144
DWORD color
for fixed function: ao_shadow, max_light, max_light, max_light for shader: ao_shadow, sun_light, block_light, block_id
Definition: BlockModel.h:20
bool IsUseAmbientOcclusion()
whether use ambient occlusion.
Definition: BlockModel.h:267
different physics engine has different winding order.
Definition: EventBinding.h:32
Definition: BlockModel.h:12
Definition: BlockModel.h:172
Standard 3-dimensional vector.
Definition: ParaVector3.h:16
Standard 2-dimensional vector.
Definition: ParaVector2.h:16
void SetVertexLight(DWORD nBlockLight, DWORD nSunLight)
used for shader rendering
Definition: BlockModel.h:131
Definition: BlockModelManager.h:11
AABB-related code.
Definition: ShapeAABB.h:11
bool IsUniformLighting() const
whether all vertices have same lighting value.
Definition: BlockModel.h:287
Class encapsulating a standard 4x4 homogeneous matrix.
Definition: ParaMatrix4.h:23
Definition: enum_maker.hpp:46
void SetColorStrength(byte strength)
similar to SetShadow, except that it uses a user provided value [0,255]
Definition: BlockModel.h:151
bool IsUsingSelfLighting()
whether to disable block and sun lighting when rendering this block.
Definition: BlockModel.h:283
block template base class.
Definition: BlockTemplate.h:15
bool IsDisableFaceCulling()
Is disable face culling.
Definition: BlockModel.h:279
interface class for filtering block models.
Definition: BlockModelProvider.h:12
void SetLightIntensity(uint32_t vertexId, float value)
only used for fixed function pipeline.
Definition: BlockModel.h:235
DWORD color2
color of the block, default to white.
Definition: BlockModel.h:22