00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #include "outlineShader.h"
00019 #include <lightTransition.h>
00020 #include <dftraverser.h>
00021 #include <depthTestTransition.h>
00022 #include <graphicsStateGuardian.h>
00023 #include <attribTraverser.h>
00024 #include <renderModeTransition.h>
00025 #include <cullFaceTransition.h>
00026 #include <colorTransition.h>
00027 #include <linesmoothTransition.h>
00028 #include <directRenderTraverser.h>
00029 #include <renderRelation.h>
00030
00031
00032
00033
00034 TypeHandle OutlineShader::_type_handle;
00035
00036
00037
00038
00039
00040
00041 OutlineShader::OutlineShader(void) : Shader() {
00042 set_color(Colorf(0, 0, 0, 1));
00043 }
00044
00045
00046
00047
00048
00049
00050 OutlineShader::OutlineShader(const Colorf &color) : Shader() {
00051 set_color(color);
00052 }
00053
00054
00055
00056
00057
00058
00059 void OutlineShader::config(void) {
00060 Configurable::config();
00061 }
00062
00063
00064
00065
00066
00067
00068 void OutlineShader::
00069 apply(Node *node, const AllAttributesWrapper &init_state,
00070 const AllTransitionsWrapper &net_trans, GraphicsStateGuardian *gsg) {
00071 Shader::apply(node, init_state, net_trans, gsg);
00072 DirectRenderTraverser drt(gsg, RenderRelation::get_class_type());
00073
00074
00075
00076 if (!is_textured(node, init_state)) {
00077 gsg->render_subgraph(&drt, node, init_state, net_trans);
00078 }
00079
00080
00081 AllTransitionsWrapper trans(net_trans);
00082
00083
00084 trans.set_transition(new LightTransition(LightTransition::all_off()));
00085
00086
00087 RenderModeTransition *rm =
00088 new RenderModeTransition(RenderModeProperty::M_wireframe, 2.0);
00089 trans.set_transition(rm);
00090
00091
00092
00093
00094
00095
00096 DepthTestTransition *dta =
00097 new DepthTestTransition(DepthTestProperty::M_less_equal);
00098 trans.set_transition(dta);
00099
00100
00101 CullFaceTransition *cf =
00102 new CullFaceTransition(CullFaceProperty::M_cull_counter_clockwise);
00103 trans.set_transition(cf);
00104
00105
00106 ColorTransition *c = new ColorTransition(_color);
00107 trans.set_transition(c);
00108
00109 gsg->render_subgraph(&drt, node, init_state, trans);
00110 }