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

#1
Hi,
I'm still struggeling in havin a GLB-App as reusable (ios) component.

My goal is to have an iOS - app that uses the handy functions of GLB but can be used in a "normal" xcode project. So you just would add the compiled libs from glb to your project and could have the (glb-)output on a (say) viewcontroller. As I understand so far the main.m that is generated returns a UIApplication-instance. I understand this is a singleton and so I cannot simply call main from somewhere else in my code. Is there a chance to change this (returning UIApplication)? I'd rather use the "normal" main.m instead and just create a (say) GLKit-View once I need it, and then pass this instance to GLB, so that the GLB-Output will go there?

If this is not possible, a workaround for me could be an architecture that uses the "custom sceme" variant: My "main"-App calls the "glb-App" via custom-sceme. I understand this should be possible by now, reading threads
http://www.glbasic.com/forum/index.php?topic=7974.0#top and
http://www.glbasic.com/forum/index.php?topic=7924.0
so I could just "shell out" to the glb-app (using the customsceme of the glb app) with an identifer (say the custom-sceme of the main-app) as a query-param. Then the glb-App is doing it's job and once finished calls the main app via the custom-sceme that was delivered before. But: How can I achive the latter? Is there a way to call a custom-sceme in GLB?

Is there anyone having a better idea?

Thanx in advance for any hint or idea
Det
#2
I'm newbie as well (to glbasic as to android, but got some years experince in java / eclipse) but at least I can answer the 2nd part of question 3:
You can run or build from out of eclips: Import the android - distribution to the exlips (or adt) workspace.
Caution: There a two problem that I faced:
- Distribution packes an activity under "com.glbasic.test": Don't know where that came from, but you have to change this packe to " org.libsdl.app"
- My Project seems to loose the setting under project->properties->Android->ProjectBuildTarget.

run build.xml ant script.

rebuild if necessary.

At least I had the chance of compiling under ADT, I don't see why I should not be able to extend the project from now on.
BTW: Had some issues concerning NDK: Had to adjust local.properties to point to my android\sdk and had to adjust AndroidManifest.xml to use this
       <uses-sdk
        android:minSdkVersion="14"
        android:targetSdkVersion="17" />

(not too sure whether this is needed at all)

Please let me know if this was helpful
Det
#3
Thanks all,
now I now what to do (the grabsprite-idea should work, i'll check it out).
But somewhere I'm missing the point: between kanonet's "ue can't use scaled or rotatet sprites as the computer does not know which state of the sprite you ment to use for your collisioncheck" and the existance of a grabsprite that is designed for just that purpose: get me the sprite as it is when drawn on screen. I'd thought it would be a good default to use the copy that "grabsprites" would deliver for collsiontesting as well.
Anyway: I'm new to glbasic and so I'm not the one to discuss design-issues.

Thank you, so I can at least work on this "father and son" projekt whilst I'm stuck on my other questions


#4
Strange: Does not seem ok, even with you code.
Perhaps an issue with scaling (ROTOZOOMSPRITE)?

If you like look at my code (quit ugly hack, just to check things out)...

Code (glbasic) Select
// --------------------------------- //
// Project: Testprojekt
// Start: Friday, March 08, 2013
// IDE Version: 10.202


SETCURRENTDIR("Media") // go to media files

LOADBMP "hintergrund.jpg"
LOADSPRITE "spr_hexagonal_Enemy_02.png", 1
LOADSPRITE "spr_hexagonal_Enemy_02.png",2
LOADSPRITE "YOUWIN.png",3
LOADSPRITE "youloose.png",4
SETSCREEN 1600,900,0

Nochmal:


xPos = 800
yPos = 450
geschwindigkeit=1

richtung=1



hauptspiel:

IF (KEY(30)=1)
richtung=2
ENDIF
IF (KEY(32)=1)
richtung=1
ENDIF
IF (KEY(17)=1)
richtung=4
ENDIF
IF (KEY(31)=1)
richtung=3
ENDIF

IF (KEY(200)=1)
geschwindigkeit=geschwindigkeit+1
ENDIF

IF (KEY(208)=1)

geschwindigkeit=geschwindigkeit-1
IF (geschwindigkeit<0)
geschwindigkeit=0
ENDIF

ENDIF


IF (richtung=1)
xPos=xPos+geschwindigkeit
ROTOZOOMSPRITE 1, xPos,yPos, 270, 0.5
ELSEIF (richtung=2)
xPos=xPos-geschwindigkeit
ROTOZOOMSPRITE 1, xPos,yPos, 90, 0.5
ELSEIF (richtung=3)
yPos=yPos+geschwindigkeit
ROTOZOOMSPRITE 1, xPos,yPos, 180, 0.5
ELSEIF (richtung=4)
yPos=yPos-geschwindigkeit
ROTOZOOMSPRITE 1, xPos,yPos, 0, 0.5
ENDIF
DRAWSPRITE 2 ,50,600
//ZOOMSPRITE 1, xPos, yPos, 0.5, 0.5
richtungschonangepasst=richtungschonangepasst-1
IF SPRCOLL(1,xPos,yPos,2,50,600)
IF (richtung=3 AND geschwindigkeit <3 )
GOTO youwin
ENDIF
GOTO youloose
ENDIF
SHOWSCREEN
GOTO hauptspiel

youwin:


DRAWSPRITE 3, 100, 100

SHOWSCREEN

IF (KEY(57)=1)
GOTO ende
ENDIF
GOTO youwin

youloose:
DRAWSPRITE 4, 100, 100

SHOWSCREEN

IF (KEY(57)=1)
GOTO ende
ENDIF
GOTO youloose

ende:
GOTO Nochmal
END
#5
Hi folks,
here's some question that should be easily answered:
Obviously SPRCOL is not handling transparent pixels that are defined as "pink" RGB(255,0,128)? My Colliosiondetection is quite ugly.
What am I supposed to do to have a pixel-collision only with non-transparent pixels=
Thank's a lot
Det

#6
(Wer nicht fragt bleibt dumm... )

Da ich an der inhaltlichen Baustelle gerade festhänge (siehe thread:Frage zu X_SCRREN2WORLD, X_COLLISIONRAY und X_GETFACE) hab ich mich mal daran gewagt, die Integration des GLBasic-Codes in ein iOS Projekt zu wagen.

Ziel: Ich habe ein xcode-projekt und möchte einen ViewController haben, in dem ein GLBasic-Code läuft. Der Rest der App ist komplett ObjectiveC, nur in einem DetailView möchte ich GLBasic benutzen. Idealerweise gelingt es mir ein delegate aufzurufen, um Werte aus dem GLBasic-Teil abrufen zu können. Sinnvol wäre es nat. auch Parameter an den GLBasic-code zu übergeben.

Problem: Ich sehe aktuell nur einen "Absprung":  im main.m der Aufruf
GLB-iPhone_call_main

Der erzeugt offenbar ein UIApplication-Objekt, und da ich da nur eines von haben darf, bin ich an der Stelle schon aufgeschmissen.

Und damit hier die Frage: Was gibt's da für Möglichkeiten? Gibt es eine Dokumentation  der Funktionen aus z.b. libGLBasiciPhone-egl? Wäre das ein Feature-Request (die Schaffung eines "Embedded GLBasic", das ich als Komponente in Android oder iOS verbauen kann)? Oder gibt es das schon?

Danke
Det




#7
komischer und komischer, sagte alice...

dieser code:

Code (glbasic) Select
LOADSPRITE "Media/WorldTexture.jpg", 0
X_LOADOBJ "Media/MyWorldTri.ddd", 0

LOCAL col

SYSTEMPOINTER 1

WHILE TRUE


X_MAKE3D 1, 50, 45
X_CAMERA 25,15,25,0,0,0

X_LINE 0,0,0,30,10,30, 3,RGB(255,0,255)
col = X_COLLISIONRAY (0,0,30,10,30,0,0,0)
DEBUG "Col: " + col
X_DRAWAXES 0,0,0
X_SETTEXTURE 0, -1
X_DRAWOBJ 0,0
SHOWSCREEN
WEND


Nur feste Werte, nix aufregendes. Und doch: In der debug-Ausgabe ist "Col: 0" . Hrmpf. Also Screen2World / Maus und sonstiges spielen nicht mit. Aber die Col sollte doch wohl !=0 sein?

(Anbei ein Screenshot)

Ich bin jetzt erstmal ratlos..

BTW: Wenn ich meine Line nicht zeichne, finde ich trotz "Debug mode" die versprochene rote linie nicht. Das würde ja zur "Col=0" passen, allein: Wo ist sie denn dann?

Benutzt X_COLLISIONRAY keine 2PunkteForm um die Linie zu zeichnen?


#8
Hmm. Nee hat nix gebracht. Die distanz zum Object ist mir jetzt erstmal egal, mir reicht 0 oder !0
zweimal Screen2world hat das ergebnis nicht verbessert:
ich nehme an, du meinst so:
   X_SCREEN2WORLD mx, my,0, msx,msy,msz
   X_SCREEN2WORLD mx, my,1, cx,cy,cz
   col = X_COLLISIONRAY(0, 0, cx,cy,cz, msx,msy,msz)
Damit wird der "Trefferkreis" eher kleiner :(

Konntest Du das Problem verifizieren, oder soll ich noch meine Ressourcen dazupacken?
#9
Hello again,
today it's me again having problems with the above functions.
I built up a small testscenario to check a collision with ny 3d-object.
Goal: Read out the coordinates under the mouseposition in the uv-map of my texture.
Test: Created a 3d-object in blender, exported as obj and converted to ddd. Result: All neat. Object visible at (0,0,0) (I think), camera in distance 15 along the x-axis, looking at (0,0,0) as well.
Now I use X_COLLISIONRAY: Stuffed in two point-coordinates: I decided that the first point is my camerapostion: (15,0,0) the othe one is wherever the user touched (positioned the mouse). I understood tha I have to transform the Screencoordinates the the user gave with the mouse have to be converted using "X_SCREEN2WORLD" (right?).
Now I get some collisions listed. BUT: The area that detects a collision is far smaller than the visible object. How come? Is it because of my Screen2World-Z-Parameter? Don't know what this is used for and cannot imagine a possible value. 1 did at least the trick... (Help please!)

Next problem: (Ignoring the first). I get a faceId. But: I do not at all understand the faces-array (not because I don't understand the two-dimensional arrays, but because of the values in nodes...) So: The face consists of three edges (nodes). This be my first dimension. But: Why can I ask a node for it's "texture-coordinates" (at index 3 and 4)? As value for face[0][3] I get something like:
Tx: 0.6175429821 ty:0.3996520042
I had thought of a more "direkt" coordinate. How am I supposed to transform this value back to my texture-map?

Some samplecode:
Code (glbasic) Select
LOADSPRITE "Media/WorldTexture.jpg", 0
X_LOADOBJ "Media/MyWorldResized.ddd", 0
LOCAL mx,my,b1,b2
LOCAL col
LOCAL cx,cy,cz
LOCAL faceIdx, face[]

SYSTEMPOINTER 1

WHILE TRUE
MOUSESTATE mx,my,b1,b2
X_SCREEN2WORLD mx, my, 1, cx,cy,cz

col = X_COLLISIONRAY(0, 0, 15,0,0, cx,cy,cz)
IF (col<>0)
DEBUG ("Coll det" + col + ".."+ "\n")
faceIdx=X_GETCOLLISIONFACE()
X_GETFACE 0,0,faceIdx,face[]
DEBUG ("Tx: " + face[0][3] + " ty:" + face[0][4] + "\n");
ELSE
DEBUG ("NO Coll det " + "\n")
ENDIF

X_MAKE3D 1, 50, 45
X_CAMERA 15,0,0,0,0,0
X_SETTEXTURE 0, -1

X_ROTATION 0,0,1,0
X_ROTATION 0,0,0,1
X_DRAWAXES 10,10,10
X_DRAWOBJ 0,0
SHOWSCREEN
WEND


As always: I'd be very glad for any input.
TIA
Det
#10
Und heute mal wieder eine Frage auf deutsch (hab mich noch nicht entschieden, ob es sich lohnt auf englisch zu posten...)

Ich habe ein Testszenario aufgebaut, um eine Kollision mit meinem 3D-Objekt zu erproben.

Ziel: Koordinatenpaar des Objekts unter der Mausposition auf der UV-Map der Textur finden.

Versuchsanordnung: 3DObjekt mit Blender erstellt -als obj exportiert zu ddd konvertiert.
Eingelesen
Zeigt 1a Ergebnis. Objekt positioniert im Ursprung (denke ich), Kamera auf der x-Achse mit entfernung 15.

Was ich bisher verstanden habe: Collisionray gibt eine Distanz oder 0 zurück. Offenbar gebe ich 2 Punkte rein. Als Quellpunkt gebe ich meine Kamera vor. Zweiter Punkt wird meine Maus, aber von Screen auf Weltkoordinaten umgerechnet.

Ergebnis ist so lala: Auf einem Kreis um die Bildschirmmitte (wo ja nun auch mein Objekt liegt) bekomme ich Kollisionen. Aber: Der Kreis ist deutlich kleiner als mein Objekt...

Denkbare Probleme: Meine Screen2World-Transformation ist müll. Kann gut sein, da die Z-Angabe "geraten" ist (1):
Frage: Was gebe ich da sinnvollerweise an?

Nächstes Problem: Wenn ich mich mal das Problem der fehlenden Treffer ignoriere: Ich bekomme eine Face-Id. Prima. Aber ehrlich gesagt raffe ich den Aufbau des face-Arrays nicht. Nicht weil es ein 2Dimensionales Array ist, sondern die Unterteilung in nodes verstehe ich nicht. Also: Das Face besteht (weil ich es aus Dreiecken aufgebaut habe) aus 3 Kanten. Wieso hat eine Kante eine tx,ty-Koordinate in die Textur (Wenn ich die Doku richtig lese, z.b. tx=[0][3])? Als Werte bekomme ich so etwas:
Tx: 0.6175429821 ty:0.3996520042
Ich hatte mit etwas "direkterem" gerechnet, wie transformiere ich das zurück in meine Textur-Map?


Samplecode:
Code (glbasic) Select

LOADSPRITE "Media/WorldTexture.jpg", 0
X_LOADOBJ "Media/MyWorldResized.ddd", 0
LOCAL mx,my,b1,b2
LOCAL col
LOCAL cx,cy,cz
LOCAL faceIdx, face[]

SYSTEMPOINTER 1

WHILE TRUE
MOUSESTATE mx,my,b1,b2
X_SCREEN2WORLD mx, my, 1, cx,cy,cz

col = X_COLLISIONRAY(0, 0, 15,0,0, cx,cy,cz)
IF (col<>0)
DEBUG ("Coll det" + col + ".."+ "\n")
faceIdx=X_GETCOLLISIONFACE()
X_GETFACE 0,0,faceIdx,face[]
DEBUG ("Tx: " + face[0][3] + " ty:" + face[0][4] + "\n");
ELSE
DEBUG ("NO Coll det " + "\n")
ENDIF

X_MAKE3D 1, 50, 45
X_CAMERA 15,0,0,0,0,0
X_SETTEXTURE 0, -1

X_ROTATION 0,0,1,0
X_ROTATION 0,0,0,1
X_DRAWAXES 10,10,10
X_DRAWOBJ 0,0
SHOWSCREEN
WEND



Das sind jetzt leider einige Fragen in einem Thread, aber da die alle zusammenhängen passt das vielleicht...

Mir fehlt jetzt so'n bisschen die Idee wie ich weiterkomme, und ich freu' mich über jede Anmerkung

TIA
Det
#11
Hi matchy,
thank's a lot for caring! Obviosly I stripped down my code too much (it was late yesterday  :().

But anyway: I figured it out by myself. The problem seems to be that mixing mouseaxis and mousestate in one loop is not that good an idea...

that code that did not work for me was:
Code (glbasic) Select

FUNCTION getMice:
// Diese Variablen sind als LOCAL definiert:
//
LOCAL x1%,y1%,b1%,b2%, xs%, ys%

maus.numberofusedmice=0;
FOR x=0 TO GETMOUSECOUNT()-1

SETACTIVEMOUSE x
MOUSESTATE x1%,y1%,b1%,b2%

IF (b1=1)
maus.usedmice[maus.numberofusedmice]=x
maus.mousedata[x].x=x1
maus.mousedata[x].y=y1
maus.mousedata[x].b1=b1
maus.mousedata[x].b2=b2
                        xs=MOUSEAXIS(0)
                        ys=MOUSEAXIS(1)
maus.mousedata[0].xaxis=xs
maus.mousedata[0].yaxis=ys
INC maus.numberofusedmice, 1

ENDIF
NEXT
RETURN



and this finally does the trick:
Code (glbasic) Select

FUNCTION getMice:
// Diese Variablen sind als LOCAL definiert:
//
LOCAL x1%,y1%,b1%,b2%, xs%, ys%

maus.numberofusedmice=0;
FOR x=0 TO GETMOUSECOUNT()-1

SETACTIVEMOUSE x
xs=MOUSEAXIS(0)
ys=MOUSEAXIS(1)
maus.mousedata[x].xaxis=xs
maus.mousedata[x].yaxis=ys
NEXT
FOR x=0 TO GETMOUSECOUNT()-1

SETACTIVEMOUSE x
MOUSESTATE x1%,y1%,b1%,b2%

maus.usedmice[maus.numberofusedmice]=x
maus.mousedata[x].x=x1
maus.mousedata[x].y=y1
maus.mousedata[x].b1=b1
maus.mousedata[x].b2=b2
IF (b1=1)
ConOut ( "x1: " + x1 + " xaxis: " + maus.mousedata[x].xaxis)
INC maus.numberofusedmice, 1
ENDIF
NEXT
RETURN



ENDFUNCTION // GETMICE
#12
Yes, I read this, but as ist was over a year old I thought it was fixed. Anway:this is not the point, my problem is mixing mouseaxis and code for mousedetection
#13
Hi,
it seem's to me, I did not understand the mouse / touch behaviours in total, perhaps someone could point me to the right direction or has similar problems.

What I did was make a small testprogram for the iPad that should react to touches.

After I've learned that getmouscount will always deliver 16 (or should? there seems to be a bug when more than 5 fingers are placed? Anyway) and in a call Mousestate x,y,b1,b2 the b1 gives me the hint that this "finger" is "active" I came to the point that drives me nuts: Obviously I've got the chance to check whether I've got two finges places (need this, want to implement a "pinch"-gesture) my "swipe" does not work anylonger, without implementing "pinch" my "swipe works. My swipe uses the mouseaxis function.
I assume it is because of the checkroutine that always runs through 16 available mouses and asks for the button1. To do this I need to call "setactivemouse" prior to mousestate. But: This checkroutine is called in an endless loop. So I assume it's an timing / threading issue: I'm afraid the mousaxis-function is interrupted by the "check-function" to early to return an appropriate value.

Anyone else who has witnessed this problem?

Checker-Function:

Code (glbasic) Select

TYPE MOUSEDATA
x
y
b1
b2
xaxis
yaxis
ENDTYPE

TYPE MOUSEINFO
mockamouse=-1
numberofusedmice // Anzahl der Mäuse mit gedrücktemButton als limit der usedMice
usedmice[16] // Indize ins mousedata-array um werte zu kriegen
mousedata[16] AS MOUSEDATA // alle werte der gedrückten mäuse
ENDTYPE
LOCAL i

WHILE TRUE

getMice()



i=maus.numberofusedmice
IF i=2
// pinch, code dropped

       ELSE
// swipe, code dropped
       ENDIF
WEND

// ------------------------------------------------------------- //
// ---  GETMICE  ---
// ------------------------------------------------------------- //
FUNCTION getMice:
// Diese Variablen sind als LOCAL definiert:
//
LOCAL x1%,y1%,b1%,b2%, xs%, ys%

maus.numberofusedmice=0;
FOR x=0 TO GETMOUSECOUNT()-1

SETACTIVEMOUSE x
MOUSESTATE x1%,y1%,b1%,b2%

IF (b1=1)
maus.usedmice[maus.numberofusedmice]=x
maus.mousedata[x].x=x1
maus.mousedata[x].y=y1
maus.mousedata[x].b1=b1
maus.mousedata[x].b2=b2

INC maus.numberofusedmice, 1

ENDIF
NEXT
RETURN



ENDFUNCTION // GETMICE



Ideas anyone?
Thanx in advance
Det
#14
It's OK now, I think it was 2 things that made up the error:
- the result was better after I changed the texture to a size a power of 2
- the result became even better with some "handcrafting" done on the uv-mapping.

Thank you very much!
#15
Thanks a lot for caring. Too bad, I have to work for a living as well, so I haven't had time to check out all of your proposals. I'll be back later and report the results of my efforts. Stay tuned :)