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

Pages: 1 [2]
16
Support / Re: Animating
« on: September 07, 2011, 10:03:07 am »
Cheers for your suggestion - it seems to have improved the smoothness of the animation already. I'll be able to better see how it goes when I get home to my desktop next week. It usually runs at 20-30 fps on that.

A snippet of my code just confirm I am actually implementing what you suggested:

Code: [Select]
/**
* This method is used for animation - this is the event loop.
*/
public void onDrawFrame(GL10 gl) {

Calendar now = Calendar.getInstance();

if ( previousFrameTime < 0 )
{
previousFrameTime = now.getTimeInMillis();
}
else
{
if ( cameraX < destinationX-1 || cameraX > destinationX+1 )
{
long millisecondsPassed = now.getTimeInMillis() - previousFrameTime;

Float xModifier = 1f;

if ( cameraX > destinationX )
{
xModifier = -1f;
}

cameraX = cameraX + (0.01f * xModifier * millisecondsPassed);
}
previousFrameTime = now.getTimeInMillis();
}

camera.setPosition(cameraX,cameraY,cameraZ-10);

17
Support / Animating
« on: September 07, 2011, 07:03:03 am »
This isn't a question specifically about JPCT-AE and more about GLSurfaceView.

I have a 5x5 grid of tiles. If I touch one of the tiles on screen the camera re-adjusts so that it is centered on that tile. I am trying to animate this process so that it is a smooth transition rather than instant.

To do this I've set up two sets of co-ordinates:

1) The destination x, y, and z co-ords.
2) The current camera co-ordinates

I'm only looking at the x axis currently. In the onDrawFrame() method I do a check. If the current camera X position is not (roughly) equal to the destination X position, then I increment/decrement the current camera X co-ordinate by some small amount (0.1 units for example) to bring it closer to the destination.

My thinking is that it will continue to increment or decrement itself until it is equal to the destination X position, in which case we've reached our destination and no more animation is required.

My problem is:

- If I have the increment amount to something small (cameraX = cameraX + 0.001) then the animation is smooth but extremely SLOW.
- If I have the increment amount to something bigger (cameraX = cameraX + 1) then the animation is fast enough but extremely CHUNKY.

Is my approach valid? How do I implement smooth camera movement animation?

Any help would be much appreciated.

FYI my animation code is below. The modifier is either +1 or -1 depending if the destination is to the left or the right of the current position.

Code: [Select]
public void onDrawFrame(GL10 gl) {

if ( cameraX < destinationX-0.1 || cameraX > destinationX+0.1 )
{
Float xModifier = 1f;

if ( cameraX > destinationX )
{
xModifier = -1f;
}

cameraX = cameraX + (1f * xModifier);
}

camera.setPosition(cameraX,cameraY,cameraZ-10);

...

In my AVD I'm getting only 9 FPS on average. It's a Mac laptop (I'm away on holiday). Not sure if this is related to the chunkiness.

18
Support / Re: Axes in JPCT and 3DS Max
« on: August 25, 2011, 10:05:45 pm »
Thanks Egon - that's what I was doing (minus the rotateMesh()) and its working. I was just thinking if there were an easier way to do it, as I'm going to be adding 50+ 3DS models to my scene and thought there might be an easier way to handle this without rotating each object (some kind of global world rotate).

Thomas - I will talk to my friend and do some research around changing the co-ordinate system in 3DS Max. In the end, it might be easier for me to deal with the difference using rotations because he's used max for years and habitually considers the positive z axis as "up".

Cheers for your input, it confirms my approach is at least valid.

19
Support / Re: object is null while object picking
« on: August 25, 2011, 12:19:17 pm »
I may have had the same problem, and ended up removing the status and title bars from my program (which I would have done anyway for aesthetics):

Code: [Select]
protected void onCreate(Bundle savedInstanceState)
{
// Disable the title bar or it will throw off our picking coordinates.
requestWindowFeature(Window.FEATURE_NO_TITLE);

// Disable the status bar or it will throw off our picking coordinates.
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);

... (etc)

20
Support / Axes in JPCT and 3DS Max
« on: August 25, 2011, 12:14:23 pm »
Hi all,

Apologies if I'm asking a question already covered in previous posts. I've looked around but not found the discussion I'm after.

I have a friend developing models in 3DS Max and I am importing them and using them in JPCT. Naturally the co-ordinate system is quite different:



What's the best way of handling the difference in axes? When he sends me a model which is facing "forward" it is facing "down" to me and I see its feet (as per the difference in axes).

Is there a way to change the axes in JPCT? Or is it better practice to rotate each Object3D in my scene to fit the existing JPCT system?

Ideally I'd like to import models and have them show up as my colleague sees if this is possible.

21
Support / Re: Matching co-ordinate scale from JPCT and 3DS Max
« on: August 22, 2011, 11:23:03 am »
Thanks... I understand now. It is a silly question... So a 10x10 tile in 3DS will always be a 10x10 tile in OpenGL too... Makes sense.

22
Support / Re: Problem Loading Texture
« on: August 20, 2011, 02:33:45 am »
And if you use the asset folder it's just:

Code: [Select]
// Create a stream to grab the data from the 3DS model file.
AssetManager.AssetInputStream inStream = (AssetInputStream) assetManager.open(fileName);

// Insert all of the models from the file into an array of Object3D's.
tempObjects = Loader.load3DS(inStream, 1.0f);

23
Support / Matching co-ordinate scale from JPCT and 3DS Max
« on: August 20, 2011, 01:42:06 am »
My friend is creating tiles for a game we're developing for Android.

In JPCT-AE/OpenGL I want each tile to be exactly 10x10 units in size (so I could place one tile at (0,0,0), (0,-10,0),(10,-10,0),(10,0,0) (for example).

Has anyone discovered a way to synchronise the units that he sees in 3DS Max to the measurements I have in JPCT-AE or vice versa? I want him to be able to make the tile to the correct scale for me to use or alternatively a way I can scale his tile to be perfect 10x10 units in size on the zx plane.

Or have any resources explaining how the unit systems work in the Open GL Cartesian Co-ordinate system?

I want these tiles to be perfectly flush with each other.

Many thanks,

Stephen

24
Support / Re: Behaviour of World.addObject() method
« on: August 20, 2011, 01:34:43 am »
Thanks for your answer. The issue was that my modeller wasn't choosing an origin for the models, so they were being place far away in the world space from where I expected them to be.

25
Support / Behaviour of World.addObject() method
« on: August 18, 2011, 10:21:50 pm »
Hi all,

I've imported a 3DS model created by a friend which is a flat map-like model to be used as the basis for my level.

Once I've created it and I call world.addObject(level1map); what is the default position in world space at which the object is added? The origin?

And how does it place the object? Which vertex does it choose to position at the origin/start point? i.e. does it start from the lowest x, highest y, lowest z co-ordinate or something? Or is there a "centre" property in a 3DS model?

At the moment its centred at 717,-83,95 and I don't know why.

(In writing this I think I might know why this is happening... I'm scaling the model to 1% of its original size which is my problem - if I am going to scale it I probably need to find the "centre" of the model and place it on the origin first if I want it to sit at 0,0,0 in world space).

Any advice / points to information around how to translate and find the centre of an object in worldspace would be much appreciated.

FYI I'm new to 3D modelling in Android, but I have done two basic Open GL projects using GL/GLU/GLUT in the distant past.

Pages: 1 [2]