Panda3D
Loading...
Searching...
No Matches
multitexReducer.h
Go to the documentation of this file.
1/**
2 * PANDA 3D SOFTWARE
3 * Copyright (c) Carnegie Mellon University. All rights reserved.
4 *
5 * All use of this software is subject to the terms of the revised BSD
6 * license. You should have received a copy of this license along
7 * with this source code in a file named "LICENSE."
8 *
9 * @file multitexReducer.h
10 * @author drose
11 * @date 2004-11-30
12 */
13
14#ifndef MULTITEXREDUCER_H
15#define MULTITEXREDUCER_H
16
17#include "pandabase.h"
18#include "texture.h"
19#include "textureAttrib.h"
20#include "textureStage.h"
21#include "texMatrixAttrib.h"
22#include "transformState.h"
23#include "geomNode.h"
24#include "nodePath.h"
25#include "luse.h"
26#include "pointerTo.h"
27#include "pmap.h"
28#include "pvector.h"
29
30class GraphicsOutput;
31class PandaNode;
32class RenderState;
33class TransformState;
34
35/**
36 * This object presents an interface for generating new texture images that
37 * represent the combined images from one or more individual textures,
38 * reproducing certain kinds of multitexture effects without depending on
39 * multitexture support in the hardware.
40 *
41 * This also flattens out texture matrices and removes extra texture
42 * coordinates from the Geoms. It is thus not a complete substitute for true
43 * multitexturing, because it does not lend itself well to dynamic animation
44 * of the textures once they have been flattened. It is, however, useful for
45 * "baking in" a particular multitexture effect.
46 */
47class EXPCL_PANDA_GRUTIL MultitexReducer {
48PUBLISHED:
51
52 void clear();
53 INLINE void scan(const NodePath &node);
54 INLINE void scan(const NodePath &node, const NodePath &state_from);
55 void scan(PandaNode *node, const RenderState *state,
56 const TransformState *transform);
57
58 void set_target(TextureStage *stage);
59 void set_use_geom(bool use_geom);
60 void set_allow_tex_mat(bool allow_tex_mat);
61
62 void flatten(GraphicsOutput *window);
63
64private:
65 class StageInfo {
66 public:
67 StageInfo(TextureStage *stage, const TextureAttrib *ta,
68 const TexMatrixAttrib *tma);
69
70 INLINE bool operator < (const StageInfo &other) const;
71
72 PT(TextureStage) _stage;
73 PT(Texture) _tex;
74 CPT(TransformState) _tex_mat;
75 };
76
78
79 class GeomInfo {
80 public:
81 INLINE GeomInfo(const RenderState *state, const RenderState *geom_net_state,
82 GeomNode *geom_node, int index);
83
84 CPT(RenderState) _state;
85 CPT(RenderState) _geom_net_state;
86 PT(GeomNode) _geom_node;
87 int _index;
88 };
89
91
92 class GeomNodeInfo {
93 public:
94 INLINE GeomNodeInfo(const RenderState *state, GeomNode *geom_node);
95 CPT(RenderState) _state;
96 PT(GeomNode) _geom_node;
97 };
98
100
102 Stages _stages;
103 GeomNodeList _geom_node_list;
104
105 PT(TextureStage) _target_stage;
106 bool _use_geom;
107 bool _allow_tex_mat;
108
109private:
110 void scan_geom_node(GeomNode *node, const RenderState *state,
111 const TransformState *transform);
112
113 void record_stage_list(const StageList &stage_list,
114 const GeomInfo &geom_info);
115
116 size_t choose_model_stage(const StageList &stage_list) const;
117 bool determine_uv_range(LTexCoord &min_uv, LTexCoord &max_uv,
118 const StageInfo &model_stage,
119 const GeomList &geom_list) const;
120
121 void get_uv_scale(LVecBase2 &uv_scale, LVecBase2 &uv_trans,
122 const LTexCoord &min_uv, const LTexCoord &max_uv) const;
123
124 void choose_texture_size(int &x_size, int &y_size,
125 const StageInfo &model_stage,
126 const LVecBase2 &uv_scale,
127 GraphicsOutput *window) const;
128
129 void make_texture_layer(const NodePath &render,
130 const StageInfo &stage_info,
131 const GeomList &geom_list,
132 const LTexCoord &min_uv, const LTexCoord &max_uv,
133 bool force_use_geom, bool transparent_base);
134 void transfer_geom(GeomNode *geom_node, const InternalName *texcoord_name,
135 const GeomList &geom_list, bool preserve_color);
136
137 void scan_color(const GeomList &geom_list, LColor &geom_color,
138 int &num_colors) const;
139 bool scan_decal(const StageList &stage_list) const;
140
141};
142
143#include "multitexReducer.I"
144
145#endif
A node that holds Geom objects, renderable pieces of geometry.
Definition geomNode.h:34
This is a base class for the various different classes that represent the result of a frame of render...
Encodes a string name in a hash table, mapping it to a pointer.
This object presents an interface for generating new texture images that represent the combined image...
NodePath is the fundamental system for disambiguating instances, and also provides a higher-level int...
Definition nodePath.h:159
A basic node of the scene graph or data graph.
Definition pandaNode.h:65
This represents a unique collection of RenderAttrib objects that correspond to a particular renderabl...
Definition renderState.h:47
Applies a transform matrix to UV's before they are rendered.
Indicates the set of TextureStages and their associated Textures that should be applied to (or remove...
Defines the properties of a named stage of the multitexture pipeline.
Represents a texture object, which is typically a single 2-d image but may also represent a 1-d or 3-...
Definition texture.h:72
Indicates a coordinate-system transform on vertices.
This is our own Panda specialization on the default STL map.
Definition pmap.h:49
This is our own Panda specialization on the default STL vector.
Definition pvector.h:42
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.