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 - Tishu

Pages: 1 [2] 3
16
Support / Re: Texture repeat
« on: September 11, 2011, 08:07:48 pm »
I am not sure what you mean by

Quote
I think if you use one single bitmap which you would manually tile in an image editor, and slap it on just one flat UVed object, it would look nicer, and improve the fps...

Do you mean you would rather repeat the texture in a photoshop like program to get approximately the size of the plane rather than making the renderer repeat it at runtime?

17
Support / Re: Texture repeat
« on: September 11, 2011, 07:39:02 pm »
I tweaked a bit the bitmaps (size, JPEG compression, seamless) and it looks quite good now. I also followed your advice on the "onSurfaceCreated". That didn't make a noticeable performance change but am convinced that it is better to put the code there.

Performance is better now but there is a huge correlation between performance and the amount of time  textures are repeated. I guess this is good in a way, it makes me bear in mind technical limitations rather than just making everything "hi-res" :)



Thx
Nicolas

18
Support / Re: Texture repeat
« on: September 11, 2011, 06:46:20 pm »
Wow, your code just produces awesome results. Only problem is that FPS has taken a serious hit. I'm not stretching the planes too much though, ie there's not a crazy amount of repeats. Any idea why this?

Thx
Nicolas

19
Support / Re: Texture repeat
« on: September 11, 2011, 06:01:10 pm »
Thank you for your suggestion. I ended up "gridifying" all my large planes, and marking all edges as "seem" in blender. After UVMap, it looks much better:



I will spend a bit more time on it to see if I can fix the few border artifacts, if not, will try your suggestion.

Thanks!
Nicolas

20
Support / Re: Texture repeat
« on: September 11, 2011, 04:40:30 pm »
Anyone has an idea?

I tried to look for texturing tutorials for JPCT and coulnd't find much. Does ayone have a link to share?

Thx
Nicolas

21
Support / Texture repeat
« on: September 10, 2011, 11:27:46 am »
Hello,

I am building a 3D world, and in Blender I have set the textures to repeat over my models. I get the following in Blender:



ie the texture does repeat.

In JPCT however, the texture seems to strecth and distort:



I have not explicitely set any repeat attribute in JPCT as I could not find any (thought it would read from the 3DS file). I load the texture and the model with the following codes.

Code: [Select]
final Texture sea = new Texture(Flight.getInstance().getResources().openRawResource(R.raw.seaday));
TextureManager.getInstance().addTexture("seaday.jpg", sea);

Code: [Select]
Object3D[] model = Loader.load3DS(file, scale);
Object3D o3d = new Object3D(0);
Object3D temp = null;
for (int i = 0; i < model.length; i++) {
    temp = model[i];
    temp.setCenter(SimpleVector.ORIGIN);
    temp.rotateX((float)( -.5*Math.PI));
    temp.rotateMesh();
    temp.setRotationMatrix(new Matrix());
    o3d = Object3D.mergeObjects(o3d, temp);
    o3d.build();
}
return o3d;

Is there a way to specify a repeat ratio in JPCT (something like "wrapTextureSpherical" but with repeat?)

Thanks
Nicolas

22
Support / Re: Collision between two complex objects?
« on: September 05, 2011, 11:37:02 pm »
That you very much for your help. It made it a lot clearer to me.

I have now pretty much worked how the transformed center of the plane collides with the ground in my code, it will be possible for me to finish the job with the few tips on your last message.

Regards,
Nicolas

23
Support / Re: Collision between two complex objects?
« on: September 05, 2011, 10:20:28 pm »
I tried to use plane.getTransformedCenter as you recommended and I agree the figures I see make much more sense. I am not sure I understand why however.

If org is the position in world space from where the translation starts, it seems correct to me to start translating the ground from where it is (ground.getTransformedCenter()) with a vector which is opposite to the plane's movement. This is equivalent as moving the plane towards the ground with its own motion vector.

Moreover, if I calculate such distance from the plane center, this does not allow me to do what I was initially trying to do which is to find out which part of the plane hits the ground.

24
Support / Re: Collision between two complex objects?
« on: September 05, 2011, 10:02:46 pm »
This might be why! Perhaps I misunderstood the arguments of this method:

Code: [Select]
public float calcMinDistance(SimpleVector org, SimpleVector dr)
Returns the minimal distance to some polygon of the object from a particular position vector looking into a specific direction.

org - a SimpleVector containing the position vector
dr - a SimpleVector containing the direction vector

I assumed that org was the initial position of the ground, and from there it tried to move dr. If it hit any other polygon of the world, that's a collision.

I agree that in this case it does not make much sense passing the first argument, but what should it be then?

EDIT: Or should I calculate the distance from the center of the plane? In that case, how do I know whether it is the wing or the landing gear that has hit the ground?

Thx

25
Support / Re: Collision between two complex objects?
« on: September 05, 2011, 09:49:13 pm »
I agree that on my picture there is no collision - it was more to show a generic case. But even when I fly trough the object representing the water, I do not get a collision.

I have tried your suggestion. I changed the collision detection method to:

Code: [Select]
public float checkCollision(SimpleVector sv)
{
sv = sv.normalize();
final float minDist = ground.calcMinDistance(ground.getTransformedCenter(), sv);
if(!(minDist == Object3D.COLLISION_NONE))
{
Log.e("Collision", Float.toString(minDist));
}
return null;
}

Collision is almost never triggered when I fly trough the plane, but is sometimes randomely triggered for some minDist figures around 50.

I strongly suspect that I am doing something wrong, perhaps with the coordinates system, but could not find anything obvious. I have even changed the translation vector sv to always point straight up towards the plane.

Would you mind if I sent you my two models? Without textures, but they should still load properly. I load them via the code pasted a few messages above. For the plane, I do not set any collision attributes. For the ground, I set

Code: [Select]
ground.setCollisionMode(Object3D.COLLISION_CHECK_OTHERS);
ground.setCollisionOptimization(Object3D.COLLISION_DETECTION_OPTIMIZED);

Many thanks
Nicolas

26
Support / Re: Collision between two complex objects?
« on: September 05, 2011, 08:50:00 pm »
Thanks for your quick reply. Much appreciated. This seems to be what I am looking for. I am now trying to make it work in practice, and am having a few problems. The values returned by this method do not make sense to me, I must be doing something wrong. As per the below picture, I have a plane (black), the translation vector for the next frame (red) and the ground (blue).



I have enabled COLLISION_CHECK_OTHER on the ground, with collision improvement. To check collision, I use the following code:

Code: [Select]
public float checkCollision(SimpleVector sv)
{
// sv is the opposite the plane movement
final int id = ground.checkForCollision(sv, 10);
if(id != Object3D.NO_OBJECT)
{
return ground.calcMinDistance(ground.getTransformedCenter(), sv);
}
return Object3D.NO_OBJECT;
}

In this scenario, the collision is never detected (id is always Object3D.NO_OBJECT even if I fly trough the sea). Also when I check values for the min distance, it varies between 1E12 (max float I guess) and figures between 50 and 200 depending on the areas I fly over but not depending on my altitude. I would like to remind that the ground is a set of Object3D laoded via 3DS and regrouped via the following code, but should still behave as an atomic object right?

Code: [Select]
private static Object3D loadModel(InputStream file, float scale) {
Object3D[] model = Loader.load3DS(file, scale);
        Object3D o3d = new Object3D(0);
        Object3D temp = null;
        for (int i = 0; i < model.length; i++) {
temp = model[i];
temp.setCenter(SimpleVector.ORIGIN);
temp.rotateX((float)( -.5*Math.PI));
temp.rotateMesh();
temp.setRotationMatrix(new Matrix());
o3d = Object3D.mergeObjects(o3d, temp);
o3d.build();
}
        return o3d;
}

Thanks for you patience
Nicolas

27
Support / Collision between two complex objects?
« on: September 05, 2011, 07:57:16 pm »
Hello

I have been reading the documentation on collisions, as well as existing resource on this forum, but could not find my answer. I am trying to detect collisions between a complex object (a plane) and the ground which can be considered as a plane (it is actually an assembly of several planes grouped into one Object3D loaded via the 3DS loader).

From what I have read, if I do not want to consider the plane as an ellipsoid (I need to be accurate for example for the landing gear, the wings etc - I have tried the Ellipsoid but this did not provide accurate enough results), I need to set the ground to COLLISION_OTHERS and check collisions from it calling "checkCollision". I have now two options (let's say two as Spherical and Ellipsoid are roughly the same here).

- If I check for collisions using a casted ray from the ground, my understanding is that this does not return the new translation vector which is collision free. This is no good to me as the plane needs to "fit" the ground on landing.
- If I check for collisions using an Ellipsoid, I will need to "wrap" the ground into an Ellipsoid. Problem is that the ground is huge compared to the plane and this would not be accurate enough.

What I would be looking for really is to calculate collisions between two complex Object3D. Is this possible with the current JPCT framework and have I missed something? Or should I look for another collision detector framwork?

Thanks in advance.
Nicolas

28
Bugs / Re: No texture when loading multiple 3DS
« on: July 31, 2011, 11:45:41 pm »
Thanks for your advice, it seems to help. I can't explain why in the previous case it was working when the camera was set to view the airport and not when it was set on the plane.

I will let you know if I see other related issues.

Regards
Tishu

29
Bugs / Re: No texture when loading multiple 3DS
« on: July 31, 2011, 10:24:18 pm »
EgonOlsen,

I sent you a workspace in a private message. You should see the behaviour described above..

Thanks
Tishu

30
Bugs / Re: No texture when loading multiple 3DS
« on: July 31, 2011, 09:47:30 pm »
Right, while trying to set up a test case I think I understood what was wrong. I don't know if I am not using the API correctly of if there is an issue with it.

I have three objects in my world
- A plane
- A landing strip
- A control tower

On every frame, I draw the plane, then translate/rotate the landing strip and the control tower. On the first frame you cannot see either of these, but you can see the plane.
The camera is always looking at (0,0,0), where my plane is, and where my airport is at the beginning, when the models are loaded.
I setup the camera this way to always see the plane from behind:

Code: [Select]
final Camera cam = world.getCamera();
final SimpleVector pos = new SimpleVector();
pos.set(plane.getTransformedCenter());
pos.y = -2;
pos.z = 10;
cam.setPosition(pos);
cam.setFOV(60f);
cam.lookAt(plane.getTransformedCenter());

When I do it like this, after flying around with the plane, when the airport comes visible, it is not textured. When I place the camera on the original position of the airport however (which is the same as the model is at (0,0,0) when the stuff is initialised), it appears textured.

Code: [Select]
final Camera cam = world.getCamera();
final SimpleVector pos = new SimpleVector();
pos.set(strip.getTransformedCenter());
pos.y = -2;
pos.z = 10;
cam.setPosition(pos);
cam.setFOV(60f);
cam.lookAt(strip.getTransformedCenter());

I suppose this is something to do with lazy texturing - do not texture something that is not visible. In this case however, either I am not using the API correcly (should I reset the camera on every frame?) or there is an issue when those become visible.

I hope I was clear - this was a bit tricky to explain.

Thx
Tishu

Pages: 1 [2] 3