vrshoot

diff 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
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/libs/assimp/COBScene.h	Sat Feb 01 19:58:19 2014 +0200
     1.3 @@ -0,0 +1,271 @@
     1.4 +/*
     1.5 +Open Asset Import Library (assimp)
     1.6 +----------------------------------------------------------------------
     1.7 +
     1.8 +Copyright (c) 2006-2012, assimp team
     1.9 +All rights reserved.
    1.10 +
    1.11 +Redistribution and use of this software in source and binary forms, 
    1.12 +with or without modification, are permitted provided that the 
    1.13 +following conditions are met:
    1.14 +
    1.15 +* Redistributions of source code must retain the above
    1.16 +copyright notice, this list of conditions and the
    1.17 +following disclaimer.
    1.18 +
    1.19 +* Redistributions in binary form must reproduce the above
    1.20 +copyright notice, this list of conditions and the
    1.21 +following disclaimer in the documentation and/or other
    1.22 +materials provided with the distribution.
    1.23 +
    1.24 +* Neither the name of the assimp team, nor the names of its
    1.25 +contributors may be used to endorse or promote products
    1.26 +derived from this software without specific prior
    1.27 +written permission of the assimp team.
    1.28 +
    1.29 +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
    1.30 +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
    1.31 +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
    1.32 +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
    1.33 +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
    1.34 +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
    1.35 +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
    1.36 +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 
    1.37 +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
    1.38 +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
    1.39 +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    1.40 +
    1.41 +----------------------------------------------------------------------
    1.42 +*/
    1.43 +
    1.44 +/** @file  COBScene.h
    1.45 +*  @brief Utilities for the COB importer.
    1.46 +*/
    1.47 +#ifndef INCLUDED_AI_COB_SCENE_H
    1.48 +#define INCLUDED_AI_COB_SCENE_H
    1.49 +
    1.50 +#include <boost/shared_ptr.hpp>
    1.51 +#include "BaseImporter.h"
    1.52 +
    1.53 +namespace Assimp	{
    1.54 +	namespace COB {
    1.55 +
    1.56 +// ------------------
    1.57 +/** Represents a single vertex index in a face */
    1.58 +struct VertexIndex
    1.59 +{
    1.60 +	// intentionally uninitialized
    1.61 +	unsigned int pos_idx,uv_idx;
    1.62 +};
    1.63 +
    1.64 +// ------------------
    1.65 +/** COB Face data structure */
    1.66 +struct Face
    1.67 +{
    1.68 +	// intentionally uninitialized
    1.69 +	unsigned int material, flags;
    1.70 +	std::vector<VertexIndex> indices;
    1.71 +};
    1.72 +
    1.73 +// ------------------
    1.74 +/** COB chunk header information */
    1.75 +struct ChunkInfo
    1.76 +{
    1.77 +	enum {NO_SIZE=UINT_MAX};
    1.78 +
    1.79 +	ChunkInfo ()
    1.80 +		:	id        (0)
    1.81 +		,	parent_id (0)
    1.82 +		,	version	  (0)
    1.83 +		,	size	  (NO_SIZE)
    1.84 +	{}
    1.85 +
    1.86 +	// Id of this chunk, unique within file
    1.87 +	unsigned int id;
    1.88 +
    1.89 +	// and the corresponding parent
    1.90 +	unsigned int parent_id;
    1.91 +
    1.92 +	// version. v1.23 becomes 123
    1.93 +	unsigned int version;
    1.94 +
    1.95 +	// chunk size in bytes, only relevant for binary files
    1.96 +	// NO_SIZE is also valid.
    1.97 +	unsigned int size;
    1.98 +};
    1.99 +
   1.100 +// ------------------
   1.101 +/** A node in the scenegraph */
   1.102 +struct Node : public ChunkInfo
   1.103 +{
   1.104 +	enum Type {
   1.105 +		TYPE_MESH,TYPE_GROUP,TYPE_LIGHT,TYPE_CAMERA,TYPE_BONE
   1.106 +	};
   1.107 +
   1.108 +	virtual ~Node() {}
   1.109 +	Node(Type type) : type(type), unit_scale(1.f){}
   1.110 +
   1.111 +	Type type;
   1.112 +
   1.113 +	// used during resolving
   1.114 +	typedef std::deque<const Node*> ChildList;
   1.115 +	mutable ChildList temp_children;
   1.116 +
   1.117 +	// unique name
   1.118 +	std::string name;
   1.119 +
   1.120 +	// local mesh transformation
   1.121 +	aiMatrix4x4 transform;
   1.122 +
   1.123 +	// scaling for this node to get to the metric system
   1.124 +	float unit_scale;
   1.125 +};
   1.126 +
   1.127 +// ------------------
   1.128 +/** COB Mesh data structure */
   1.129 +struct Mesh : public Node
   1.130 +{
   1.131 +	using ChunkInfo::operator=;
   1.132 +	enum DrawFlags {
   1.133 +		SOLID = 0x1,
   1.134 +		TRANS = 0x2,
   1.135 +		WIRED = 0x4,
   1.136 +		BBOX  = 0x8,
   1.137 +		HIDE  = 0x10
   1.138 +	};
   1.139 +
   1.140 +	Mesh() 
   1.141 +		: Node(TYPE_MESH)
   1.142 +		, draw_flags(SOLID) 
   1.143 +	{}
   1.144 +
   1.145 +	// vertex elements
   1.146 +	std::vector<aiVector2D> texture_coords;
   1.147 +	std::vector<aiVector3D> vertex_positions;
   1.148 +
   1.149 +	// face data
   1.150 +	std::vector<Face> faces;
   1.151 +
   1.152 +	// misc. drawing flags
   1.153 +	unsigned int draw_flags;
   1.154 +
   1.155 +	// used during resolving
   1.156 +	typedef std::deque<Face*> FaceRefList;
   1.157 +	typedef std::map< unsigned int,FaceRefList > TempMap;
   1.158 +	TempMap temp_map;
   1.159 +};
   1.160 +
   1.161 +// ------------------
   1.162 +/** COB Group data structure */
   1.163 +struct Group : public Node
   1.164 +{
   1.165 +	using ChunkInfo::operator=;
   1.166 +	Group() : Node(TYPE_GROUP) {}
   1.167 +};
   1.168 +
   1.169 +// ------------------
   1.170 +/** COB Bone data structure */
   1.171 +struct Bone : public Node
   1.172 +{
   1.173 +	using ChunkInfo::operator=;
   1.174 +	Bone() : Node(TYPE_BONE) {}
   1.175 +};
   1.176 +
   1.177 +// ------------------
   1.178 +/** COB Light data structure */
   1.179 +struct Light : public Node
   1.180 +{
   1.181 +	enum LightType {
   1.182 +		SPOT,LOCAL,INFINITE
   1.183 +	};
   1.184 +
   1.185 +	using ChunkInfo::operator=;
   1.186 +	Light() : Node(TYPE_LIGHT),angle(),inner_angle(),ltype(SPOT) {}
   1.187 +
   1.188 +	aiColor3D color;
   1.189 +	float angle,inner_angle;
   1.190 +
   1.191 +	LightType ltype;
   1.192 +};
   1.193 +
   1.194 +// ------------------
   1.195 +/** COB Camera data structure */
   1.196 +struct Camera : public Node
   1.197 +{
   1.198 +	using ChunkInfo::operator=;
   1.199 +	Camera() : Node(TYPE_CAMERA) {}
   1.200 +};
   1.201 +
   1.202 +// ------------------
   1.203 +/** COB Texture data structure */
   1.204 +struct Texture
   1.205 +{
   1.206 +	std::string path;
   1.207 +	aiUVTransform transform;
   1.208 +};
   1.209 +
   1.210 +// ------------------
   1.211 +/** COB Material data structure */
   1.212 +struct Material : ChunkInfo
   1.213 +{
   1.214 +	using ChunkInfo::operator=;
   1.215 +	enum Shader {
   1.216 +		FLAT,PHONG,METAL
   1.217 +	};
   1.218 +
   1.219 +	enum AutoFacet {
   1.220 +		FACETED,AUTOFACETED,SMOOTH
   1.221 +	};
   1.222 +
   1.223 +	Material() : alpha(),exp(),ior(),ka(),ks(1.f),
   1.224 +		matnum(UINT_MAX),
   1.225 +		shader(FLAT),autofacet(FACETED),
   1.226 +		autofacet_angle()
   1.227 +	{}
   1.228 +
   1.229 +	std::string type;
   1.230 +
   1.231 +	aiColor3D rgb;
   1.232 +	float alpha, exp, ior,ka,ks;
   1.233 +
   1.234 +	unsigned int matnum;
   1.235 +	Shader shader; 
   1.236 +
   1.237 +	AutoFacet autofacet;
   1.238 +	float autofacet_angle;
   1.239 +
   1.240 +	boost::shared_ptr<Texture> tex_env,tex_bump,tex_color;
   1.241 +};
   1.242 +
   1.243 +// ------------------
   1.244 +/** Embedded bitmap, for instance for the thumbnail image */
   1.245 +struct Bitmap : ChunkInfo
   1.246 +{
   1.247 +	Bitmap() : orig_size() {}
   1.248 +	struct BitmapHeader 
   1.249 +	{
   1.250 +	};
   1.251 +
   1.252 +	BitmapHeader head;
   1.253 +	size_t orig_size;
   1.254 +	std::vector<char> buff_zipped;
   1.255 +};
   1.256 +
   1.257 +typedef std::deque< boost::shared_ptr<Node> > NodeList;
   1.258 +typedef std::vector< Material > MaterialList;
   1.259 +
   1.260 +// ------------------
   1.261 +/** Represents a master COB scene, even if we loaded just a single COB file */
   1.262 +struct Scene
   1.263 +{
   1.264 +	NodeList nodes;
   1.265 +	MaterialList materials;
   1.266 +
   1.267 +	// becomes *0 later
   1.268 +	Bitmap thumbnail;
   1.269 +};
   1.270 +
   1.271 +	} // end COB
   1.272 +} // end Assimp
   1.273 +
   1.274 +#endif