game-model.h
2.65 KB
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#ifndef GAME_MODEL_H
#define GAME_MODEL_H
/*
* Copyright (c) 2020 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
#include <dali/public-api/rendering/geometry.h>
#include <dali/public-api/rendering/vertex-buffer.h>
#include <inttypes.h>
/**
* @brief The ModelHeader struct
* Model file header structure
*/
struct ModelHeader
{
uint32_t tag; /// 'MODV' tag
uint32_t version; /// File version
uint32_t vertexBufferSize; /// total size of the vertex buffer to allocate
uint32_t attributeCount; /// number of stored attributes
uint32_t attributeFormat[16]; /// format encoded as ((type << 16)|(count)); 'type' represents primitive type, 'count' represents number of components ( 1-4 )
uint32_t attributeOffset[16]; /// attribute offsets
uint32_t attributeSize[16]; /// attribute size in bytes
uint32_t vertexStride; /// vertex stride
uint32_t reserved; /// reserved, may point at additional structure
uint32_t dataBeginOffset; /// start of actual vertex data
};
/**
* @brief The GameModel class
* GameModel represents model geometry. It loads model data from external model file ( .mod file ).
* Such data is ready to be used as GL buffer so it can be copied directly into the VertexBuffer
* object.
*
* Model file is multi-architecture so can be loaded on little and big endian architectures
*/
class GameModel
{
public:
/**
* Creates an instance of GameModel and loads the '.mod' file
* @param[in] filename Name of file to load
*/
GameModel(const char* filename);
/**
* Destroys an instance of GameModel
*/
~GameModel();
/**
* Returns DALi geometry object
* @return Returns DALi geometry object
*/
Dali::Geometry& GetGeometry();
/**
* Checks status of model, returns false if failed to load
* @return true if model has been loaded, false otherwise
*/
bool IsReady();
/**
* Returns unique Id of the texture
* @return Unique Id
*/
uint32_t GetUniqueId();
private:
Dali::Geometry mGeometry;
Dali::VertexBuffer mVertexBuffer;
ModelHeader mHeader;
uint32_t mUniqueId;
bool mIsReady;
};
#endif