Show Posts

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.

Messages - sticksen

Pages: [1]
Bugs / Re: Memory Leak when removing Objects from World?
« on: December 31, 2011, 12:16:03 am »
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!


Bugs / Memory Leak when removing Objects from World?
« on: December 30, 2011, 11:12:12 pm »

Iīve got this following mini project:
In this simplistic app, every frame all objects are cleared from the world and then one new object is added. If I run it, the consumed memory continously begins to grow. Why is that?

I came across this problem because in a bigger project, I have to add around 500 Object3Ds with 400 Vertices each continously again and again, i.e. remove them from the world, add them again, remove them etc.
With every step my app consumed 50MB more of Heapsize!

Anybody with a clue?

Cheers, Marc

Thanks for your help! I have to look into this later, will report here!


alright, I guess this is a problem onlz occuring to me, but I just wanted to let you know:

When the scale parts of an Object3D rotation matrix are used (for some cause), billboarded objects seem to be scaled double the size it's supposed to be. Could there be an easy fix (maybe in a new release)?


Support / Re: Scale around a center point?
« on: October 26, 2011, 06:50:32 pm »
Finally I got it working...first the code:
Code: [Select]
* 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
SimpleVector worldCoord = getCollisionCoordinates(backgroundName, scaleMidpoint);

SimpleVector translation = rootNode.getTranslation();
Matrix mat = rootNode.getRotationMatrix();
mat.translate(-(worldCoord.x - translation.x), -(worldCoord.y - translation.y), 0);
Matrix scale = getScaleMatrix(scaleDelta);
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;
Ok, this is kind of a hack, because there's no rootNode.getMatrix() or setMatrix, only getTranslationMatrix and getRotationMatrix. getScaleMatrix also isn't present, so I had to use the rotation matrix and add scale values to it, which don't seem to be stripped afterwards.
The Matrix class itself features .translate, .rotate, but also no .scale, which is another inconsistency.

All other tips mentioned here didn't work for me.

This seems to be the only way things are happening like I want it to, but now another problem arises: Billboarded objects seem to be scaled double. I'm opening a new thread on this.

Thanks for all your help!

Support / Re: Scale around a center point?
« on: October 11, 2011, 02:00:42 pm »
Hi again,

@stownshend: No distortion or anything like that needed.

Sadly that doesnīt work either.
Well, problem is: the 'point to scale around' changes during runtime. As I mentioned, Iīm implementing a pinch-zoom gesture, and every time the user puts 2 fingers on the screen, the scalepoint changes. Thus I have to modify the object at runtime...

I stumbled upon something else: I now donīt call createDummyObj() for my rootNode anymore, instead Iīm just instantiating the exact same rectangle as for the background. Now when I donīt call build on the rootNode and scale it, all children are scaled around top left. After calling build for the root, all childs scale around the center. So build definitely does something that influences the scaling. Damn closed source, it was easier when one could have a look at what itīs doing...:)

Also, javadoc says there's something like unbuild(), but I guess this function isnīt public anymore?


Support / Re: Scale around a center point?
« on: October 10, 2011, 10:25:14 pm »
Still not the wished still scales around the center. Does it matter when the object is built? I need to modify the object space coordinates after build() was called. Do I need a VertexController then? I read this:

Code: [Select]
A VertexController is the only way for an application to modify the vertex data of jPCT's meshes after build-time.

Support / Re: Scale around a center point?
« on: October 10, 2011, 09:41:39 pm »
Ok, I tried to get it working, but somehow I canīt figure it out.

Code: [Select]
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);

//in onDrawFrame
background.translate(100, 0, 0);
background.translate(-100, 0, 0);

Now whatever values I translate and back-translate the background, it always scales around the center in this example. My first example, which scaled around top left was a 'rootNode', which was instantiated by Object3D.createDummyObj() and is used to group objects. From the above code, I expected to receive a scaling around the right edge of my background rectangle. Am I doing something wrong?

Cheers and thanks for all your efforts!

Support / Re: Scale around a center point?
« on: October 09, 2011, 08:50:24 pm »
oh, just to verify if I understood it correctly: if I have 100 objects, all as a child of an Object 'rootNode', I have to get my point to scale around, read out all Objects, translate them, scale, translate them back? Itīs not possible to just translate my rootNode and then scale, because the object space of the childs doesnīt change, right?
Maybe then Iīm rather going for option 2...


Support / Re: Scale around a center point?
« on: October 09, 2011, 06:02:09 pm »
I'm not sure what "scaling around a point" actually means!?

well, currently the object 'grows' to the right and to the bottom, while the upper left corner stays at the same place. I need to 'grow' it in all 4 directions, while only a certain point (given by e.g. a pinch-zoom event) stays at the same place.

Support / Scale around a center point?
« on: October 09, 2011, 03:20:19 pm »

is there any way to scale an Object3D around some arbitrary point? As far as I can see, currently itīs always scaling around the objectīs origin in (0,0,0) , so I would have to calculate something to translate it afterwards? Iīm needing this for correct Pinch-Zooming.


Support / Re: Flickering when using world.removeObject ?
« on: October 05, 2011, 03:43:25 am »
ok, that seems to be the problem. thank you!

Support / Flickering when using world.removeObject ?
« on: October 05, 2011, 12:34:38 am »
Hi there,

When Iīm using world.removeObject, sometimes the screen flickers. Log shows repeatedly:

Code: [Select]
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(
10-05 00:22:33.270: INFO/jPCT-AE(23039):     at com.threed.jpct.World.draw(
10-05 00:22:33.270: INFO/jPCT-AE(23039):     at com.threed.jpct.World.draw(
10-05 00:22:33.270: INFO/jPCT-AE(23039):     at
10-05 00:22:33.270: INFO/jPCT-AE(23039):     at android.opengl.GLSurfaceView$GLThread.guardedRun(
10-05 00:22:33.270: INFO/jPCT-AE(23039):     at android.opengl.GLSurfaceView$

So Iīm guessing itīs this NullPointerException that causes the flickering.

My relevant code:
Code: [Select]
//this is triggered by some external source...maybe every 100ms
Object3D traj3D = trajectory.generateObject3D();
traj3D.setName("" + trajectory.getId());;
Object3D lookup = world.getObjectByName("" + trajectory.getId());
//TODO this is flickering
if (lookup != null) {

Code: [Select]
    public void onDrawFrame(GL10 gl) {
// Log.v(TAG, "onDrawFrame");

try {
    if (!stop) {


if (System.currentTimeMillis() - time >= 1000) {
    Logger.log(fps + "fps");
    fps = 0;
    time = System.currentTimeMillis();
    } else {
if (fb != null) {
    fb = null;
} catch (Exception e) {
    Logger.log(e, Logger.MESSAGE);
Any guess what it could be? Any chance to get the relevant jpct code lines?

Cheers, Marc

Support / Re: Problem with FOV value
« on: October 04, 2011, 11:06:56 pm »
thank you for your answer!
Ok, tan of the angle, now it makes sense. Itīs only named tanFOV in the setter and I didnīt have a look at that. So, in actual degrees, the FOV is 51,34° as default?

Well, I had a look at Interact2D.reproject2D3DWS already, but somehow it doesnīt do what I need.

Example: I moved my finger on the screen by 17 Pixels in x-direction on the screen, indicating I want to translate the scene under my finger. Distance from camera to scene is 120. By what value do I have to translate my scene?

Answer: (tan(51,34°/2) * distance from camera to scene)*2 = width of current scene = ~115,35
Screen is 1280px wide, so every pixel on the screen corresponds to 0,09 voxel x-values in scene. Conversion should thus give me 0,09*17 = 1,53 in voxel x-direction.
The output from Interact2D always gives me negative values and also doesnīt deliver the right absolute values. Maybe Iīm just getting this conversion functions wrong?


Support / Problem with FOV value
« on: October 04, 2011, 02:56:52 pm »
Hi there,

Iīm developing an Android app and am currently facing the problem of converting screen in world(or scene) coordinates.
Anyways, I need to know the FOV value in degrees or maybe rad for this, but all jpct gives is a (proprietary?) FOV value that I canīt decode right. What exactly is this jpct FOV value and how can I calculate it back to deg or rad?
Additionally, it confuses me that jpct assigns a FOV to the x-axis. In standard OpenGL, the y-axis is been given the FOV and the x-axis FOV is calculated from it, so itīs exactly the other way round. Any ideas why?


Pages: [1]