Jump to content
  • Advertisement
Sign in to follow this  
CdrTomalak

Vector3 modification when using orthogonal matrix

This topic is 2300 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm trying to figure out how to change the Vector3 array representing my sprite position on the screen.

Currently I transform my Vector3 array using an Orthographic matrix. I am working on functions to handle movement, and as such I want to modify the sprite position in pixel units rather than cartesian.

How do I do this?

For example, from one of my log files you can see the current failed attempt where the penny drops regarding this issue:

27/08/2012 22:37:01
timeStampString = 27082012_223701
moveDownLog()...
...Proceeding with Move down...
...BEFORE: position[0] = [X:-0.8 Y:0.8 Z:0.5]...
...BEFORE: position[1] = [X:-0.6 Y:0.8 Z:0.5]...
...BEFORE: position[2] = [X:-0.8 Y:0.6 Z:0.5]...
...BEFORE: position[3] = [X:-0.6 Y:0.6 Z:0.5]...
...Changed Vector3[] position array OK...
...AFTER: position[0] = [X:-0.8 Y:20.8 Z:0.5]...
...AFTER: position[1] = [X:-0.6 Y:20.8 Z:0.5]...
...AFTER: position[2] = [X:-0.8 Y:20.6 Z:0.5]...
...AFTER: position[3] = [X:-0.6 Y:20.6 Z:0.5]...

I've just tried to subtract 20 from the Y value for all my vectors! The reason why my sprite disappears off the face of the earth is all too apparent now. The reason I am subtracting 20 is because my tile size is 20 pixels. wacko.png

Share this post


Link to post
Share on other sites
Advertisement
It looks like this:

for(int c=0;c<noOfVertices;c++)
{
position[c] = SlimDX.Vector3.TransformCoordinate(position[c],spriteOrthoMatrix);
}

However, I managed to get round the issue in the end by recalculating a quad's position on the screen based on it's grid reference. My first question was poorly worded on reflection, and essentially I was looking for something to UN-transform my vectors. There doesn't seem to be anything in the SlimDX API that does this. Edited by CdrTomalak

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!