I will $pay$ for this routine to be coded.

BlitzMax Forums/BlitzMax Programming/I will $pay$ for this routine to be coded.

MGE(Posted 2007) [#1]
I have so many things going on that I don't have time to code everything I need, so I don't mind paying other people to do routines for me. This is one of those times... :)

Basically I want a 4 point texture render routine. The routine would be called something like this:

4PointRender(img,srcx,srcy,srcwidth,srcheight,dx1,dy1,dx2,dy2,dx3,dy3,dx4,dy4)

img - image to render
srcx,srcy,srcwidth,srcheight - defines the source rectangle inside the source texture.

dx1,dy1 - dx4,dy4 are 4 destination points that the source rect gets rendered to on the screen. By clever manipulation of the destination points you should be able to do some cool 3D type fx for simulated perspectives, etc, etc.

Ofcourse the routine needs to support alpha, blend states and be compatible with both DX7 and OGL.

Here's an example shot of the type of render that should be possible. The image on the left has the 4 points in a typical square arrangement. The image on the right, has the 4 points arranged similar to a triangle resulting in more of a perspective view.



If you can do something like this for me, please email me (check my profile) and show me a demo and how much you would charge for coding the routine. I may have other routines for you to do as well! :) Thanks!


xMicky(Posted 2007) [#2]
What about:

In principle, it contains the functionality you have asked for and it should be easy to amend the parameters of the call in the desired way


MGE(Posted 2007) [#3]
Took a look at it, it didn't work, or maybe I couldn't make it work like I wanted it to? Either way, I just don't have time to research and code some of these lower level routines I need. So I don't mind paying someone for there time to write them for me. I'd rather make the puzzle rather than the pieces of the puzzle. ;) lol..


Grey Alien(Posted 2007) [#4]
I'd love something like this too. A while ago I posted because I wanted "3D in 2D" so the ability to get a 2D image and rotate it around the X or Y axis and add perspective.


tonyg(Posted 2007) [#5]
There's a few existing texturedpoly routines.


FlameDuck(Posted 2007) [#6]
I have a routine that does something *like* this. It's software only, so it's absurdly slow, but you can have it if you want.


MGE(Posted 2007) [#7]
Thanks for the offer FlameDuck! But it needs to be 3D hardware supported for use in games, etc. ;)


JoshK(Posted 2007) [#8]
For OpenGL you would just draw a poly with texcoords. Not sure about DX.


Oddball(Posted 2007) [#9]
Here have this one on the house. It's based on code by Yan so I can't take all the credit and it isn't perfect, but it should be enough to get you started.



You need to supply your own image. I used the one that is in the help docs.

Personally though I'd just use Yan's code out-of-the-box as it's more versatile.



Grey Alien(Posted 2007) [#10]
This could be rad. MGE, I'll be keen to hear you report back on if it cuts the mustard.


Oddball(Posted 2007) [#11]
I'll be keen to hear you report back on if it cuts the mustard
The only issue really is some warping of the texture due to me placing the center point based on the mean of the four points. To correct it all that needs to be done is to calculate the center point based on perspective. Oh and a few more segments wouldn't go a miss either.


ImaginaryHuman(Posted 2007) [#12]
You will need to do more than just change the x and y coordinates of the corners if you want it to have proper perspetive. Changing a square into a trapezium will simply squeeze the rows horizontally but will not alter the vertical position of the rows, and any vertical stretching will be applied uniformly across the image with no sense of perspective. You would have to draw your source image with a fake perspective stretch and then apply the corner coords.

OR - you would actually define a Z coordinate for each corner and have the routine use a persective projection to place the quad in real 3d space - then you wouldn't have to supply corner coordinates for every corner, you could just say `put a quad with x width and y height centered at coords x,y,z with x,y,z rotation.


MGE(Posted 2007) [#13]
Thanks DaveW, oh so VERY close AS IS! But like you said there is some warping, etc, when trying to simulate a perspective. I don't have time to dig in and do the suggested updates, if you care to get this working as flexable as possible, I will be glad to send you a payment for your time! :) Looks like GA might do the same once it's working properly. ;) lol..


ImaginaryHuman(Posted 2007) [#14]
You could pre-stretch your image so that the vertical aspect of the perspectective effect is already done, then when you draw it with moved corners it will look like it's right - you just wouldn't be able to change the angle of perspective afterwards. I did that on a small shootemup that I started a few years ago, where I had that persective ground effect - had to pre-perspectivize the ground image then scale is horizontally in realtime.


Jake L.(Posted 2007) [#15]
Why don't you just use 3D?

Didn't tested it, but couldn't you just draw in 2D, switch the projection matrix from ortho to default 3D (with perspective) and draw in 3D space after that?

Or will switching the projection matrix apply to the already drawn vertices, too?


ImaginaryHuman(Posted 2007) [#16]
It applies only to things about to be drawn.


MGE(Posted 2007) [#17]
Thanks IH for your insight. I'm looking for a more global solution compared to doing any pre-rendering.


Grey Alien(Posted 2007) [#18]
Bah, it's not so cool then. Seems like the real solution would be to get the 3D card to render a 2D scene then force it into 3D mode for a few textures, then back to 2D. Can that be done though?

Or I guess draw your whole game onto a single 2D texture in a 3D world and then move around your 3D textures in front of it...


Jake L.(Posted 2007) [#19]
Here's the OGL-part for switching to 2D (btw, including scaling, so you got width/height mapped onto scr_w/scr_h). I use it to setup my engine:

glMatrixMode GL_PROJECTION
					glLoadIdentity
					glOrtho 0,width,height,0,-1,1
glTranslatef (0.375, 0.375, 0.0)
					glMatrixMode GL_MODELVIEW
					glViewport 0,0,scr_w,scr_h


Don't know about a proper 3D matrix. Maybe someone can provide a DX7 version of this.