00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043 #include <stdlib.h>
00044 #include <stdio.h>
00045
00046 #include <OSGConfig.h>
00047
00048 #include "OSGMaterialDrawable.h"
00049
00050 #include <OSGDrawAction.h>
00051 #include <OSGRenderAction.h>
00052 #include <OSGIntersectAction.h>
00053 #include <OSGSimpleGeometry.h>
00054
00055 OSG_USING_NAMESPACE
00056
00061
00062
00064
00065 MaterialDrawable::MaterialDrawable(void) :
00066 Inherited()
00067 {
00068 }
00069
00071
00072 MaterialDrawable::MaterialDrawable(const MaterialDrawable &source) :
00073 Inherited(source)
00074 {
00075 }
00076
00078
00079 MaterialDrawable::~MaterialDrawable(void)
00080 {
00081 }
00082
00083
00084
00086
00087 Action::ResultE MaterialDrawable::drawPrimitives (DrawActionBase *)
00088 {
00089 FWARNING (("You should overload drawPrimitives in your code\n"));
00090
00091 return Action::Continue;
00092 }
00093
00094 Action::ResultE MaterialDrawable::renderActionHandler(Action *action)
00095 {
00096 RenderAction *a = dynamic_cast<RenderAction *>(action);
00097
00098 Material::DrawFunctor func;
00099 func = osgTypedMethodFunctor1ObjPtr(this,
00100 &MaterialDrawable::drawPrimitives);
00101
00102 Material* m = a->getMaterial();
00103
00104 if(m == NULL)
00105 {
00106 if(getMaterial() != NullFC)
00107 {
00108 m = getMaterial().getCPtr();
00109 }
00110 else
00111 {
00112 m = getDefaultMaterial().getCPtr();
00113 FNOTICE(("MaterialDrawable::render: no Material!?!\n"));
00114 }
00115 }
00116
00117 a->dropFunctor(func, m);
00118
00119 return Action::Continue;
00120 }
00121
00122 Action::ResultE MaterialDrawable::drawActionHandler(Action * action )
00123 {
00124 DrawAction *a = dynamic_cast<DrawAction*>(action);
00125 Material::DrawFunctor func;
00126
00127 func=osgTypedMethodFunctor1ObjPtr(&(*this),
00128 &MaterialDrawable::drawPrimitives);
00129
00130 if(a->getMaterial() != NULL)
00131 {
00132 a->getMaterial()->draw(func, a);
00133 }
00134 else if ( getMaterial() != NullFC )
00135 {
00136 getMaterial()->draw( func, a );
00137 }
00138 else
00139 {
00140 getDefaultMaterial()->draw( func, a );
00141 FWARNING(("MaterialDrawable::draw:: no material!\n"));;
00142 }
00143 return Action::Continue;
00144 }
00145
00146
00147 void MaterialDrawable::initMethod (void)
00148 {
00149 }
00150
00152
00153 void MaterialDrawable::changed(BitVector whichField, UInt32 origin)
00154 {
00155 Inherited::changed(whichField, origin);
00156 }
00157
00159
00160 void MaterialDrawable::dump( UInt32 ,
00161 const BitVector ) const
00162 {
00163 SLOG << "Dump MaterialDrawable NI" << std::endl;
00164 }
00165
00166
00167
00168
00169
00170 #ifdef OSG_SGI_CC
00171 #pragma set woff 1174
00172 #endif
00173
00174 #ifdef OSG_LINUX_ICC
00175 #pragma warning( disable : 177 )
00176 #endif
00177
00178 namespace
00179 {
00180 static Char8 cvsid_cpp [] = "@(#)$Id: OSGMaterialDrawable.cpp,v 1.7 2003/11/01 01:57:26 vossg Exp $";
00181 static Char8 cvsid_hpp [] = OSGMATERIALDRAWABLEBASE_HEADER_CVSID;
00182 static Char8 cvsid_inl [] = OSGMATERIALDRAWABLEBASE_INLINE_CVSID;
00183
00184 static Char8 cvsid_fields_hpp[] = OSGMATERIALDRAWABLEFIELDS_HEADER_CVSID;
00185 }
00186
00187 #ifdef __sgi
00188 #pragma reset woff 1174
00189 #endif
00190