vrshoot

annotate libs/assimp/COBScene.h @ 0:b2f14e535253

initial commit
author John Tsiombikas <nuclear@member.fsf.org>
date Sat, 01 Feb 2014 19:58:19 +0200
parents
children
rev   line source
nuclear@0 1 /*
nuclear@0 2 Open Asset Import Library (assimp)
nuclear@0 3 ----------------------------------------------------------------------
nuclear@0 4
nuclear@0 5 Copyright (c) 2006-2012, assimp team
nuclear@0 6 All rights reserved.
nuclear@0 7
nuclear@0 8 Redistribution and use of this software in source and binary forms,
nuclear@0 9 with or without modification, are permitted provided that the
nuclear@0 10 following conditions are met:
nuclear@0 11
nuclear@0 12 * Redistributions of source code must retain the above
nuclear@0 13 copyright notice, this list of conditions and the
nuclear@0 14 following disclaimer.
nuclear@0 15
nuclear@0 16 * Redistributions in binary form must reproduce the above
nuclear@0 17 copyright notice, this list of conditions and the
nuclear@0 18 following disclaimer in the documentation and/or other
nuclear@0 19 materials provided with the distribution.
nuclear@0 20
nuclear@0 21 * Neither the name of the assimp team, nor the names of its
nuclear@0 22 contributors may be used to endorse or promote products
nuclear@0 23 derived from this software without specific prior
nuclear@0 24 written permission of the assimp team.
nuclear@0 25
nuclear@0 26 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
nuclear@0 27 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
nuclear@0 28 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
nuclear@0 29 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
nuclear@0 30 OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
nuclear@0 31 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
nuclear@0 32 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
nuclear@0 33 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
nuclear@0 34 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
nuclear@0 35 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
nuclear@0 36 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
nuclear@0 37
nuclear@0 38 ----------------------------------------------------------------------
nuclear@0 39 */
nuclear@0 40
nuclear@0 41 /** @file COBScene.h
nuclear@0 42 * @brief Utilities for the COB importer.
nuclear@0 43 */
nuclear@0 44 #ifndef INCLUDED_AI_COB_SCENE_H
nuclear@0 45 #define INCLUDED_AI_COB_SCENE_H
nuclear@0 46
nuclear@0 47 #include <boost/shared_ptr.hpp>
nuclear@0 48 #include "BaseImporter.h"
nuclear@0 49
nuclear@0 50 namespace Assimp {
nuclear@0 51 namespace COB {
nuclear@0 52
nuclear@0 53 // ------------------
nuclear@0 54 /** Represents a single vertex index in a face */
nuclear@0 55 struct VertexIndex
nuclear@0 56 {
nuclear@0 57 // intentionally uninitialized
nuclear@0 58 unsigned int pos_idx,uv_idx;
nuclear@0 59 };
nuclear@0 60
nuclear@0 61 // ------------------
nuclear@0 62 /** COB Face data structure */
nuclear@0 63 struct Face
nuclear@0 64 {
nuclear@0 65 // intentionally uninitialized
nuclear@0 66 unsigned int material, flags;
nuclear@0 67 std::vector<VertexIndex> indices;
nuclear@0 68 };
nuclear@0 69
nuclear@0 70 // ------------------
nuclear@0 71 /** COB chunk header information */
nuclear@0 72 struct ChunkInfo
nuclear@0 73 {
nuclear@0 74 enum {NO_SIZE=UINT_MAX};
nuclear@0 75
nuclear@0 76 ChunkInfo ()
nuclear@0 77 : id (0)
nuclear@0 78 , parent_id (0)
nuclear@0 79 , version (0)
nuclear@0 80 , size (NO_SIZE)
nuclear@0 81 {}
nuclear@0 82
nuclear@0 83 // Id of this chunk, unique within file
nuclear@0 84 unsigned int id;
nuclear@0 85
nuclear@0 86 // and the corresponding parent
nuclear@0 87 unsigned int parent_id;
nuclear@0 88
nuclear@0 89 // version. v1.23 becomes 123
nuclear@0 90 unsigned int version;
nuclear@0 91
nuclear@0 92 // chunk size in bytes, only relevant for binary files
nuclear@0 93 // NO_SIZE is also valid.
nuclear@0 94 unsigned int size;
nuclear@0 95 };
nuclear@0 96
nuclear@0 97 // ------------------
nuclear@0 98 /** A node in the scenegraph */
nuclear@0 99 struct Node : public ChunkInfo
nuclear@0 100 {
nuclear@0 101 enum Type {
nuclear@0 102 TYPE_MESH,TYPE_GROUP,TYPE_LIGHT,TYPE_CAMERA,TYPE_BONE
nuclear@0 103 };
nuclear@0 104
nuclear@0 105 virtual ~Node() {}
nuclear@0 106 Node(Type type) : type(type), unit_scale(1.f){}
nuclear@0 107
nuclear@0 108 Type type;
nuclear@0 109
nuclear@0 110 // used during resolving
nuclear@0 111 typedef std::deque<const Node*> ChildList;
nuclear@0 112 mutable ChildList temp_children;
nuclear@0 113
nuclear@0 114 // unique name
nuclear@0 115 std::string name;
nuclear@0 116
nuclear@0 117 // local mesh transformation
nuclear@0 118 aiMatrix4x4 transform;
nuclear@0 119
nuclear@0 120 // scaling for this node to get to the metric system
nuclear@0 121 float unit_scale;
nuclear@0 122 };
nuclear@0 123
nuclear@0 124 // ------------------
nuclear@0 125 /** COB Mesh data structure */
nuclear@0 126 struct Mesh : public Node
nuclear@0 127 {
nuclear@0 128 using ChunkInfo::operator=;
nuclear@0 129 enum DrawFlags {
nuclear@0 130 SOLID = 0x1,
nuclear@0 131 TRANS = 0x2,
nuclear@0 132 WIRED = 0x4,
nuclear@0 133 BBOX = 0x8,
nuclear@0 134 HIDE = 0x10
nuclear@0 135 };
nuclear@0 136
nuclear@0 137 Mesh()
nuclear@0 138 : Node(TYPE_MESH)
nuclear@0 139 , draw_flags(SOLID)
nuclear@0 140 {}
nuclear@0 141
nuclear@0 142 // vertex elements
nuclear@0 143 std::vector<aiVector2D> texture_coords;
nuclear@0 144 std::vector<aiVector3D> vertex_positions;
nuclear@0 145
nuclear@0 146 // face data
nuclear@0 147 std::vector<Face> faces;
nuclear@0 148
nuclear@0 149 // misc. drawing flags
nuclear@0 150 unsigned int draw_flags;
nuclear@0 151
nuclear@0 152 // used during resolving
nuclear@0 153 typedef std::deque<Face*> FaceRefList;
nuclear@0 154 typedef std::map< unsigned int,FaceRefList > TempMap;
nuclear@0 155 TempMap temp_map;
nuclear@0 156 };
nuclear@0 157
nuclear@0 158 // ------------------
nuclear@0 159 /** COB Group data structure */
nuclear@0 160 struct Group : public Node
nuclear@0 161 {
nuclear@0 162 using ChunkInfo::operator=;
nuclear@0 163 Group() : Node(TYPE_GROUP) {}
nuclear@0 164 };
nuclear@0 165
nuclear@0 166 // ------------------
nuclear@0 167 /** COB Bone data structure */
nuclear@0 168 struct Bone : public Node
nuclear@0 169 {
nuclear@0 170 using ChunkInfo::operator=;
nuclear@0 171 Bone() : Node(TYPE_BONE) {}
nuclear@0 172 };
nuclear@0 173
nuclear@0 174 // ------------------
nuclear@0 175 /** COB Light data structure */
nuclear@0 176 struct Light : public Node
nuclear@0 177 {
nuclear@0 178 enum LightType {
nuclear@0 179 SPOT,LOCAL,INFINITE
nuclear@0 180 };
nuclear@0 181
nuclear@0 182 using ChunkInfo::operator=;
nuclear@0 183 Light() : Node(TYPE_LIGHT),angle(),inner_angle(),ltype(SPOT) {}
nuclear@0 184
nuclear@0 185 aiColor3D color;
nuclear@0 186 float angle,inner_angle;
nuclear@0 187
nuclear@0 188 LightType ltype;
nuclear@0 189 };
nuclear@0 190
nuclear@0 191 // ------------------
nuclear@0 192 /** COB Camera data structure */
nuclear@0 193 struct Camera : public Node
nuclear@0 194 {
nuclear@0 195 using ChunkInfo::operator=;
nuclear@0 196 Camera() : Node(TYPE_CAMERA) {}
nuclear@0 197 };
nuclear@0 198
nuclear@0 199 // ------------------
nuclear@0 200 /** COB Texture data structure */
nuclear@0 201 struct Texture
nuclear@0 202 {
nuclear@0 203 std::string path;
nuclear@0 204 aiUVTransform transform;
nuclear@0 205 };
nuclear@0 206
nuclear@0 207 // ------------------
nuclear@0 208 /** COB Material data structure */
nuclear@0 209 struct Material : ChunkInfo
nuclear@0 210 {
nuclear@0 211 using ChunkInfo::operator=;
nuclear@0 212 enum Shader {
nuclear@0 213 FLAT,PHONG,METAL
nuclear@0 214 };
nuclear@0 215
nuclear@0 216 enum AutoFacet {
nuclear@0 217 FACETED,AUTOFACETED,SMOOTH
nuclear@0 218 };
nuclear@0 219
nuclear@0 220 Material() : alpha(),exp(),ior(),ka(),ks(1.f),
nuclear@0 221 matnum(UINT_MAX),
nuclear@0 222 shader(FLAT),autofacet(FACETED),
nuclear@0 223 autofacet_angle()
nuclear@0 224 {}
nuclear@0 225
nuclear@0 226 std::string type;
nuclear@0 227
nuclear@0 228 aiColor3D rgb;
nuclear@0 229 float alpha, exp, ior,ka,ks;
nuclear@0 230
nuclear@0 231 unsigned int matnum;
nuclear@0 232 Shader shader;
nuclear@0 233
nuclear@0 234 AutoFacet autofacet;
nuclear@0 235 float autofacet_angle;
nuclear@0 236
nuclear@0 237 boost::shared_ptr<Texture> tex_env,tex_bump,tex_color;
nuclear@0 238 };
nuclear@0 239
nuclear@0 240 // ------------------
nuclear@0 241 /** Embedded bitmap, for instance for the thumbnail image */
nuclear@0 242 struct Bitmap : ChunkInfo
nuclear@0 243 {
nuclear@0 244 Bitmap() : orig_size() {}
nuclear@0 245 struct BitmapHeader
nuclear@0 246 {
nuclear@0 247 };
nuclear@0 248
nuclear@0 249 BitmapHeader head;
nuclear@0 250 size_t orig_size;
nuclear@0 251 std::vector<char> buff_zipped;
nuclear@0 252 };
nuclear@0 253
nuclear@0 254 typedef std::deque< boost::shared_ptr<Node> > NodeList;
nuclear@0 255 typedef std::vector< Material > MaterialList;
nuclear@0 256
nuclear@0 257 // ------------------
nuclear@0 258 /** Represents a master COB scene, even if we loaded just a single COB file */
nuclear@0 259 struct Scene
nuclear@0 260 {
nuclear@0 261 NodeList nodes;
nuclear@0 262 MaterialList materials;
nuclear@0 263
nuclear@0 264 // becomes *0 later
nuclear@0 265 Bitmap thumbnail;
nuclear@0 266 };
nuclear@0 267
nuclear@0 268 } // end COB
nuclear@0 269 } // end Assimp
nuclear@0 270
nuclear@0 271 #endif