You are not logged in.

#1 2009-06-22 06:42:28

giantpune
Member

How do I define more than 4 points to skew an image?

Ok, in the GRRLIB_DrawImg() function, there are defined 4 points to be used as corners for the image drawn.  What must I change to create a similar function that lets me define 8 points for a single image?  Or is there already an image map function that I am not aware of?

Basically I have an image that I want to put onto 3 sides of a 3D box.  I have worked out the  x and y for all the corners, but when I go to apply the image to this it draws the entire image on all 3 sides rather than wrapping the one image around.  Please,  somebody save me.

Offline

 

#2 2009-06-23 02:23:18

TPAINROXX
Member

Re: How do I define more than 4 points to skew an image?

giantpune wrote:

Ok, in the GRRLIB_DrawImg() function, there are defined 4 points to be used as corners for the image drawn.  What must I change to create a similar function that lets me define 8 points for a single image?  Or is there already an image map function that I am not aware of?

Basically I have an image that I want to put onto 3 sides of a 3D box.  I have worked out the  x and y for all the corners, but when I go to apply the image to this it draws the entire image on all 3 sides rather than wrapping the one image around.  Please,  somebody save me.

4 Points?

There are only 2 to place the coordinate.

Here's the function, right? (straight from GRRLIB.c):

Code:

/**
 * Draw a texture.
 * @param xpos specifies the x-coordinate of the upper-left corner.
 * @param ypos specifies the y-coordinate of the upper-left corner.
 * @param tex texture to draw.
 * @param degrees angle of rotation.
 * @param scaleX
 * @param scaleY
 * @param color
 */
inline void GRRLIB_DrawImg(f32 xpos, f32 ypos, GRRLIB_texImg tex, float degrees, float scaleX, f32 scaleY, u32 color )

I might not know enough about GRRLIB to know what your talking about but sorry if I'm way off.

Last edited by TPAINROXX (2009-06-23 02:26:02)

Offline

 

#3 2009-06-23 03:36:51

giantpune
Member

Re: How do I define more than 4 points to skew an image?

Inside the GRRLIB_DrawImg() function it talks to gx.h inside devkit and actually tells it 4 points.

Code:

    GX_Begin(GX_QUADS, GX_VTXFMT0, 4);
    GX_Position3f32(-width, -height, 0);
    GX_Color1u32(color);
    GX_TexCoord2f32(0, 0);

    GX_Position3f32(width, -height, 0);
    GX_Color1u32(color);
    GX_TexCoord2f32(1, 0);

    GX_Position3f32(width, height, 0);
    GX_Color1u32(color);
    GX_TexCoord2f32(1, 1);

    GX_Position3f32(-width, height, 0);
    GX_Color1u32(color);
    GX_TexCoord2f32(0, 1);
    GX_End();

These are the 4 corners of the image.  I with to be able to tell gx.h 8 points and have it stretch 1 image across all 8 points.

Offline

 

#4 2009-06-23 10:38:57

NoNameNo
Administrator

Re: How do I define more than 4 points to skew an image?

get the svn version and have a look at the GRRLIB_DrawImgQuad function, you will be able to code easilly a mapped cube.
sample code in examples/ nonameno01/ source/ main.c

there is a better way to do it, but GRRLIB intend to be a 2D library, so....

Offline

 

Board footer

Powered by FluxBB