wie kann man GUI durchsichtig kriegen??

Übersicht BlitzBasic Allgemein

Neue Antwort erstellen

DaviD4D

Betreff: wie kann man GUI durchsichtig kriegen??

BeitragFr, Jul 29, 2005 16:56
Antworten mit Zitat
Benutzer-Profile anzeigen
hi all !

weiss nicht wie man es machen würde.. so wie hier http://www.blitzbasic.com/gall...mp;page=28

mfg David

TheShadow

Moderator

BeitragFr, Jul 29, 2005 17:01
Antworten mit Zitat
Benutzer-Profile anzeigen
in bb3d nimmt man dazu einfach transparente sprites...
AMD64 3500+ | GeForce6600GT 128MB | 1GB DDR | WinXPsp2

DaviD4D

BeitragFr, Jul 29, 2005 17:49
Antworten mit Zitat
Benutzer-Profile anzeigen
TheShadow hat Folgendes geschrieben:
in bb3d nimmt man dazu einfach transparente sprites...
und wenn die Camera in der Nähe von der Wand wird.... wird man kein GUI sehen?? Smile
 

Dreamora

BeitragFr, Jul 29, 2005 18:15
Antworten mit Zitat
Benutzer-Profile anzeigen
Man wirds immer sehen, dafür gibts EntityOrder ja schliesslich Wink
Ihr findet die aktuellen Projekte unter Gayasoft und könnt mich unter @gayasoft auf Twitter erreichen.

DaviD4D

BeitragFr, Jul 29, 2005 18:20
Antworten mit Zitat
Benutzer-Profile anzeigen
und könnt ihr mir auch zeigen wie es geht (ein Beispiel)... PLEASE ! Smile
 

Dreamora

BeitragFr, Jul 29, 2005 18:27
Antworten mit Zitat
Benutzer-Profile anzeigen
1. Kamera erstellen
2. GUI laden als Sprite und vor Kamera positionieren
3. Kamera als Parent von GUI definieren
4. EntityOrder der GUI ändern so dass sie erst nach allem anderen gezeigt wird (müsste -1 sein)

Wenn dein GUI dynamisch ist, kannst du ja mittels TextureBuffer auf die Textur des Sprites jeweils die neuen Daten zeichnen, so wie sie sein sollen.
Ihr findet die aktuellen Projekte unter Gayasoft und könnt mich unter @gayasoft auf Twitter erreichen.
  • Zuletzt bearbeitet von Dreamora am Sa, Jul 30, 2005 17:00, insgesamt einmal bearbeitet
 

BlitzBasic303

Betreff: RE:

BeitragSa, Jul 30, 2005 14:59
Antworten mit Zitat
Benutzer-Profile anzeigen
Code: [AUSKLAPPEN]

positionentity guisprite,entityx(camera),entityy(camera),entityz(camera)+1
text x,y,"Da is´en Gui vor unserer Nase!"

Lunatix

BeitragSo, Jul 31, 2005 12:46
Antworten mit Zitat
Benutzer-Profile anzeigen
Das geht auch mit nem image. Musst nur jeden 2. pixel weiß machen und ihn dann mit ,ähh, maskimage 255,255,255 masken, schon ists transparent. Aber sprites ist einfacher, glaube.
[size=9]Pro|gram|mier|er: Ein Organismus, der Koffein in Software umwandelt.
Geben Sie eine beliebige 11-stellige Primzahl ein, um fortzusetzen...

Sebastian

BeitragSo, Jul 31, 2005 15:51
Antworten mit Zitat
Benutzer-Profile anzeigen
BlitzBasic: [AUSKLAPPEN]

Graphics 1024,768,16,1


SetBuffer FrontBuffer()

Color 125,125,125

For c = 1 To 20

Rect Rnd(0,400),Rnd(0,400),Rnd(10,100),Rnd(10,100),0

Next

GUI = CreateImage(380,280)

SetBuffer ImageBuffer(GUI)

Color 50,50,50
Rect 0,0,380,380,1

Color 0,0,0
For x = 0 To 380 Step 2
For y = 0 To 380 Step 2
Plot x,y
Next
Next

Color 255,255,255
Text 10,10,\"Die GUI\"


WaitKey()

SetBuffer FrontBuffer()


DrawImage GUI,10,10

WaitKey



Sieht etwas löchrig aus ...


Wenn ich sowas wie auf dem Bild machen müsste würde das so ausehen :

BlitzBasic: [AUSKLAPPEN]


SetBuffer FrontBuffer()

ClsColor 0,0,255
Cls
Color 0,255,0

For c = 1 To 20

Rect Rnd(0,400),Rnd(0,400),Rnd(10,100),Rnd(10,100),1

Next


;Bild erstellen

GUI = CreateImage(380,280)
Dim pix(380,380)



LockBuffer FrontBuffer()
For x = 1 To 380
For y = 1 To 380
argb = ReadPixelFast(x + 10,y +10) ; RGB-werte cachen

;Aufsplitten

r = (argb Shr 16) And $FF ; Nur Rot
g = (argb Shr 8) And $FF ; Nur Grün
b = (argb) And $FF ; Nur Blau

r = r - 100 ; Abdunkeln
g = g - 100
b = b - 100

If r < 0 Then r = 0
If g < 0 Then g = 0
If b < 0 Then b = 0

;Wieder Zusammensetzen

argb2 = b
argb2 = (g Shl 8) Or argb2
argb2 = (r Shl 16) Or argb2

pix(x,y) = argb2


Next
Next



UnlockBuffer FrontBuffer()

SetBuffer ImageBuffer(GUI)


LockBuffer ImageBuffer(GUI)

For x = 1 To 380
For y = 1 To 380

WritePixelFast x,y,pix(x,y) ; Gecachetes malen


Next
Next

UnlockBuffer ImageBuffer(GUI)

Color 255,255,255
Text 10,10,\"Die GUI\"


SetBuffer FrontBuffer()


DrawImage GUI,10,10 ; GUI einbelnden

WaitKey

End
Seit 2 Jahren kein BlitzBasic und kein Windows mehr, und stolz darauf !
 

DoomMaster

BeitragSo, Jul 31, 2005 16:41
Antworten mit Zitat
Benutzer-Profile anzeigen
also ich habe mal angefabgen eine auf Sprite basierende GUI zu entwickeln sie ist funktionstüchtig aber nicht immer schön gelöst wenn du wilst kann ich dir mal den code schicken

ein kleines beispiel:

user posted image
Für ewentuelle Rechtschreibfehler ist mein Duden verantwortlich

DaviD4D

BeitragSo, Jul 31, 2005 22:55
Antworten mit Zitat
Benutzer-Profile anzeigen
DoomMaster hat Folgendes geschrieben:
also ich habe mal angefabgen eine auf Sprite basierende GUI zu entwickeln sie ist funktionstüchtig aber nicht immer schön gelöst wenn du wilst kann ich dir mal den code schicken
klar will ich... DaviD4D@gmx.de DaviD4D@web.de

Danke im Voraus... Smile Smile

Mattis_the_brain

BeitragMo, Aug 01, 2005 0:10
Antworten mit Zitat
Benutzer-Profile anzeigen
OmG... wo sind wir hin geraten... Shocked
 

DoomMaster

BeitragMo, Aug 01, 2005 19:52
Antworten mit Zitat
Benutzer-Profile anzeigen
also ich poste hier einfach mal den code wie gesagt da das projekt nach der GC letztes jahr nicht weitergeführt wurde ist die GUI auch nicht komplet aber so als Denkanstoss:

Der Code zum erzeugen eines Fenster`s usw:

BlitzBasic: [AUSKLAPPEN]

window = create_window(100,100,400,200)
local_button = create_button(window,20,-150,40,20,\"media\gfx\HUD/GUI_HUD_BTN.bmp\")
zone_button = create_button(window,20,-120,40,20,\"media\gfx\HUD/GUI_HUD_BTN.bmp\")
privat_button = create_button(window,20,-90,40,20,\"media\gfx\HUD/GUI_HUD_BTN.bmp\")
clan_button = create_button(window,20,-60,40,20,\"media\gfx\HUD/GUI_HUD_BTN.bmp\")
Local_label = create_label(window,70,-150,100,20,\"Local\",91,123,142)
zone_label = create_label(window,70,-120,100,20,\"Zone\",91,123,142)
privat_label = create_label(window,70,-90,100,20,\"Privat\",91,123,142)
privat_label = create_label(window,70,-60,100,20,\"Privat\",91,123,142)
create_label(window,150,192,100,20,\"Hypercom\",91,123,142)
inv_imag_5 = create_imagebox(window3,160,-60,120,100,\"media\gfx\inv\free\")
inv_imag_6 = create_imagebox(window3,300,-60,120,100,\"media\gfx\inv\free\")


und hier die funktionssammlung

BlitzBasic: [AUSKLAPPEN]

Function create_window(x_pos,y_pos,x_scal,y_scal)
f.fenster = New fenster
f\sprite = CreateSprite(camera);temp)
EntityFX f\sprite,8
ScaleSprite f\sprite ,x_scal,y_scal
EntityAlpha f\sprite,.8
HandleSprite f\sprite,-1,1
PositionEntity f\sprite,((x_pos)*2)-aufx,-((y_pos)*2)+aufy,aufx
;PositionEntity f\sprite,x_pos,-y_pos,1024
temp = LoadTexture (\"media\gfx\HUD/GUI_SKILL\",1)
EntityTexture f\sprite ,temp
EntityBlend f\sprite,1
EntityOrder f\sprite,-1
f\x_scal = x_scal
f\x = x_pos
f\y = y_pos
Return f\sprite
End Function

Function create_button(wnd,x_pos,y_pos,x_scal,y_scal,tex$)
b.button = New button
b\sprite = CreateSprite(wnd)
b\tex = LoadAnimTexture (tex,4,40,20,0,2)
EntityFX b\sprite,8
b\x=x_pos
b\y=y_pos
HandleSprite b\sprite,-1,-1
ScaleSprite b\sprite ,x_scal,y_scal
MoveEntity b\sprite ,x_pos*2,y_pos*2-(y_scal*2),0
EntityTexture b\sprite,b\tex,0
EntityBlend b\sprite,3
EntityOrder b\sprite,-1
Return b\sprite
End Function

Function move_window(x_ver,y_ver,mx,my)
For f.fenster = Each fenster
If MouseDown(1) Then
If (mx>f\x) And (mx<(f\x+f\x_scal))Then
If (my>f\y) And (my<(f\y+20)) Then
f\x = f\x + x_ver
f\y = f\y - y_ver
PositionEntity f\sprite ,EntityX(f\sprite)+(x_ver*2),EntityY(f\sprite)+(y_ver*2),EntityZ(f\sprite)
EndIf
EndIf
EndIf
Next
End Function

Function destoy_GUI()
For b.button = Each button
FreeEntity b\sprite
Delete b
Next
For f.fenster = Each fenster
FreeEntity f\sprite
Delete f
Next
End Function

Function create_label(wnd,x_pos,y_pos,x_scal,y_scal,inhalt$,r,g,b)
SetFont Font
ClsColor 0,0,0
l.label = New label
l\sprite = CreateSprite(wnd)
EntityFX l\sprite,8
HandleSprite l\sprite,-1,-1
EntityAlpha l\sprite,.9
ScaleSprite l\sprite ,x_scal,y_scal
MoveEntity l\sprite ,x_pos*2,y_pos*2-(y_scal*2),0
temp = CreateTexture(x_scal,y_scal)
SetBuffer TextureBuffer(temp)
Cls
Color 255,255,255
Text 0,0,inhalt
SetBuffer BackBuffer()
EntityTexture l\sprite,temp
EntityBlend l\sprite,3
EntityOrder l\sprite,-1.5
Return l\sprite
SetFont Font2
End Function

Function create_imagebox(wnd,x_pos,y_pos,x_scal,y_scal,url$)
i.image = New image
i\sprite = CreateSprite(wnd)
EntityFX i\sprite,8
i\x=x_pos
i\y=y_pos
HandleSprite i\sprite,-1,-1
ScaleSprite i\sprite ,x_scal,y_scal
EntityAlpha i\sprite,.7
MoveEntity i\sprite ,x_pos*2,y_pos*2-(y_scal*2),0
DebugLog(url)
i\textur = LoadTexture (url)
EntityTexture i\sprite,i\textur
EntityOrder i\sprite,-1
Return i\sprite
End Function

Function update_label(lbl,sting$,x_scal,y_scal)
SetFont Font
temp = CreateTexture(x_scal,y_scal)
SetBuffer TextureBuffer(temp)
Color 255,255,255
Text 0,0,sting
SetBuffer BackBuffer()
EntityTexture lbl,temp
SetFont Font2
End Function

Function create_textbox(wnd,x_pos,y_pos,x_scal,y_scal,String_v$,r,g,b)
SetFont Font
t.text_box = New text_box
t\sprite = CreateSprite(wnd)
EntityFX t\sprite,8
HandleSprite t\sprite,-1,-1
ScaleSprite t\sprite ,x_scal,y_scal
MoveEntity t\sprite ,x_pos*2,y_pos*2-(y_scal*2),0
temp = CreateTexture(x_scal,y_scal)
SetBuffer TextureBuffer(temp)
ClsColor 0,0,0
Color 255,255,255
ClsColor 0,0,0
Cls
PrintText(String_v,y_scal,x_scal,0,0)
SetBuffer BackBuffer()
EntityTexture t\sprite,temp
EntityBlend t\sprite,3
EntityOrder t\sprite,-2
SaveBuffer(TextureBuffer(temp),\"tempos.bmp\")
Return t\sprite
SetFont Font2
End Function



Function PrintText(Text$,H#,W#,X#,Y#)
Local l = Len(Text)
Local Ausgabe$
Local lges = 1
Local SH = StringHeight(Text)
Local TH = 0
Local Text2$ = Text
Local Zeilen = 0
Local LastString
.NewLine
For i% = 1 To Len(Text2)
If H > Zeilen * SH Then
If StringWidth(Mid (Text2,1, i)) > W Then
Ausgabe = Mid (Text2,1, i)
If Left(Ausgabe,1) = \" \" Then
Ausgabe = Mid(Ausgabe,2,Len(Ausgabe))
EndIf
Text2 = Mid(Text2,i+1,Len(Text))
Text X,Y+TH,Ausgabe
Zeilen = Zeilen + 1
LastString = i
Exit
Else
If StringWidth(Mid (Text2,1, i)) < W Then
If Len(Text2) < LastString Then
Ausgabe = Mid (Text2,1, Len(Text2))
If Left(Ausgabe,1) = \" \" Then
Ausgabe = Mid(Ausgabe,2,Len(Ausgabe))
EndIf
Text2 = \"\"
Text X,Y+TH,Ausgabe
Zeilen = Zeilen + 1
EndIf
EndIf
EndIf
Else
Goto TextEnd
EndIf
Next
If Len(text2) > 0 Then
TH = TH + SH
Goto NewLine
End If
.TextEnd
End Function





Function update_button(mx,my)
For b.button = Each button
If m_button = 1 Then
CameraProject camera,EntityX(b\sprite,1),EntityY(b\sprite,1),EntityZ(b\sprite,1)
If (mx > ProjectedX()) And (mx < (ProjectedX()+40)) Then
If (my>(ProjectedY()-20)) And (my < ProjectedY()) Then
EntityTexture b\sprite,b\tex,1
Return b\sprite
EndIf
EndIf
Else
EntityTexture b\sprite,b\tex,0
EndIf
Next


End Function

Function Edit_input$(x,y,txt$,id)
key=GetKey()
If key>31 Then txt$=txt$+Chr(key)
If KeyHit(181) Then txt$=Left(txt$,Len(txt$)-1):txt$=txt$+\"/\"
If KeyHit(83) Then txt$=txt$+\",\"
If KeyHit(14) And Len(txt$)>0 Then txt$=Left(txt$,Len(txt$)-1)
Return txt$
End Function

Function create_Edit(wnd,x_pos,y_pos,x_scal,y_scal,inhalt$,r,g,b)
E.Edit = New Edit
e\sprite = CreateSprite(wnd)
HandleSprite e\sprite,-1,-1
EntityAlpha e\sprite,.9
ScaleSprite e\sprite ,x_scal,y_scal
MoveEntity e\sprite ,x_pos*2,y_pos*2-(y_scal*2),0
e\texture = CreateTexture(x_scal,y_scal)
SetBuffer TextureBuffer(e\texture)
Color 255,255,255
ClsColor 0,0,0
Cls
Text 0,0,inhalt
SetBuffer BackBuffer()
EntityTexture e\sprite,e\texture
EntityBlend e\sprite,3
EntityOrder e\sprite,-2
e\x_scal=x_scal
e\y_scal = y_scal
e\aktiv = 0
e\inhalt = inhalt
SaveBuffer (TextureBuffer(e\texture),\"test.bmp\")
Return e\sprite
End Function

Function update_edit()
For e.edit = Each edit
If KeyDown(28) Then e\aktiv = 0
If MouseDown(1)
e\aktiv = 0
CameraProject camera,EntityX(e\sprite,1),EntityY(e\sprite,1),EntityZ(e\sprite,1)
If (MouseX() > ProjectedX()) And (MouseX() < (ProjectedX()+e\x_scal)) Then
If (MouseY()>(ProjectedY()-e\y_scal)) And (MouseY() < ProjectedY()) Then
e\aktiv = 1
FlushKeys
EndIf
EndIf
EndIf
FreeTexture e\texture
If e\aktiv = 1 Then
e\inhalt = Edit_input$(10,20,e\inhalt,1)
e\texture = write_Edit(e\sprite,Str(e\inhalt),300,40,100,100,100)
Else
e\texture = write_Edit(e\sprite,Str(e\inhalt),300,40,50,50,50)
EndIf
Next
End Function

Function write_Edit(lbl,sting$,x_scal,y_scal,r,g,b)
SetFont Font
tex = CreateTexture(x_scal,y_scal)
SetBuffer TextureBuffer(tex)
Color 255,255,255
ClsColor r,g,b
Cls
Text 0,0,sting
SetBuffer BackBuffer()
EntityTexture lbl,tex
Return tex
SetFont Font2
End Function

Function update_imagebox(img,url$)
For i.image = Each image
If img = i\sprite Then
i\textur = LoadTexture(url)
DebugLog(url)
EntityTexture i\sprite,i\textur
EndIf
Next
End Function

Function create_quickbar(url$,x_pos,y_pos)
q.quickbar = New quickbar
q\img = LoadImage(url)
q\x = x_pos
q\y = y_pos
q\item = \"0\"
End Function

Function draw_quickbar()
For q.quickbar = Each quickbar
DrawImage q\img,q\x,q\y
Next
End Function

Function draw_quickbar_item()
temp = 0
For q.quick_bar = Each quick_bar
If temp > 9 Then
FreeImage q\item
Delete q
Else
DrawImage q\item,953,134+(temp*38)
temp = temp + 1
EndIf
Next
End Function

Function use_quick_bar()
anz.anz_in_qbar = First anz_in_qbar

akt.akt_qbar = First akt_qbar

If KeyHit(11) Then
If anz\anz > -1 Then
If akt\akt <> 0 Then
akt.akt_qbar = First akt_qbar
akt\akt = 0
Else
akt\akt = -1
EndIf
Else
akt\akt = -1
EndIf
EndIf

If KeyHit(2) Then
If anz\anz > 0 Then
If akt\akt <> 1 Then
akt.akt_qbar = First akt_qbar
akt\akt = 1
Else
akt\akt = -1
EndIf
Else
akt\akt = -1
EndIf
EndIf

If KeyHit(3) Then
If anz\anz > 1 Then
If akt\akt <> 2 Then
akt.akt_qbar = First akt_qbar
akt\akt = 2
Else
akt\akt = -1
EndIf
Else
akt\akt = -1
EndIf
EndIf

If KeyHit(4) Then
If anz\anz > 2 Then
If akt\akt <> 3 Then
akt.akt_qbar = First akt_qbar
akt\akt = 3
Else
akt\akt = -1
EndIf
Else
akt\akt = -1
EndIf
EndIf

If KeyHit(5) Then
If anz\anz > 3 Then
If akt\akt <> 4 Then
akt.akt_qbar = First akt_qbar
akt\akt = 4
Else
akt\akt = -1
EndIf
Else
akt\akt = -1
EndIf
EndIf

If KeyHit(6) Then
If anz\anz > 4 Then
If akt\akt <> 5 Then
akt.akt_qbar = First akt_qbar
akt\akt = 5
Else
akt\akt = -1
EndIf
Else
akt\akt = -1
EndIf
EndIf

If KeyHit(7) Then
If anz\anz > 5 Then
If akt\akt <> 6 Then
akt.akt_qbar = First akt_qbar
akt\akt = 6
Else
akt\akt = -1
EndIf
Else
akt\akt = -1
EndIf
EndIf

If KeyHit(8) Then
If anz\anz > 6 Then
If akt\akt <> 7 Then
akt.akt_qbar = First akt_qbar
akt\akt = 7
Else
akt\akt = -1
EndIf
Else
akt\akt = -1
EndIf
EndIf

If KeyHit(9) Then
If anz\anz > 7 Then
If akt\akt <> 8 Then
akt.akt_qbar = First akt_qbar
akt\akt = 8
Else
akt\akt = -1
EndIf
Else
akt\akt = -1
EndIf
EndIf


If KeyHit(10) Then
If anz\anz > 8 Then
If akt\akt <> 9 Then
akt.akt_qbar = First akt_qbar
akt\akt = 9
Else
akt\akt = -1
EndIf
Else
akt\akt = -1
EndIf
EndIf

End Function

Function show_qbar_item()
akt.akt_qbar = First akt_qbar
temp = 0
For q.quick_bar = Each quick_bar
temp = temp + 1
If temp = akt\akt Then
If akt\model <> 0 Then FreeEntity akt\model
akt\model = LoadMesh(\"media\gfx\weapon\\" + q\url + \".3DS\",camera)
EntityColor akt\model,150,150,150
;EntityFX akt\model,8
If q\url = \"Pistol2\" Then
MoveEntity akt\model,.08,-.02,.14
ScaleMesh akt\model,.1,.1,.1
TurnEntity akt\model,0,180,0
EndIf
If q\url = \"Pistol1\" Then
MoveEntity akt\model,.08,-.02,.14
ScaleMesh akt\model,.0035,.0035,.0035
TurnEntity akt\model,0,90,0
EndIf
EndIf
Next
If akt\akt = -1 Then
If akt\model <> 0 Then
FreeEntity akt\model
akt\model = 0
EndIf
EndIf


End Function

[/syntax]
Für ewentuelle Rechtschreibfehler ist mein Duden verantwortlich

DaviD4D

BeitragMo, Aug 01, 2005 23:08
Antworten mit Zitat
Benutzer-Profile anzeigen
DoomMaster hat Folgendes geschrieben:
also ich poste hier einfach mal den code wie gesagt da das projekt nach der GC letztes jahr nicht weitergeführt wurde ist die GUI auch nicht komplet aber so als Denkanstoss:
.........
DANKE !! Smile

Neue Antwort erstellen


Übersicht BlitzBasic Allgemein

Gehe zu:

Powered by phpBB © 2001 - 2006, phpBB Group