-
Notifications
You must be signed in to change notification settings - Fork 5
/
poObjectModifier.h
89 lines (74 loc) · 2.55 KB
/
poObjectModifier.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
/*
* Copyright 2012 Potion Design. All rights reserved.
* This file is part of pocode.
*
* pocode is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation, either version 3 of
* the License, or (at your option) any later version.
*
* pocode is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with pocode. If not, see <http://www.gnu.org/licenses/>.
*
*/
//
// poObjectModifier.h
// pocode
//
// Created by Joshua Fisher on 5/20/11.
// Copyright 2011 Potion Design. All rights reserved.
//
#pragma once
class poObject;
// CLASS NOTES
//
// A poObjectModifer can be attached to a poObject and can change that poObject
// on every frame. poObjectModifier, as a base class, does not change anything.
//
// A poObjectModifier has two virtual methods, doSetUp() and doSetDown(). These are
// are called before and after the draw() method of the attached object.
//
// A poObjectModifier can alter any of the public properties of an object and may
// also call any of its public methods, either before or after drawing. Oftentimes,
// poObjectModifiers are used to enable and disable OpenGL state.
//
// Examples of poObjectModifiers the poCamera and poGeometry Mask. Disabling a
// poObjectModifier just tempoarily turns it off, and can be switched back on
// at any time.
//
class poObjectModifier
{
public:
poObjectModifier() : enabled(true) {}
virtual poObjectModifier* copy() {return new poObjectModifier();}
// ENABLE & DISABLE
bool isEnabled() const {return enabled;}
void setEnabled(bool b) {enabled = b;}
// SETUP
// This is called just BEFORE the draw() method of the poObject it is attached to.
void setUp( poObject* obj ) {
if(isEnabled())
doSetUp(obj);
}
// SETDOWN
// This is called just AFTER the draw() method of the poObject it is attached to.
void setDown( poObject* obj ) {
if(isEnabled())
doSetDown(obj);
}
protected:
// VIRTUAL METHODS
// THESE METHODS ARE THE ONES THAT WILL GET CALLED SO SUBCLASS THEM
virtual void doSetUp(poObject*) {}
virtual void doSetDown(poObject*) {}
void clone(poObjectModifier *obj) {
obj->enabled = enabled;
}
private:
bool enabled;
};