added IRenderContext3D.clearDepth
This commit is contained in:
parent
6baffc5f6c
commit
9c33d7b6f7
|
@ -1,5 +1,6 @@
|
||||||
package com.danitheskunk.skunkworks;
|
package com.danitheskunk.skunkworks;
|
||||||
|
|
||||||
|
import com.danitheskunk.skunkworks.gfx.Color;
|
||||||
import com.danitheskunk.skunkworks.gfx.IRenderContext;
|
import com.danitheskunk.skunkworks.gfx.IRenderContext;
|
||||||
import com.danitheskunk.skunkworks.gfx.ITexture;
|
import com.danitheskunk.skunkworks.gfx.ITexture;
|
||||||
import com.danitheskunk.skunkworks.gfx.Image;
|
import com.danitheskunk.skunkworks.gfx.Image;
|
||||||
|
@ -12,6 +13,7 @@ import java.nio.IntBuffer;
|
||||||
@SuppressWarnings("ALL")
|
@SuppressWarnings("ALL")
|
||||||
public class Test3D extends BaseGame {
|
public class Test3D extends BaseGame {
|
||||||
private final Mesh[] meshes;
|
private final Mesh[] meshes;
|
||||||
|
int trans;
|
||||||
|
|
||||||
public Test3D() {
|
public Test3D() {
|
||||||
super(new Vec2i(1920, 1080), "Skunkworks 3d test");
|
super(new Vec2i(1920, 1080), "Skunkworks 3d test");
|
||||||
|
@ -20,12 +22,13 @@ public class Test3D extends BaseGame {
|
||||||
Assimp.aiGetVersionMinor(),
|
Assimp.aiGetVersionMinor(),
|
||||||
Assimp.aiGetVersionPatch()
|
Assimp.aiGetVersionPatch()
|
||||||
);
|
);
|
||||||
|
trans = 255;
|
||||||
var path = "C:\\stream\\models\\Dani.glb";
|
var path = "C:\\stream\\models\\Dani.glb";
|
||||||
//path = "C:\\stream\\models\\Amber_Arakada_V5_Blendshape.glb";
|
//path = "C:\\stream\\models\\Amber_Arakada_V5_Blendshape.glb";
|
||||||
//path = "C:\\stream\\models\\Temp Chan 3.glb";
|
//path = "C:\\stream\\models\\Temp Chan 3.glb";
|
||||||
var bytes = engine.loadBytes(path);
|
var bytes = engine.loadBytes(path);
|
||||||
var flags = Assimp.aiProcess_Triangulate;
|
var flags = Assimp.aiProcess_Triangulate;
|
||||||
flags |= Assimp.aiProcess_PreTransformVertices;
|
//flags |= Assimp.aiProcess_PreTransformVertices;
|
||||||
var ai = Assimp.aiImportFile(path, flags);
|
var ai = Assimp.aiImportFile(path, flags);
|
||||||
if(ai == null) {
|
if(ai == null) {
|
||||||
throw new RuntimeException("couldn't load model because: " +
|
throw new RuntimeException("couldn't load model because: " +
|
||||||
|
@ -53,9 +56,8 @@ public class Test3D extends BaseGame {
|
||||||
null
|
null
|
||||||
);
|
);
|
||||||
var tpathstr = tpath.dataString();
|
var tpathstr = tpath.dataString();
|
||||||
matTex[i] = tpathstr.startsWith("*") ?
|
matTex[i] = tpathstr.startsWith("*") ? Integer.parseInt(tpathstr.substring(
|
||||||
Integer.parseInt(tpathstr.substring(
|
1)) : -1;
|
||||||
1)) : -1;
|
|
||||||
System.out.printf("tex count: %d, path: %s\n",
|
System.out.printf("tex count: %d, path: %s\n",
|
||||||
texCount,
|
texCount,
|
||||||
tpath.dataString()
|
tpath.dataString()
|
||||||
|
@ -111,8 +113,22 @@ public class Test3D extends BaseGame {
|
||||||
@Override
|
@Override
|
||||||
protected void render3D(IRenderContext3D rc) {
|
protected void render3D(IRenderContext3D rc) {
|
||||||
for(int i = 0; i < meshes.length; ++i) {
|
for(int i = 0; i < meshes.length; ++i) {
|
||||||
rc.renderMesh(meshes[i]);
|
//rc.renderMesh(meshes[i], new Color(255, 255, 255));
|
||||||
|
}
|
||||||
|
rc.clearDepth();
|
||||||
|
rc.renderMesh(meshes[trans * (meshes.length-1) / 255]);
|
||||||
|
for(int i = 0; i < meshes.length; ++i) {
|
||||||
|
//rc.renderMesh(meshes[i], new Color(255, 255, 255, 255 - trans));
|
||||||
}
|
}
|
||||||
//rc.renderMesh(meshes[14]);
|
//rc.renderMesh(meshes[14]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void update(double delta) {
|
||||||
|
if(trans > 0) {
|
||||||
|
trans -= 1;
|
||||||
|
} else {
|
||||||
|
trans = 255;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,6 +72,11 @@ public class RenderContext3D extends BaseRenderContext3D {
|
||||||
glEnd();
|
glEnd();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void clearDepth() {
|
||||||
|
glClear(GL_DEPTH_BUFFER_BIT);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void renderTriangle(Vec3f p1, Vec3f p2, Vec3f p3) {
|
public void renderTriangle(Vec3f p1, Vec3f p2, Vec3f p3) {
|
||||||
glBegin(GL_TRIANGLES);
|
glBegin(GL_TRIANGLES);
|
||||||
|
|
|
@ -7,4 +7,5 @@ public interface IRenderContext3D {
|
||||||
void renderTriangle(Vec3f p1, Vec3f p2, Vec3f p3);
|
void renderTriangle(Vec3f p1, Vec3f p2, Vec3f p3);
|
||||||
void renderMesh(Mesh mesh);
|
void renderMesh(Mesh mesh);
|
||||||
void renderMesh(Mesh mesh, Color tint);
|
void renderMesh(Mesh mesh, Color tint);
|
||||||
|
void clearDepth();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue