Skip to content
This repository has been archived by the owner on Apr 29, 2024. It is now read-only.

Commit

Permalink
Merge pull request #509 from storm-devs/model_rotation_angle
Browse files Browse the repository at this point in the history
add message to set base rotation angle for model
  • Loading branch information
espkk committed Nov 8, 2023
2 parents 5528c00 + ff78caa commit 3cd2ced
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/libs/location/src/location.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ uint64_t Location::ProcessMessage(MESSAGE &message)
{
int32_t i;
float u0, v0, u1, v1;
float ax, ay, az;
int32_t level;
LocatorArray *la;
switch (message.Long())
Expand Down Expand Up @@ -285,6 +286,14 @@ uint64_t Location::ProcessMessage(MESSAGE &message)
u1 = message.Float(); // rz
model.SetRotation(lastLoadStaticModel, u0, v0, u1);
return 1;
case MSG_LOCATION_MODEL_SET_ROT_ANGLE:
if (lastLoadStaticModel < 0)
return 0;
ax = message.Float(); // ax
ay = message.Float(); // ay
az = message.Float(); // az
model.SetRotationAngle(lastLoadStaticModel, ax, ay, az);
return 1;
case MSG_LOCATION_MODEL_SET_UVS:
if (lastLoadStaticModel < 0)
return 0;
Expand Down
11 changes: 11 additions & 0 deletions src/libs/location/src/model_array.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,17 @@ void ModelArray::SetRotation(int32_t modelIndex, float rx, float ry, float rz)
model[modelIndex].rotator->rz = rz;
}

// Set base rotation angle
void ModelArray::SetRotationAngle(int32_t modelIndex, float ax, float ay, float az)
{
Assert(modelIndex >= 0 && modelIndex < numModels);
auto *mdl = static_cast<MODEL *>(core.GetEntityPointer(model[modelIndex].id));
if (mdl)
{
CMatrix mtr(ax, ay, az);
mdl->mtx = CMatrix(mtr, mdl->mtx);
}
}
// Set the reflection matrix generation mode to the model
void ModelArray::SetReflection(int32_t modelIndex, float scale)
{
Expand Down
2 changes: 2 additions & 0 deletions src/libs/location/src/model_array.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ class ModelArray
void SetUVSlide(int32_t modelIndex, float u0, float v0, float u1, float v1);
// Set a rotation animation to the model
void SetRotation(int32_t modelIndex, float rx, float ry, float rz);
// Set base rotation angle
void SetRotationAngle(int32_t modelIndex, float ax, float ay, float az);
// Set the reflection matrix generation mode to the model
void SetReflection(int32_t modelIndex, float scale);

Expand Down
1 change: 1 addition & 0 deletions src/libs/shared_headers/include/shared/messages.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@
#define MSG_LOCATION_MODEL_LAMPS 30113 // "l" add the current model to the ignore list for tracing rays from lamps
// "lf" set the effect of generating the matrix for reflection, f is the scaling factor
#define MSG_LOCATION_MODEL_REFLECTION 30114
#define MSG_LOCATION_MODEL_SET_ROT_ANGLE 30115 // "lfff" set the base rotation angle of the last loaded model
// Install patches
#define MSG_LOCATION_SET_CHRS_PATCH 30120 // "ls" load the character patch
#define MSG_LOCATION_SET_CAM_PATCH 30121 // "ls" load camera patch
Expand Down

0 comments on commit 3cd2ced

Please sign in to comment.