Wow! That was a quick and easy fix, thank you! I don´t know at which developing step I left fb.display() out, and I´m still wondering why the program at all worked without this line, but now it´s good again!
Cheers,
Marc
Cheers,
Marc
This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
Show posts Menu/**
* Scales whole scene via scaleDelta. Note that scale value is handled as
* accumulative, not absolute. Scene is scaled around scaleMidpoint
*
* @param scaleDelta
* accumulative scale value
* @param scaleMidpoint
* midpoint in screen coordinates
*/
public void scale(float scaleDelta, Vector3f scaleMidpoint) {
//obtain world coordinates of scaleMidpoint
backgroundMap.setCollisionMode(Object3D.COLLISION_CHECK_OTHERS);
SimpleVector worldCoord = getCollisionCoordinates(backgroundName, scaleMidpoint);
backgroundMap.setCollisionMode(Object3D.COLLISION_CHECK_NONE);
SimpleVector translation = rootNode.getTranslation();
Matrix mat = rootNode.getRotationMatrix();
mat.translate(-(worldCoord.x - translation.x), -(worldCoord.y - translation.y), 0);
Matrix scale = getScaleMatrix(scaleDelta);
mat.matMul(scale);
mat.translate(worldCoord.x - translation.x, worldCoord.y - translation.y, 0);
}
private Matrix getScaleMatrix(float scale) {
Matrix scaleMat = new Matrix();
scaleMat.setDump(new float[] { scale, 0, 0, 0, 0, scale, 0, 0, 0, 0, scale, 0, 0, 0, 0, 1 });
return scaleMat;
}
//mesh.setVertexController:
A VertexController is the only way for an application to modify the vertex data of jPCT's meshes after build-time.
private final static float textureMaxX = 100f;
private final static float textureMaxY = 130f;
//in some init function. this draws a rectangle which is later been filled by a texture
Object3D background = new Object3D(2);
SimpleVector vert1 = new SimpleVector(0, 0, 0);
SimpleVector vert2 = new SimpleVector(textureMaxX, 0, 0);
SimpleVector vert3 = new SimpleVector(textureMaxX, textureMaxY, 0);
SimpleVector vert4 = new SimpleVector(0, textureMaxY, 0);
background.addTriangle(vert3, 1, 1, vert2, 1, 0, vert1, 0, 0);
background.addTriangle(vert3, 1, 1, vert1, 0, 0, vert4, 0, 1);
world.addObject(background);
//in onDrawFrame
background.translate(100, 0, 0);
background.translateMesh();
background.scale(1.01f);
background.translate(-100, 0, 0);
background.translateMesh();
Quote from: EgonOlsen on October 09, 2011, 04:26:26 PM
I'm not sure what "scaling around a point" actually means!?
10-05 00:22:32.890: INFO/jPCT-AE(23039): Loading Texture...
10-05 00:22:33.060: INFO/jPCT-AE(23039): OpenGL vendor: NVIDIA Corporation
10-05 00:22:33.060: INFO/jPCT-AE(23039): OpenGL renderer: NVIDIA AP
10-05 00:22:33.060: INFO/jPCT-AE(23039): OpenGL version: OpenGL ES-CM 1.1
10-05 00:22:33.060: INFO/jPCT-AE(23039): OpenGL renderer initialized (using 2 texture stages)
10-05 00:22:33.060: INFO/jPCT-AE(23039): Subobject of object 2/0 compiled to flat fixed point data using 24 vertices in 0ms!
10-05 00:22:33.060: INFO/jPCT-AE(23039): Static references cleared...
10-05 00:22:33.060: INFO/jPCT-AE(23039): Object 2/0 compiled to 1 subobjects in 1ms!
10-05 00:22:33.100: INFO/jPCT-AE(23039): 0fps
10-05 00:22:33.170: INFO/jPCT-AE(23039): Static references cleared...
10-05 00:22:33.180: INFO/jPCT-AE(23039): Subobject of object 6/1 compiled to flat fixed point data using 6 vertices in 0ms!
10-05 00:22:33.180: INFO/jPCT-AE(23039): Object 6/1 compiled to 1 subobjects in 2ms!
10-05 00:22:33.270: INFO/jPCT-AE(23039): Static references cleared...
10-05 00:22:33.270: INFO/jPCT-AE(23039): java.lang.NullPointerException
10-05 00:22:33.270: INFO/jPCT-AE(23039): at com.threed.jpct.GLRenderer.drawVertexArray(GLRenderer.java:2015)
10-05 00:22:33.270: INFO/jPCT-AE(23039): at com.threed.jpct.World.draw(World.java:1355)
10-05 00:22:33.270: INFO/jPCT-AE(23039): at com.threed.jpct.World.draw(World.java:1136)
10-05 00:22:33.270: INFO/jPCT-AE(23039): at myPackage.gl.MapRenderer.onDrawFrame(MapRenderer.java:186)
10-05 00:22:33.270: INFO/jPCT-AE(23039): at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1429)
10-05 00:22:33.270: INFO/jPCT-AE(23039): at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1184)
//this is triggered by some external source...maybe every 100ms
Object3D traj3D = trajectory.generateObject3D();
traj3D.setName("" + trajectory.getId());
traj3D.build();
Object3D lookup = world.getObjectByName("" + trajectory.getId());
world.addObject(traj3D);
rootNode.addChild(traj3D);
//TODO this is flickering
if (lookup != null) {
world.removeObject(lookup);
rootNode.removeChild(lookup);
}
@Override
public void onDrawFrame(GL10 gl) {
// Log.v(TAG, "onDrawFrame");
try {
if (!stop) {
fb.clear(back);
world.renderScene(fb);
world.draw(fb);
fb.display();
if (System.currentTimeMillis() - time >= 1000) {
Logger.log(fps + "fps");
fps = 0;
time = System.currentTimeMillis();
}
fps++;
} else {
if (fb != null) {
fb.dispose();
fb = null;
}
}
} catch (Exception e) {
Logger.log(e, Logger.MESSAGE);
}
}
Page created in 0.024 seconds with 13 queries.