[SOLVED]How to: Draw 'vertex-color-pos' polygon on rectangle?

I cannot figure this out:

I have a rectangle, something like (100,100,100,100) drawn on screen, using a sprite…

On top of that, I want to draw a single triangle using vector-color-positions, between any 3 corners or the rect.

But because the vector-color-positions internal coordinate system starts at the center of the screen, and only goes between -1 and 1,
I cannot get the 2 to overlap…

Can someone help with a way to turn a screen coordinate into a vector-color-pos position?

Uh, maybe look at the source code for spriteBatch and remove one vertex

Thanks, but I dont know what that means, I’m affraid…

All I know about spriteBatch is that I use it to draw my texture in a rectangle, but then I .End() it to draw my ver-col-positions as a seperate triangle. Im not trying to do anything with the sprite texture, I’m trying to draw a separate triangle using just the same coordinates as the corners of the rectangle. The texture is just there so I can see the rectangle.

I’ll try and clarify:
What I really need is a method or function that takes a vector2 screen coordinate, and returns a corresponding Vector3 vertex.position.

The idea is simply transferring from one coordinate system to another, I just cant seem to code it, for some stupid reason.

Do I understand correctly you want to go from a [0,1280]x[0,800] (for example) system to [-1,1]x[-1,1]?

The transformation would be

pixel / Vec2 (width/2, height/2) - vec2(1,1)

For z you can take 0

Yes! Exactly!

By pixel I assume you mean screen coordinate, I will try this after I take a break, but it totally looks like what I am trying to express.

I will post back!

@kosmonautgames Ok, I tried it out, and just like my own previous code, the x coordinates match, but the y coordinates are flipped or mirrored…

Something about the Ys is all messed up, although the Xs are fine.

x goes from left to right, y goes from top to bottom.

You can simply try to multiply the final y values with -1

I’ve tried, doesnt work… Some other operation must be required :slight_smile: This is so strange. points are inserted as far from the TOP, as they should be from the bottom…

Here you can see, the red triangle should be on the green square… X matches, y does not.
<img src="/uploads/default/original/2X/6/6afa46f18aacd5e6164f96b9851ff22870d0fce9.png" width=“690” height="388"r

EDIT: Nevermind, I had to reverse the draw order w´hen I inverted the y… Now the match, and I can finally move on! Thank you so far!