File: WallSceneNode.h

package info (click to toggle)
bzflag 2.0.13.20080902-1
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 27,564 kB
  • ctags: 34,716
  • sloc: cpp: 139,842; ansic: 14,510; sh: 10,715; makefile: 2,454; perl: 477; php: 428; python: 345; objc: 243; xml: 24
file content (163 lines) | stat: -rw-r--r-- 4,368 bytes parent folder | download
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
/* bzflag
 * Copyright (c) 1993 - 2008 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.
 */

/* WallSceneNode:
 *	Encapsulates information for rendering an wall.
 *
 * WallGeometry:
 *	Encapsulates vertices and uv's for a wall
 *
 * Walls are flat and don't move.  A wall also picks a level of
 * detail based on its projected area and on the presence of
 * light sources nearby (to capture light highlights).
 */

#ifndef	BZF_WALL_SCENE_NODE_H
#define	BZF_WALL_SCENE_NODE_H

#include "common.h"
#include "SceneNode.h"

class WallSceneNode : public SceneNode {
  public:
			WallSceneNode();
			~WallSceneNode();

    const GLfloat*	getColor() const;
    const GLfloat*	getDynamicColor() const;
    const GLfloat*	getModulateColor() const;
    const GLfloat*	getLightedColor() const;
    const GLfloat*	getLightedModulateColor() const;
    GLfloat		getDistance(const GLfloat*) const;
    virtual bool	inAxisBox (const Extents& exts) const;

    void		setColor(GLfloat r, GLfloat g,
				GLfloat b, GLfloat a = 1.0f);
    void		setColor(const GLfloat* rgba);
    void		setModulateColor(GLfloat r, GLfloat g,
				GLfloat b, GLfloat a = 1.0f);
    void		setModulateColor(const GLfloat* rgba);
    void		setLightedColor(GLfloat r, GLfloat g,
				GLfloat b, GLfloat a = 1.0f);
    void		setLightedColor(const GLfloat* rgba);
    void		setLightedModulateColor(GLfloat r, GLfloat g,
				GLfloat b, GLfloat a = 1.0f);
    void		setLightedModulateColor(const GLfloat* rgba);
    void		setMaterial(const OpenGLMaterial&);
    void		setTexture(const int);
    void		setTextureMatrix(const GLfloat* texmat);
    void		setDynamicColor(const float* color);
    void		setBlending(bool);
    void		setSphereMap(bool);
    void		setNoCulling(bool);
    void		setNoSorting(bool);
    void		setAlphaThreshold(float);
    void		setRadarColor(const float color[4]);

    void		setColor();

    bool		cull(const ViewFrustum&) const;
    void		notifyStyleChange();

    void		copyStyle(WallSceneNode*);

    void		setUseColorTexture(bool use){useColorTexture=use;}
  protected:
    int			getNumLODs() const;
    void		setNumLODs(int, float* elementAreas);
    void		setPlane(const GLfloat[4]);
    int			pickLevelOfDetail(const SceneRenderer&) const;

    int			getStyle() const;
    const OpenGLGState*	getGState() const { return &gstate; }
    const OpenGLGState*	getWallGState() const;

    static int		splitWall(const GLfloat* plane,
				const GLfloat3Array& vertices,
				const GLfloat2Array& uvs,
				SceneNode*& front, SceneNode*& back); // const

  private:
    static void splitEdge(float d1, float d2,
			  const GLfloat* p1, const GLfloat* p2,
			  const GLfloat* uv1, const GLfloat* uv2,
			  GLfloat* p, GLfloat* uv); //const

  private:
    int			numLODs;
    float*		elementAreas;
    const GLfloat*	dynamicColor;
    GLfloat		color[4];
    GLfloat		modulateColor[4];
    GLfloat		lightedColor[4];
    GLfloat		lightedModulateColor[4];
    float		alphaThreshold;
    int			style;
    bool		noCulling;
    bool		noSorting;
    bool		isBlended;
    bool		wantBlending;
    bool		wantSphereMap;
    OpenGLGState	gstate;
    bool		useColorTexture;
};

//
// WallSceneNode
//

inline int WallSceneNode::getNumLODs() const
{
  return numLODs;
}

inline const GLfloat* WallSceneNode::getColor() const
{
  return color;
}
inline const GLfloat* WallSceneNode::getDynamicColor() const
{
  return dynamicColor;
}
inline const GLfloat* WallSceneNode::getModulateColor() const
{
  return modulateColor;
}
inline const GLfloat* WallSceneNode::getLightedColor() const
{
  return lightedColor;
}
inline const GLfloat* WallSceneNode::getLightedModulateColor() const
{
  return lightedModulateColor;
}

inline int WallSceneNode::getStyle() const
{
  return style;
}
inline const OpenGLGState* WallSceneNode::getWallGState() const
{
  return &gstate;
}


#endif // BZF_WALL_SCENE_NODE_H

// Local Variables: ***
// mode:C++ ***
// tab-width: 8 ***
// c-basic-offset: 2 ***
// indent-tabs-mode: t ***
// End: ***
// ex: shiftwidth=2 tabstop=8