Implement async data/subData. Implement TriangleMeshBuilder in SimpleMesh which replaces TriangleMesh. Update Film to use new builder.
This commit is contained in:
@@ -24,15 +24,15 @@ int main(int index)
|
||||
|
||||
float trans = Pos_translate;
|
||||
float rot = Pos_rotate;
|
||||
|
||||
matrixLoadScale(mat1, 2.f, 2.f, 2.f);
|
||||
matrixTranslate(mat1, 0.f, 0.f, trans);
|
||||
matrixRotate(mat1, 90.f, 0.f, 0.f, 1.f);
|
||||
matrixRotate(mat1, rot, 1.f, 0.f, 0.f);
|
||||
storeMatrix(3, 0, mat1);
|
||||
vpLoadModelMatrix(mat1);
|
||||
|
||||
// Draw the lighting effect in the strip and fill the Z buffer.
|
||||
drawTriangleMesh(NAMED_mesh);
|
||||
|
||||
drawSimpleMesh(NAMED_mesh);
|
||||
|
||||
// Start of images.
|
||||
bindProgramFragmentStore(NAMED_PSImages);
|
||||
@@ -74,31 +74,21 @@ int main(int index)
|
||||
pos = pos - 0.75f;
|
||||
|
||||
offset = offset + triangleOffsetsCount / 2;
|
||||
|
||||
int drawit = 1;
|
||||
if (offset < 0) {
|
||||
drawit = 0;
|
||||
}
|
||||
if (offset >= triangleOffsetsCount) {
|
||||
drawit = 0;
|
||||
}
|
||||
|
||||
//if (!((offset < 0) || (offset >= triangleOffsetsCount))) {
|
||||
if (drawit) {
|
||||
if (!((offset < 0) || (offset >= triangleOffsetsCount))) {
|
||||
int start = offset -2;
|
||||
int end = offset + 2;
|
||||
|
||||
if (start < 0) {
|
||||
start = 0;
|
||||
}
|
||||
if (end > triangleOffsetsCount) {
|
||||
end = triangleOffsetsCount;
|
||||
if (end >= triangleOffsetsCount) {
|
||||
end = triangleOffsetsCount-1;
|
||||
}
|
||||
|
||||
bindTexture(NAMED_PFImages, 0, loadI32(0, imgId - 1));
|
||||
matrixLoadTranslate(mat1, -pos - loadF(5, triangleOffsetsCount / 2), 0, 0);
|
||||
vpLoadTextureMatrix(mat1);
|
||||
drawTriangleMeshRange(NAMED_mesh, loadI32(4, start), loadI32(4, end) - loadI32(4, start));
|
||||
drawSimpleMeshRange(NAMED_mesh, loadI32(4, start), (loadI32(4, end) - loadI32(4, start)));
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
|
||||
@@ -68,8 +68,6 @@ public class FilmRS {
|
||||
private RenderScript mRS;
|
||||
private Script mScriptStrip;
|
||||
private Script mScriptImage;
|
||||
private Element mElementVertex;
|
||||
private Element mElementIndex;
|
||||
private Sampler mSampler;
|
||||
private ProgramStore mPSBackground;
|
||||
private ProgramStore mPSImages;
|
||||
@@ -88,7 +86,7 @@ public class FilmRS {
|
||||
private Allocation mAllocOffsetsTex;
|
||||
private Allocation mAllocOffsets;
|
||||
|
||||
private RenderScript.TriangleMesh mMesh;
|
||||
private SimpleMesh mMesh;
|
||||
private Light mLight;
|
||||
|
||||
private FilmStripMesh mFSM;
|
||||
@@ -186,7 +184,6 @@ public class FilmRS {
|
||||
mip++;
|
||||
a.setConstraint(Dimension.LOD, mip);
|
||||
}
|
||||
a.destroy();
|
||||
|
||||
mImages[ct].uploadToTexture(1);
|
||||
mBufferIDs[ct] = mImages[ct].getID();
|
||||
@@ -204,13 +201,8 @@ public class FilmRS {
|
||||
}
|
||||
|
||||
private void initRS() {
|
||||
mElementVertex = Element.NORM_ST_XYZ_F32;
|
||||
mElementIndex = Element.INDEX_16;
|
||||
|
||||
mRS.triangleMeshBegin(mElementVertex, mElementIndex);
|
||||
mFSM = new FilmStripMesh();
|
||||
mFSM.init(mRS);
|
||||
mMesh = mRS.triangleMeshCreate();
|
||||
mMesh = mFSM.init(mRS);
|
||||
mMesh.setName("mesh");
|
||||
|
||||
initPFS();
|
||||
|
||||
@@ -22,6 +22,7 @@ import java.lang.Math;
|
||||
import android.util.Log;
|
||||
|
||||
import android.renderscript.RenderScript;
|
||||
import android.renderscript.SimpleMesh;
|
||||
|
||||
|
||||
class FilmStripMesh {
|
||||
@@ -72,27 +73,23 @@ class FilmStripMesh {
|
||||
dx /= len;
|
||||
dy /= len;
|
||||
dz /= len;
|
||||
|
||||
|
||||
nx = dx * dz;
|
||||
ny = dy * dz;
|
||||
nz = (float)java.lang.Math.sqrt(dx*dx + dy*dy);
|
||||
|
||||
|
||||
len = (float)java.lang.Math.sqrt(nx*nx + ny*ny + nz*nz);
|
||||
nx /= len;
|
||||
ny /= len;
|
||||
nz /= len;
|
||||
}
|
||||
|
||||
void addToRS(RenderScript rs) {
|
||||
rs.triangleMeshAddVertex_XYZ_ST_NORM(x, y, z, s, t, nx, ny, nz);
|
||||
}
|
||||
}
|
||||
|
||||
int[] mTriangleOffsets;
|
||||
float[] mTriangleOffsetsTex;
|
||||
int mTriangleOffsetsCount;
|
||||
|
||||
void init(RenderScript rs)
|
||||
SimpleMesh init(RenderScript rs)
|
||||
{
|
||||
float vtx[] = new float[] {
|
||||
60.431003f, 124.482050f,
|
||||
@@ -203,11 +200,11 @@ class FilmStripMesh {
|
||||
-60.862074f, 120.872604f,
|
||||
-60.431003f, 124.482050f
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
mTriangleOffsets = new int[64];
|
||||
mTriangleOffsetsTex = new float[64];
|
||||
|
||||
|
||||
mTriangleOffsets[0] = 0;
|
||||
mTriangleOffsetsCount = 1;
|
||||
|
||||
@@ -215,6 +212,8 @@ class FilmStripMesh {
|
||||
t.nxyz(1, 0, 0);
|
||||
int count = vtx.length / 2;
|
||||
|
||||
SimpleMesh.TriangleMeshBuilder tm = new SimpleMesh.TriangleMeshBuilder(rs, 3, true, true);
|
||||
|
||||
float runningS = 0;
|
||||
for (int ct=0; ct < (count-1); ct++) {
|
||||
t.x = -vtx[ct*2] / 100.f;
|
||||
@@ -228,16 +227,15 @@ class FilmStripMesh {
|
||||
t.ny /= len;
|
||||
t.y = -0.5f;
|
||||
t.t = 0;
|
||||
//Log.e("xx", "vtx " + t.x + " " + t.y + " " + t.z);
|
||||
t.addToRS(rs);
|
||||
tm.add_XYZ_ST_NORM(t.x, t.y, t.z, t.s, t.t, t.nx, t.ny, t.nz);
|
||||
//android.util.Log.e("rs", "vtx x="+t.x+" y="+t.y+" z="+t.z+" s="+t.s+" t="+t.t);
|
||||
t.y = .5f;
|
||||
t.t = 1;
|
||||
t.addToRS(rs);
|
||||
tm.add_XYZ_ST_NORM(t.x, t.y, t.z, t.s, t.t, t.nx, t.ny, t.nz);
|
||||
//android.util.Log.e("rs", "vtx x="+t.x+" y="+t.y+" z="+t.z+" s="+t.s+" t="+t.t);
|
||||
|
||||
//LOGE(" %f", runningS);
|
||||
if((runningS*2) > mTriangleOffsetsCount) {
|
||||
//LOGE("**** img %i %i", gTriangleOffsetsCount, ct*2);
|
||||
mTriangleOffsets[mTriangleOffsetsCount] = ct*2;
|
||||
mTriangleOffsets[mTriangleOffsetsCount] = ct*2 * 3;
|
||||
mTriangleOffsetsTex[mTriangleOffsetsCount] = t.s;
|
||||
mTriangleOffsetsCount ++;
|
||||
}
|
||||
@@ -245,9 +243,10 @@ class FilmStripMesh {
|
||||
|
||||
count = (count * 2 - 2);
|
||||
for (int ct=0; ct < (count-2); ct+= 2) {
|
||||
rs.triangleMeshAddTriangle(ct, ct+1, ct+2);
|
||||
rs.triangleMeshAddTriangle(ct+1, ct+3, ct+2);
|
||||
tm.addTriangle(ct, ct+1, ct+2);
|
||||
tm.addTriangle(ct+1, ct+3, ct+2);
|
||||
}
|
||||
return tm.create();
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user