OSDN Git Service

27ff79cb93903c02da266141fc0455404e061dde
[moflib/moflib.git] / moflib-1.0 / moflib / moflib / mof / Container3D.cpp
1 #include "mof/Container3D.h"
2
3
4
5 mof::Container3D::Container3D()
6 : mof::Component3D() 
7 {
8 }
9
10
11 mof::Container3D::~Container3D(){
12
13         for(int i = 0 ; i < m_children.size() ; i ++){
14                 delete m_children.at(i);
15         }
16 }
17
18 bool mof::Container3D::draw(){
19         for(int i = 0 ; i < m_children.size() ; i ++){
20                 if(m_children.at(i) == NULL)continue;
21                 m_children.at(i)->draw(m_worldTransform);
22         }
23         return true;
24 }
25
26
27 bool mof::Container3D::draw(mof::Matrix3D& transform){
28         transform = m_worldTransform * transform;
29         for(int i = 0 ; i < m_children.size() ; i ++){
30                 if(m_children.at(i) == NULL)continue;
31                 m_children.at(i)->draw(transform);
32         }
33         return true;
34 }       
35
36 bool mof::Container3D::update(){
37         for(int i = 0 ; i < m_children.size() ; i ++){
38                 if(m_children.at(i) == NULL)continue;
39                 m_children.at(i)->update();
40         }
41         return mof::Component3D::update();
42 }
43
44
45 void mof::Container3D::add(mof::Component3D* component){
46         for(int i = 0 ; i < m_children.size() ; i ++){
47                 if(m_children.at(i) == NULL){
48                         m_children.at(i) = component;
49                         return;
50                 }
51         }
52         m_children.push_back(component);
53 }
54
55 mof::Component3D* mof::Container3D::get(int index){
56         return m_children.at(index);
57 }
58
59 mof::Vector3D mof::Container3D::getPositionOf(int index){
60         return get(index)->getPosition() * m_worldTransform;
61         //return get(index)->getPosition();
62 }