1#include "ObjectBase.hh"
3#include "game/field/ObjectDirector.hh"
5#include "game/system/CourseMap.hh"
6#include "game/system/ResourceManager.hh"
7#include "game/system/map/MapdataPointInfo.hh"
9#include <egg/math/Math.hh>
17 : m_drawMdl(nullptr), m_resFile(nullptr), m_id(static_cast<ObjectId>(params.id())),
18 m_flags(0x3), m_pos(params.pos()), m_rot(params.rot() * DEG2RAD), m_scale(params.scale()),
19 m_transform(
EGG::Matrix34f::ident), m_mapObj(¶ms) {}
22ObjectBase::~ObjectBase() {
28void ObjectBase::calcModel() {
33const char *ObjectBase::getResources()
const {
34 const auto &flowTable = ObjectDirector::Instance()->flowTable();
35 const auto *collisionSet = flowTable.set(flowTable.slot(m_id));
37 return collisionSet->resources;
41void ObjectBase::loadGraphics() {
42 const char *name = getResources();
43 if (strcmp(name,
"-") == 0) {
48 snprintf(filename,
sizeof(filename),
"%s.brres", name);
50 auto *resMgr = System::ResourceManager::Instance();
51 const void *resFile = resMgr->getFile(filename,
nullptr, System::ArchiveId::Course);
59void ObjectBase::loadRail() {
64 s16 pathId = m_mapObj->pathId();
70 auto *point = System::CourseMap::Instance()->getPointInfo(pathId);
71 f32 speed =
static_cast<f32
>(m_mapObj->setting(0));
73 if (point->setting(0) == 0) {
74 m_railInterpolator =
new RailLinearInterpolator(speed, pathId);
76 m_railInterpolator =
new RailSmoothInterpolator(speed, pathId);
81const char *ObjectBase::getKclName()
const {
82 const auto &flowTable = ObjectDirector::Instance()->flowTable();
83 const auto *collisionSet = flowTable.set(flowTable.slot(m_id));
85 return collisionSet->resources;
89void ObjectBase::calcTransform() {
91 m_transform.makeRT(m_rot, m_pos);
93 }
else if (m_flags & 1) {
94 m_transform.setBase(3, m_pos);
99void ObjectBase::linkAnims(
const std::span<const char *> &names,
100 const std::span<Render::AnmType> types) {
105 ASSERT(names.size() == types.size());
107 for (
size_t i = 0; i < names.size(); ++i) {
108 m_drawMdl->linkAnims(i, m_resFile, names[i], types[i]);
115 SetRotTangentHorizontal(m_transform, up, tangent);
116 m_transform.setBase(3, m_pos);
123 mat.
setBase(3, EGG::Vector3f::zero);
Represents a binary resource file which contains object models, textures, and animations.
void setBase(size_t col, const Vector3f &base)
Sets one column of a matrix.
void setAxisRotation(f32 angle, const Vector3f &axis)
Rotates the matrix about an axis.
Vector3f ps_multVector(const Vector3f &vec) const
Paired-singles impl. of multVector.
f32 dot(const Vector3f &rhs) const
The dot product between two vectors.