alphagui problem
Blitz3D Forums/Blitz3D Userlibs/alphagui problem
| ||
I created a gui and it works great...only one problem there is a miniature version of it on the ground in my game as well as the one taking the whole screen. Any reasoning for this? Chris |
| ||
can you be more specific??? Post some screens?? |
| ||
here is a link to the screen shot you request![]() |
| ||
..may i see pieces of code you initialize AlphaGui as well as commands related to it within main loop, in relation with renderworld.. |
| ||
AlphaInit ; initialize the gui system; create the camera used throughout the system. AlphaGuiLoad("ar.gui") ; load the gui in, set to fill the whole screen then in the main loop RenderWorld tween AlphaGui play\px = EntityX(play\entity) : play\py = EntityY(play\entity) : play\pz = EntityZ(play\entity) Flip Wend End |
| ||
..you should put AlphaGui() update before renderworld since updates of all gadgets should happen before rendering..another thing what may causing this issue is that you using custom camera, after AlphaInit()...It is because after AlphaInit(), its created GUI camera..and obviously on your screen you have 2 cameras, i guess one you have created and another one belong to GUI...if so, you should do this: AlphaInit() AlphaGuiLoad("Example.gui") ;camera camera=CreateCamera() ;and now, place your GUI in front of camera you have created AlphaToFront ; bring the gui camera to front, in front of the previously created camera and keep AlphaGui() at begining of rendering loop, not after..keep in mind...you have 2 cams here..one AlphaGui and one yours.. I hope this helps.. |
| ||
Here is the full code minus typesAppTitle "Alternate Realities client Test" Dim splitdata$(10) ; collision determinators Const TYPE_PLAYER=1,TYPE_BULLET=2,TYPE_TARGET=3 Const TYPE_SCENERY=10,TYPE_TERRAIN=11 Global noserver=0 Global fps = 30 Global send_freq=2 ;send every fifth update Global networked=0 Dim splitdata$(1) SeedRnd MilliSecs() Global my_status$ Global play.player Global message$ Global msg$ Global client_id$ Global me_net ; basic graphics setup ;Include "start.bb" Graphics3D 1024,768,16,2 send_ct=1 Include "3denginefunctions.bb" ; all functions for world interaction Include "3denginetypes.bb" ; all types and structures Include "Alpha_Include.bb" ; include the functions Global player_model Global water_level=-98 Global light,castle,land,ground,water,sky Global bull_x#=1.5 Global playercount Collisions TYPE_PLAYER,TYPE_TERRAIN,2,3 Collisions TYPE_PLAYER,TYPE_SCENERY,2,3 Collisions TYPE_BULLET,TYPE_TERRAIN,2,1 Collisions TYPE_BULLET,TYPE_SCENERY,2,1 Collisions TYPE_TARGET,TYPE_TERRAIN,2,2 Collisions TYPE_TARGET,TYPE_SCENERY,2,2 setupworld() ChangeDir "environ" LoadEnviron( "terrain-1.jpg","water-2_mip.bmp","sky","heightmap_256.bmp" ) ChangeDir "..\" ; connect to server name$=Input("what is your name?") ip$="ar.game-host.org" port=8080 Global stream=OpenTCPStream(ip$,port) If stream=0 Print "could not connect to server...playing solo" Print "press a key to continue" WaitKey() Else split(ReadLine(stream)) play.player=createplayer(0,8,5) playercount=Int(splitdata$(1)) play\netid=Int(splitdata$(2)) play\name$=name$ networked=1 Print "You are playerid:"+play\netid+" and there are currently " + playercount + " players connected" WaitKey() EndIf Global walk=ExtractAnimSeq(play\model,280,310) ; AnimateMD2 play\model,1,1,32,100,1 play\stream=stream If networked=1 And playercount>1 WriteLine(play\stream,1+","+play\netid+","+EntityX(play\entity)+","+EntityY(play\entity)+","+EntityZ(play\entity)+","+EntityPitch(play\entity)+","+EntityYaw(play\entity)+","+EntityRoll(play\entity)+",1,1,"+name$) ; notify new player of all existing player If ReadAvail(stream) For ct=1 To playercount-1 p.player=createplayer(0,8,5) Line$=ReadLine(stream) split(Line$) p\netid=Int(splitdata$(2)) p\px=Float(splitdata$(3)):p\py=Float(splitdata$(4)):p\pz=Float(splitdata$(5)):p\rx=Float(splitdata$(6)):p\ry=Float(splitdata$(7)):p\rz=Float(splitdata$(8)) p\Aniseq=Int(splitdata$(9)):p\animframe=Int(splitdata$(10)):p\name$=splitdata$(11) p\stream=stream PositionEntity p\entity,p\px,p\py,p\pz,1 RotateEntity p\entity,p\rx,p\ry,p\rz Next End If End If camera1.ChaseCam=CreateChaseCam( play\entity ) listener=CreateListener( play\entity,.1,1,.2 ) period=1000/fps time=MilliSecs()-period piv=CreatePivot() PositionEntity piv,0,10,40 AlphaInit ; initialize the gui system; create the camera used throughout the system. AlphaGuiLoad("ar.gui") ; load the gui in, set to fill the whole screen While Not KeyHit(1) AlphaGui AlphaToFront If KeyHit(17) wire=Not wire WireFrame wire EndIf Repeat elapsed=MilliSecs()-time Until elapsed ;how many 'frames' have elapsed ticks=elapsed/period ;fractional remainder tween#=Float(elapsed Mod period)/Float(period) For k=1 To ticks time=time+period If k=ticks Then CaptureWorld TurnEntity piv,0,5,0 PositionEntity piv,0,7,40;47+Sin(time*.1)*40,40 UpdateGame() UpdateWorld For c.ChaseCam=Each ChaseCam UpdateChaseCam( c ) PositionEntity sky,EntityX(c\camera),EntityY(c\camera),EntityZ(c\camera) Next Next RenderWorld tween play\px = EntityX(play\entity) : play\py = EntityY(play\entity) : play\pz = EntityZ(play\entity) Flip Wend End Function UpdateGame() ;For h.Hole=Each Hole ; UpdateHole( h ) ;Next ;For b.Bullet=Each Bullet ; UpdateBullet( b ) ;Next ;For s.Spark=Each Spark ; UpdateSpark( s ) ;Next UpdatePlayer(play ) updatenetwork() End Function Function setupworld() do1=LoadMesh("drawftest.b3d") ScaleEntity do1,.03,.03,.03 PositionEntity do1,0,130,0 ; ScaleEntity do1,.003,.003,.003 EntityType do1, TYPE_SCENERY text2=LoadTexture("s04_stone01_s_01.tga") EntityTexture(do1,text2) player_model=LoadAnimMesh( "necromancer.b3d" ) DebugLog(AnimLength(player_model)); ScaleEntity player_model,.03,.03,.03 RotateEntity player_model,0,180,0; TranslateEntity player_model,0,-1.25,0 HideEntity player_model ; setup collisions - PLAYER TO DUNGEON End Function Function UpdateNetwork() While ReadAvail(stream) split(ReadLine(stream)) Select splitdata$(1) Case 1 For p.player=Each player If Int(splitdata$(2))=p\netid p\px=Float(splitdata$(3)):p\py=Float(splitdata$(4)):p\pz=Float(splitdata$(5)):p\rx=Float(splitdata$(6)):p\ry=Float(splitdata$(7)):p\rz=Float(splitdata$(8)) p\Aniseq=Int(splitdata$(9)):p\animframe=Int(splitdata$(10)):p\name$=splitdata$(11) PositionEntity p\entity,p\px,p\py,p\pz,1 RotateEntity p\entity,p\rx,p\ry,p\rz p\anim_speed=1.75 If Not AnimSeq(p\model) = walk necro_anim(p) EndIf EndIf Next Case 2 p.player=createplayer(0,1.501,5) Animate p\model,0 p\netid=splitdata$(2) Case 7 For p.player=Each player If Int(splitdata$(2))=p\netid FreeEntity p\entity Delete p EndIf Next End Select Wend For p.player=Each player If Animating(p\model)=False And anim_whichone(p\model)<>1 Animate p\model,0 EndIf Next End Function Function UpdateChaseCam( c.chasecam ) If KeyDown(200) TranslateEntity c\heading,0,-3,0 Else If KeyDown(208) TranslateEntity c\heading,0,+3,0 EndIf dx#=EntityX(c\target,True)-EntityX(c\camera,True) dy#=EntityY(c\target,True)-EntityY(c\camera,True) dz#=EntityZ(c\target,True)-EntityZ(c\camera,True) TranslateEntity c\camera,dx*.1,dy*.1,dz*.1 PointEntity c\camera,c\heading PositionEntity c\target,0,0,0 ResetEntity c\target PositionEntity c\target,0,3,-10 ; PositionEntity c\sky,EntityX(c\camera),EntityY(c\camera),EntityZ(c\camera) AlphaToFront End Function Function CreatePlayer.Player( x#,y#,z#) p.Player=New Player p\px=x p\py=y p\pz=z p\entity=CreatePivot() p\model=CopyEntity( player_model,p\entity ) PositionEntity p\entity,x,y,z,0 EntityType p\entity,TYPE_PLAYER EntityRadius p\entity,1.5 ResetEntity p\entity HideEntity player_model Return p End Function Function CreateChaseCam.ChaseCam( entity ) c.ChaseCam=New ChaseCam c\entity=entity c\camera=CreateCamera() c\target=CreatePivot( entity ) PositionEntity c\target,0,3,-10 EntityType c\target,TYPE_TARGET c\heading=CreatePivot( entity ) PositionEntity c\heading,0,0,20 ; c\sky=CopyEntity( sky ) Return c End Function Function UpdatePlayer( p.Player ) DebugLog("anim frame:"+AnimTime#(p\model)) move$="" If KeyHit(56) ;fire? ; CreateBullet( p ) EndIf If KeyDown(203) ;left/right move$="L" TurnEntity p\entity,0,6,0 ;turn player left/right ElseIf KeyDown(205) move$=move$+"R" TurnEntity p\entity,0,-6,0 EndIf If KeyDown(30) ;forward move$=move$+"F" If p\anim_speed<=0 p\anim_speed=1.75 ; Stop DebugLog("animseq:"+AnimSeq(p\model)) If Not AnimSeq(p\model) = walk necro_anim(p) EndIf ; anim_walk(p) EndIf MoveEntity p\entity,0,0,1 ElseIf KeyDown(44) ;back move$=move$+"B" If p\anim_speed>=0 p\anim_speed=-1.75 If Not AnimSeq(p\model) = walk necro_anim(p) EndIf EndIf MoveEntity p\entity,0,0,-1 ElseIf p\anim_speed p\anim_speed=0 Animate p\model,0 ; anim_idle(p) ;move$="I" EndIf Goto skip ex#=EntityX(p\entity):ez#=EntityZ(p\entity) PositionEntity p\entity,ex,TerrainY( land,ex,0,ez )+1.5,ez Return .skip ty#=EntityY(p\entity) y_vel#=(ty-p\player_y) p\player_y=ty If KeyHit(57) ;jump? y_vel=5 ;2.4 ;move$=move$+"JUMP" Else y_vel=y_vel-.5 ;2 EndIf TranslateEntity p\entity,0,y_vel,0 If networked=1 And move$<>"" ; p\Animframe=MD2AnimTime(p\model) If Instr(move$,"L") Or Instr(move$,"R") Then WriteLine(stream,1+","+p\netid+","+p\px+","+p\py+","+p\pz+","+p\rx+","+p\ry+","+p\rz+","+7+","+p\animframe+","+p\name$) If Instr(move$,"F") Or Instr(move$,"B") Then WriteLine(stream,1+","+p\netid+","+p\px+","+p\py+","+p\pz+","+p\rx+","+p\ry+","+p\rz+","+8+","+p\animframe+","+p\name$) EndIf p\px=EntityX(p\entity) p\py=EntityY(p\entity) p\pz=EntityZ(p\entity) p\rx=EntityPitch(p\entity) p\ry=EntityYaw(p\entity) p\rz=EntityRoll(p\entity) my_status$="A" .totallyskip End Function Function LoadEnviron( land_tex$,water_tex$,sky_tex$,height_map$ ) light=CreateLight() TurnEntity light,45,45,0 LightRange light,500 ; AmbientLight 10,10,10 ;dungeon to be dark, except for torch (local) lighting LightRange light,1 land_tex=LoadTexture( land_tex$,1 ) ScaleTexture land_tex,10,10 land=LoadTerrain( height_map$ ) EntityTexture land,land_tex TerrainShading land,True PositionEntity land,-1000,-100,-1000 ScaleEntity land,2000.0/256,100,2000.0/256 EntityType land,TYPE_TERRAIN TerrainDetail land,750,True For k=1 To n_trees Repeat tx#=Rnd(-70,70)-150 tz#=Rnd(-70,70)+400 ty#=TerrainY( land,tx,0,tz ) Until ty>water_level t=CopyEntity( tree_sprite ) PositionEntity t,tx,ty,tz ScaleSprite t,Rand(2,3),Rand(4,6) Next ground=CreatePlane() EntityTexture ground,land_tex PositionEntity ground,0,-100,0 EntityOrder ground,9 water_tex=LoadTexture( water_tex$,3 ) ScaleTexture water_tex,20,20 water=CreatePlane() EntityTexture water,water_tex PositionEntity water,0,water_level,0 sky=LoadSkyBox( sky_tex$ ) EntityOrder sky,10 HideEntity sky End Function Function LoadSkyBox( file$ ) m=CreateMesh() ;front face b=LoadBrush( file$+"_FR.jpg",49 ) s=CreateSurface( m,b ) AddVertex s,-1,+1,-1,0,0:AddVertex s,+1,+1,-1,1,0 AddVertex s,+1,-1,-1,1,1:AddVertex s,-1,-1,-1,0,1 AddTriangle s,0,1,2:AddTriangle s,0,2,3 FreeBrush b ;right face b=LoadBrush( file$+"_LF.jpg",49 ) s=CreateSurface( m,b ) AddVertex s,+1,+1,-1,0,0:AddVertex s,+1,+1,+1,1,0 AddVertex s,+1,-1,+1,1,1:AddVertex s,+1,-1,-1,0,1 AddTriangle s,0,1,2:AddTriangle s,0,2,3 FreeBrush b ;back face b=LoadBrush( file$+"_BK.jpg",49 ) s=CreateSurface( m,b ) AddVertex s,+1,+1,+1,0,0:AddVertex s,-1,+1,+1,1,0 AddVertex s,-1,-1,+1,1,1:AddVertex s,+1,-1,+1,0,1 AddTriangle s,0,1,2:AddTriangle s,0,2,3 FreeBrush b ;left face b=LoadBrush( file$+"_RT.jpg",49 ) s=CreateSurface( m,b ) AddVertex s,-1,+1,+1,0,0:AddVertex s,-1,+1,-1,1,0 AddVertex s,-1,-1,-1,1,1:AddVertex s,-1,-1,+1,0,1 AddTriangle s,0,1,2:AddTriangle s,0,2,3 FreeBrush b ;top face b=LoadBrush( file$+"_UP.jpg",49 ) s=CreateSurface( m,b ) AddVertex s,-1,+1,+1,0,1:AddVertex s,+1,+1,+1,0,0 AddVertex s,+1,+1,-1,1,0:AddVertex s,-1,+1,-1,1,1 AddTriangle s,0,1,2:AddTriangle s,0,2,3 FreeBrush b ;bottom face b=LoadBrush( file$+"_DN.jpg",49 ) s=CreateSurface( m,b ) AddVertex s,-1,-1,-1,1,0:AddVertex s,+1,-1,-1,1,1 AddVertex s,+1,-1,+1,0,1:AddVertex s,-1,-1,+1,0,0 AddTriangle s,0,1,2:AddTriangle s,0,2,3 FreeBrush b ScaleMesh m,100,100,100 FlipMesh m EntityFX m,1 Return m End Function Function anim_walk(p.player) If anim_whichone(p\model)<>2 ; DebugLog("frame:"+MD2AnimTime(p\model)) ; AnimateMD2 p\model,1,p\anim_speed,1,31,1 EndIf End Function Function anim_walk2(p.player) If anim_whichone(p\model)<>2 ; DebugLog("frame:"+MD2AnimTime(p\model)) ;AnimateMD2 p\model,3,p\anim_speed,1,31,1 EndIf End Function Function anim_idle(p.player) If anim_whichone(p\model)<>1 ; AnimateMD2 p\model,1,1,32,100,1 End If End Function Function anim_whichone(md2) End Function Function pnu(p.player) pack$ = EntityX(p\Entity)+" "+EntityY(p\Entity)+" "+EntityZ(p\Entity) ; SendNBMsg(1,pack,0,mainstream) pitch# = EntityPitch(p\entity) roll# = EntityRoll(p\entity) pack$=LSet$( pitch,7 )+LSet$( EntityYaw(p\entity),7 )+LSet$( roll,7 ) ; SendNBMsg(3,pack,nbmsgfrom(mainstream),mainstream) End Function Function Split(DataToSplit$) ;Declare our variables Local splitcounter = 0, pntr = -1,chris=1, pntr2 = 0, counter = 0 ; Continue to check for splits until we reach the end of the string Local a=0 While pntr <> 0 pntr = Instr(datatosplit$, ",", chris) ; If we found a split then add 1 to the counter If pntr > 0 Then splitcounter = splitcounter + 1 chris=pntr+1 a=a+1 Wend ; Now we have the amount of items (-1) in the string so we can dimension our array Dim SplitData$(splitcounter + 1) ; the first item in the string is handled differently than the rest since there is no comma preceding it pntr = 0:pntr2 = Instr(DataToSplit$, ",", 1) SplitData$(1) = Left$(DataToSplit$, pntr2 - 1) ; After splitting off the first item we move on to the rest of the string. For counter = 2 To splitcounter ; These 2 pointers keep track of the beginning and ending of the item we are looking for in the string. pntr = pntr2 + 1 pntr2 = Instr(DataToSplit$, ",", pntr) ; Now that we have the items location we can pull it from the main string and insert it in to our return array SplitData$(counter) = Mid$(DataToSplit$, pntr, (pntr2 - pntr)) Next ; Once we have done every instance of the comma delimiters we are left with the very end of the string ; This also is handled differently than the rest of the string since there is no comma after it. SplitData$(counter) = Right$(DataToSplit$, Len(DataToSplit$) - pntr2) ; Now we can return the # of items located in the string back to the calling program. Return (splitcounter + 1) End Function Function necro_anim(p.player) ;If Animateseq(p\model)=False Animate p\model,1,p\anim_speed,1,10 ;EndIf End Function |
| ||
sorry its very NOT finished...so a lot of useless stuff in it |
| ||
AlphaToFront() should be before main loop, after AlphaGuiLoad.. ;like this: ;############################ AlphaInit() ; initialize the gui system; create the camera used throughout the system. AlphaGuiLoad("ar.gui") ; load the gui in, set to fill the whole screen AlphaToFront() While Not KeyHit(1) CLS AlphaGui ;################################### |
| ||
didnt work here is fixed part AlphaInit() ; initialize the gui system; create the camera used throughout the system. AlphaGuiLoad("ar.gui") ; load the gui in, set to fill the whole screen AlphaToFront() While Not KeyHit(1) Cls AlphaGui If KeyHit(17) wire=Not wire WireFrame wire EndIf Repeat elapsed=MilliSecs()-time Until elapsed |
| ||
i keep trying everything you are saying, but still its there ;( |
| ||
..Chris..one of your cams are ON..thats why you have double HUD elements..Ill take a look closer when i came back...but point is..take a careful look where you updating your game camera in relation with Alpha Gui update... |
| ||
the only cam I have is a chase cam |
| ||
there is also AlphaGui cam created..do you have same FOV set for both cams?? |
| ||
probably since i dont think i set that at all |
| ||
..ahh..ok..i see that you using AlphaInit, after creating your camera..that should happen (AlphaInit) after Graphics3D command and BEFORE any camera of yours...second I see that you using AlphatoFront in your camera update, and before main loop too, whats shouldnt be a case.. so, try to structure like this Graphics3D AlphaInit() AlphaGuiLoad() MyCamera=CreateCamera() AlphaToFront() ;main loop repeat AlphaGui() ..blah blah UpdateWorld() RenderWorld() Flip Until KeyDown(1) |
| ||
if I do that the gui goes away all together :( |
| ||
..thats very very weird..it must be something more you messing with..because this basic structure should work with no problems at all..I never had issue with it.. |
| ||
..try to keep same structure as I posted, except changing AlphaGui() position in relation with renderworld() |