1// tInstance.cpp 
2// 
3// This file implements tScene instances. An instance is essentially a transformation (position, rotation, scale) in 
4// addition to a reference to the object being instanced. In a tScene, this reference consists of the ID of a 
5// particular type of object. 
6// 
7// Copyright (c) 2006, 2017 Tristan Grimmer. 
8// Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby 
9// granted, provided that the above copyright notice and this permission notice appear in all copies. 
10// 
11// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL 
12// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, 
13// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN 
14// AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 
15// PERFORMANCE OF THIS SOFTWARE. 
16 
17#include "Scene/tInstance.h" 
18namespace tScene 
19
20 
21 
22void tInstance::Save(tChunkWriter& chunk) const 
23
24 chunk.Begin(tChunkID::Scene_Instance); 
25
26 tObject::Save(chunk); 
27 
28 chunk.Begin(tChunkID::Scene_InstanceParameters); 
29
30 chunk.Write(ObjectType); 
31 chunk.Write(ObjectID); 
32 chunk.Write(Transform); 
33
34 chunk.End(); 
35
36 chunk.End(); 
37
38 
39 
40void tInstance::Load(const tChunk& instChunk
41
42 tAssert(instChunk.ID() == tChunkID::Scene_Instance); 
43 Clear(); 
44 
45 for (tChunk chunk = instChunk.First(); chunk.Valid(); chunk = chunk.Next()) 
46
47 switch (chunk.ID()) 
48
49 case tChunkID::Scene_Object
50 tObject::Load(chunk); 
51 break
52 
53 case tChunkID::Scene_InstanceParameters
54
55 chunk.GetItem(ObjectType); 
56 chunk.GetItem(ObjectID); 
57 chunk.GetItem(Transform); 
58 break
59
60
61
62
63 
64 
65
66