1
Support / Texturing a triangle
« on: April 18, 2012, 10:42:42 pm »
Guys, I'm trying to texture the triangle faces of a rhombus with this code:
The Object3D structure is fine, but I'm positive my U/V-coordinates are wrong because it is not showing it how I expected.
The texture is a 128x128 black png with a transparent triangle with its base running along the base of the picture and its top touching the middle of the picture's top border (sorry, I can't upload it right now). I wanna make a red, wireframed rhombus.
This is how I'm adding the textures I use to the TextureManager tm:
And this is how I Multi-texture them:
Help, please!
Code: [Select]
public Object3D buildMarker(){
Object3D mrkr = new Object3D(8);
mrkr.setCulling(false);
float offset = MARKER_SIZE/2;
mrkr.addTriangle(new SimpleVector(-offset, 0,-offset), 0, 1,
new SimpleVector( offset, 0,-offset), 1, 1,
new SimpleVector( 0,-MARKER_SIZE, 0), 0.5f, 0);
mrkr.addTriangle(new SimpleVector( offset, 0,-offset), 0, 1,
new SimpleVector( offset, 0, offset), 1, 1,
new SimpleVector( 0,-MARKER_SIZE, 0), 0.5f, 0);
mrkr.addTriangle(new SimpleVector( offset, 0, offset), 0, 1,
new SimpleVector(-offset, 0, offset), 1, 1,
new SimpleVector( 0,-MARKER_SIZE, 0), 0.5f, 0);
mrkr.addTriangle(new SimpleVector(-offset, 0, offset), 0, 1,
new SimpleVector(-offset, 0,-offset), 1, 1,
new SimpleVector( 0,-MARKER_SIZE, 0), 0.5f, 0);
mrkr.addTriangle(new SimpleVector( offset, 0,-offset), 0, 1,
new SimpleVector(-offset, 0,-offset), 1, 1,
new SimpleVector( 0,MARKER_SIZE, 0), 0.5f, 0);
mrkr.addTriangle(new SimpleVector( offset, 0, offset), 0, 1,
new SimpleVector( offset, 0,-offset), 1, 1,
new SimpleVector( 0,MARKER_SIZE, 0), 0.5f, 0);
mrkr.addTriangle(new SimpleVector(-offset, 0, offset), 0, 1,
new SimpleVector( offset, 0, offset), 1, 1,
new SimpleVector( 0,MARKER_SIZE, 0), 0.5f, 0);
mrkr.addTriangle(new SimpleVector(-offset, 0,-offset), 0, 1,
new SimpleVector(-offset, 0, offset), 1, 1,
new SimpleVector( 0,MARKER_SIZE, 0), 0.5f, 0);
return mrkr;
}
The Object3D structure is fine, but I'm positive my U/V-coordinates are wrong because it is not showing it how I expected.
The texture is a 128x128 black png with a transparent triangle with its base running along the base of the picture and its top touching the middle of the picture's top border (sorry, I can't upload it right now). I wanna make a red, wireframed rhombus.
This is how I'm adding the textures I use to the TextureManager tm:
Code: [Select]
tm.addTexture("frame", new Texture("markerFrame.png"));
tm.addTexture("red", new Texture(8,8,java.awt.Color.RED));
And this is how I Multi-texture them:
Code: [Select]
tInfo = new TextureInfo(tm.getTextureID("frame"));
tInfo.add(tm.getTextureID("red"), TextureInfo.MODE_ADD);
Help, please!