• FEATURED

View more

View more

View more

### Image of the Day Submit

IOTD | Top Screenshots

### The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.

# Vector3 modification when using orthogonal matrix

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

2 replies to this topic

### #1CdrTomalak  Members

Posted 27 August 2012 - 03:53 PM

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.

### #2greenvertex  Members

Posted 28 August 2012 - 11:26 AM

What does your orthographic transform look like?

### #3CdrTomalak  Members

Posted 29 August 2012 - 03:50 PM

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, 29 August 2012 - 03:51 PM.

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.