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 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254
|
/* bzflag
* Copyright (c) 1993-2025 Tim Riker
*
* This package is free software; you can redistribute it and/or
* modify it under the terms of the license found in the file
* named COPYING that should have accompanied this file.
*
* THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
/* TankSceneNode:
* Encapsulates information for rendering a tank
*/
#ifndef BZF_TANK_SCENE_NODE_H
#define BZF_TANK_SCENE_NODE_H
// Inherits from
#include "SceneNode.h"
// Common headers
#include "OpenGLLight.h"
#include "TankGeometryMgr.h"
class TankSceneNode;
class TankDeathOverride
{
public:
virtual ~TankDeathOverride() {};
class DeathParams
{
public:
DeathParams( float param, fvec4 c): part()
{
scale = fvec3(1,1,1);
explodeParam = param;
color = c;
draw = true;
}
TankGeometryEnums::TankPart part;
fvec3 pos;
fvec3 rot;
fvec3 scale;
float explodeParam;
fvec4 color;
bool draw;
};
virtual bool SetDeathRenderParams ( DeathParams &/*params*/ ) = 0;
virtual bool ShowExplosion ( void ) = 0;
virtual bool GetDeathVector ( fvec3 &/*vel*/ ) = 0;
};
class TankIDLSceneNode : public SceneNode
{
public:
TankIDLSceneNode(const TankSceneNode*);
~TankIDLSceneNode();
void move(const GLfloat plane[4]);
void notifyStyleChange() override;
void addRenderNodes(SceneRenderer&) override;
// Irix 7.2.1 and solaris compilers appear to have a bug. if the
// following declaration isn't public it generates an error when trying
// to declare SphereFragmentSceneNode::FragmentRenderNode a friend in
// SphereSceneNode::SphereRenderNode. i think this is a bug in the
// compiler because:
// no other compiler complains
// public/protected/private adjust access not visibility
// SphereSceneNode isn't requesting access, it's granting it
// protected:
public:
class IDLRenderNode : public RenderNode
{
public:
IDLRenderNode(const TankIDLSceneNode*);
~IDLRenderNode();
void render() override;
const GLfloat* getPosition() const override;
private:
const TankIDLSceneNode* sceneNode;
static const int idlFaces[][5];
static const GLfloat idlVertex[][3];
};
friend class IDLRenderNode;
private:
const TankSceneNode *tank;
GLfloat plane[4];
OpenGLGState gstate;
IDLRenderNode renderNode;
};
class TankSceneNode : public SceneNode
{
friend class TankIDLSceneNode;
friend class TankIDLSceneNode::IDLRenderNode;
public:
TankSceneNode(const GLfloat pos[3],
const GLfloat forward[3]);
~TankSceneNode();
void move(const GLfloat pos[3], const GLfloat forward[3]);
void setColor(GLfloat r, GLfloat g,
GLfloat b, GLfloat a = 1.0f);
void setColor(const GLfloat* rgba);
void setMaterial(const OpenGLMaterial&);
void setTexture(const int);
void setJumpJetsTexture(const int);
void setNormal();
void setObese();
void setTiny();
void setNarrow();
void setThief();
void setDimensions(const float size[3]);
void setClipPlane(const float plane[4]);
void resetClipPlane();
void setExplodeFraction(float t);
void setJumpJets(float scale);
void setInTheCockpit(bool value);
void setOnlyShadows(bool value);
void rebuildExplosion();
void addTreadOffsets(float left, float right);
void notifyStyleChange();
void addRenderNodes(SceneRenderer&);
void addShadowNodes(SceneRenderer&);
bool cullShadow(int planeCount,
const float (*planes)[4]) const;
void addLight(SceneRenderer&);
void renderRadar();
static void setMaxLOD(int maxLevel);
void setDeathOverride( TankDeathOverride* o)
{
deathOverride = o;
}
TankDeathOverride *getDeathOverride( void )
{
return deathOverride;
}
fvec3 explodePos;
protected:
TankDeathOverride *deathOverride;
class TankRenderNode : public RenderNode
{
public:
TankRenderNode(const TankSceneNode*);
~TankRenderNode();
void setShadow();
void setRadar(bool);
void setTreads(bool);
void setTankLOD(TankGeometryEnums::TankLOD);
void setTankSize(TankGeometryEnums::TankSize);
void sortOrder(bool above, bool towards, bool left);
void setNarrowWithDepth(bool narrow);
const GLfloat* getPosition() const override;
void render() override;
void renderPart(TankGeometryEnums::TankPart part);
void renderParts();
void renderTopParts();
void renderLeftParts();
void renderRightParts();
void renderNarrowWithDepth();
void renderLights();
void renderJumpJets();
void setupPartColor(TankGeometryEnums::TankPart part);
bool setupTextureMatrix(TankGeometryEnums::TankPart part);
protected:
const TankSceneNode* sceneNode;
TankGeometryEnums::TankLOD drawLOD;
TankGeometryEnums::TankSize drawSize;
const GLfloat* color;
GLfloat alpha;
bool isRadar;
bool isTreads;
bool isShadow;
bool left;
bool above;
bool towards;
bool isExploding;
bool narrowWithDepth;
GLfloat explodeFraction;
static const GLfloat centerOfGravity[TankGeometryEnums::LastTankPart][3];
};
friend class TankRenderNode;
private:
GLfloat azimuth, elevation;
GLfloat baseRadius;
float dimensions[3]; // tank dimensions
float leftTreadOffset;
float rightTreadOffset;
float leftWheelOffset;
float rightWheelOffset;
bool useDimensions;
bool onlyShadows;
bool transparent, sort;
float explodeFraction;
bool clip;
bool inTheCockpit;
GLfloat color[4];
GLdouble clipPlane[4];
OpenGLGState gstate;
OpenGLGState treadState;
OpenGLGState lightsGState;
TankRenderNode tankRenderNode;
TankRenderNode treadsRenderNode;
TankRenderNode shadowRenderNode;
TankGeometryEnums::TankSize tankSize;
GLfloat vel[TankGeometryEnums::LastTankPart][3];
GLfloat spin[TankGeometryEnums::LastTankPart][4];
bool jumpJetsOn;
GLfloat jumpJetsScale;
GLfloat jumpJetsLengths[4];
GLfloat jumpJetsPositions[4][3];
OpenGLLight jumpJetsRealLight;
OpenGLLight jumpJetsGroundLights[4];
OpenGLGState jumpJetsGState;
static int maxLevel;
static const int numLOD;
static GLfloat jumpJetsModel[4][3];
};
#endif // BZF_TANK_SCENE_NODE_H
// Local Variables: ***
// mode: C++ ***
// tab-width: 4 ***
// c-basic-offset: 4 ***
// indent-tabs-mode: nil ***
// End: ***
// ex: shiftwidth=4 tabstop=4
|