summaryrefslogtreecommitdiff
path: root/ZAPD/ZLimb.h
blob: 52919bed92103eb7e5cc92567955af5daf096298 (plain)
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
#pragma once

#include <cstdint>
#include <string>
#include <vector>

#include "OtherStructs/SkinLimbStructs.h"
#include "ZDisplayList.h"
#include "ZFile.h"

enum class ZLimbType
{
	Invalid,
	Standard,
	LOD,
	Skin,
	Curve,
	Legacy,
};

class ZLimbTable;

class ZLimb : public ZResource
{
public:
	std::string enumName;
	ZLimbTable* limbsTable = nullptr;  // borrowed pointer, do not delete!

	ZLimbType type = ZLimbType::Standard;

	ZLimbSkinType skinSegmentType = ZLimbSkinType::SkinType_Null;  // Skin only
	segptr_t skinSegment = 0;                                      // Skin only
	SkinAnimatedLimbData segmentStruct;                            // Skin only

	// Legacy only
	float legTransX, legTransY, legTransZ;  // Vec3f
	uint16_t rotX, rotY, rotZ;              // Vec3s
	segptr_t childPtr;                      // LegacyLimb*
	segptr_t siblingPtr;                    // LegacyLimb*

	segptr_t dListPtr = 0;
	segptr_t dList2Ptr = 0;  // LOD and Curve Only

	int16_t transX, transY, transZ;
	uint8_t childIndex, siblingIndex;

	uint8_t limbIndex = 0;

	ZLimb(ZFile* nParent);

	void ExtractFromBinary(uint32_t nRawDataIndex, ZLimbType nType);

	void ParseXML(tinyxml2::XMLElement* reader) override;
	void ParseRawData() override;
	void DeclareReferences(const std::string& prefix) override;

	std::string GetBodySourceCode() const override;
	std::string GetDefaultName(const std::string& prefix) const override;

	size_t GetRawDataSize() const override;
	std::string GetSourceTypeName() const override;
	ZResourceType GetResourceType() const override;

	ZLimbType GetLimbType();
	void SetLimbType(ZLimbType value);
	static const char* GetSourceTypeName(ZLimbType limbType);
	static ZLimbType GetTypeByAttributeName(const std::string& attrName);

	void SetLimbIndex(uint8_t nLimbIndex);

protected:
	void DeclareDList(segptr_t dListSegmentedPtr, const std::string& prefix,
	                  const std::string& limbSuffix);
};