I've been using POLYVECTOR a lot in my current game. Here's a screenshot:
(http://mysite.verizon.net/ress6zfh/sitebuildercontent/sitebuilderpictures/firstperson.jpg)
All of the walls in this shot are drawn with POLYVECTOR. However, while the textures on sprites with all 90-degree angles are fine (like on the wall straight-ahead), the textures on the distorted sprites (like on the lefthand side) don't map correctly. The drawing errors seem to follow a diagonal line from the top-left to the bottom-right of each sprite.
I'm posting this in the general forum area because it's not really a bug, more of a feature request. :) Any thoughts about the possibility of working on this? Or does someone have a workaround? This screenshot is from the PC, but it happens on the GP2X (for which I'm designing the game) as well.
So far, my solution has been to use mostly textures that don't have obvious straight lines, so the distortion isn't noticeable. But that doesn't help with doors & text...
Thanks!
Polyvector?
You write your game in raycastingstyle? .... awesome :D
Heh, yeah, I programmed the bulk of it before 3D was implemented on the GP2X. :P At this point, I'm more excited about continuing work on all the game details like quests & inventory, rather than spend all the time starting over from scratch with a different 3D "engine."
Interesting application of polyvectoring..
Curious are you properly shifting the texture coordinates on the diagonal surfaces?
Does it happen, when the poly gets out of the window?
Only on GP2X or even on Win32?
Quote from: Kitty Hello on 2008-Nov-07
Does it happen, when the poly gets out of the window?
Only on GP2X or even on Win32?
In my experience, it happens all the time, whether the poly is entirely within the window or not. It happens on both the GP2X and Win32.
Quote from: Hemlos on 2008-Nov-07
Curious are you properly shifting the texture coordinates on the diagonal surfaces?
I think I'm applying the texture correctly. Here are some code examples, and the results I get (from the Win32 compile)...
(http://mysite.verizon.net/ress6zfh/poly1.jpg)
|
LOADSPRITE "test.png", 0
// square STARTPOLY 0 POLYVECTOR 60, 20, 0, 0, RGB(255, 255, 255) POLYVECTOR 60, 220, 0, 200, RGB(255, 255, 255) POLYVECTOR 260, 220, 200, 200, RGB(255, 255, 255) POLYVECTOR 260, 20, 200, 0, RGB(255, 255, 255) ENDPOLY
SHOWSCREEN MOUSEWAIT
|
(http://mysite.verizon.net/ress6zfh/poly2.jpg)
|
LOADSPRITE "test.png", 0
// angle left STARTPOLY 0 POLYVECTOR 70, 10, 0, 0, RGB(255, 255, 255) POLYVECTOR 70, 230, 0, 200, RGB(255, 255, 255) POLYVECTOR 250, 200, 200, 200, RGB(255, 255, 255) POLYVECTOR 250, 40, 200, 0, RGB(255, 255, 255) ENDPOLY
SHOWSCREEN MOUSEWAIT
|
(http://mysite.verizon.net/ress6zfh/poly3.jpg)
|
LOADSPRITE "test.png", 0
// angle right STARTPOLY 0 POLYVECTOR 70, 40, 0, 0, RGB(255, 255, 255) POLYVECTOR 70, 200, 0, 200, RGB(255, 255, 255) POLYVECTOR 250, 230, 200, 200, RGB(255, 255, 255) POLYVECTOR 250, 10, 200, 0, RGB(255, 255, 255) ENDPOLY
SHOWSCREEN MOUSEWAIT
|
(http://mysite.verizon.net/ress6zfh/poly4.jpg)
|
LOADSPRITE "test.png", 0
// angle up STARTPOLY 0 POLYVECTOR 50, 30, 0, 0, RGB(255, 255, 255) POLYVECTOR 80, 210, 0, 200, RGB(255, 255, 255) POLYVECTOR 240, 210, 200, 200, RGB(255, 255, 255) POLYVECTOR 270, 30, 200, 0, RGB(255, 255, 255) ENDPOLY
SHOWSCREEN MOUSEWAIT
|
(http://mysite.verizon.net/ress6zfh/poly5.jpg)
|
LOADSPRITE "test.png", 0
// angle down STARTPOLY 0 POLYVECTOR 60+20, 20+10, 0, 0, RGB(255, 255, 255) POLYVECTOR 60-10, 220-10, 0, 200, RGB(255, 255, 255) POLYVECTOR 260+10, 220-10, 200, 200, RGB(255, 255, 255) POLYVECTOR 260-20, 20+10, 200, 0, RGB(255, 255, 255) ENDPOLY
SHOWSCREEN MOUSEWAIT
|
The "test.png" image I'm using is 200x200, and can be downloaded here: http://mysite.verizon.net/ress6zfh/test.png (http://mysite.verizon.net/ress6zfh/test.png)
Note that no matter which way the sprite is altered, the green border around the edge still tracks more or less correctly. However, the distortion very clearly always runs from the top-left corner to the bottom-right corner.
Ahhh youre not going to like this answer...
Make a polygon as 12 vectors....4 triangles....this is sophisticated, youll need to shift the center texture coordinate aspect ratio....start each triangle at center of polygon, then add coordinates counterclockwise.
To calculate the texture coordinates...maybe you can figgure this part out, you seem pretty good with math in the first place, considering you figgured out raycasting 2d surfaces.
Here is a 4 triangle example using your third sample: (hopefully you can make an algorithm to fill in the ? marks)
STARTPOLY 1
POLYVECTOR 160,80, ?, ?, RGB(255, 255, 255)
POLYVECTOR 70, 40, 0, 0, RGB(255, 255, 255)
POLYVECTOR 70, 200, 200, 0, RGB(255, 255, 255)
ENDPOLY
STARTPOLY 1
POLYVECTOR 160,80, ?, ?, RGB(255, 255, 255)
POLYVECTOR 70, 200, 0, 200, RGB(255, 255, 255)
POLYVECTOR 250, 230, 200, 200, RGB(255, 255, 255)
ENDPOLY
STARTPOLY 1
POLYVECTOR 160,80, ?, ?, RGB(255, 255, 255)
POLYVECTOR 250, 230, 200, 200, RGB(255, 255, 255)
POLYVECTOR 250, 10, 200, 0, RGB(255, 255, 255)
ENDPOLY
STARTPOLY 1
POLYVECTOR 160,80, ?, ?, RGB(255, 255, 255)
POLYVECTOR 250, 10, 200, 0, RGB(255, 255, 255)
POLYVECTOR 70, 40, 0, 0, RGB(255, 255, 255)
ENDPOLY
I Recommend 3d...MUCH easier mathwise, and you can do these walls with just 4 coordinates with no texture anomolies:
SYSTEMPOINTER TRUE
LOADSPRITE "square.png",0
LOADSPRITE "test.png", 1
cpcolor=RGB(255,255,255)
X_OBJSTART 0
X_OBJADDVERTEX 1, 100, -100, 0, 0, cpcolor
X_OBJADDVERTEX 1, 100, 100, 1, 0, cpcolor
X_OBJADDVERTEX 1, -100, -100, 0, 1, cpcolor
X_OBJADDVERTEX 1, -100, 100, 1, 1, cpcolor
X_OBJNEWGROUP
X_OBJEND
WHILE TRUE
MOUSESTATE MX,MY,MB1,MB2
X_MAKE3D 1, 500, 45
X_CAMERA 300*SIN(MX), 112, 300*COS(MX), 0,0,0
oldshift=wallshift
IF MB1 THEN wallshift=wallshift+10
IF MB2 THEN wallshift=wallshift-10
IF oldshift<>wallshift THEN objshift(wallshift)
X_MOVEMENT 0,0,0
X_SETTEXTURE 0,-1
X_DRAWOBJ 0,0
SHOWSCREEN
WEND
FUNCTION objshift: shift
cpcolor=RGB(255,255,255)
X_OBJSTART 0
X_OBJADDVERTEX 1, 100+shift, -100, 0, 0, cpcolor //ul
X_OBJADDVERTEX 1, 100-shift, 100, 1, 0, cpcolor //ur
X_OBJADDVERTEX 1, -100+shift, -100, 0, 1, cpcolor //ll
X_OBJADDVERTEX 1, -100-shift, 100, 1, 1, cpcolor //lr
X_OBJNEWGROUP
X_OBJEND
ENDFUNCTION
[edit]
Hemlos is right. GLBasic / OpenGL / DirectX whatever, draws a TRIANGLE_FAN. first 3 nodes form a triangle, 4th one with 2-3-4.
It's correct, so Hem's solution is the only way.
It's a perspective correction problem, that old games had:
Watch this as a very bad example (see walls right beside the camera)
http://www.youtube.com/watch?v=DJRgQeVXmcg (http://www.youtube.com/watch?v=DJRgQeVXmcg)
Okay, thanks for the help, guys.
3D commands obviously are the way to go. On the other hand, my current game has a completely-working engine (texture issues notwithstanding), so I may just release it as-is just to get it out the door, and focus on full 3D commands for my next game. I need to think about that... :bed: