Richard Boegli's CnC_Generals_Zero_Hour Fork WIP
This is documentation of Richard Boegil's Zero Hour Fork
 
Loading...
Searching...
No Matches
proto.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/proto.h $*
26 * *
27 * Author:: Greg Hjelstrom *
28 * *
29 * $Modtime:: 1/08/01 10:04a $*
30 * *
31 * $Revision:: 1 $*
32 * *
33 *---------------------------------------------------------------------------------------------*
34 * Functions: *
35 * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
36
37
38#if defined(_MSC_VER)
39#pragma once
40#endif
41
42#ifndef PROTO_H
43#define PROTO_H
44
45#include "always.h"
46#include <stdlib.h>
47#include "w3d_file.h"
48
49class RenderObjClass;
50class ChunkLoadClass;
51
52/*
53** W3D Prototype system
54**
55** Prototypes are basically abstract factories for render objects.
56** Prototype Loaders are abstract factories for prototypes.
57** Here is an example of the sequence of events that happen when
58** a mesh is loaded into the asset manager and then used by the
59** user:
60**
61** - At initialization time, a mesh prototype loader is installed automatically
62** - User asks the asset manager to load "mesh.w3d"
63** - asset manager encounters a W3D_CHUNK_MESH
64** - asset manager looks through its loaders to find one that claims to handle this chunk
65** - the meshloader object is found and its Load method called
66** - the meshloader creates a mesh prototype object which the asset manager adds to its list
67** - User asks for the render object named "Mesh"
68** - asset manager searches through its prototypes to find the one named "Mesh"
69** - the mesh prototype object is found and the asset manager calls its "Create" method
70** - the mesh prototype creates a mesh (clones the one it contains) which is returned to the user.
71*/
72
73/*
74** PrototypeClass
75** This class is a generic interface to a render object prototype.
76** The asset manager will store a these and use them whenever the
77** user wants to create an instance of a named render object.
78** Some simple render objects will be created through cloning. In
79** that case, their associated prototype simply stores an object and
80** clones it whenever the Create method is called. More complex
81** composite render objects will be created from a "blueprint" object.
82** Basically this class simply associates a name with a render object
83** creation function.
84*/
86{
87
88public:
89
90 PrototypeClass(void) : NextHash(NULL) {}
91
92 virtual const char * Get_Name(void) const = 0;
93 virtual int Get_Class_ID(void) const = 0;
94 virtual RenderObjClass * Create(void) = 0;
95 virtual void DeleteSelf() = 0;
96
97 inline void friend_setNextHash(PrototypeClass* n) { NextHash = n; }
98 inline PrototypeClass* friend_getNextHash() { return NextHash; }
99
100protected:
101 virtual ~PrototypeClass(void) {};
102
103private:
104 PrototypeClass * NextHash;
105
106 // Not Implemented
107 PrototypeClass(const PrototypeClass & that);
108 PrototypeClass & operator = (const PrototypeClass & that);
109};
110
112{
114public:
116
117 virtual const char * Get_Name(void) const;
118 virtual int Get_Class_ID(void) const;
119 virtual RenderObjClass * Create(void);
120 virtual void DeleteSelf() { delete this; }
121
123
124protected:
125 virtual ~PrimitivePrototypeClass(void);
126};
127
128/*
129** PrototypeLoaderClass
130** This is the interface for an object which recognizes a certain
131** chunk type in a W3D file and can load it and create a PrototypeClass
132** for it.
133*/
135{
136
137public:
138
141
142 virtual int Chunk_Type(void) = 0;
143 virtual PrototypeClass * Load_W3D(ChunkLoadClass & cload) = 0;
144
145private:
146
147 // Not Implemented:
149 PrototypeLoaderClass & operator = (const PrototypeLoaderClass & that);
150
151};
152
153
154/*
155** Default Prototype Loaders for Meshes and HModels
156*/
158{
159public:
160
161 virtual int Chunk_Type(void) { return W3D_CHUNK_MESH; }
162 virtual PrototypeClass * Load_W3D(ChunkLoadClass & cload);
163};
164
166{
167public:
168
169 virtual int Chunk_Type(void) { return W3D_CHUNK_HMODEL; }
170 virtual PrototypeClass * Load_W3D(ChunkLoadClass & cload);
171};
172
173
174/*
175** Instances of the default loaders which the asset manager can
176** automatically install at creation time
177*/
180
181
182
183#endif
#define NULL
Definition BaseType.h:92
@ W3D_CHUNK_HMODEL
Definition w3d_file.h:418
@ W3D_CHUNK_MESH
Definition w3d_file.h:341
#define W3DMPO_GLUE(ARGCLASS)
Definition always.h:120
virtual PrototypeClass * Load_W3D(ChunkLoadClass &cload)
Definition proto.cpp:158
virtual int Chunk_Type(void)
Definition proto.h:169
virtual int Chunk_Type(void)
Definition proto.h:161
virtual PrototypeClass * Load_W3D(ChunkLoadClass &cload)
Definition proto.cpp:120
virtual void DeleteSelf()
Definition proto.h: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
virtual RenderObjClass * Create(void)=0
virtual const char * Get_Name(void) const =0
PrototypeClass * friend_getNextHash()
Definition proto.h:98
virtual void DeleteSelf()=0
PrototypeClass(void)
Definition proto.h:90
virtual ~PrototypeClass(void)
Definition proto.h:101
void friend_setNextHash(PrototypeClass *n)
Definition proto.h:97
virtual int Get_Class_ID(void) const =0
PrototypeLoaderClass(void)
Definition proto.h:139
virtual PrototypeClass * Load_W3D(ChunkLoadClass &cload)=0
~PrototypeLoaderClass(void)
Definition proto.h:140
virtual int Chunk_Type(void)=0
HModelLoaderClass _HModelLoader
Definition proto.cpp:53
MeshLoaderClass _MeshLoader
Definition proto.cpp:52