]> Dogcows Code - chaz/yoink/blob - src/scene.cc
big batch of progress
[chaz/yoink] / src / scene.cc
1
2 /*******************************************************************************
3
4 Copyright (c) 2009, Charles McGarvey
5 All rights reserved.
6
7 Redistribution and use in source and binary forms, with or without
8 modification, are permitted provided that the following conditions are met:
9
10 * Redistributions of source code must retain the above copyright notice,
11 this list of conditions and the following disclaimer.
12 * Redistributions in binary form must reproduce the above copyright notice,
13 this list of conditions and the following disclaimer in the documentation
14 and/or other materials provided with the distribution.
15
16 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
20 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
22 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
23 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
24 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26
27 *******************************************************************************/
28
29 #include <map>
30 #include <vector>
31
32 #include "mippleton.hh"
33 #include "deserializer.hh"
34 #include "serializable.hh"
35 #include "aabb.hh"
36
37 #include "scene.hh"
38
39
40 namespace dc {
41
42
43 class scene::scene_impl : public mippleton<scene_impl>
44 {
45 static bool loadBox(aabb& theBox, serializable_ptr obj)
46 {
47 std::vector<serializable_ptr> numbers;
48
49 if (obj->get(numbers))
50 {
51 if (numbers.size() == 6)
52 {
53 double num;
54
55 if (numbers[0]->getNumber(num))
56 {
57
58 }
59 }
60 }
61
62 return false;
63 }
64
65 public:
66
67 scene_impl(const std::string& name) :
68 mippleton<scene_impl>(name)
69 {
70 loadFromFile();
71 }
72
73
74 void loadFromFile()
75 {
76 std::string filePath = scene::getPathToResource(getName());
77
78 deserializer in(filePath, true);
79
80 serializable_ptr root = in.deserialize();
81
82 if (root)
83 {
84 std::map<std::string,serializable_ptr> rootObj;
85
86 if (root->get(rootObj))
87 {
88 std::map<std::string,serializable_ptr>::iterator it;
89
90 if ((it = rootObj.find("playfield_bounds")) != rootObj.end())
91 {
92 loadBox(playfieldBounds, (*it).second);
93 }
94 if ((it = rootObj.find("maximum_bounds")) != rootObj.end())
95 {
96 loadBox(maximumBounds, (*it).second);
97 }
98
99 //for (i = rootObj.begin(); i != rootObj.end(); i++)
100 //{
101 //sequences.insert(std::pair<std::string,sequence>((*i).first,
102 //sequence((*i).second)));
103 //}
104 }
105 }
106 }
107
108 aabb playfieldBounds;
109 aabb maximumBounds;
110
111 };
112
113
114 scene::scene(const std::string& name) :
115 // pass through
116 impl(scene::scene_impl::retain(name), &scene::scene_impl::release) {}
117
118
119 void scene::draw(scalar alpha)
120 {
121 }
122
123
124 /**
125 * Specialized search location for scene files. They can be found in the
126 * "scenes" subdirectory of any of the searched directories.
127 */
128
129 std::string scene::getPathToResource(const std::string& name)
130 {
131 return resource::getPathToResource("scenes/" + name + ".json");
132 }
133
134
135 } // namespace dc
136
137 /** vim: set ts=4 sw=4 tw=80: *************************************************/
138
This page took 0.036078 seconds and 4 git commands to generate.