aboutsummaryrefslogtreecommitdiffstats
path: root/src/jake2/render/model_t.java
blob: 5ee824c1e586d8c326b4e93bfcef42ec82f6571e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
/*
Copyright (C) 1997-2001 Id Software, Inc.

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  

See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.

*/

// Created on 20.11.2003 by RST.
// $Id: model_t.java,v 1.3 2004-07-09 06:50:47 hzi Exp $

package jake2.render;

import java.util.Vector;

import jake2.qcommon.*;
import jake2.util.Lib;
import jake2.util.Math3D;
import jake2.*;
import jake2.game.*;

public class model_t implements Cloneable {
	
	public String name = "";

	public int registration_sequence;

	// was enum modtype_t
	public int type;
	public int numframes;

	public int flags;

	//
	// volume occupied by the model graphics
	//		
	public float[] mins = { 0, 0, 0 }, maxs = { 0, 0, 0 };
	public float radius;

	//
	// solid volume for clipping 
	//
	public boolean clipbox;
	public float clipmins[] = { 0, 0, 0 }, clipmaxs[] = { 0, 0, 0 };

	//
	// brush model
	//
	public int firstmodelsurface, nummodelsurfaces;
	public int lightmap; // only for submodels

	public int numsubmodels;
	public mmodel_t submodels[];

	public int numplanes;
	public cplane_t planes[];

	public int numleafs; // number of visible leafs, not counting 0
	public mleaf_t leafs[];

	public int numvertexes;
	public mvertex_t vertexes[];

	public int numedges;
	public medge_t edges[];

	public int numnodes;
	public int firstnode;
	public mnode_t nodes[];

	public int numtexinfo;
	public mtexinfo_t texinfo[];

	public int numsurfaces;
	public msurface_t surfaces[];

	public int numsurfedges;
	public int surfedges[];

	public int nummarksurfaces;
	public msurface_t marksurfaces[];

	public qfiles.dvis_t vis;

	public byte lightdata[];

	// for alias models and skins
	// was image_t *skins[]; (array of pointers)
	public image_t skins[] = new image_t[Defines.MAX_MD2SKINS];

	public int extradatasize;

	// or whatever
	public Object extradata;
	
	public void clear() {
		name = "";
		registration_sequence = 0;

		// was enum modtype_t
		type = 0;
		numframes = 0;
		flags = 0;

		//
		// volume occupied by the model graphics
		//		
		Math3D.VectorClear(mins);
		Math3D.VectorClear(maxs);
		radius = 0;

		//
		// solid volume for clipping 
		//
		clipbox = false;
		Math3D.VectorClear(clipmins);
		Math3D.VectorClear(clipmaxs);

		//
		// brush model
		//
		firstmodelsurface = nummodelsurfaces = 0;
		lightmap = 0; // only for submodels

		numsubmodels = 0;
		submodels = null;

		numplanes = 0;
		planes = null;

		numleafs = 0; // number of visible leafs, not counting 0
		leafs = null;

		numvertexes = 0;
		vertexes = null;

		numedges = 0;
		edges = null;

		numnodes = 0;
		firstnode = 0;
		nodes = null;

		numtexinfo = 0;
		texinfo = null;

		numsurfaces = 0;
		surfaces = null;

		numsurfedges = 0;
		surfedges = null;

		nummarksurfaces = 0;
		marksurfaces = null;

		vis = null;

		lightdata = null;

		// for alias models and skins
		// was image_t *skins[]; (array of pointers)
		for (int i = 0; i < skins.length; i++)
		{
			skins[i] = null;
		}

		extradatasize = 0;

		// or whatever
		extradata = null;
	}
	
	// TODO replace with set(model_t from)
	public model_t copy() {
		model_t theClone = null;
		try
		{
			theClone = (model_t)super.clone();
			theClone.mins = Lib.clone(this.mins);
			theClone.maxs = Lib.clone(this.maxs);
			theClone.clipmins = Lib.clone(this.clipmins);
			theClone.clipmaxs = Lib.clone(this.clipmaxs);
			
		}
		catch (CloneNotSupportedException e)
		{
		}
		return (model_t)theClone;
	}
}