File: AssIO.h

package info (click to toggle)
spring 103.0%2Bdfsg2-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 43,720 kB
  • ctags: 63,685
  • sloc: cpp: 368,283; ansic: 33,988; python: 12,417; java: 12,203; awk: 5,879; sh: 1,846; xml: 655; perl: 405; php: 211; objc: 194; makefile: 77; sed: 2
file content (54 lines) | stat: -rw-r--r-- 1,447 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */

#ifndef ASS_IO_H
#define ASS_IO_H

#include "lib/assimp/include/assimp/IOStream.hpp"
#include "lib/assimp/include/assimp/IOSystem.hpp"
class CFileHandler;

// Custom implementation of Assimp IOStream to support Spring's VFS
// Required because Assimp models often need to load textures from other files

class AssVFSStream : public Assimp::IOStream
{
	friend class AssVFSSystem;
	CFileHandler* file;

protected:
	// Constructor protected for private usage by AssVFSSystem
	AssVFSStream(const std::string& pFile, const std::string& pMode);

public:
	~AssVFSStream(void);
	size_t Read( void* pvBuffer, size_t pSize, size_t pCount);
	size_t Write( const void* pvBuffer, size_t pSize, size_t pCount);
	aiReturn Seek( size_t pOffset, aiOrigin pOrigin);
	size_t Tell() const;
	size_t FileSize() const;
	void Flush ();
};


// Spring VFS Filesystem Wrapper for Assimp

class AssVFSSystem : public Assimp::IOSystem
{
public:
	AssVFSSystem() { }
	~AssVFSSystem() { }

	// Check whether a specific file exists
	bool Exists( const char* pFile) const;

	// Get the path delimiter character we'd like to get
	char getOsSeparator() const;
	bool ComparePaths (const std::string& one, const std::string& second) const;

	// open a custom stream
	Assimp::IOStream* Open( const char* pFile, const char* pMode  = "rb" );

	void Close( Assimp::IOStream* pFile);
};

#endif // ASS_IO_H