jPCT-AE - a 3d engine for Android > Support

How to force object creation?

(1/2) > >>

zbych:
Hi.
When I create my scene some objects are not created immediately, they are created when camera get closer to them (or camera is pointing on them not sure).
I want to avoid it, I want to force to create VBOs for all objects on scene. Is any possiblity to do that (beside moving camera to different locations)?

EgonOlsen:
Yes, you can use this: http://www.jpct.net/jpct-ae/doc/com/threed/jpct/World.html#compileAllObjects()

zbych:
I am still unable to resolve this problem. The objects are added to world and their visibility is set to FALSE. In the initialization procedure I want to force objects to be created, so I make something like this (the objects might appear behind camera):

--- Code: ---for(int i=0;i< _blocks.length; ++i) {
  _blocks[i].lBlockObj.setVisibility(true);
  _blocks[i].rBlockObj.setVisibility(true);
  _trackGen.getPositionAtTime(_tempVector, 2000, 0);
  _blocks[i].lBlockObj.root.clearTranslation();
  _blocks[i].lBlockObj.root.translate(_tempVector);
}
world.compileAllObjects();
world.renderScene(frameBuf);
world.draw(frameBuf);
clenup();

--- End code ---

but instead of series of messages "VBO created for object 'object' " I got:
I/jPCT-AE(7001): Additional visibility list (195) created with size: 512
The cleanup procedure makes objects invisible again. I am suspecting that this group of objects might freeze the game for a few seconds on slow devices. The objects have attached a shader so there is additional pause for shader compilation. Am I doing something wrong?

EgonOlsen:
Each call to draw() that's not followed by a display()-call in that iteration will cause a new display list to be created. If you then call display(), all these objects will be rendered as many times as you have called draw. It's actually not a good idea to call renderScene/draw from anywhere but onDrawFrame().
You should also call build() (i don't see this in your code snippet). So actually this should be more like a build/compileAllObjects-sequence.
Do these blocks share geometry?

zbych:
Maybe I have explained it wrong, but the problem is with "VBO creation". The objects are build and compiled but when I call FrameBuffer.draw() only for few of them are created VBOs, and during the game I can see all the time messages: "creating buffers" and "VBO created for object..", and in situation when the larger group of objects becomes visible for the camera, the slow devices are freezed for few seconds.

Navigation

[0] Message Index

[#] Next page

Go to full version