Richard Boegli's CnC_Generals_Zero_Hour Fork WIP
This is documentation of Richard Boegil's Zero Hour Fork
 
Loading...
Searching...
No Matches
proto.cpp
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/proto.cpp $*
26 * *
27 * Org Author:: Greg Hjelstrom *
28 * *
29 * Author : Kenny Mitchell *
30 * *
31 * $Modtime:: 06/27/02 3:51p $*
32 * *
33 * $Revision:: 2 $*
34 * *
35 * 06/26/02 KM Integrating shader system
36 *---------------------------------------------------------------------------------------------*
37 * Functions: *
38 * MeshLoaderClass::Load -- reads in a mesh and creates a prototype for it *
39 * HModelLoaderClass::Load -- reads in an hmodel definition and creates a prototype for it *
40 * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
41
42
43#include "proto.h"
44#include "mesh.h"
45#include "hmdldef.h"
46#include "hlod.h"
47#include "w3derr.h"
48
49/*
50** Global instances of the default loaders for the asset manager to install
51*/
54
55
56/*
57** Prototype Classes
58** These prototypes are the "built-in" ones for the W3D library.
59*/
61{
62 Proto = proto;
63 assert(Proto);
64 Proto->Add_Ref();
65}
67{
68 if (Proto) {
69 Proto->Release_Ref();
70 }
71}
72
73const char * PrimitivePrototypeClass::Get_Name(void) const
74{
75 return Proto->Get_Name();
76}
77
79{
80 return Proto->Class_ID();
81}
82
87
88
90{
92public:
94
95 virtual const char * Get_Name(void) const { return HModelDef->Get_Name(); }
96 virtual int Get_Class_ID(void) const { return RenderObjClass::CLASSID_HLOD; }
97 virtual RenderObjClass * Create(void) { return NEW_REF( HLodClass, (*HModelDef) ); }
98 virtual void DeleteSelf() { delete this; }
99
101
102protected:
103 virtual ~HModelPrototypeClass(void) { if (HModelDef) delete HModelDef; }
104
105};
106
107
108/***********************************************************************************************
109 * MeshLoaderClass::Load -- reads in a mesh and creates a prototype for it *
110 * *
111 * INPUT: *
112 * *
113 * OUTPUT: *
114 * *
115 * WARNINGS: *
116 * *
117 * HISTORY: *
118 * 7/28/98 GTH : Created. *
119 *=============================================================================================*/
121{
122 MeshClass * mesh = NEW_REF( MeshClass, () );
123
124 if (mesh == NULL) {
125 return NULL;
126 }
127
128 if (mesh->Load_W3D(cload) != WW3D_ERROR_OK) {
129
130 // if the load failed, delete the mesh
131 assert(mesh->Num_Refs() == 1);
132 mesh->Release_Ref();
133 return NULL;
134
135 } else {
136
137 // create the prototype and add it to the lists
139 mesh->Release_Ref();
140 return newproto;
141
142 }
143}
144
145
146/***********************************************************************************************
147 * HModelLoaderClass::Load -- reads in an hmodel and creates a prototype for it *
148 * *
149 * INPUT: *
150 * *
151 * OUTPUT: *
152 * *
153 * WARNINGS: *
154 * *
155 * HISTORY: *
156 * 7/28/98 GTH : Created. *
157 *=============================================================================================*/
159{
161
162 if (hdef == NULL) {
163 return NULL;
164 }
165
166 if (hdef->Load_W3D(cload) != HModelDefClass::OK) {
167
168 // load failed, delete the model and return an error
169 delete hdef;
170 return NULL;
171
172 } else {
173
174 // ok, accept this model!
176 return hproto;
177
178 }
179}
180
#define NULL
Definition BaseType.h:92
#define W3DMPO_GLUE(ARGCLASS)
Definition always.h:120
#define W3DNEW
Definition always.h:109
int Load_W3D(ChunkLoadClass &cload)
Definition hmdldef.cpp:123
virtual PrototypeClass * Load_W3D(ChunkLoadClass &cload)
Definition proto.cpp:158
virtual ~HModelPrototypeClass(void)
Definition proto.cpp:103
HModelDefClass * HModelDef
Definition proto.cpp:100
HModelPrototypeClass(HModelDefClass *def)
Definition proto.cpp:93
virtual const char * Get_Name(void) const
Definition proto.cpp:95
virtual RenderObjClass * Create(void)
Definition proto.cpp:97
virtual int Get_Class_ID(void) const
Definition proto.cpp:96
virtual void DeleteSelf()
Definition proto.cpp:98
WW3DErrorType Load_W3D(ChunkLoadClass &cload)
Definition mesh.cpp:1139
virtual PrototypeClass * Load_W3D(ChunkLoadClass &cload)
Definition proto.cpp:120
virtual ~PrimitivePrototypeClass(void)
Definition proto.cpp:66
virtual RenderObjClass * Create(void)
Definition proto.cpp:83
virtual const char * Get_Name(void) const
Definition proto.cpp:73
RenderObjClass * Proto
Definition proto.h:122
virtual int Get_Class_ID(void) const
Definition proto.cpp:78
PrimitivePrototypeClass(RenderObjClass *proto)
Definition proto.cpp:60
PrototypeClass(void)
Definition proto.h:90
int Num_Refs(void) const
Definition refcount.h:159
WWINLINE void Release_Ref(void) const
Definition refcount.h:146
HModelLoaderClass _HModelLoader
Definition proto.cpp:53
MeshLoaderClass _MeshLoader
Definition proto.cpp:52
#define SET_REF_OWNER(P)
Definition refcount.h:63
#define NEW_REF(C, P)
Definition refcount.h:62
@ WW3D_ERROR_OK
Definition w3derr.h:52