www.jpct.net

jPCT-AE - a 3d engine for Android => Support => Topic started by: mAlinka on November 19, 2015, 07:33:05 am

Title: Re: 3ds max tips
Post by: mAlinka on November 19, 2015, 07:33:05 am
Hello.
I just started to learn JPCT-AE enjine and have a problem with models exported from 3DS Max. When I try to load them call to Loader.load3DS(...) just hangs.
Log output:
Quote
11-19 01:15:32.238: I/jPCT-AE(1056): Loading file from InputStream
11-19 01:15:32.238: I/jPCT-AE(1056): Expanding buffers...16384 bytes
11-19 01:15:32.358: I/jPCT-AE(1056): File from InputStream loaded...13681 bytes
11-19 01:15:32.438: I/jPCT-AE(1056): Processing object from 3DS-file: Box001
11-19 01:15:32.778: I/jPCT-AE(1056): Object 'Box001_jPCT0' created using 12 polygons and 8 vertices.
11-19 01:15:32.788: I/jPCT-AE(1056): Processing object from 3DS-file: Box002
11-19 01:15:33.028: I/jPCT-AE(1056): Object 'Box002_jPCT1' created using 12 polygons and 8 vertices.
11-19 01:15:33.028: I/jPCT-AE(1056): Processing object from 3DS-file: Box003
11-19 01:15:33.528: I/jPCT-AE(1056): Object 'Box003_jPCT2' created using 12 polygons and 8 vertices.
11-19 01:15:33.528: I/jPCT-AE(1056): Processing object from 3DS-file: Box004
11-19 01:15:34.098: I/jPCT-AE(1056): Object 'Box004_jPCT3' created using 12 polygons and 8 vertices.
11-19 01:15:34.098: I/jPCT-AE(1056): Processing object from 3DS-file: Box005
11-19 01:15:34.348: I/jPCT-AE(1056): Object 'Box005_jPCT4' created using 12 polygons and 8 vertices.
11-19 01:15:34.348: I/jPCT-AE(1056): Processing object from 3DS-file: Box006
11-19 01:15:34.718: I/jPCT-AE(1056): Name in hierarchy found: Box001
And that's all.
Could you suggest me please how to solve this?
Title: Re: Re: 3ds max tips
Post by: EgonOlsen on November 19, 2015, 08:28:33 am
Can you provide me with the model to check this out?
Title: Re: Re: 3ds max tips
Post by: mAlinka on November 19, 2015, 09:38:49 am
Yes of course. Thank you for fast reply!
The model is very simple. We made it just for test
Title: Re: 3ds max tips
Post by: EgonOlsen on November 19, 2015, 06:34:11 pm
Strange. This file contains a chunk with a size of 0, which is not right IMHO. It should at least have the size that it takes to indicate type and size, i.e. 6 bytes. I've uploaded a version that should handle this case here: http://jpct.de/download/beta/jpct_ae.jar (http://jpct.de/download/beta/jpct_ae.jar)
Title: Re: 3ds max tips
Post by: mAlinka on November 20, 2015, 07:38:42 am
I tried it, but unfortunatelly loading still hangs  :(
Title: Re: 3ds max tips
Post by: EgonOlsen on November 20, 2015, 08:35:04 am
 ??? Strange...can you please try the latest official release from yesterday instead: http://www.jpct.net/download.html (http://www.jpct.net/download.html)?

Are you REALLY sure that you've replaced the jar?
Title: Re: 3ds max tips
Post by: mAlinka on November 20, 2015, 01:52:48 pm
It was my first assumption that I used old jar. So I've checked it twice.
Tried the release version and had no success((

May be there is something else in model file that abnormally? Is there some necessary rules how to create and export model from 3DS Max to make it valid?
Title: Re: 3ds max tips
Post by: EgonOlsen on November 20, 2015, 02:38:19 pm
I loaded the model without a problem at home with the new version. I'll check later and report back...
Title: Re: 3ds max tips
Post by: EgonOlsen on November 20, 2015, 05:24:58 pm
It was caused by me being stupid. Try this jar: http://jpct.de/download/beta/jpct_ae.jar (http://jpct.de/download/beta/jpct_ae.jar)
Title: Re: 3ds max tips
Post by: mAlinka on November 23, 2015, 09:24:11 am
Now the loading stage is passed without hangs but the the object is not displaying.
Here is two logs: the first one is for this problem model and second one is for model that had't any problem with loading
Quote
11-23 02:16:25.795: I/jPCT-AE(1329): Loading file from InputStream
11-23 02:16:25.805: I/jPCT-AE(1329): Expanding buffers...16384 bytes
11-23 02:16:25.805: I/jPCT-AE(1329): File from InputStream loaded...13681 bytes
11-23 02:16:25.805: I/jPCT-AE(1329): Processing object from 3DS-file: Box001
11-23 02:16:25.815: I/jPCT-AE(1329): Object 'Box001_jPCT0' created using 12 polygons and 8 vertices.
11-23 02:16:25.815: I/jPCT-AE(1329): Processing object from 3DS-file: Box002
11-23 02:16:25.815: I/jPCT-AE(1329): Object 'Box002_jPCT1' created using 12 polygons and 8 vertices.
11-23 02:16:25.815: I/jPCT-AE(1329): Processing object from 3DS-file: Box003
11-23 02:16:25.945: I/jPCT-AE(1329): Object 'Box003_jPCT2' created using 12 polygons and 8 vertices.
11-23 02:16:25.945: I/jPCT-AE(1329): Processing object from 3DS-file: Box004
11-23 02:16:25.955: I/jPCT-AE(1329): Object 'Box004_jPCT3' created using 12 polygons and 8 vertices.
11-23 02:16:25.955: I/jPCT-AE(1329): Processing object from 3DS-file: Box005
11-23 02:16:25.965: I/jPCT-AE(1329): Object 'Box005_jPCT4' created using 12 polygons and 8 vertices.
11-23 02:16:25.965: I/jPCT-AE(1329): Processing object from 3DS-file: Box006
11-23 02:16:25.965: I/jPCT-AE(1329): Name in hierarchy found: Box001
11-23 02:16:25.965: I/jPCT-AE(1329): Object 'Box006_jPCT5' created using 12 polygons and 8 vertices.
11-23 02:16:26.425: I/jPCT-AE(1329): Normal vectors calculated in 183ms!
11-23 02:16:32.335: I/jPCT-AE(1329): Memory usage before compacting: 7570 KB used out of 10152 KB. Max. memory available to the VM is 49152 KB.
11-23 02:16:32.705: I/jPCT-AE(1329): Subobject of object 12/object14 compiled to indexed fixed point data using 216/120 vertices in 246ms!
11-23 02:16:32.705: I/jPCT-AE(1329): Object 12/object14 compiled to 1 subobjects in 379ms!
11-23 02:16:34.015: I/jPCT-AE(1329): Memory usage after compacting: 7328 KB used out of 10152 KB. Max. memory available to the VM is 49152 KB.

Quote
11-23 02:50:56.995: I/jPCT-AE(1409): Loading file from InputStream
11-23 02:50:56.995: I/jPCT-AE(1409): Expanding buffers...16384 bytes
11-23 02:50:56.995: I/jPCT-AE(1409): Expanding buffers...24576 bytes
11-23 02:50:56.995: I/jPCT-AE(1409): File from InputStream loaded...19295 bytes
11-23 02:50:56.995: I/jPCT-AE(1409): Processing new material bear!
11-23 02:50:57.005: I/jPCT-AE(1409): Texture named BEAR_DIFF.PN added to TextureManager!
11-23 02:50:57.005: I/jPCT-AE(1409): Processing new material bear_eyes!
11-23 02:50:57.005: I/jPCT-AE(1409): Processing new material pupil!
11-23 02:50:57.005: I/jPCT-AE(1409): Processing new material bear_nose!
11-23 02:50:57.005: I/jPCT-AE(1409): Processing object from 3DS-file: bear
11-23 02:50:57.235: I/jPCT-AE(1409): Name in hierarchy found: bear
11-23 02:50:58.415: I/jPCT-AE(1409): Object 'bear_jPCT0' created using 1004 polygons and 564 vertices.
11-23 02:51:00.205: I/jPCT-AE(1409): Normal vectors calculated in 1605ms!
11-23 02:51:03.085: I/jPCT-AE(1409): Memory usage before compacting: 8168 KB used out of 10244 KB. Max. memory available to the VM is 49152 KB.
11-23 02:51:04.825: I/jPCT-AE(1409): Memory usage after compacting: 7641 KB used out of 10244 KB. Max. memory available to the VM is 49152 KB.
11-23 02:51:05.265: I/jPCT-AE(1409): Subobject of object 2/object4 compiled to indexed fixed point data using 2727/488 vertices in 1548ms!
11-23 02:51:05.325: I/jPCT-AE(1409): Subobject of object 2/object4 compiled to indexed fixed point data using 285/76 vertices in 57ms!
11-23 02:51:05.335: I/jPCT-AE(1409): Object 2/object4 compiled to 2 subobjects in 2245ms!
11-23 02:51:05.475: I/jPCT-AE(1409): Creating buffers...
11-23 02:51:05.545: I/jPCT-AE(1409): VBO created for object 'object4'
11-23 02:51:05.925: I/jPCT-AE(1409): Creating buffers...
11-23 02:51:05.935: I/jPCT-AE(1409): VBO created for object 'object4'
Title: Re: 3ds max tips
Post by: EgonOlsen on November 23, 2015, 10:09:00 am
Log output looks fine. There's no guarantee that a loaded model is located and scaled correctly so that it's visible without rescaling or translating it. A first step would be to print out the result of Object3D.getCenter() to see there the object is located in object space. It should be somewhere around the origin, but some models are way off.
Title: Re: 3ds max tips
Post by: mAlinka on November 23, 2015, 12:44:36 pm
Yes, you are right. The object was placed too far away from camera. Thank you so much for help!
Title: Re: 3ds max tips
Post by: mAlinka on December 15, 2015, 11:25:20 am
Hello!
Its me again. I need a little advice. I faced with the same problem: model has successfully loaded but not visible on the scene.

Model parameters are:
Origin : (0.0,0.0,0.0)
Center (Transformed center) : (-0.38567856,-2007.5032,-570.4014)
Bounding box : [-1455.0249, 1380.9241, -2979.1418, 174.60309, -944.2183, 26.167683]

Camera position is (0.0,-1402.2693,-5674.8354) and it looks at model's transformed center.

I supposed that model should be in camera's scope.
May the problem be not in model location? Some wrong materials or something else?
(I've attached the model file if you need to try to load it.)
Title: Re: 3ds max tips
Post by: EgonOlsen on December 15, 2015, 12:23:21 pm
-5674.8354 is far beyond the default clipping distance. Try to adjust http://www.jpct.net/jpct-ae/doc/com/threed/jpct/World.html#setClippingPlanes(float, float) (http://www.jpct.net/jpct-ae/doc/com/threed/jpct/World.html#setClippingPlanes(float, float)) to a far plane of maybe 10.000 and see if that helps.
Title: Re: 3ds max tips
Post by: mAlinka on December 15, 2015, 01:17:36 pm
The object is still invisible(
Title: Re: 3ds max tips
Post by: EgonOlsen on December 15, 2015, 01:44:03 pm
In that case, it's most likely just out of sight. What does http://www.jpct.net/jpct-ae/doc/com/threed/jpct/Object3D.html#wasVisible() (http://www.jpct.net/jpct-ae/doc/com/threed/jpct/Object3D.html#wasVisible()) return?
Title: Re: 3ds max tips
Post by: mAlinka on December 15, 2015, 02:44:33 pm
It returns false. So how can I configure my camera to make it capture the object? I mean what is the general practice of camera set up to be sure that the object will be visible?
Title: Re: 3ds max tips
Post by: EgonOlsen on December 15, 2015, 03:12:08 pm
lookAt() at the transformed center is usually ok...have you tried to increase the far plane even further? Like 20.000 or 100.000?
Title: Re: 3ds max tips
Post by: mAlinka on December 16, 2015, 08:17:12 am
Yes, and it has no effect.
Title: Re: 3ds max tips
Post by: EgonOlsen on December 16, 2015, 08:28:58 am
Can't you make sure that the object is located at the origin and that the camera looks straight to it? With your current scene setup, it's a bit more complicated than it needs to be...
Title: Re: 3ds max tips
Post by: mAlinka on December 16, 2015, 09:38:09 am
I tried another way - make camera look at (0, 0, 0) and then translate my object to put its transformed center to (0, 0, 0). After that object.wasVisible() starts return true, but screen is still empty.
Title: Re: 3ds max tips
Post by: EgonOlsen on December 16, 2015, 10:30:11 am
Maybe the object is so large that you are standing inside it? Try another scale.
Title: Re: 3ds max tips
Post by: EgonOlsen on December 16, 2015, 10:32:22 am
...or maybe you are rendering a dark object in front of a dark background or something like that. It always helped me to clear the background in some color like blue or red in such cases.
Title: Re: 3ds max tips
Post by: mAlinka on December 16, 2015, 01:55:52 pm
The scene has a transparent background and there is camera preview behind it.
I tried scaling. It did not help.

I asked our designer to scale down the model and now it has such properties:
bounding box : [-56.823803, 54.82773, -113.101685, -20.355627, -29.19638, 7.774193];
transformed center : (-0.74186236, -83.03801, -14.0675335);
origin : (0.0, 0.0, 0.0).

Camera position is (0.0,-66.72865,-168.31546) now ant it looks at (0.0,-66.72865,0.0).

Calling to wasVisible() returns true without any additional transformations (no scaling, no translation). And object is still invisible...
Title: Re: 3ds max tips
Post by: EgonOlsen on December 16, 2015, 04:25:30 pm
Have you tried to set the transparency to -1? Some files contain bogus alpha values for the model and jPCT-AE reads and uses those.
Title: Re: 3ds max tips
Post by: EgonOlsen on December 16, 2015, 05:59:18 pm
I just dropped the model in some basic HelloWorld example and it displayed just fine. Looks like as if the importer can't read its diffuse color information, so it ended up all black. But apart from that, all was well. How are you loading the model/adding it to the world?
Title: Re: 3ds max tips
Post by: mAlinka on December 17, 2015, 08:02:03 am
Here is my code.
World creation:
Code: [Select]
CurrentWorld = new World();
CurrentWorld.setAmbientLight(20, 20, 20);
CurrentWorld.setClippingPlanes(1, 100000);    //added after your recomendation

Object loading:
Code: [Select]
Object3D[] subobjects = null;
try
{
subobjects = Loader.load3DS(stream, DefaultScale);
}
catch(Exception ex)
{
LogSystem.LogException(TAG, "Loading model raised an exception", ex);
}

if(subobjects != null)
{
Object3D wholeObject  = new Object3D(0);

Object3D subobject = null;
for (int i = 0; i < subobjects.length; i++)
{
subobject = subobjects[i];
subobject.setCenter(SimpleVector.ORIGIN);
subobject.rotateX((float)( -.5 * Math.PI));
subobject.rotateMesh();
subobject.setRotationMatrix(new Matrix());
wholeObject = Object3D.mergeObjects(wholeObject, subobject);
}

        wholeObject.calcBoundingBox();
wholeObject.calcNormals();
wholeObject.setName("myself");
        wholeObject.build();
        return wholeObject;
}

Object adding to scene:
Code: [Select]
CurrentWorld.addObject(object);
object.setCollisionMode(Object3D.COLLISION_CHECK_OTHERS);
object.setTransparency(-1);       //added after your recomendation

Camera setup:
Code: [Select]
float[] box = object.getMesh().getBoundingBox();
SimpleVector camPos = CurrentWorld.getCamera().getPosition();
float objectHeight = box[3] - box[2];
float newZPos = box[4] - objectHeight * 1.5f;
float halfHeightPos = box[3] - objectHeight  * 0.5f;

SimpleVector newPos = new SimpleVector(camPos.x, halfHeightPos, newZPos);  //trying to put camera at the half of objects height and in front of object by 1.5 of height
CurrentWorld.getCamera().setPosition(newPos);

SimpleVector lookPos = new SimpleVector(camPos.x, halfHeightPos, 0);
CurrentWorld.getCamera().lookAt(lookPos);            //look at object transform center also been tried

It works fine for other models. Some of them were exported from Blender and some from 3Ds Max as this one.
Title: Re: 3ds max tips
Post by: EgonOlsen on December 17, 2015, 08:31:33 am
Looks ok at first glance. I would take a step back and use a modified HelloWorld example to see if the model actually renders at all. Maybe it's an entirely different issue than what you think it is...