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 #include "Teddy/Materials/Material.h"
00026 #include "Teddy/Models/Model.h"
00027 #include "Teddy/Models/Geometry.h"
00028 #include "Teddy/PhysicalComponents/Projection.h"
00029 #include "Teddy/Scenes/Camera.h"
00030 #include "Teddy/SysSupport/StdMaths.h"
00031 #include "Teddy/SysSupport/Messages.h"
00032 using namespace Teddy::Graphics;
00033 using namespace Teddy::Materials;
00034 using namespace Teddy::Scenes;
00035 using namespace Teddy::SysSupport;
00036
00037
00038 namespace Teddy {
00039 namespace Models {
00040
00041
00043 void Model::doMaterial( Projection *p, Model *parent ){
00044 if( material == NULL ){
00045 if( parent != NULL ){
00046 parent->doMaterial( p );
00047 }else{
00048 p->doMaterial( &Material::RED );
00049 }
00050 }else{
00051 p->doMaterial( material );
00052 }
00053 }
00054
00055
00057 void Model::draw( Projection *p, Model *parent ){
00058 Camera *c = p->getCamera();
00059
00060 if( isEnabled(OPT_VISIBLE) == true ){
00061 bool setup = false;
00062
00063
00064 c->doObjectMatrix( p, getLocalToWorldMatrix() );
00065 if( c->cull(*this) == false ){
00066 if( geometry != NULL ){
00067 doMaterial( p, parent );
00068 setup = true;
00069
00070
00071 while( p->materialPass() ){
00072 geometry->draw( p );
00073 }
00074 }else{
00075
00076 }
00077 }else{
00078
00079 }
00080
00081
00082 if( children.size() > 0 ){
00083 if( setup == false ){
00084 doMaterial( p, parent );
00085 }
00086 c->pushObjectMatrix();
00087 list<Model*>::iterator m_it = children.begin();
00088 while( m_it != children.end() ){
00089 (*m_it)->draw( p, material != NULL ? this : parent );
00090 m_it++;
00091 }
00092 c->popObjectMatrix();
00093 }
00094 }else{
00095
00096 }
00097 }
00098
00099
00100 };
00101 };
00102