absence_thelab

view src/3deng/objects.h @ 1:4d5933c261c3

todo and .hgignore
author John Tsiombikas <nuclear@member.fsf.org>
date Thu, 23 Oct 2014 02:18:43 +0300
parents
children
line source
1 #ifndef _OBJECTS_H_
2 #define _OBJECTS_H_
4 #include <string>
5 #include "3dengine.h"
6 #include "n3dmath.h"
7 #include "3dgeom.h"
8 #include "material.h"
9 #include "motion.h"
11 class Object {
12 protected:
13 GraphicsContext *gc;
14 RenderParams rendp;
16 TriMesh *mesh;
17 TriMesh **ShadowVolumes;
18 int ShadowCount;
19 bool CastShadows;
21 Matrix4x4 WorldXForm;
22 // Matrix4x4 TransMat, RotMat, ScaleMat, GRotMat;
23 Matrix4x4 TextureMatrix;
24 bool UseTextureMatrix;
26 bool AutoSetZWrite;
28 void Render2TexUnits();
29 void Render4TexUnits();
30 void Render8TexUnits();
32 public:
33 std::string name;
34 Material material;
35 MotionController controller;
37 Matrix4x4 TransMat, RotMat, ScaleMat, GRotMat;
39 Object(GraphicsContext *gc, byte DetailLevels = 1);
40 ~Object();
42 TriMesh *GetTriMesh();
44 void ResetTransform();
45 void ResetTranslation();
46 void ResetRotation();
47 void ResetGlobalRotation();
48 void ResetScaling();
50 void Translate(float tx, float ty, float tz);
51 void Rotate(float rx, float ry, float rz);
52 void Rotate(const Vector3 &axis, float angle);
53 void Rotate(const Matrix4x4 &rot);
54 void GlobalRotate(float rx, float ry, float rz);
55 void GlobalRotate(const Vector3 &axis, float angle);
56 void GlobalRotate(const Matrix4x4 &rot);
57 void Scale(float sx, float sy, float sz);
59 void SetTranslation(float tx, float ty, float tz);
60 void SetRotation(float rx, float ry, float rz);
61 void SetRotation(const Vector3 &axis, float angle);
62 void SetRotation(const Matrix4x4 &rot);
63 void SetGlobalRotation(float rx, float ry, float rz);
64 void SetGlobalRotation(const Vector3 &axis, float angle);
65 void SetGlobalRotation(const Matrix4x4 &rot);
66 void SetScaling(float sx, float sy, float sz);
68 const Matrix4x4 GetWorldTransform() const;
70 void SetTextureMatrix(Matrix4x4 mat);
71 Matrix4x4 GetTextureMatrix() const;
73 // set render parameters
74 void SetVertexProgram(dword VertexProgram);
75 void SetPixelProgram(dword PixelProgram);
76 void SetShadingMode(ShadeMode smode);
77 void SetWriteZBuffer(bool enable);
78 void SetBlendFunc(BlendingFactor src, BlendingFactor dest);
79 void GetBlendFunc(BlendingFactor *src, BlendingFactor *dest);
81 // about shadows
82 void CalculateShadows(const Light **lights, int LightCount);
83 TriMesh *GetShadowVolume(int light);
84 void SetShadowCasting(bool enable);
85 bool GetShadowCasting() const;
87 void SetRenderStates();
88 void Render();
89 void RenderBare();
91 // generate geometry
92 void CreatePlane(float size, dword subdivisions);
93 void CreateCube(float size);
94 };
97 #endif // _OBJECTS_H_