Main Menu
Menu

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.

Show posts Menu

Messages - nathan

#1
Support / Loader doesn't load 3DS normal vectors?
May 02, 2013, 06:34:50 AM
When I load a 3DS model, it seems that you re-calculate normal vectors:

QuoteI/jPCT-AE ( 8492): Object Cube_jPCT6 hasn't been build yet. Forcing build()!
I/jPCT-AE ( 8492): Normal vectors calculated in 5ms!

Why?  Is there a way I can prevent the normals from being rebuilt? Or are the normals not exporting properly? (Blender 2.6 doesn't have an option to tick for normals)

Actually, I just tried the same with OBJ, with "export normals" ticked.  And checking the OBJ file, the normals are written there.  So, what is going on?  Why won't it keep the normals from the object?
#2
Support / Re: Caching Vertex/UV/Normal data
May 02, 2013, 03:16:22 AM
Okay, that would work.  I wanted to have a MeshData class that handled all this by itself, but I guess I can just hold an Object3D inside my MeshData, and just use that to copy it. 
#3
Support / Caching Vertex/UV/Normal data
May 01, 2013, 10:41:20 PM
I don't want to open an InputStream to my 3DS model every time I want to instantiate a new one.  I would like to load that data somehow. From what I have read, there is no simple way of doing this.  Why?

I can get the UV coordinates from the Object3D.getPolygonManager().getTextureUV()
I can get the Vertex coordinates from the GenericVertexController.getSourceMesh()
I can get the Normal coordinates from the GenericVertexController.getSourceNormals()

Then I can flatten all the information into a bunch of float arrays. 

Then, I can instantiate new Object3D with the UV and Vertex information
But to get the normal data back in, I have to then make another GenericVertexController to modify the DestinationNormals.

Why is this so complicated? There should be a simple method to cache this information.
When I instantiate the new object, what should I put into the int[] index field?
#4
I want the buttons to appear at an angle, behind GL objects, etc.  How would I do this without it being a texture?
#5
Support / Rendering a Android View onto a texture
April 29, 2013, 03:27:00 AM
I would like to have a standard android View (such as Button), and render its graphics onto a texture.  I can create a bitmap, create a canvas for the bitmap, and have the view draw onto the bitmap through the canvas.  Then, I can take the bitmap and turn it into a texture.  This works fine. However I am having difficulties with updating that texture later (button was pressed, text changed, etc).  Of course I cannot create a new texture each time it changes.

I thought the solution was to change the render target of the framebuffer to the texture, and then blit the bitmap onto it.  However, this doesn't seem to work.

I think the problem is that I am using OpenGL ES 1.0.  What is the minimum version of OpenGL ES I need to do this?  What is the optimum way of doing this?  One framebuffer per texture? Or one framebuffer that gets passed around?  The javadoc says that blit(int[]) is slow, is there an alternative without having to create a new texture every time the android view changes?
#6
Support / Re: Child/Parent relationship
April 11, 2013, 07:13:06 PM
Thank you,
I will do just that
#7
Support / Child/Parent relationship
April 11, 2013, 12:40:47 AM
Why is there no method like
Object3D[] getChildren()
but there is
Object3D[] getParents()

I have a group of objects (From another example, it is a car and its 4 wheels).  I want them all to move together, so I add them as children to another object, which is a collision mesh.  And, now I would like to pass the reference to the outer object around, and change all the children simultaneously.  For instance, I want to change visibility, or remove them from the world.

All I can think of doing is extend the Object3D class, override the addChild() function to also add the child to a list.  Then add a getChildren() function that just returns that list as an array and use this in my own functions. 

I just don't understand why there is no getChildren() function?
#8
Support / Re: One World, Two OpenGL Contexts
April 11, 2013, 12:01:26 AM
Using android's top program
$ top
  PID PR CPU% S  #THR     VSS     RSS PCY UID      Name
1182  1   1% S    12 765720K 316980K  fg u0_a55   <my application>

I see that the memory allocated for my app constantly increases.  And I am not doing anything else in this app that would allocate memory.
#9
Support / One World, Two OpenGL Contexts
April 10, 2013, 11:23:28 PM
I am trying to render the same scene onto two displays, using Android's Presentation mode.  Because of Presentation mode, I am required to have two OpenGL threads and contexts.

I, of course, do not want to have two Worlds and two of every object.  So I created one world, and had both scenes render it.  Of course this would cause threading issues, so I synchronized the calls in a method called doRender()  Only one thread is ever reading the World data, and I have confirmed this with logs.

This seems to run just fine.  And, every time my doRender() function is called, I get this at the begining:
I/jPCT-AE ( 1784): OpenGL context has changed(2)...recovering for renderer 1/0!
I/jPCT-AE ( 1784): Creating buffers...

I believe this is because the World knows that it is being asked to render to a different context, and so it loads different texture buffers, etc.  Is that right?  I know this is not ideal, but it may be necessary.

And, this runs for a few minutes, but then will crash. And I get this:
I/jPCT-AE ( 1976): OpenGL context has changed(2)...recovering for renderer 0/1!
E/SurfaceTextureClient( 1976): queueBuffer: error queuing buffer to SurfaceTexture, -12
I/jPCT-AE ( 1976): Creating buffers...
W/GLThread( 1976): eglSwapBuffers failed: EGL_BAD_NATIVE_WINDOW
F/libc    ( 1976): Fatal signal 11 (SIGSEGV) at 0x00000000 (code=1), thread 1990 (Thread-145)

And it prints a bunch of debug information
This seems to happen near the 12750th call to doRender

Why is this crashing?  Is it allocating too much memory every time the buffers are created?

Is there a way to tell JPCT that it will constantly be switching between two GL contexts?
#10
Support / Re: Find an object at a 3D location
April 10, 2013, 10:57:18 PM
Yes, that seems to work well. Thank you
#11
Support / Re: Find an object at a 3D location
April 09, 2013, 03:37:57 AM
Thank you, that will help.

But, what if the object has children?  I would have to do getWorldSpaceBounds() on every child, and their children recursively. 

For instance, I loaded a 3DS file of a car.  The wheels are different objects than the car body.  I then created a new empty Object3D and added these loaded Object3Ds as children to it.  However, of course, getWorldSpaceBounds() only works on the object itself, not its children.  How do I get the objects children?  There is no getChildren() method?

Alternatively (and I don't want to do this), is to check collision for every object (including the children) and then follow the parent trail up.  A problem here is an object can have multiple parents.

Another solution that I haven't tested, and I think will have other drawbacks, is to use mergeAll().  Will this remove animations / ability for the wheels to rotate?  It seems that it would merge the meshes so that getWorldSpaceBounds() would work.
#12
So I would put a collision listener on every one of my objects?  It seems that I can use the same instance of the CollisionListener, because the CollisionEvent has targets. 
#13
The function
public int checkCollision(SimpleVector org, SimpleVector dr, float step)
returns the id of the object that the collision happens with.  However, the function
public SimpleVector checkCollisionSpherical(SimpleVector org, SimpleVector translation, float radius)
does not.  Instead it returns the vector that is safe to translate before the collision happens.

Why is the functionality different?  And is there any way I can check what object I collide with when I use checkCollisionSpherical()?
#14
Support / Re: Find an object at a 3D location
April 08, 2013, 02:51:04 AM
Okay, I found that you can get the BoundingBox using

object.getMesh().getBoundingBox();

This solves my problem.

But just to confirm (it works now), I would do:

boolean doesIntersect;
SimpleVector cursorLocation = new SimpleVector(x,y,z);
SimpleVector centerOfObject = object.getTransformedCenter();
SimpleVector relativeLocation = new SimpleVector(cursorLocation);
relativeLocation.sub(centerOfObject);

float[] bb = object.getMesh().getBoundingBox();
if(relativeLocation.x < bb[0]) doesIntersect = false;
else if(relativeLocation.x > bb[1]) doesIntersect = false;
..
..
..
else doesIntersect = true;


Is there any other way?  And will object.getTransformedCenter() always be good?

What if there are child objects? Will this method still work?



#15
Support / Find an object at a 3D location
April 08, 2013, 02:09:56 AM
Suppose I have a cursor in 3D space and want to perform a click.  I want to know what object the cursor is intersecting.  Is there a way to ask the world what object is at X,Y,Z location?  The checkCollision functions only check collision with the polygons of an object, so it only detects collisions on entering/exiting the object.

The best solution I can come up with is to constantly check collision whenever the cursor moves,  and keep track of entering/exiting objects. 

However, this solution isn't perfect, and I can think of many ways that this will fail.  An obvious example is that the object moves far enough away, without the cursor moving / updating, and next time the cursor moves, it doesn't realize it has left the object.

Is there any way to get the bounding box of the object?  I know you can setBoundingBox, and calculationBoundingBox, but there is no getBoundingBox, as far as I can tell.