Public Group

# 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.

## 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.

##### Share on other sites
What does your orthographic transform look like?

##### Share on other sites
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

1. 1
2. 2
Rutin
21
3. 3
4. 4
A4L
15
5. 5
khawk
14

• 13
• 26
• 10
• 11
• 44
• ### Forum Statistics

• Total Topics
633742
• Total Posts
3013630
×