Object3D's transparency issue

Started by AeroShark333, December 06, 2014, 12:07:56 PM

Previous topic - Next topic

AeroShark333

Hey everyone,

I had a hard time trying to register to this forums, so I used my schoolemail...  :o
Anyway, I have an issue with 2 Object3D's...
Both objects are cubed. They have individual textures on each face.
Both objects have this transparency value: this.setTransparency(300);
Box1 is in box2. (their center point is equal)
Box1's dimensions: 2f * 2f * 2f
Box2's dimensions: 2.2f * 2.2f * 2.2f
Box2 has more transparent area's than box1.
However, box2's non-transparent textures don't seem to be visible...
When I remove this.setTransparency(300); from box1, then those non-transparent textures do show up... (but then I get black-ish areas on the box1 texture...)

How can I solve this problem?

Cheers,
Abiram

PS: This library is AWESOME   ;D

EgonOlsen

That's most likely caused by render order. Transparent objects are sorted by depth, but that happens on a per object base. If you put one object into another one, there's no correct ordering. Your case is a quite special one. It might be sufficient to force an order between the two cubes. Try something like box1.setSortOffset(10) and see if that helps.

AeroShark333

#2
Thanks for the quick reply and it worked! :D

However, I have another issue now...
I have a box3 and a box4 next to each other (touched).
Both faces that touch each othe, do intersect each other on the whole face.
And I get something like in the picture... (both have transparency set to 300)

Picture: Left one is what I got. Right one is what I want.

EgonOlsen

That's basically the same issue. Transparent have to be sorted and that happen per object (it has to). This sorting isn't perfect in cases where object intersect or a close to one another. Sorting issues with transparent objects can only be avoided by not using them in the first place. Or by tweaking the sort order like you did in the former case, but for the general case, this isn't possible. I'm not sure if it is in your case. What's the actual idea behind what you are doing? What are these boxes, in which ways are then moving and why do they touch?

AeroShark333

#4
Well here is the idea:
The app I am working on is a skinviewer for Minecraft and Minebuilder.
The user selects a .png file skin and the app will 'visualise' a 3D version of it.
Since skin files usually contain transparent areas, I have decided to enable transparency on every object.
The objects do not move (yet), but the camera rotates around the objects/skin. (I will add user input and animation-ish movements later)

I released the app today:
https://play.google.com/store/apps/details?id=com.aeroshark333.skinviewer (this version has box1's transparency disabled though, the next update will include the sorting order)

I am not a really good developer, neither am I very good with Java and OpenGL. But this is some kind of hobby :)

The transparency issue with the objects next to each other depends on the device too I guess


EgonOlsen

No, they have nothing to do with the device. Not even with the engine. They are a common problem whenever transparent objects intersect. The only option would be use alpha testing instead of alpha blending. But jPCT-AE doesn't support this out of the box. You would have to use the OpenGL ES 2.0 pipeline and write an alpha testing shader.
If you can provide a simplified test case that shows the issue, i'll have a look and provide you with something to get you started.

AeroShark333

#6
The 'issue' is very small though, but noticable. (see screenshot in attachment)
Since the camera rotates around the 'center', the 'issue' moves from the left leg to the right leg and visa versa.

Well this is my code:

SkinActivity.class (the GameRenderer class in this class only)
class GameRenderer implements GLSurfaceView.Renderer {
final World mainWorld;
final Camera mainCamera;
FrameBuffer frameBuffer;

public GameRenderer(World world) {
this.mainWorld = world;
this.mainCamera = this.mainWorld.getCamera();
}


@Override
public void onSurfaceCreated(GL10 gl, EGLConfig config) {

}

@Override
public void onSurfaceChanged(GL10 gl, int width, int height) {
this.frameBuffer = new FrameBuffer(width, height);

totalSkin.hasAlpha();
InnerHead iH = new InnerHead();
OuterHead oH = new OuterHead();
Body b = new Body();
RightArm rA = new RightArm();
LeftArm lA = new LeftArm();
RightLeg rL = new RightLeg();
LeftLeg lL = new LeftLeg();

mainWorld.addObject(iH);
mainWorld.addObject(oH);
mainWorld.addObject(b);
mainWorld.addObject(rA);
mainWorld.addObject(lA);
mainWorld.addObject(rL);
mainWorld.addObject(lL);

this.mainWorld.setAmbientLight(255, 255, 255);

final float dScreen = (float) height/(float)width;

this.mainCamera.setPosition(0, 0.25f, (-9 / dScreen));
this.mainCamera.lookAt(b.getCenter());

iH.translate(0, -2.51f, 0);
oH.translate(0, -2.605f, 0);
rA.translate(-1.5f, 0, 0);
lA.translate(1.5f, 0, 0);
rL.translate(-0.5f, 3f, 0);
lL.translate(0.5f, 3f, 0);


System.runFinalization();
System.gc();
MemoryHelper.compact();
}

@Override
public void onDrawFrame(GL10 gl) {
frameBuffer.clear(new RGBColor(132, 189, 240));

SimpleVector moveLine = new SimpleVector(0.333f, 0, 0.333f);
com.threed.jpct.Matrix m = moveLine.normalize().getRotationMatrix();
m.rotateAxis(m.getYAxis(), (float) -Math.PI / 2f);
mainCamera.moveCamera(Camera.CAMERA_MOVEIN, 10);
mainCamera.rotateAxis(m.invert3x3().getYAxis(),
moveLine.length() / 30f);
mainCamera.moveCamera(Camera.CAMERA_MOVEOUT, 10);
mainCamera.lookAt(mainWorld.getObjectByName("body").getCenter());

final Texture t1 = TextureManager.getInstance().getTexture("bg");
frameBuffer.blit(t1, 0, t1.getHeight(), 0, 0, t1.getWidth(),
-t1.getHeight(), frameBuffer.getWidth(),
frameBuffer.getHeight(), -1, false);
mainWorld.renderScene(frameBuffer);
mainWorld.draw(frameBuffer);
frameBuffer.display();
}

}


Body:
package com.aeroshark333.skinviewer.skinparts;

import com.threed.jpct.Object3D;
import com.threed.jpct.SimpleVector;
import com.threed.jpct.TextureManager;

public class Body extends Object3D {

private static final long serialVersionUID = 8216608860877707087L;

public Body() {

super(12);

final Object3D box = this;

SimpleVector upperLeftFront = new SimpleVector(-1, -1.5f, -0.5f);
SimpleVector upperRightFront = new SimpleVector(1, -1.5f, -0.5f);
SimpleVector lowerLeftFront = new SimpleVector(-1, 1.5f, -0.5f);
SimpleVector lowerRightFront = new SimpleVector(1, 1.5f, -0.5f);

SimpleVector upperLeftBack = new SimpleVector(-1, -1.5f, 0.5f);
SimpleVector upperRightBack = new SimpleVector(1, -1.5f, 0.5f);
SimpleVector lowerLeftBack = new SimpleVector(-1, 1.5f, 0.5f);
SimpleVector lowerRightBack = new SimpleVector(1, 1.5f, 0.5f);

// Front
box.addTriangle(upperLeftFront, 0, 0, lowerLeftFront, 0, 1,
upperRightFront, 1, 0, TextureManager.getInstance()
.getTextureID("bodyfront"));
box.addTriangle(upperRightFront, 1, 0, lowerLeftFront, 0, 1,
lowerRightFront, 1, 1, TextureManager.getInstance()
.getTextureID("bodyfront"));
// Back
box.addTriangle(upperLeftBack, 0, 0, upperRightBack, 1, 0,
lowerLeftBack, 0, 1,
TextureManager.getInstance().getTextureID("bodyback"));
box.addTriangle(upperRightBack, 1, 0, lowerRightBack, 1, 1,
lowerLeftBack, 0, 1,
TextureManager.getInstance().getTextureID("bodyback"));
// Top
box.addTriangle(upperLeftBack, 0, 0, upperLeftFront, 0, 1,
upperRightBack, 1, 0, TextureManager.getInstance()
.getTextureID("bodytop"));
box.addTriangle(upperRightBack, 1, 0, upperLeftFront, 0, 1,
upperRightFront, 1, 1, TextureManager.getInstance()
.getTextureID("bodytop"));
// Bottom
box.addTriangle(lowerLeftBack, 0, 0, lowerRightBack, 1, 0,
lowerLeftFront, 0, 1, TextureManager.getInstance()
.getTextureID("bodybottom"));
box.addTriangle(lowerRightBack, 1, 0, lowerRightFront, 1, 1,
lowerLeftFront, 0, 1, TextureManager.getInstance()
.getTextureID("bodybottom"));
// Right
box.addTriangle(upperLeftFront, 0, 0, upperLeftBack, 1, 0,
lowerLeftFront, 0, 1, TextureManager.getInstance()
.getTextureID("bodyright"));
box.addTriangle(upperLeftBack, 1, 0, lowerLeftBack, 1, 1,
lowerLeftFront, 0, 1, TextureManager.getInstance()
.getTextureID("bodyright"));
// Left
box.addTriangle(upperRightFront, 0, 0, lowerRightFront, 0, 1,
upperRightBack, 1, 0, TextureManager.getInstance()
.getTextureID("bodyleft"));
box.addTriangle(upperRightBack, 1, 0, lowerRightFront, 0, 1,
lowerRightBack, 1, 1, TextureManager.getInstance()
.getTextureID("bodyleft"));

this.setTransparency(300);

box.setName("body");

box.build();
}
}



Innerhead:
package com.aeroshark333.skinviewer.skinparts;

import com.threed.jpct.Object3D;
import com.threed.jpct.SimpleVector;
import com.threed.jpct.TextureManager;

public class InnerHead extends Object3D {

private static final long serialVersionUID = 4848178494608221837L;

public InnerHead() {

super(12);

final Object3D box = this;

SimpleVector upperLeftFront = new SimpleVector(-1, -1, -1);
SimpleVector upperRightFront = new SimpleVector(1, -1, -1);
SimpleVector lowerLeftFront = new SimpleVector(-1, 1, -1);
SimpleVector lowerRightFront = new SimpleVector(1, 1, -1);

SimpleVector upperLeftBack = new SimpleVector(-1, -1, 1);
SimpleVector upperRightBack = new SimpleVector(1, -1, 1);
SimpleVector lowerLeftBack = new SimpleVector(-1, 1, 1);
SimpleVector lowerRightBack = new SimpleVector(1, 1, 1);

// Front
box.addTriangle(upperLeftFront, 0, 0, lowerLeftFront, 0, 1,
upperRightFront, 1, 0, TextureManager.getInstance()
.getTextureID("headfront"));
box.addTriangle(upperRightFront, 1, 0, lowerLeftFront, 0, 1,
lowerRightFront, 1, 1, TextureManager.getInstance()
.getTextureID("headfront"));
// Back
box.addTriangle(upperLeftBack, 0, 0, upperRightBack, 1, 0,
lowerLeftBack, 0, 1,
TextureManager.getInstance().getTextureID("headback"));
box.addTriangle(upperRightBack, 1, 0, lowerRightBack, 1, 1,
lowerLeftBack, 0, 1,
TextureManager.getInstance().getTextureID("headback"));
// Top
box.addTriangle(upperLeftBack, 0, 0, upperLeftFront, 0, 1,
upperRightBack, 1, 0, TextureManager.getInstance()
.getTextureID("headtop"));
box.addTriangle(upperRightBack, 1, 0, upperLeftFront, 0, 1,
upperRightFront, 1, 1, TextureManager.getInstance()
.getTextureID("headtop"));
// Bottom
box.addTriangle(lowerLeftBack, 0, 0, lowerRightBack, 1, 0,
lowerLeftFront, 0, 1, TextureManager.getInstance()
.getTextureID("headbottom"));
box.addTriangle(lowerRightBack, 1, 0, lowerRightFront, 1, 1,
lowerLeftFront, 0, 1, TextureManager.getInstance()
.getTextureID("headbottom"));
// Right
box.addTriangle(upperLeftFront, 0, 0, upperLeftBack, 1, 0,
lowerLeftFront, 0, 1, TextureManager.getInstance()
.getTextureID("headright"));
box.addTriangle(upperLeftBack, 1, 0, lowerLeftBack, 1, 1,
lowerLeftFront, 0, 1, TextureManager.getInstance()
.getTextureID("headright"));
// Left
box.addTriangle(upperRightFront, 0, 0, lowerRightFront, 0, 1,
upperRightBack, 1, 0, TextureManager.getInstance()
.getTextureID("headleft"));
box.addTriangle(upperRightBack, 1, 0, lowerRightFront, 0, 1,
lowerRightBack, 1, 1, TextureManager.getInstance()
.getTextureID("headleft"));

this.setTransparency(300);

box.setName("head");

box.setSortOffset(9);

box.build();
}
}


Leftarm:
package com.aeroshark333.skinviewer.skinparts;

import com.threed.jpct.Object3D;
import com.threed.jpct.SimpleVector;
import com.threed.jpct.TextureManager;

//biological left :p
public class LeftArm extends Object3D{

/**
*
*/
private static final long serialVersionUID = -5036321054138114930L;

public LeftArm() {

super(12);

final Object3D box = this;

SimpleVector upperLeftFront = new SimpleVector(-0.5f, -1.5f, -0.5f);
SimpleVector upperRightFront = new SimpleVector(0.5f, -1.5f, -0.5f);
SimpleVector lowerLeftFront = new SimpleVector(-0.5f, 1.5f, -0.5f);
SimpleVector lowerRightFront = new SimpleVector(0.5f, 1.5f, -0.5f);

SimpleVector upperLeftBack = new SimpleVector(-0.5f, -1.5f, 0.5f);
SimpleVector upperRightBack = new SimpleVector(0.5f, -1.5f, 0.5f);
SimpleVector lowerLeftBack = new SimpleVector(-0.5f, 1.5f, 0.5f);
SimpleVector lowerRightBack = new SimpleVector(0.5f, 1.5f, 0.5f);

// Front
box.addTriangle(upperLeftFront, 0, 0, lowerLeftFront, 0, 1,
upperRightFront, 1, 0, TextureManager.getInstance()
.getTextureID("armfront"));
box.addTriangle(upperRightFront, 1, 0, lowerLeftFront, 0, 1,
lowerRightFront, 1, 1, TextureManager.getInstance()
.getTextureID("armfront"));
// Back
box.addTriangle(upperLeftBack, 0, 0, upperRightBack, 1, 0,
lowerLeftBack, 0, 1,
TextureManager.getInstance().getTextureID("armback"));
box.addTriangle(upperRightBack, 1, 0, lowerRightBack, 1, 1,
lowerLeftBack, 0, 1,
TextureManager.getInstance().getTextureID("armback"));
// Top
box.addTriangle(upperLeftBack, 0, 0, upperLeftFront, 0, 1,
upperRightBack, 1, 0, TextureManager.getInstance()
.getTextureID("armtop"));
box.addTriangle(upperRightBack, 1, 0, upperLeftFront, 0, 1,
upperRightFront, 1, 1, TextureManager.getInstance()
.getTextureID("armtop"));
// Bottom
box.addTriangle(lowerLeftBack, 0, 0, lowerRightBack, 1, 0,
lowerLeftFront, 0, 1, TextureManager.getInstance()
.getTextureID("armbottom"));
box.addTriangle(lowerRightBack, 1, 0, lowerRightFront, 1, 1,
lowerLeftFront, 0, 1, TextureManager.getInstance()
.getTextureID("armbottom"));
// Right
box.addTriangle(upperLeftFront, 0, 0, upperLeftBack, 1, 0,
lowerLeftFront, 0, 1, TextureManager.getInstance()
.getTextureID("armright"));
box.addTriangle(upperLeftBack, 1, 0, lowerLeftBack, 1, 1,
lowerLeftFront, 0, 1, TextureManager.getInstance()
.getTextureID("armright"));
// Left
box.addTriangle(upperRightFront, 0, 0, lowerRightFront, 0, 1,
upperRightBack, 1, 0, TextureManager.getInstance()
.getTextureID("armleft"));
box.addTriangle(upperRightBack, 1, 0, lowerRightFront, 0, 1,
lowerRightBack, 1, 1, TextureManager.getInstance()
.getTextureID("armleft"));

this.setTransparency(300);

box.setName("leftarm");


box.build();
}
}


Leftleg:
package com.aeroshark333.skinviewer.skinparts;

import com.threed.jpct.Object3D;
import com.threed.jpct.SimpleVector;
import com.threed.jpct.TextureManager;

//biological left
public class LeftLeg extends Object3D{
/**
*
*/
private static final long serialVersionUID = 4705719438846904180L;

public LeftLeg() {

super(12);

final Object3D box = this;

SimpleVector upperLeftFront = new SimpleVector(-0.5f, -1.5f, -0.5f);
SimpleVector upperRightFront = new SimpleVector(0.5f, -1.5f, -0.5f);
SimpleVector lowerLeftFront = new SimpleVector(-0.5f, 1.5f, -0.5f);
SimpleVector lowerRightFront = new SimpleVector(0.5f, 1.5f, -0.5f);

SimpleVector upperLeftBack = new SimpleVector(-0.5f, -1.5f, 0.5f);
SimpleVector upperRightBack = new SimpleVector(0.5f, -1.5f, 0.5f);
SimpleVector lowerLeftBack = new SimpleVector(-0.5f, 1.5f, 0.5f);
SimpleVector lowerRightBack = new SimpleVector(0.5f, 1.5f, 0.5f);

// Front
box.addTriangle(upperLeftFront, 0, 0, lowerLeftFront, 0, 1,
upperRightFront, 1, 0, TextureManager.getInstance()
.getTextureID("legfront"));
box.addTriangle(upperRightFront, 1, 0, lowerLeftFront, 0, 1,
lowerRightFront, 1, 1, TextureManager.getInstance()
.getTextureID("legfront"));
// Back
box.addTriangle(upperLeftBack, 0, 0, upperRightBack, 1, 0,
lowerLeftBack, 0, 1,
TextureManager.getInstance().getTextureID("legback"));
box.addTriangle(upperRightBack, 1, 0, lowerRightBack, 1, 1,
lowerLeftBack, 0, 1,
TextureManager.getInstance().getTextureID("legback"));
// Top
box.addTriangle(upperLeftBack, 0, 0, upperLeftFront, 0, 1,
upperRightBack, 1, 0, TextureManager.getInstance()
.getTextureID("legtop"));
box.addTriangle(upperRightBack, 1, 0, upperLeftFront, 0, 1,
upperRightFront, 1, 1, TextureManager.getInstance()
.getTextureID("legtop"));
// Bottom
box.addTriangle(lowerLeftBack, 0, 0, lowerRightBack, 1, 0,
lowerLeftFront, 0, 1, TextureManager.getInstance()
.getTextureID("legbottom"));
box.addTriangle(lowerRightBack, 1, 0, lowerRightFront, 1, 1,
lowerLeftFront, 0, 1, TextureManager.getInstance()
.getTextureID("legbottom"));
// Right
box.addTriangle(upperLeftFront, 0, 0, upperLeftBack, 1, 0,
lowerLeftFront, 0, 1, TextureManager.getInstance()
.getTextureID("legright"));
box.addTriangle(upperLeftBack, 1, 0, lowerLeftBack, 1, 1,
lowerLeftFront, 0, 1, TextureManager.getInstance()
.getTextureID("legright"));
// Left
box.addTriangle(upperRightFront, 0, 0, lowerRightFront, 0, 1,
upperRightBack, 1, 0, TextureManager.getInstance()
.getTextureID("legleft"));
box.addTriangle(upperRightBack, 1, 0, lowerRightFront, 0, 1,
lowerRightBack, 1, 1, TextureManager.getInstance()
.getTextureID("legleft"));

this.setTransparency(300);

box.setName("leftleg");


box.build();
}
}


Outerhead:
package com.aeroshark333.skinviewer.skinparts;

import com.threed.jpct.Object3D;
import com.threed.jpct.SimpleVector;
import com.threed.jpct.TextureManager;

public class OuterHead extends Object3D{

private static final long serialVersionUID = 3950765561884516490L;

public OuterHead() {

super(12);

final Object3D box = this;

SimpleVector upperLeftFront = new SimpleVector(-1.1f, -1.1f, -1.1f);
SimpleVector upperRightFront = new SimpleVector(1.1f, -1.1f, -1.1f);
SimpleVector lowerLeftFront = new SimpleVector(-1.1f, 1.1f, -1.1f);
SimpleVector lowerRightFront = new SimpleVector(1.1f, 1.1f, -1.1f);

SimpleVector upperLeftBack = new SimpleVector(-1.1f, -1.1f, 1.1f);
SimpleVector upperRightBack = new SimpleVector(1.1f, -1.1f, 1.1f);
SimpleVector lowerLeftBack = new SimpleVector(-1.1f, 1.1f, 1.1f);
SimpleVector lowerRightBack = new SimpleVector(1.1f, 1.1f, 1.1f);

// Front
box.addTriangle(upperLeftFront, 0, 0, lowerLeftFront, 0, 1,
upperRightFront, 1, 0, TextureManager.getInstance()
.getTextureID("hatfront"));
box.addTriangle(upperRightFront, 1, 0, lowerLeftFront, 0, 1,
lowerRightFront, 1, 1, TextureManager.getInstance()
.getTextureID("hatfront"));
// Back
box.addTriangle(upperLeftBack, 0, 0, upperRightBack, 1, 0,
lowerLeftBack, 0, 1,
TextureManager.getInstance().getTextureID("hatback"));
box.addTriangle(upperRightBack, 1, 0, lowerRightBack, 1, 1,
lowerLeftBack, 0, 1,
TextureManager.getInstance().getTextureID("hatback"));
// Top
box.addTriangle(upperLeftBack, 0, 0, upperLeftFront, 0, 1,
upperRightBack, 1, 0, TextureManager.getInstance()
.getTextureID("hattop"));
box.addTriangle(upperRightBack, 1, 0, upperLeftFront, 0, 1,
upperRightFront, 1, 1, TextureManager.getInstance()
.getTextureID("hattop"));
// Bottom
box.addTriangle(lowerLeftBack, 0, 0, lowerRightBack, 1, 0,
lowerLeftFront, 0, 1, TextureManager.getInstance()
.getTextureID("hatbottom"));
box.addTriangle(lowerRightBack, 1, 0, lowerRightFront, 1, 1,
lowerLeftFront, 0, 1, TextureManager.getInstance()
.getTextureID("hatbottom"));
// Right
box.addTriangle(upperLeftFront, 0, 0, upperLeftBack, 1, 0,
lowerLeftFront, 0, 1, TextureManager.getInstance()
.getTextureID("hatright"));
box.addTriangle(upperLeftBack, 1, 0, lowerLeftBack, 1, 1,
lowerLeftFront, 0, 1, TextureManager.getInstance()
.getTextureID("hatright"));
// Left
box.addTriangle(upperRightFront, 0, 0, lowerRightFront, 0, 1,
upperRightBack, 1, 0, TextureManager.getInstance()
.getTextureID("hatleft"));
box.addTriangle(upperRightBack, 1, 0, lowerRightFront, 0, 1,
lowerRightBack, 1, 1, TextureManager.getInstance()
.getTextureID("hatleft"));

this.setTransparency(300);


box.setName("hat");

box.build();
}
}


Rightarm:
package com.aeroshark333.skinviewer.skinparts;

import com.threed.jpct.Object3D;
import com.threed.jpct.SimpleVector;
import com.threed.jpct.TextureManager;

//biological right
public class RightArm extends Object3D{

/**
*
*/
private static final long serialVersionUID = -5257845406283197478L;

public RightArm() {

super(12);

final Object3D box = this;

SimpleVector upperLeftFront = new SimpleVector(-0.5f, -1.5f, -0.5f);
SimpleVector upperRightFront = new SimpleVector(0.5f, -1.5f, -0.5f);
SimpleVector lowerLeftFront = new SimpleVector(-0.5f, 1.5f, -0.5f);
SimpleVector lowerRightFront = new SimpleVector(0.5f, 1.5f, -0.5f);

SimpleVector upperLeftBack = new SimpleVector(-0.5f, -1.5f, 0.5f);
SimpleVector upperRightBack = new SimpleVector(0.5f, -1.5f, 0.5f);
SimpleVector lowerLeftBack = new SimpleVector(-0.5f, 1.5f, 0.5f);
SimpleVector lowerRightBack = new SimpleVector(0.5f, 1.5f, 0.5f);

// Front
box.addTriangle(upperLeftFront, 0, 0, lowerLeftFront, 0, 1,
upperRightFront, 1, 0, TextureManager.getInstance()
.getTextureID("armfront"));
box.addTriangle(upperRightFront, 1, 0, lowerLeftFront, 0, 1,
lowerRightFront, 1, 1, TextureManager.getInstance()
.getTextureID("armfront"));
// Back
box.addTriangle(upperLeftBack, 0, 0, upperRightBack, 1, 0,
lowerLeftBack, 0, 1,
TextureManager.getInstance().getTextureID("armback"));
box.addTriangle(upperRightBack, 1, 0, lowerRightBack, 1, 1,
lowerLeftBack, 0, 1,
TextureManager.getInstance().getTextureID("armback"));
// Top
box.addTriangle(upperLeftBack, 0, 0, upperLeftFront, 0, 1,
upperRightBack, 1, 0, TextureManager.getInstance()
.getTextureID("armtop"));
box.addTriangle(upperRightBack, 1, 0, upperLeftFront, 0, 1,
upperRightFront, 1, 1, TextureManager.getInstance()
.getTextureID("armtop"));
// Bottom
box.addTriangle(lowerLeftBack, 0, 0, lowerRightBack, 1, 0,
lowerLeftFront, 0, 1, TextureManager.getInstance()
.getTextureID("armbottom"));
box.addTriangle(lowerRightBack, 1, 0, lowerRightFront, 1, 1,
lowerLeftFront, 0, 1, TextureManager.getInstance()
.getTextureID("armbottom"));
// Right
box.addTriangle(upperLeftFront, 0, 0, upperLeftBack, 1, 0,
lowerLeftFront, 0, 1, TextureManager.getInstance()
.getTextureID("armright"));
box.addTriangle(upperLeftBack, 1, 0, lowerLeftBack, 1, 1,
lowerLeftFront, 0, 1, TextureManager.getInstance()
.getTextureID("armright"));
// Left
box.addTriangle(upperRightFront, 0, 0, lowerRightFront, 0, 1,
upperRightBack, 1, 0, TextureManager.getInstance()
.getTextureID("armleft"));
box.addTriangle(upperRightBack, 1, 0, lowerRightFront, 0, 1,
lowerRightBack, 1, 1, TextureManager.getInstance()
.getTextureID("armleft"));

this.setTransparency(300);

box.setName("rightarm");


box.build();
}
}


Rightleg:
package com.aeroshark333.skinviewer.skinparts;

import com.threed.jpct.Object3D;
import com.threed.jpct.SimpleVector;
import com.threed.jpct.TextureManager;

//biological right
public class RightLeg extends Object3D {

/**
*
*/
private static final long serialVersionUID = 8223363127837467932L;

public RightLeg() {

super(12);

final Object3D box = this;

SimpleVector upperLeftFront = new SimpleVector(-0.5f, -1.5f, -0.5f);
SimpleVector upperRightFront = new SimpleVector(0.5f, -1.5f, -0.5f);
SimpleVector lowerLeftFront = new SimpleVector(-0.5f, 1.5f, -0.5f);
SimpleVector lowerRightFront = new SimpleVector(0.5f, 1.5f, -0.5f);

SimpleVector upperLeftBack = new SimpleVector(-0.5f, -1.5f, 0.5f);
SimpleVector upperRightBack = new SimpleVector(0.5f, -1.5f, 0.5f);
SimpleVector lowerLeftBack = new SimpleVector(-0.5f, 1.5f, 0.5f);
SimpleVector lowerRightBack = new SimpleVector(0.5f, 1.5f, 0.5f);

// Front
box.addTriangle(upperLeftFront, 0, 0, lowerLeftFront, 0, 1,
upperRightFront, 1, 0, TextureManager.getInstance()
.getTextureID("legfront"));
box.addTriangle(upperRightFront, 1, 0, lowerLeftFront, 0, 1,
lowerRightFront, 1, 1, TextureManager.getInstance()
.getTextureID("legfront"));
// Back
box.addTriangle(upperLeftBack, 0, 0, upperRightBack, 1, 0,
lowerLeftBack, 0, 1,
TextureManager.getInstance().getTextureID("legback"));
box.addTriangle(upperRightBack, 1, 0, lowerRightBack, 1, 1,
lowerLeftBack, 0, 1,
TextureManager.getInstance().getTextureID("legback"));
// Top
box.addTriangle(upperLeftBack, 0, 0, upperLeftFront, 0, 1,
upperRightBack, 1, 0, TextureManager.getInstance()
.getTextureID("legtop"));
box.addTriangle(upperRightBack, 1, 0, upperLeftFront, 0, 1,
upperRightFront, 1, 1, TextureManager.getInstance()
.getTextureID("legtop"));
// Bottom
box.addTriangle(lowerLeftBack, 0, 0, lowerRightBack, 1, 0,
lowerLeftFront, 0, 1, TextureManager.getInstance()
.getTextureID("legbottom"));
box.addTriangle(lowerRightBack, 1, 0, lowerRightFront, 1, 1,
lowerLeftFront, 0, 1, TextureManager.getInstance()
.getTextureID("legbottom"));
// Right
box.addTriangle(upperLeftFront, 0, 0, upperLeftBack, 1, 0,
lowerLeftFront, 0, 1, TextureManager.getInstance()
.getTextureID("legright"));
box.addTriangle(upperLeftBack, 1, 0, lowerLeftBack, 1, 1,
lowerLeftFront, 0, 1, TextureManager.getInstance()
.getTextureID("legright"));
// Left
box.addTriangle(upperRightFront, 0, 0, lowerRightFront, 0, 1,
upperRightBack, 1, 0, TextureManager.getInstance()
.getTextureID("legleft"));
box.addTriangle(upperRightBack, 1, 0, lowerRightFront, 0, 1,
lowerRightBack, 1, 1, TextureManager.getInstance()
.getTextureID("legleft"));

this.setTransparency(300);

box.setName("rightleg");


box.build();
}
}

EgonOlsen

An example in form of a zipped project would help. I can't be bithered to create one out of individual sources.

Lobby

As already suggested, a fragment shader using alpha testing would be the best solution. Except if you want semi transparent textures...

Here a little sample how this works: https://dl.dropboxusercontent.com/u/1618711/web/software/AlphaTest.zip

AeroShark333

Thanks for the replies!

I kind of solved my problem already.
I added box.setSortOffset(9); to both RightLeg.java and LeftLeg.java (which seemed to work)
I think this fix was a bit logical (now that I think about it... :|)

Thanks a lot for the support! (I have no idea what alpha testing is, so I guess it is better I don't have to use that difficult stuff xD)

My final question: Is my app project-worthy? (for this page: http://www.jpct.net/projects.html)

AeroShark333

The issue in post #2 does not happen on all devices for some reason...
But it does on a few...
Is there an easier solution?

EgonOlsen

Can you provide a more detailed screen shot? If it's a transparency issue, it has to appear on all devices. There's no way that the device has any influence on it...unless it's another issue, but i can't tell it from the shots.

AeroShark333

On tablet the issue is visible, on phones it isn't (I suppose the width of the screen does have an effect on the bug's visibility)

Anyway, here is a screenshot: https://dl.dropboxusercontent.com/u/47988037/Android/Skin%20Viewer%203D/Screenshot/bug.png
(Look at the right arm (biological left arm))

EgonOlsen

Looks just like the usual sorting issues that we already described. I don't see any way in which these can depend on the device. On randoness maybe, but not on the device. Given that textures, why are you using transparency anyway? I don't see any transparent parts on them... ???

AeroShark333

It is possible to use transparent skins in Minecraft.
A skin is a 64x32 png file.
Since every bodypart can have transparent elements, I decided to enable transparency for every part.
Is 'alpha testing' easy to do?
Or are there other solutions?

I tried to make the parts not touch each other using about 0.03f space between the parts. But it did not help at all...
Is it possible to have more drawing/sorting precision? Using the Config perhaps?

What will happen in I enlarge the parts a lot and zoom out the camera? The same?