V-Gears 0
Free Final Fantasy VII engine.
VGearsPFile.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2022 The V-Gears Team
3 *
4 * This file is part of V-Gears
5 *
6 * V-Gears is free software: you can redistribute it and/or modify it under
7 * terms of the GNU General Public License as published by the Free Software
8 * Foundation, version 3.0 (GPLv3) of the License.
9 *
10 * V-Gears is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 */
15
16#pragma once
17
18#include <OgreAxisAlignedBox.h>
19#include <OgreColourValue.h>
20#include <OgreMesh.h>
21#include <OgreResource.h>
22#include <Ogre.h>
23#include "common/TypeDefine.h"
25#include "data/VGearsRSDFile.h"
26
27namespace VGears{
28
38 class PFile : public Ogre::Resource{
39
40 public:
41
56 PFile(
57 Ogre::ResourceManager* creator, const String &name, Ogre::ResourceHandle handle,
58 const String& group, bool is_manual = false,
59 Ogre::ManualResourceLoader* loader = nullptr
60 );
61
65 virtual ~PFile();
66
72 virtual bool IsValid();
73
79 virtual bool IsPolygonDefinitionListValid();
80
91 virtual void AddGroups(
92 Ogre::Mesh *mesh, const String &bone_name, const RSDFilePtr &rsd
93 ) const;
94
98 struct Edge{
99
104 };
105
110
115
120
125
130
135
140 };
141
146
151 };
152
156 struct Group{
157
164
169
174
179
184
189
194
199
204
209
214
219
224
229 };
230
234 struct BBoxEntry{
235
240
244 Ogre::AxisAlignedBox bbox;
245 };
246
247 typedef Ogre::ColourValue Colour;
248
249 typedef std::vector<Ogre::Vector3> VertexList;
250
251 typedef std::vector<Ogre::Vector3> NormalList;
252
253 typedef std::vector<Ogre::Vector3> Unkown1List;
254
255 typedef std::vector<Ogre::Vector2> TextureCoordinateList;
256
257 typedef std::vector<Colour> VertexColorList;
258
259 typedef std::vector<Colour> PolygonColorList;
260
261 typedef std::vector<Edge> EdgeList;
262
263 typedef std::vector<PolygonDefinition> PolygonDefinitionList;
264
265 typedef std::vector<Group> GroupList;
266
267 typedef std::vector<BBoxEntry> BBoxList;
268
272 static const String RESOURCE_TYPE;
273
279 virtual VertexList& GetVertices();
280
286 virtual NormalList& GetNormals();
287
293 virtual Unkown1List& GetUnknown1();
294
301
308
315
321 virtual EdgeList& GetEdges();
322
329
337 virtual GroupList& GetGroups();
338
344 virtual BBoxList& GetBBoxes();
345
346 protected:
350 virtual void loadImpl() override;
351
355 virtual void unloadImpl() override;
356
363 virtual size_t calculateSize() const override;
364
376 virtual void AddGroup(
377 const Group &group, ManualObject &mo, const String &sub_name,
378 const String &material_base_name, const Ogre::Bone *bone
379 ) const;
380
387 virtual Ogre::Vector3 GetPosition(const Ogre::Bone *bone) const;
388
392 static const Ogre::Quaternion STATIC_ROTATION;
393
397 static Ogre::Quaternion CreateStaticRotation();
398
399 private:
400
405
410
415
420
425
430
435
440
445
450 };
451
452 typedef Ogre::SharedPtr<PFile> PFilePtr;
453}
A manually handled object.
Definition: VGearsManualObject.h:32
Handles P files.
Definition: VGearsPFile.h:38
static Ogre::Quaternion CreateStaticRotation()
Creates a static rotation.
Definition: VGearsPFile.cpp:187
std::vector< Colour > PolygonColorList
Definition: VGearsPFile.h:259
virtual VertexList & GetVertices()
Retrieves the vertices in the file.
Definition: VGearsPFile.cpp:60
virtual NormalList & GetNormals()
Retrieves the normals in the file.
Definition: VGearsPFile.cpp:62
std::vector< Group > GroupList
Definition: VGearsPFile.h:265
std::vector< Colour > VertexColorList
Definition: VGearsPFile.h:257
virtual PolygonDefinitionList & GetPolygonDefinitions()
Retrieves the polygon definitions in the file.
Definition: VGearsPFile.cpp:76
virtual PolygonColorList & GetPolygonColors()
Retrieves the polygon colours in the file.
Definition: VGearsPFile.cpp:72
Unkown1List unknown_1_
List of unknown data.
Definition: VGearsPFile.h:414
VertexColorList vertex_colours_
The list of vertex colours.
Definition: VGearsPFile.h:424
std::vector< Ogre::Vector3 > Unkown1List
Definition: VGearsPFile.h:253
GroupList groups_
The list of groups.
Definition: VGearsPFile.h:444
virtual ~PFile()
Destructor.
Definition: VGearsPFile.cpp:37
virtual VertexColorList & GetVertexColors()
Retrieves the vertex colurs in the file.
Definition: VGearsPFile.cpp:70
static const Ogre::Quaternion STATIC_ROTATION
Static rotation.
Definition: VGearsPFile.h:392
virtual void unloadImpl() override
Unloads the file.
Definition: VGearsPFile.cpp:47
Ogre::ColourValue Colour
Definition: VGearsPFile.h:247
std::vector< Edge > EdgeList
Definition: VGearsPFile.h:261
BBoxList bounding_boxes_
The list of bounding boxes.
Definition: VGearsPFile.h:449
virtual EdgeList & GetEdges()
Retrieves the edges in the file.
Definition: VGearsPFile.cpp:74
NormalList normals_
The list of normals.
Definition: VGearsPFile.h:409
PFile(Ogre::ResourceManager *creator, const String &name, Ogre::ResourceHandle handle, const String &group, bool is_manual=false, Ogre::ManualResourceLoader *loader=nullptr)
Constructor.
Definition: VGearsPFile.cpp:31
PolygonColorList polygon_colours_
The list of polygon colours.
Definition: VGearsPFile.h:429
std::vector< Ogre::Vector3 > VertexList
Definition: VGearsPFile.h:249
TextureCoordinateList texture_coordinates_
The list of texture coordinates.
Definition: VGearsPFile.h:419
virtual TextureCoordinateList & GetTextureCoordinates()
Retrieves the texture coordinates in the file.
Definition: VGearsPFile.cpp:66
virtual Ogre::Vector3 GetPosition(const Ogre::Bone *bone) const
Retrieves the position of a bone.
Definition: VGearsPFile.cpp:142
PolygonDefinitionList polygon_definitions_
The list of polygon definitions.
Definition: VGearsPFile.h:439
virtual bool IsValid()
Indicates if the file is a valid P file.
Definition: VGearsPFile.cpp:98
virtual void loadImpl() override
Loads the file.
Definition: VGearsPFile.cpp:39
std::vector< Ogre::Vector3 > NormalList
Definition: VGearsPFile.h:251
virtual bool IsPolygonDefinitionListValid()
Indicates if the poligons definitions are valid.
Definition: VGearsPFile.cpp:100
EdgeList edges_
The list of edges.
Definition: VGearsPFile.h:434
virtual size_t calculateSize() const override
Calculates the size of the palette.
Definition: VGearsPFile.cpp:84
std::vector< BBoxEntry > BBoxList
Definition: VGearsPFile.h:267
virtual void AddGroups(Ogre::Mesh *mesh, const String &bone_name, const RSDFilePtr &rsd) const
Adds a resource group.
Definition: VGearsPFile.cpp:128
virtual BBoxList & GetBBoxes()
Retrieves the bounding boxes in the file.
Definition: VGearsPFile.cpp:82
virtual GroupList & GetGroups()
Retrieves the groups in the file.
Definition: VGearsPFile.cpp:80
virtual Unkown1List & GetUnknown1()
Retrieves unknown data from the file.
Definition: VGearsPFile.cpp:64
std::vector< Ogre::Vector2 > TextureCoordinateList
Definition: VGearsPFile.h:255
std::vector< PolygonDefinition > PolygonDefinitionList
Definition: VGearsPFile.h:263
virtual void AddGroup(const Group &group, ManualObject &mo, const String &sub_name, const String &material_base_name, const Ogre::Bone *bone) const
Add a group to the file.
Definition: VGearsPFile.cpp:152
VertexList vertices_
The list of vertices.
Definition: VGearsPFile.h:404
static const String RESOURCE_TYPE
The type of resource.
Definition: VGearsPFile.h:272
Definition: FF7NameLookup.h:24
Ogre::SharedPtr< PFile > PFilePtr
Definition: VGearsPFile.h:452
Ogre::uint16 uint16
Definition: TypeDefine.h:32
Ogre::String String
Definition: TypeDefine.h:37
Ogre::SharedPtr< RSDFile > RSDFilePtr
Definition: VGearsRSDFile.h:198
Ogre::uint32 uint32
Definition: TypeDefine.h:33
HRCFile::Bone Bone
Definition: VGearsHRCMeshLoader.cpp:26
Ogre::uint8 uint8
Definition: TypeDefine.h:31
A bounding box entry in a P file.
Definition: VGearsPFile.h:234
uint32 unknown
Unknown data.
Definition: VGearsPFile.h:239
Ogre::AxisAlignedBox bbox
The bounding box.
Definition: VGearsPFile.h:244
An edge.
Definition: VGearsPFile.h:98
uint16 index[2]
Each of the edge vertices.
Definition: VGearsPFile.h:103
Group data in a P file.
Definition: VGearsPFile.h:156
uint32 has_texture
Indicates if the group has an assigned texture.
Definition: VGearsPFile.h:223
uint32 texture_index
Index of the assigned texture (if any).
Definition: VGearsPFile.h:228
uint32 num_polygons
The number of polygons in the group.
Definition: VGearsPFile.h:173
uint32 unknown_20
Unknown data.
Definition: VGearsPFile.h:203
uint32 nuvertices_
The number of vertices in the group.
Definition: VGearsPFile.h:183
uint32 unknown_28
Unknown data.
Definition: VGearsPFile.h:213
uint32 vertex_start_index
Definition: VGearsPFile.h:178
uint32 polygon_start_index
Definition: VGearsPFile.h:168
uint32 texture_coordinate_start_index
Definition: VGearsPFile.h:218
uint32 unknown_1C
Unknown data.
Definition: VGearsPFile.h:198
uint32 unknown_24
Unknown data.
Definition: VGearsPFile.h:208
uint32 nuedges_
The number of edges in the group.
Definition: VGearsPFile.h:193
uint32 primitive_type
The primitive type of the group.
Definition: VGearsPFile.h:163
uint32 edge_start_index
Definition: VGearsPFile.h:188
Material information in a P file.
Definition: VGearsPFile.h:145
uint8 unknown[100]
Unknown data.
Definition: VGearsPFile.h:150
A polygon definition in the P file.
Definition: VGearsPFile.h:109
uint16 vertex[3]
Polygon vertices (3, always a triangle).
Definition: VGearsPFile.h:119
uint16 unknown_14
Unknown data.
Definition: VGearsPFile.h:134
uint16 edge[3]
The edges of the polygon (3, always a triangle).
Definition: VGearsPFile.h:129
uint16 unknown_16
Unknown data.
Definition: VGearsPFile.h:139
uint16 normal[3]
The polygon normal (three components).
Definition: VGearsPFile.h:124
uint16 unknown_00
Unknown data.
Definition: VGearsPFile.h:114