34 bound(lowBound, highBound),
name(name_, nameLength),
isWmo(isWmo_) { }
41typedef std::unordered_map<uint32, GameobjectModelData>
ModelList;
56 if (fread(magic, 1, 8, model_list_file) != 8
60 fclose(model_list_file);
64 uint32 name_length, displayId;
70 if (fread(&displayId,
sizeof(
uint32), 1, model_list_file) != 1)
71 if (feof(model_list_file))
74 if (fread(&isWmo,
sizeof(
uint8), 1, model_list_file) != 1
75 || fread(&name_length,
sizeof(
uint32), 1, model_list_file) != 1
76 || name_length >=
sizeof(buff)
77 || fread(&buff,
sizeof(
char), name_length, model_list_file) != name_length
78 || fread(&v1,
sizeof(Vector3), 1, model_list_file) != 1
79 || fread(&v2,
sizeof(Vector3), 1, model_list_file) != 1)
85 if (v1.isNaN() || v2.isNaN())
91 model_list.emplace(std::piecewise_construct, std::forward_as_tuple(displayId), std::forward_as_tuple(&buff[0], name_length, v1, v2, isWmo != 0));
94 fclose(model_list_file);
106 ModelList::const_iterator it =
model_list.find(modelOwner->GetDisplayId());
110 G3D::AABox mdl_box(it->second.bound);
112 if (mdl_box == G3D::AABox::zero())
114 TC_LOG_ERROR(
"misc",
"GameObject model {} has zero bounds, loading skipped", it->second.name);
123 name = it->second.name;
124 iPos = modelOwner->GetPosition();
126 iScale = modelOwner->GetScale();
129 G3D::Matrix3 iRotation = G3D::Matrix3::fromEulerAnglesZYX(modelOwner->GetOrientation(), 0, 0);
132 mdl_box = AABox(mdl_box.low() *
iScale, mdl_box.high() *
iScale);
133 AABox rotated_bounds;
134 for (
int i = 0; i < 8; ++i)
135 rotated_bounds.merge(iRotation * mdl_box.corner(i));
140 for (
int i = 0; i < 8; ++i)
142 Vector3 pos(
iBound.corner(i));
143 modelOwner->DebugVisualizeCorner(pos);
147 owner = std::move(modelOwner);
148 isWmo = it->second.isWmo;
155 if (!mdl->
initialize(std::move(modelOwner), dataPath))
169 float time = ray.intersectionTime(
iBound);
170 if (time == G3D::finf())
175 Ray modRay(p,
iInvRot * ray.direction());
191 if (!
iBound.contains(point))
196 Vector3 zDirModel =
iInvRot * Vector3(0.f, 0.f, -1.f);
202 Vector3 modelGround = pModel + zDist * zDirModel;
239 G3D::AABox mdl_box(it->second.bound);
241 if (mdl_box == G3D::AABox::zero())
243 TC_LOG_ERROR(
"misc",
"GameObject model {} has zero bounds, loading skipped", it->second.name);
249 G3D::Matrix3 iRotation = G3D::Matrix3::fromEulerAnglesZYX(
owner->GetOrientation(), 0, 0);
252 mdl_box = AABox(mdl_box.low() *
iScale, mdl_box.high() *
iScale);
253 AABox rotated_bounds;
254 for (
int i = 0; i < 8; ++i)
255 rotated_bounds.merge(iRotation * mdl_box.corner(i));
260 for (
int i = 0; i < 8; ++i)
262 Vector3 pos(
iBound.corner(i));
263 owner->DebugVisualizeCorner(pos);
std::unordered_map< uint32, GameobjectModelData > ModelList
void LoadGameObjectModelList(std::string const &dataPath)
#define TC_LOG_ERROR(filterType__,...)
#define TC_LOG_INFO(filterType__,...)
uint32 GetMSTimeDiffToNow(uint32 oldMSTime)
bool GetLocationInfo(G3D::Vector3 const &point, VMAP::LocationInfo &info, uint32 ph_mask) const
VMAP::WorldModel * iModel
static GameObjectModel * Create(std::unique_ptr< GameObjectModelOwnerBase > modelOwner, std::string const &dataPath)
bool GetLiquidLevel(G3D::Vector3 const &point, VMAP::LocationInfo &info, float &liqHeight) const
std::unique_ptr< GameObjectModelOwnerBase > owner
bool intersectRay(const G3D::Ray &Ray, float &MaxDist, bool StopAtFirstHit, uint32 ph_mask, VMAP::ModelIgnoreFlags ignoreFlags) const
bool initialize(std::unique_ptr< GameObjectModelOwnerBase > modelOwner, std::string const &dataPath)
bool GetLiquidLevel(const G3D::Vector3 &pos, float &liqHeight) const
static VMapManager2 * createOrGetVMapManager()
void releaseModelInstance(const std::string &filename)
WorldModel * acquireModelInstance(const std::string &basepath, const std::string &filename, uint32 flags=0)
bool IntersectRay(const G3D::Ray &ray, float &distance, bool stopAtFirstHit, ModelIgnoreFlags ignoreFlags) const
bool GetLocationInfo(const G3D::Vector3 &p, const G3D::Vector3 &down, float &dist, GroupLocationInfo &info) const
const char GAMEOBJECT_MODELS[]
GameobjectModelData(char const *name_, uint32 nameLength, Vector3 const &lowBound, Vector3 const &highBound, bool isWmo_)
GroupModel const * hitModel