nuclear@0: /* nuclear@0: Open Asset Import Library (assimp) nuclear@0: ---------------------------------------------------------------------- nuclear@0: nuclear@0: Copyright (c) 2006-2012, assimp team nuclear@0: All rights reserved. nuclear@0: nuclear@0: Redistribution and use of this software in source and binary forms, nuclear@0: with or without modification, are permitted provided that the nuclear@0: following conditions are met: nuclear@0: nuclear@0: * Redistributions of source code must retain the above nuclear@0: copyright notice, this list of conditions and the nuclear@0: following disclaimer. nuclear@0: nuclear@0: * Redistributions in binary form must reproduce the above nuclear@0: copyright notice, this list of conditions and the nuclear@0: following disclaimer in the documentation and/or other nuclear@0: materials provided with the distribution. nuclear@0: nuclear@0: * Neither the name of the assimp team, nor the names of its nuclear@0: contributors may be used to endorse or promote products nuclear@0: derived from this software without specific prior nuclear@0: written permission of the assimp team. nuclear@0: nuclear@0: THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS nuclear@0: "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT nuclear@0: LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR nuclear@0: A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT nuclear@0: OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, nuclear@0: SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT nuclear@0: LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, nuclear@0: DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY nuclear@0: THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT nuclear@0: (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE nuclear@0: OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. nuclear@0: nuclear@0: ---------------------------------------------------------------------- nuclear@0: */ nuclear@0: nuclear@0: /** @file COBScene.h nuclear@0: * @brief Utilities for the COB importer. nuclear@0: */ nuclear@0: #ifndef INCLUDED_AI_COB_SCENE_H nuclear@0: #define INCLUDED_AI_COB_SCENE_H nuclear@0: nuclear@0: #include nuclear@0: #include "BaseImporter.h" nuclear@0: nuclear@0: namespace Assimp { nuclear@0: namespace COB { nuclear@0: nuclear@0: // ------------------ nuclear@0: /** Represents a single vertex index in a face */ nuclear@0: struct VertexIndex nuclear@0: { nuclear@0: // intentionally uninitialized nuclear@0: unsigned int pos_idx,uv_idx; nuclear@0: }; nuclear@0: nuclear@0: // ------------------ nuclear@0: /** COB Face data structure */ nuclear@0: struct Face nuclear@0: { nuclear@0: // intentionally uninitialized nuclear@0: unsigned int material, flags; nuclear@0: std::vector indices; nuclear@0: }; nuclear@0: nuclear@0: // ------------------ nuclear@0: /** COB chunk header information */ nuclear@0: struct ChunkInfo nuclear@0: { nuclear@0: enum {NO_SIZE=UINT_MAX}; nuclear@0: nuclear@0: ChunkInfo () nuclear@0: : id (0) nuclear@0: , parent_id (0) nuclear@0: , version (0) nuclear@0: , size (NO_SIZE) nuclear@0: {} nuclear@0: nuclear@0: // Id of this chunk, unique within file nuclear@0: unsigned int id; nuclear@0: nuclear@0: // and the corresponding parent nuclear@0: unsigned int parent_id; nuclear@0: nuclear@0: // version. v1.23 becomes 123 nuclear@0: unsigned int version; nuclear@0: nuclear@0: // chunk size in bytes, only relevant for binary files nuclear@0: // NO_SIZE is also valid. nuclear@0: unsigned int size; nuclear@0: }; nuclear@0: nuclear@0: // ------------------ nuclear@0: /** A node in the scenegraph */ nuclear@0: struct Node : public ChunkInfo nuclear@0: { nuclear@0: enum Type { nuclear@0: TYPE_MESH,TYPE_GROUP,TYPE_LIGHT,TYPE_CAMERA,TYPE_BONE nuclear@0: }; nuclear@0: nuclear@0: virtual ~Node() {} nuclear@0: Node(Type type) : type(type), unit_scale(1.f){} nuclear@0: nuclear@0: Type type; nuclear@0: nuclear@0: // used during resolving nuclear@0: typedef std::deque ChildList; nuclear@0: mutable ChildList temp_children; nuclear@0: nuclear@0: // unique name nuclear@0: std::string name; nuclear@0: nuclear@0: // local mesh transformation nuclear@0: aiMatrix4x4 transform; nuclear@0: nuclear@0: // scaling for this node to get to the metric system nuclear@0: float unit_scale; nuclear@0: }; nuclear@0: nuclear@0: // ------------------ nuclear@0: /** COB Mesh data structure */ nuclear@0: struct Mesh : public Node nuclear@0: { nuclear@0: using ChunkInfo::operator=; nuclear@0: enum DrawFlags { nuclear@0: SOLID = 0x1, nuclear@0: TRANS = 0x2, nuclear@0: WIRED = 0x4, nuclear@0: BBOX = 0x8, nuclear@0: HIDE = 0x10 nuclear@0: }; nuclear@0: nuclear@0: Mesh() nuclear@0: : Node(TYPE_MESH) nuclear@0: , draw_flags(SOLID) nuclear@0: {} nuclear@0: nuclear@0: // vertex elements nuclear@0: std::vector texture_coords; nuclear@0: std::vector vertex_positions; nuclear@0: nuclear@0: // face data nuclear@0: std::vector faces; nuclear@0: nuclear@0: // misc. drawing flags nuclear@0: unsigned int draw_flags; nuclear@0: nuclear@0: // used during resolving nuclear@0: typedef std::deque FaceRefList; nuclear@0: typedef std::map< unsigned int,FaceRefList > TempMap; nuclear@0: TempMap temp_map; nuclear@0: }; nuclear@0: nuclear@0: // ------------------ nuclear@0: /** COB Group data structure */ nuclear@0: struct Group : public Node nuclear@0: { nuclear@0: using ChunkInfo::operator=; nuclear@0: Group() : Node(TYPE_GROUP) {} nuclear@0: }; nuclear@0: nuclear@0: // ------------------ nuclear@0: /** COB Bone data structure */ nuclear@0: struct Bone : public Node nuclear@0: { nuclear@0: using ChunkInfo::operator=; nuclear@0: Bone() : Node(TYPE_BONE) {} nuclear@0: }; nuclear@0: nuclear@0: // ------------------ nuclear@0: /** COB Light data structure */ nuclear@0: struct Light : public Node nuclear@0: { nuclear@0: enum LightType { nuclear@0: SPOT,LOCAL,INFINITE nuclear@0: }; nuclear@0: nuclear@0: using ChunkInfo::operator=; nuclear@0: Light() : Node(TYPE_LIGHT),angle(),inner_angle(),ltype(SPOT) {} nuclear@0: nuclear@0: aiColor3D color; nuclear@0: float angle,inner_angle; nuclear@0: nuclear@0: LightType ltype; nuclear@0: }; nuclear@0: nuclear@0: // ------------------ nuclear@0: /** COB Camera data structure */ nuclear@0: struct Camera : public Node nuclear@0: { nuclear@0: using ChunkInfo::operator=; nuclear@0: Camera() : Node(TYPE_CAMERA) {} nuclear@0: }; nuclear@0: nuclear@0: // ------------------ nuclear@0: /** COB Texture data structure */ nuclear@0: struct Texture nuclear@0: { nuclear@0: std::string path; nuclear@0: aiUVTransform transform; nuclear@0: }; nuclear@0: nuclear@0: // ------------------ nuclear@0: /** COB Material data structure */ nuclear@0: struct Material : ChunkInfo nuclear@0: { nuclear@0: using ChunkInfo::operator=; nuclear@0: enum Shader { nuclear@0: FLAT,PHONG,METAL nuclear@0: }; nuclear@0: nuclear@0: enum AutoFacet { nuclear@0: FACETED,AUTOFACETED,SMOOTH nuclear@0: }; nuclear@0: nuclear@0: Material() : alpha(),exp(),ior(),ka(),ks(1.f), nuclear@0: matnum(UINT_MAX), nuclear@0: shader(FLAT),autofacet(FACETED), nuclear@0: autofacet_angle() nuclear@0: {} nuclear@0: nuclear@0: std::string type; nuclear@0: nuclear@0: aiColor3D rgb; nuclear@0: float alpha, exp, ior,ka,ks; nuclear@0: nuclear@0: unsigned int matnum; nuclear@0: Shader shader; nuclear@0: nuclear@0: AutoFacet autofacet; nuclear@0: float autofacet_angle; nuclear@0: nuclear@0: boost::shared_ptr tex_env,tex_bump,tex_color; nuclear@0: }; nuclear@0: nuclear@0: // ------------------ nuclear@0: /** Embedded bitmap, for instance for the thumbnail image */ nuclear@0: struct Bitmap : ChunkInfo nuclear@0: { nuclear@0: Bitmap() : orig_size() {} nuclear@0: struct BitmapHeader nuclear@0: { nuclear@0: }; nuclear@0: nuclear@0: BitmapHeader head; nuclear@0: size_t orig_size; nuclear@0: std::vector buff_zipped; nuclear@0: }; nuclear@0: nuclear@0: typedef std::deque< boost::shared_ptr > NodeList; nuclear@0: typedef std::vector< Material > MaterialList; nuclear@0: nuclear@0: // ------------------ nuclear@0: /** Represents a master COB scene, even if we loaded just a single COB file */ nuclear@0: struct Scene nuclear@0: { nuclear@0: NodeList nodes; nuclear@0: MaterialList materials; nuclear@0: nuclear@0: // becomes *0 later nuclear@0: Bitmap thumbnail; nuclear@0: }; nuclear@0: nuclear@0: } // end COB nuclear@0: } // end Assimp nuclear@0: nuclear@0: #endif