Rube textures question

General discussion about the R.U.B.E editor
Post Reply
Rogerboy
Posts: 9
Joined: Thu Aug 29, 2013 11:18 pm

Rube textures question

Post by Rogerboy »

Hi,

I have recently purchased Rube to use on my project, its going well but I am having trouble displaying textures on the screen in my engine. I am using Marmalade SDK for mobile devices.

So I successfully get the list of textures and load them but I am not sure what some of the member data variables actually do. Most of them I can figure out but not these:

b2dJsonImage

b2Vec2 center; //Center of what?
float angle; //Angle of what?
float scale; //Scale of what?
float aspectScale; //Scale of what?

b2Vec2 corners[4]; //Corners of what?

//VBO data? //Is this used to create a VBO (geometry) to apply the texture onto? These are not even used //in the sfml sample.
int numPoints;
float* points;
float* uvCoords;
int numIndices;
unsigned short* indices;
//

Please help as there is no documentation and the variables are not commented.

Thanks a lot,

-Rogerboy
iforce2d
Site Admin
Posts: 861
Joined: Sat Dec 22, 2012 7:20 pm

Re: Rube textures question

Post by iforce2d »

Have you seen this? https://www.iforce2d.net/rube/json-structure

The parts that look like VBO data are indeed precalculated data that can be useful if you're loading images as textures in OpenGL and you would be drawing them with for example glDrawArrays, or glVertex2f (for the corners). If the framework you're using lets you set the position, scale etc for a sprite without needing to specify individual vertices, then you can ignore them. They can be excluded from the exported file to reduce file size, in the export options tab of the scene settings dialog (under Scene in the main menu).
Rogerboy
Posts: 9
Joined: Thu Aug 29, 2013 11:18 pm

Re: Rube textures question

Post by Rogerboy »

Ok so corners is the same as points? In reality I only need points and uvcoords then with gldrawelements call?
Have you tested this? Should I be drawing it with GL_TRIANGLES or what?
iforce2d
Site Admin
Posts: 861
Joined: Sat Dec 22, 2012 7:20 pm

Re: Rube textures question

Post by iforce2d »

I don't see the 'points' property you are referring to, but 'corners' are the corners of the image (the vertex locations that you would give to glVertex2f). Yes, I think we are talking about the same thing :)

Yes, as described in the page I linked to, "Indices for drawing GL_TRIANGLES with the glDrawElements function". Probably the best way to see how these properties can be used is to look at the reference implementation in the C++ sample loader, or also viewable here on github: https://github.com/iforce2d/b2dJson/blo ... OpenGL.cpp
Note that when rendering using corners, the uv coords are by default 0 and 1.
Post Reply