• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Legacy GM Applying One Texture Across Multiple Faces?

B

Bowbowis

Guest
Hello, I've been using GM for several years now but this is my first time posting on the forum so forgive me if I make any mistakes here.

My problem is thus, I'm creating a game in which I have a number of textures, like this:
blocknormal.png

I need to resize one side of these textures so that it appears to be further than the other, like this:
blockskew.png
I've been able to recreate the effect by using textured line primitives for each column of pixels, but it chews up a ton of RAM and only works for resizing the left or right side. To combat this problem I've been trying to use a square made from a triangle strip like this:

Code:
draw_primitive_begin_texture (pr_trianglestrip, bgtex);

draw_vertex_texture_colour (px0 + 000, py0 + 160, uvs [0] / (texmapw * 1), uvs [3] / (texmaph * 1), -1, alpha);
draw_vertex_texture_colour (px0 + 000, py0 + 000, uvs [0] / (texmapw * 1), uvs [1] / (texmaph * 1), -1, alpha);
draw_vertex_texture_colour (px0 + 160, py0 + 160, uvs [2] / (texmapw * 1), uvs [3] / (texmaph * 1), -1, alpha);
draw_vertex_texture_colour (px0 + 160, py0 + 000, uvs [2] / (texmapw * 1), uvs [1] / (texmaph * 1), -1, alpha);

draw_primitive_end ();
blocknormal triangle.png
The problem comes when I try to shrink one of the sides. When I reduce the distance between points this is the result:
blockfailedskew.png
As you can see the shape is correct. The problem is that each face is textured separately. Adjusting the proportions of one triangle does not affect the texture on other triangles. That brings me to my question: Is there any way to apply a single texture to both triangles so that the texture on one will be adjusted based on the vertices of the other?
 
I

Insanebrio

Guest
An easy solution is to add more points horizontally in the center to make a better image. I cant post an image now, but now you have

B D
A C

instead you should have

B D F H..
A C E G..
 
Last edited by a moderator:
D

Dennis Ross Tudor Jr

Guest
it looks like you have your draw vertices in the wrong order possibly. When I look at your last image, what I see on the right side is the wood panel coming towards me. But when I look at the left side of the image, it looks as if the wood panel is going away from me. This could be caused by either misording of the the draw vertices or by mis-ordering the text vertices. I am thinking the former because of the upper and right side of the image. Instead of ording them B, A, D, C try ordering the verices A, C, B, D instead
 
B

Bowbowis

Guest
Thanks for your suggestions guys. Unfortunately neither of them were able to solve my problem.

To reiterate I'm looking for a way to apply the texture so that the strip is treated as a single square rather than as a pair of triangles.
 
H

Harrison Vanderbyl

Guest
-use the inbuilt 3d functionality of gamemaker d3d_draw_vertex and the like
 

Nux

GameMaker Staff
GameMaker Dev.
Correct me if i'm wrong, but when I worked with primitives, I was certain they went in a backwards-Z action, not an N action.
Code:
C-----D            _.D
 \              _.-
  \            C
   \    -->     \
    \          A._\
     \            -.\
A-----B             -B
               (omg this is so bad)

Edit: Ho boy, I didn't even know what affine texture mapping was, sorry! Follow Lonewolff's advice.
 
Last edited:
Top