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]
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!

Cheers,
Marc

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

Iīve got this following mini project: http://db.tt/aslRLtOp
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

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

4
Hi,

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)?

Cheers,
Marc

5
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
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;
}
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!

6
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?

Cheers,
Marc

7
Support / Re: Scale around a center point?
« on: October 10, 2011, 10:25:14 pm »
Still not the wished effect...it 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]
//mesh.setVertexController:
A VertexController is the only way for an application to modify the vertex data of jPCT's meshes after build-time.
Cheers,
Marc

8
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);
world.addObject(background);

//in onDrawFrame
background.translate(100, 0, 0);
background.translateMesh();
background.scale(1.01f);
background.translate(-100, 0, 0);
background.translateMesh();

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!
Marc


9
Support / Re: Scale around a center point?
« on: October 09, 2011, 08:50:24 pm »
oh ok...so, 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...

Cheers,
Marc

10
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.

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

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.

Cheers,
Marc

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

13
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(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)

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());
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);
}

Code: [Select]
@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);
}
    }
Any guess what it could be? Any chance to get the relevant jpct code lines?

Cheers, Marc

14
Support / Re: Problem with FOV value
« on: October 04, 2011, 11:06:56 pm »
Hi,
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?

Cheers,
Marc

15
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?

Cheers,
Marc

Pages: [1]