Richard Boegli's CnC_Generals_Zero_Hour Fork WIP
This is documentation of Richard Boegil's Zero Hour Fork
 
Loading...
Searching...
No Matches
dx8polygonrenderer.h
Go to the documentation of this file.
1/*
2** Command & Conquer Generals Zero Hour(tm)
3** Copyright 2025 Electronic Arts Inc.
4**
5** This program is free software: you can redistribute it and/or modify
6** it under the terms of the GNU General Public License as published by
7** the Free Software Foundation, either version 3 of the License, or
8** (at your option) any later version.
9**
10** This program is distributed in the hope that it will be useful,
11** but WITHOUT ANY WARRANTY; without even the implied warranty of
12** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13** GNU General Public License for more details.
14**
15** You should have received a copy of the GNU General Public License
16** along with this program. If not, see <http://www.gnu.org/licenses/>.
17*/
18
19/***********************************************************************************************
20 *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S ***
21 ***********************************************************************************************
22 * *
23 * Project Name : ww3d *
24 * *
25 * $Archive:: /Commando/Code/ww3d2/dx8polygonrenderer.h $*
26 * *
27 * Original Author:: Greg Hjelstrom *
28 * *
29 * $Author:: Jani_p $*
30 * *
31 * $Modtime:: 7/12/01 6:38p $*
32 * *
33 * $Revision:: 22 $*
34 * *
35 *---------------------------------------------------------------------------------------------*
36 * Functions: *
37 * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
38
39
40#if defined(_MSC_VER)
41#pragma once
42#endif
43
44#ifndef DX8_POLYGON_RENDERER_H
45#define DX8_POLYGON_RENDERER_H
46
47
48#include "always.h"
49#include "meshmdl.h"
50#include "dx8list.h"
51#include "sortingrenderer.h"
52#include "mesh.h"
53#include "dx8wrapper.h"
54
57
58
65{
66 MeshModelClass * mmc;
67 DX8TextureCategoryClass * texture_category;
68 unsigned index_offset; // absolute index of index 0 for our parent mesh
69 unsigned vertex_offset; // absolute index of vertex 0 for our parent mesh
70 unsigned index_count; // number of indices
71 unsigned min_vertex_index; // relative index of the first vertex our polys reference
72 unsigned vertex_index_range; // range to the last vertex our polys reference
73 bool strip; // is this a strip?
74 unsigned pass; // rendering pass
75
76public:
78 unsigned index_count,
79 MeshModelClass* mmc_,
81 unsigned vertex_offset,
82 unsigned index_offset,
83 bool strip,
84 unsigned pass);
87
88 void Render(/*const Matrix3D & tm,*/int base_vertex_offset);
89 void Render_Sorted(/*const Matrix3D & tm,*/int base_vertex_offset,const SphereClass & bounding_sphere);
90 void Set_Vertex_Index_Range(unsigned min_vertex_index_,unsigned vertex_index_range_);
91
92 unsigned Get_Vertex_Offset(void) { return vertex_offset; }
93 unsigned Get_Index_Offset(void) { return index_offset; }
94 inline unsigned Get_Pass(void) { return pass; }
95
97 DX8TextureCategoryClass* Get_Texture_Category() { return texture_category; }
98 void Set_Texture_Category(DX8TextureCategoryClass* tc) { texture_category=tc; }
99
100 void Log();
101};
102
103// ----------------------------------------------------------------------------
104
105inline void DX8PolygonRendererClass::Set_Vertex_Index_Range(unsigned min_vertex_index_,unsigned vertex_index_range_)
106{
107// WWDEBUG_SAY(("Set_Vertex_Index_Range - min: %d, range: %d\n",min_vertex_index_,vertex_index_range_));
108// if (vertex_index_range_>30000) {
109// int a=0;
110// a++;
111// }
112 min_vertex_index=min_vertex_index_;
113 vertex_index_range=vertex_index_range_;
114}
115
116// ----------------------------------------------------------------------------
117
118inline void DX8PolygonRendererClass::Render(/*const Matrix3D & tm,*/int base_vertex_offset)
119{
120// DX8Wrapper::Set_Transform(D3DTS_WORLD,tm);
121// SNAPSHOT_SAY(("Set_Transform\n"));
122 SNAPSHOT_SAY(("Set_Index_Buffer_Index_Offset(%d)\n",base_vertex_offset));
123
125 if (strip) {
126 SNAPSHOT_SAY(("Draw_Strip(%d,%d,%d,%d)\n",index_offset,index_count-2,min_vertex_index,vertex_index_range));
128 index_offset,
129 index_count-2,
130 min_vertex_index,
131 vertex_index_range);
132 }
133 else {
134 SNAPSHOT_SAY(("Draw_Triangles(%d,%d,%d,%d)\n",index_offset,index_count-2,min_vertex_index,vertex_index_range));
136 index_offset,
137 index_count/3,
138 min_vertex_index,
139 vertex_index_range);
140 }
141}
142
143inline void DX8PolygonRendererClass::Render_Sorted(/*const Matrix3D & tm,*/int base_vertex_offset,const SphereClass & bounding_sphere)
144{
145 WWASSERT(!strip); // Strips can't be sorted for now
146// DX8Wrapper::Set_Transform(D3DTS_WORLD,tm);
147// SNAPSHOT_SAY(("Set_Transform\n"));
148 SNAPSHOT_SAY(("Set_Index_Buffer_Index_Offset(%d)\n",base_vertex_offset));
149 SNAPSHOT_SAY(("Insert_Sorting_Triangles(%d,%d,%d,%d)\n",index_offset,index_count-2,min_vertex_index,vertex_index_range));
150
153 bounding_sphere,
154 index_offset,
155 index_count/3,
156 min_vertex_index,
157 vertex_index_range);
158
159}
160
161#endif
#define WWASSERT
DX8TextureCategoryClass * Get_Texture_Category()
void Render_Sorted(int base_vertex_offset, const SphereClass &bounding_sphere)
void Set_Texture_Category(DX8TextureCategoryClass *tc)
DX8PolygonRendererClass(unsigned index_count, MeshModelClass *mmc_, DX8TextureCategoryClass *tex_cat, unsigned vertex_offset, unsigned index_offset, bool strip, unsigned pass)
void Render(int base_vertex_offset)
MeshModelClass * Get_Mesh_Model_Class()
void Set_Vertex_Index_Range(unsigned min_vertex_index_, unsigned vertex_index_range_)
static void Set_Index_Buffer_Index_Offset(unsigned offset)
Definition dx8wrapper.h:804
static void Draw_Strip(unsigned short start_index, unsigned short index_count, unsigned short min_vertex_index, unsigned short vertex_count)
static void Draw_Triangles(unsigned buffer_type, unsigned short start_index, unsigned short polygon_count, unsigned short min_vertex_index, unsigned short vertex_count)
static void Insert_Triangles(const SphereClass &bounding_sphere, unsigned short start_index, unsigned short polygon_count, unsigned short min_vertex_index, unsigned short vertex_count)
#define SNAPSHOT_SAY(x)
Definition ww3d.h:68