Skip to content

Commit

Permalink
GRAPHICS: Fix orientation in NWN ASCII model nodes
Browse files Browse the repository at this point in the history
ASCII models use axis + angle instead of quaternions.
  • Loading branch information
DrMcCoy committed Mar 21, 2014
1 parent d7bbd72 commit b3685d5
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/graphics/aurora/model_nwn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -993,14 +993,18 @@ void Model_NWN::loadASCIINode(ParserContext &ctx, Ogre::SceneNode *parent,
processASCIIMesh(ctx, mesh);

if ((orientation[0] == 0.0) && (orientation[1] == 0.0) && (orientation[2] == 0.0) && (orientation[3] == 0.0))
orientation[3] = 1.0;

SWAP(orientation[3], orientation[0]);
orientation[0] = 1.0;

if (ctx.hasPosition)
memcpy(ctx.nodeEntity->position, position, 3 * sizeof(float));
if (ctx.hasOrientation)
memcpy(ctx.nodeEntity->orientation, orientation, 4 * sizeof(float));
if (ctx.hasOrientation) {
Ogre::Quaternion q(Ogre::Radian(orientation[3]), Ogre::Vector3(orientation[0], orientation[1], orientation[2]));

ctx.nodeEntity->orientation[0] = q.w;
ctx.nodeEntity->orientation[1] = q.x;
ctx.nodeEntity->orientation[2] = q.y;
ctx.nodeEntity->orientation[3] = q.z;
}

nodeInherit(ctx, name);
}
Expand Down

0 comments on commit b3685d5

Please sign in to comment.