1
votes

I thought it would be simple as:

 Vector3 point = Vector3.Transform(originalPoint, worldMatrix);

But apparently not... It make's the point's numbers shoot into the thousands.

Basically, what I'm trying to do is creating a collision system and every two points in this system is a line, so basically I want to collide lines. I want the lines to be able to scale, rotate, and translate based on a world matrix (so that the collision lines are in tune with the object's scale, rotation, and translation).

I've been trying for hours now and I can't seem to figure it out. I've tried multiplying by the View Matrix as well and while that is the closest to what I want, it seems to switching between two sets of numbers! It would be perfect if it stayed with the one set, I have no idea why it keeps changing...

Any help, please? :(

Edit: To add a little, I'm constantly updating the points in an Update call. But I don't know if that would change anything, either way the points = originalpoints first.

Steve H: One line would have two points, so:

originalPoint[0] = new Vector3(-42.5f, 0f, 0f);
originalPoint[1] = new Vector3(42.5f, 0f, 0f);
point[0] = Vector3.Transform(originalPoint[0], worldMatrix);
point[1] = Vector3.Transform(originalPoint[1], worldMatrix);`

At first, point[0] & [1] equals the same as originalPoint[0] & [1]. But, the moment I move my player even just a few pixels...

point[0] = (-5782.5f, 0f, 0f)
point[1] = (-5697.5, 0f, 0f)

The player's position is -56.0f.

My worldMatrix goes as:

_world = Matrix.Identity // ISROT
       * Matrix.CreateScale(_scale) // This object's scale
       * Matrix.CreateFromQuaternion(_rotation) // It's rotation
       * Matrix.CreateTranslation(_offset) // The offset from the centre
       * Matrix.CreateFromQuaternion(_orbitRotation) // It's orbit around an object
       * _orbitObjectWorld // The object to base this world from
       * Matrix.CreateTranslation(_position); // This object's position

The objects display properly in graphics. They scale, rotate, translate completely fine. They follow the orbit's scale, rotation, and translation too but I haven't tested orbit much, yet.

I hope this is enough detail...

Edit: Upon further research, the original points are also being changed... :| I don't get why that's happening. They're the exact same as the new points...

1
That should work. Are you sure your world matrix is correct?Donnie
The world matrix I use is the exact same for the object's graphics in the game and they all display perfectly fine. Scaling and rotation all work with them. Its these points that don't seem to work properly.VRock
For us to help, please post the before & after component values of point & originalPoint & worldMatrixSteve H

1 Answers

0
votes

I figured out my problem... -_-

So, after I create the line points, I do this at the end:

originalLines = collisionLines;

collisionLines & originalLines are both Vector3[] arrays.

I guess just by making one equal the other, it's like they're the exact same and changing one changes the other... that is something I did not know.

So I made this function:

void CreateOriginalPoints()
{
    _originalPoints = new Vector3[_collisionPoints.Length];

    for (int i = 0; i < _collisionPoints.Length; i++)
        _originalPoints[i] = _collisionPoints[i];
}

And this solves the problem completely. It now makes complete sense to me why this problem was happening in the first place.

Thanks a lot Donnie & Steve H. I know you two didn't answer my question but it got me to poke around even deeper until I found the answer.