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

#1
Hi

Finally got to test this on my iPad tonight. Setting the setorientation to what I thought i should be (1 for landscape) did not do anything god BUT setting it to 0 made the app start in portrait mode and now it is correct ! I will have to check a little bit to se what impact this gives on my app but anyway I'm a huge step further.

Will investigate further to see if I can get this working too on my Acer A500 Android tab with the same settings (and preferably with the orientation in landscape mode).

Thanks

Regards
Eirik

#2
Thanks

Willl check this later today when I back on my mac and XCode installation. I tried to configure the direction the application where allowed to run in the project settings but this command looks more promising.

BTW what is exactly the sz parameter in the screen2world command ? I thougt it was the distance to the far clip-plane (or is it the distance to a plane to project the coordinates on ?) but I'm not sure (ended up with using 1.0 and divide the coordinates in x and y axis by 10 to get it right on windows but I think this only works now since I have placed the camera along the z-axis (just to keep things simple) and have a static camera pointing at 0, 0, 0).

Regards
Eirik




#3
GLBasic - en / screen2world
2012-Jan-17
Hi

Looking through the forum and testing different parameters to the screen2world command I ended up with this that works perfect on Windows but on iPad the Y-coord is wrong making the lines miss by a significant distance (to high). I can add the difference but why does this behave different on iPad vs Windows when the screen is in both tests set to 1024x768 (portrait) ? The aspect ratio of the height and width seems correct in both cases compared to 1024 x 768 screen).

(the test-program just draws a line from 0,0,0 to mousepointer on windows. On iPad it draws a line/polygon using the multitouch feature).

Code (glbasic) Select

// --------------------------------- //
// Project: MyTest
// Start: Saturday, January 14, 2012
// IDE Version: 10.231


SETCURRENTDIR("Media")

SYSTEMPOINTER TRUE

CLEARSCREEN

LOCAL points#[]
DIM points#[20][3]

WHILE TRUE
X_MAKE3D 1, 1000, 45
X_CAMERA 0, 0, 100, 0, 0, 0

LOCAL mouse%, mx%, my%, b1%, b2%, maxMouse%, currentMouse%
LOCAL wx#, wy#, wz#, lastX%, lastY%

maxMouse = GETMOUSECOUNT()
currentMouse = 0
FOR mouse = 0 TO  maxMouse - 1
      SETACTIVEMOUSE mouse
      MOUSESTATE mx, my, b1, b2
      IF b1
      lastX = mx
      lastY = my
      X_SCREEN2WORLD mx, my, 1, wx#, wy#, wz#
      points[currentMouse][0] = wx# / 10.0
      points[currentMouse][1] = wy# / 10.0
      points[currentMouse][2] = wz#
      INC currentMouse, 1
      ENDIF
    NEXT

LOCAL drawMouse%
IF currentMouse > 1
FOR drawMouse = 0 TO currentMouse - 2
X_LINE points[drawMouse][0], points[drawMouse][1], 0, points[drawMouse+1][0], points[drawMouse+1][1], 0, 5, RGB(255, 0, 0)
NEXT
X_LINE points[currentMouse - 1][0], points[currentMouse - 1][1], 0, points[0][0], points[0][1], 0, 5, RGB(255, 0, 0)
ELSE
X_LINE points[currentMouse - 1][0], points[currentMouse - 1][1], 0, 0,0,0, 5, RGB(0, 255, 0)
ENDIF

X_MAKE2D
PRINT "Mouse   : " + maxMouse, 10, 10
PRINT "Current : " + currentMouse, 10, 20
PRINT "Last    : " + lastX + ", " + lastY, 10, 30
LOCAL index%
FOR index = 0 TO currentMouse - 1
PRINT "Coords : " + points[index][0] + " , " + points[index][1] + ", " + points[index][2], 10, 40 + index * 10
NEXT
SHOWSCREEN
WEND

END





Regards
Eirik

#4
Hi

I made it work on Android but I had to add a reference to the header (check this posting earlier in the thread)  :http://www.glbasic.com/forum/index.php?topic=3561.msg53765#msg53765

//Eirik
#5
Regarding grabbing objects I did a implementation some time ago like this :

Added this together with the world definition  :

Code (glbasic) Select

b2MouseJoint* m_mouseJoint = NULL;


And this to the end of the Box2d.gbas file

Code (glbasic) Select

FUNCTION b_GrabBodyAtMouse% : BYREF mx, BYREF my
INLINE
if (m_mouseJoint != NULL)
{
return 0;
}

// Make a small box.
b2Vec2 p(mx, my);
b2AABB aabb;
b2Vec2 d;
d.Set(0.001f, 0.001f);
aabb.lowerBound = p - d;
aabb.upperBound = p + d;

// Query the world for overlapping shapes.
const int32 k_maxCount = 10;
b2Shape* shapes[k_maxCount];
int32 count = bWorld->Query(aabb, shapes, k_maxCount);
b2Body* body = NULL;
for (int32 i = 0; i < count; ++i)
{
b2Body* shapeBody = shapes[i]->GetBody();
if (shapeBody->IsStatic() == false && shapeBody->GetMass() > 0.0f)
{
bool inside = shapes[i]->TestPoint(shapeBody->GetXForm(), p);
if (inside)
{
body = shapes[i]->GetBody();
break;
}
}
}

if (body)
{
b2MouseJointDef md;
md.body1 = bWorld->GetGroundBody();
md.body2 = body;
md.target = p;
#ifdef TARGET_FLOAT32_IS_FIXED
md.maxForce = (body->GetMass() < 16.0)?
(1000.0f * body->GetMass()) : float32(16000.0);
#else
md.maxForce = 1000.0f * body->GetMass();
#endif
m_mouseJoint = (b2MouseJoint*)bWorld->CreateJoint(&md);
body->WakeUp();
}

ENDINLINE
ENDFUNCTION


FUNCTION b_GrabBodyMouseUp:
INLINE
if (m_mouseJoint)
{
bWorld->DestroyJoint(m_mouseJoint);
m_mouseJoint = NULL;
}
ENDINLINE
ENDFUNCTION

FUNCTION b_GrabBodyMouseMove : BYREF mx, BYREF my
INLINE
b2Vec2 p(mx, my);
if (m_mouseJoint)
{
m_mouseJoint->SetTarget(p);
}
ENDINLINE



Before the main loop :
Code (glbasic) Select

LOCAL mbl = 0
LOCAL mbr = 0
LOCAL mx = 0
LOCAL my = 0
LOCAL oldMbl
LOCAL oldMbr
LOCAL oldMx
LOCAL oldMy


In my main loop I added (before the b_update):

Code (glbasic) Select


oldMbl = mbl
oldMx = mx
oldMy = my
MOUSESTATE mx, my, mbl, mbr
IF mbl = 1 AND oldMbl = 0
DEBUG "Grab at : " + mx + ", " + my + "\n"
b_GrabBodyAtMouse(mx, my)
ENDIF
IF mbl = 0 AND oldMbl = 1
DEBUG "Released at : " + mx + ", " + my + "\n"
b_GrabBodyMouseUp()
ENDIF

IF mx <> oldMx OR my <> oldMy
b_GrabBodyMouseMove(mx, my)
ENDIF



Regards
Eirik

#6
 :S of course!! Thanks, have forgot to add a couple of these after starting to use functions inside types. This time I were too focused on that I probably had messed up the type definition.
#7
Hi

I'm struggling with adding new entries in an array of types. The compiler complains about the DIMPUSH statment in line 68 (marked with <=---) :

Code (glbasic) Select

// IDE Version: 10.113
// Tile
CONSTANT TS_FREE% = 0

// Brick
CONSTANT BS_NORMAL% = 0

TYPE TBrick
pX%; pY%
dX; dY
image%
status%

FUNCTION Init: aX%, aY%, aImage%
self.pX = aX
self.pY = aY
self.image = aImage
self.status = BS_NORMAL

self.dX = aX * 48
self.dY = aY * 48
ENDFUNCTION
ENDTYPE

//GLOBAL newBrick AS TBrick

TYPE TTile
pX; pY
status%

FUNCTION SetPosition : aX, aY
self.pX = aX
self.pY = aY
ENDFUNCTION

ENDTYPE

TYPE TGrid
width% ; height;
tiles[] AS TTile
bricks[] AS TBrick

FUNCTION SetSize : aWidth%, aHeight%
self.width = aWidth
self.height = aHeight
DIM self.tiles[aWidth][aHeight]
ENDFUNCTION

FUNCTION Init:
LOCAL iY%
LOCAL iX%
IF self.width > 0 AND self.height > 0
FOR iY = 0 TO self.height - 1
FOR iX = 0 TO self.width - 1
self.tiles[iX][iY].status = TS_FREE
NEXT
NEXT
ENDIF
ENDFUNCTION

FUNCTION AddBrick : aX%, aY%, aType%
IF aX < self.width AND aY < self.height
LOCAL newBrick AS TBrick
newBrick.Init(aX, aY, aType)
DIMPUSH bricks[], newBrick                             // <=-- "Wrong argument type"
ENDIF
ENDFUNCTION
ENDTYPE


#8
Hi

Can confirm that the sample and files that are in the first post of this thread (updated 28. july) works on android but I had to add a reference to the Box2D headerfile in the "Project Options/cmp" (-I<path to the box2d files>/Box2D)

Regards
Eirik


[attachment deleted by admin]
#9
Great work !

:nw:

Tested some of the examples on an Acer A500. Regarding the multitouch part it looks like it is already implemented in the 1.3 development edition of the SDL library (to be 2.0 ?).

//Eirik
#10
Hi

There are a limitation in the Box2D code that limits the number of polygonvertices to 8. It is located in the b2settings.h file (line 75 : const int32 b2_maxPolygonVertices = 8;)

Regards
Eirik
#11
Hi

How can I pass vectors to uniform defined vectors in shares (like "uniform vec3 fvLightPosition") ? Passing simple float values seems ok but I would prefer to pass vectors in one statement. I think Hemlos have asked for this before but I could not find any example or information for this (if it is possible).

//Eirik
#12
3D / Re: Model support.
2010-Apr-04
Hi

I've been using Fragmotion to do conversion between formats. Supports a number of popular formats (among them loading b3d,x and then export to e.g. 3ds for import into GLB). Checked Fragmosofts homepage now and he have just released 1.0 of the 3d tool (sep. 2009).

//Eirik
#13
Hi

The source was not included in the zip-file. Have uploaded a new zip file with source. It is also now possible to manipulate the objects using the mouse in the test program. Have fun  =D
#14
Hi

This is cool. Have created something simular using require etc but I will rather use this implementation. One problem I encountered when I extended the program with the possibility to pick objects. It just freezes for a couple of seconds and then it continues like there have been no problems. Thought first I had messed up the mouse joint but adding some debug statement indicates it happens around the showscreen function. The changes I have done is in the Box2D.gbas and the test program main.gbas (NB have not added functionality to scale the pick function to find the World coordinates. It works in this example since the world is equal to the screen.....).

Tested the program on a different computer and it works fine. Got to be something with the other installation/GFX card driver or something (the one wich works is ATI and the other is NVidia. Have had some strange GL problems earlier on the PC with the NVidia card).

[EDIT]
Just updated the NVidia driver and now it works !  =D

BR
Eirik


[attachment deleted by admin]
#15
I have the same version but did not update the header files. Works fine here. What are the changes in the header files and why should I install them ?

(From compilation of the Box2D project)

Quote
_______________________________________
*** Configuration: WIN32 ***
precompiling:
GPC - GLBasic Precompiler V.7.045 SN:eb010adf - 3D, NET
Wordcount:52 commands
compiling:

linking:
success
_______________________________________
*** Finished ***
Elapsed: 13.2 sec. Time: 14:19
Build: 1 succeeded.