File: AssIO.h

package info (click to toggle)
spring 105.0.1%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 108,860 kB
  • sloc: cpp: 467,785; ansic: 302,607; python: 12,925; java: 12,201; awk: 5,889; sh: 2,371; xml: 655; perl: 405; php: 276; objc: 194; makefile: 75; sed: 2
file content (53 lines) | stat: -rw-r--r-- 1,454 bytes parent folder | download | duplicates (3)
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
/* 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();
	size_t Read( void* pvBuffer, size_t pSize, size_t pCount) override;
	size_t Write( const void* pvBuffer, size_t pSize, size_t pCount) override;
	aiReturn Seek( size_t pOffset, aiOrigin pOrigin) override;
	size_t Tell() const override;
	size_t FileSize() const override;
	void Flush() override;
};


// 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 override;

	// Get the path delimiter character we'd like to get
	char getOsSeparator() const override;

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

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

#endif // ASS_IO_H