absence_thelab
diff src/3deng/objects.h @ 0:1cffe3409164
initial commit
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Thu, 23 Oct 2014 01:46:07 +0300 |
parents | |
children |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/3deng/objects.h Thu Oct 23 01:46:07 2014 +0300 1.3 @@ -0,0 +1,97 @@ 1.4 +#ifndef _OBJECTS_H_ 1.5 +#define _OBJECTS_H_ 1.6 + 1.7 +#include <string> 1.8 +#include "3dengine.h" 1.9 +#include "n3dmath.h" 1.10 +#include "3dgeom.h" 1.11 +#include "material.h" 1.12 +#include "motion.h" 1.13 + 1.14 +class Object { 1.15 +protected: 1.16 + GraphicsContext *gc; 1.17 + RenderParams rendp; 1.18 + 1.19 + TriMesh *mesh; 1.20 + TriMesh **ShadowVolumes; 1.21 + int ShadowCount; 1.22 + bool CastShadows; 1.23 + 1.24 + Matrix4x4 WorldXForm; 1.25 +// Matrix4x4 TransMat, RotMat, ScaleMat, GRotMat; 1.26 + Matrix4x4 TextureMatrix; 1.27 + bool UseTextureMatrix; 1.28 + 1.29 + bool AutoSetZWrite; 1.30 + 1.31 + void Render2TexUnits(); 1.32 + void Render4TexUnits(); 1.33 + void Render8TexUnits(); 1.34 + 1.35 +public: 1.36 + std::string name; 1.37 + Material material; 1.38 + MotionController controller; 1.39 + 1.40 + Matrix4x4 TransMat, RotMat, ScaleMat, GRotMat; 1.41 + 1.42 + Object(GraphicsContext *gc, byte DetailLevels = 1); 1.43 + ~Object(); 1.44 + 1.45 + TriMesh *GetTriMesh(); 1.46 + 1.47 + void ResetTransform(); 1.48 + void ResetTranslation(); 1.49 + void ResetRotation(); 1.50 + void ResetGlobalRotation(); 1.51 + void ResetScaling(); 1.52 + 1.53 + void Translate(float tx, float ty, float tz); 1.54 + void Rotate(float rx, float ry, float rz); 1.55 + void Rotate(const Vector3 &axis, float angle); 1.56 + void Rotate(const Matrix4x4 &rot); 1.57 + void GlobalRotate(float rx, float ry, float rz); 1.58 + void GlobalRotate(const Vector3 &axis, float angle); 1.59 + void GlobalRotate(const Matrix4x4 &rot); 1.60 + void Scale(float sx, float sy, float sz); 1.61 + 1.62 + void SetTranslation(float tx, float ty, float tz); 1.63 + void SetRotation(float rx, float ry, float rz); 1.64 + void SetRotation(const Vector3 &axis, float angle); 1.65 + void SetRotation(const Matrix4x4 &rot); 1.66 + void SetGlobalRotation(float rx, float ry, float rz); 1.67 + void SetGlobalRotation(const Vector3 &axis, float angle); 1.68 + void SetGlobalRotation(const Matrix4x4 &rot); 1.69 + void SetScaling(float sx, float sy, float sz); 1.70 + 1.71 + const Matrix4x4 GetWorldTransform() const; 1.72 + 1.73 + void SetTextureMatrix(Matrix4x4 mat); 1.74 + Matrix4x4 GetTextureMatrix() const; 1.75 + 1.76 + // set render parameters 1.77 + void SetVertexProgram(dword VertexProgram); 1.78 + void SetPixelProgram(dword PixelProgram); 1.79 + void SetShadingMode(ShadeMode smode); 1.80 + void SetWriteZBuffer(bool enable); 1.81 + void SetBlendFunc(BlendingFactor src, BlendingFactor dest); 1.82 + void GetBlendFunc(BlendingFactor *src, BlendingFactor *dest); 1.83 + 1.84 + // about shadows 1.85 + void CalculateShadows(const Light **lights, int LightCount); 1.86 + TriMesh *GetShadowVolume(int light); 1.87 + void SetShadowCasting(bool enable); 1.88 + bool GetShadowCasting() const; 1.89 + 1.90 + void SetRenderStates(); 1.91 + void Render(); 1.92 + void RenderBare(); 1.93 + 1.94 + // generate geometry 1.95 + void CreatePlane(float size, dword subdivisions); 1.96 + void CreateCube(float size); 1.97 +}; 1.98 + 1.99 + 1.100 +#endif // _OBJECTS_H_ 1.101 \ No newline at end of file