Tiberian Technologies Scripts Reference Revision: 9000
Loading...
Searching...
No Matches
MeshClass.h
1/* Renegade Scripts.dll
2 Copyright 2013 Tiberian Technologies
3
4 This file is part of the Renegade scripts.dll
5 The Renegade scripts.dll is free software; you can redistribute it and/or modify it under
6 the terms of the GNU General Public License as published by the Free
7 Software Foundation; either version 2, or (at your option) any later
8 version. See the file COPYING for more details.
9 In addition, an exemption is given to allow Run Time Dynamic Linking of this code with any closed source module that does not contain code covered by this licence.
10 Only the source code to the module(s) containing the licenced code has to be released.
11*/
12#ifndef TT_INCLUDE__MESHCLASS_H
13#define TT_INCLUDE__MESHCLASS_H
14#include "scripts.h"
15#include "engine_common.h"
16#include "engine_threading.h"
17#include "engine_string.h"
18#include "engine_vector.h"
19#include "RenderObjClass.h"
20#include "PrototypeClass.h"
21
22struct VertexFormatXYZNDUV2;
23class VertexMaterialClass;
24class DX8FVFCategoryContainer;
25class DecalMeshClass;
26class MaterialPassClass;
27class IndexBufferClass;
28class DX8PolygonRendererClass;
29class MeshBuilderClass;
30class MeshLoadInfoClass;
31enum WW3DErrorType;
32class MeshModelClass;
33class LightEnvironmentClass;
34#ifndef TTLE_EXPORTS
35class MeshClass : public RenderObjClass
36{
37public:
38 MeshClass(void);
39 MeshClass(const MeshClass & src);
40private:
41 MeshClass & operator = (const MeshClass &);
42public:
43 virtual ~MeshClass(void);
44 virtual RenderObjClass * Clone(void) const;
45 virtual int Class_ID(void) const { return CLASSID_MESH; }
46 virtual const char * Get_Name(void) const;
47 virtual void Set_Name(const char * name);
48 virtual int Get_Num_Polys(void) const;
49 virtual void Render(RenderInfoClass & rinfo);
50 void Render_Material_Pass(MaterialPassClass * pass,IndexBufferClass * ib);
51 virtual void Special_Render(SpecialRenderInfoClass & rinfo);
52 virtual bool Cast_Ray(RayCollisionTestClass & raytest);
53 virtual bool Cast_AABox(AABoxCollisionTestClass & boxtest);
54 virtual bool Cast_OBBox(OBBoxCollisionTestClass & boxtest);
55 virtual bool Intersect_AABox(AABoxIntersectionTestClass & boxtest);
56 virtual bool Intersect_OBBox(OBBoxIntersectionTestClass & boxtest);
57 virtual void Get_Obj_Space_Bounding_Sphere(SphereClass & sphere) const;
58 virtual void Get_Obj_Space_Bounding_Box(AABoxClass & box) const;
59 virtual void Scale(float scale);
60 virtual void Scale(float scalex, float scaley, float scalez);
61 virtual MaterialInfoClass * Get_Material_Info(void);
62 virtual int Get_Sort_Level(void) const;
63 virtual void Set_Sort_Level(int level);
64 virtual void Create_Decal(DecalGeneratorClass * generator);
65 virtual void Delete_Decal(uint32 decal_id);
66 WW3DErrorType Init(const MeshBuilderClass & builder,MaterialInfoClass * matinfo,const char * name,const char * hmodelname);
67 WW3DErrorType Load_W3D(ChunkLoadClass & cload);
68 void Generate_Culling_Tree(void);
69 MeshModelClass * Get_Model(void);
70 MeshModelClass * Peek_Model(void)
71 {
72 return Model;
73 }
74 uint32 Get_W3D_Flags(void);
75 const char * Get_User_Text(void) const;
76 bool Contains(const Vector3 &point);
77
78 void Get_Deformed_Vertices(Vector3* dst_vert, Vector3* dst_norm);
79 void Get_Deformed_Vertices(Vector3* dst_vert, Vector3* dst_norm, uint32 stride);
80 void Get_Deformed_Vertices(Vector3* dst_vert);
81
82 void Set_Lighting_Environment(LightEnvironmentClass * light_env) { LightEnvironment = light_env; }
83 LightEnvironmentClass * Get_Lighting_Environment(void) { return LightEnvironment; }
84
85 void Set_Next_Visible_Skin(MeshClass * next_visible) { NextVisibleSkin = next_visible; }
86 MeshClass * Peek_Next_Visible_Skin(void) { return NextVisibleSkin; }
87
88 void Set_Base_Vertex_Offset(int base) { BaseVertexOffset = base; }
89 int Get_Base_Vertex_Offset(void) { return BaseVertexOffset; }
90 static bool Legacy_Meshes_Fogged;
91 void Make_Unique();
92 unsigned Get_Debug_Id() const { return MeshDebugId; }
93 void Set_Debugger_Disable(bool b) { IsDisabledByDebugger=b; }
94 bool Is_Disabled_By_Debugger() const { return IsDisabledByDebugger; }
95
96 void Install_User_Lighting_Array(Vector4* lighting);
97 unsigned int* Get_User_Lighting_Array(bool alloc = false);
98 virtual void Save_User_Lighting (ChunkSaveClass& csave);
99 virtual void Load_User_Lighting (ChunkLoadClass& cload);
100 bool Use_User_Lighting(); //should this mesh have user lighting setup on it
101
102 void Enable_Alternate_Material_Description(bool onoff);
103
104protected:
105 void Free(void);
106 virtual void Add_Dependencies_To_List (DynamicVectorClass<StringClass> &file_list, bool textures_only = false);
107 virtual void Update_Cached_Bounding_Volumes(void) const;
108 DX8FVFCategoryContainer* Peek_FVF_Category_Container(void);
109 void install_materials(MeshLoadInfoClass * loadinfo);
110 void clone_materials(const MeshClass & srcmesh);
111 void setup_materials_for_user_lighting(void);
112 void setup_material_for_user_lighting(VertexMaterialClass * mtl);
113 MeshModelClass * Model;
114 DecalMeshClass * DecalMesh;
115 LightEnvironmentClass * LightEnvironment;
116 int BaseVertexOffset;
117 MeshClass * NextVisibleSkin;
118 unsigned MeshDebugId;
119 bool IsDisabledByDebugger;
120 unsigned int * UserLighting;
121 MultiListClass<DX8PolygonRendererClass> PolygonRendererList;
122
123 friend class MeshBuilderClass;
124 friend class DX8MeshRendererClass;
125 friend class DX8PolygonRendererClass;
126};
127
128class PrimitivePrototypeClass : public PrototypeClass {
129private:
130 RenderObjClass* Proto;
131public:
132 PrimitivePrototypeClass(RenderObjClass* proto)
133 {
134 Proto = proto;
135 proto->Add_Ref();
136 }
137 ~PrimitivePrototypeClass()
138 {
139 Proto->Release_Ref();
140 }
141 virtual const char *Get_Name() const
142 {
143 return Proto->Get_Name();
144 }
145 virtual int Get_Class_ID() const
146 {
147 return Proto->Class_ID();
148 }
149 virtual RenderObjClass *Create()
150 {
151 return Proto->Clone();
152 }
153};
154class MeshLoaderClass : public PrototypeLoaderClass
155{
156public:
157 MeshLoaderClass(void)
158 {
159 }
160 ~MeshLoaderClass(void)
161 {
162 }
163 virtual int Chunk_Type(void)
164 {
165 return 0;
166 }
167 virtual PrototypeClass *Load_W3D(ChunkLoadClass & cload);
168};
169
170#else
171class MeshClass : public RenderObjClass
172{
173public:
174 uint32 Get_W3D_Flags(void);
175 const char * Get_User_Text(void) const;
176 bool Use_User_Lighting(); //should this mesh have user lighting setup on it
177 void Real_Install_User_Lighting_Array(Vector4* lighting);
178 void Real_Load_User_Lighting(ChunkLoadClass& cload);
179 void Install_User_Lighting_Array(Vector4* lighting);
180 void setup_materials_for_user_lighting();
181 void setup_material_for_user_lighting(VertexMaterialClass* material);
182 void Load_User_Lighting(ChunkLoadClass& cload);
183protected:
184 MeshModelClass *model;
185};
186#endif
187#endif