Author Topic: Re: 3ds max tips  (Read 1745 times)

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11777
    • View Profile
    • http://www.jpct.net
Re: 3ds max tips
« Reply #15 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() return?

Offline mAlinka

  • byte
  • *
  • Posts: 21
    • View Profile
Re: 3ds max tips
« Reply #16 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?

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11777
    • View Profile
    • http://www.jpct.net
Re: 3ds max tips
« Reply #17 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?

Offline mAlinka

  • byte
  • *
  • Posts: 21
    • View Profile
Re: 3ds max tips
« Reply #18 on: December 16, 2015, 08:17:12 am »
Yes, and it has no effect.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11777
    • View Profile
    • http://www.jpct.net
Re: 3ds max tips
« Reply #19 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...

Offline mAlinka

  • byte
  • *
  • Posts: 21
    • View Profile
Re: 3ds max tips
« Reply #20 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.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11777
    • View Profile
    • http://www.jpct.net
Re: 3ds max tips
« Reply #21 on: December 16, 2015, 10:30:11 am »
Maybe the object is so large that you are standing inside it? Try another scale.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11777
    • View Profile
    • http://www.jpct.net
Re: 3ds max tips
« Reply #22 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.

Offline mAlinka

  • byte
  • *
  • Posts: 21
    • View Profile
Re: 3ds max tips
« Reply #23 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...
« Last Edit: December 16, 2015, 01:57:33 pm by mAlinka »

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11777
    • View Profile
    • http://www.jpct.net
Re: 3ds max tips
« Reply #24 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.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11777
    • View Profile
    • http://www.jpct.net
Re: 3ds max tips
« Reply #25 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?

Offline mAlinka

  • byte
  • *
  • Posts: 21
    • View Profile
Re: 3ds max tips
« Reply #26 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.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11777
    • View Profile
    • http://www.jpct.net
Re: 3ds max tips
« Reply #27 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...