150$ for HGE wrapper

Everything else that doesn't fall into one of the other PB categories.
mskuma
Enthusiast
Enthusiast
Posts: 573
Joined: Sat Dec 03, 2005 1:31 am
Location: Australia

Post by mskuma »

neotoma, after you get back from holidays, I'd be interested to learn how the wrapper lib & HGE dll are built, because I'd like to try to improve the way the gui button works (the way it works in HGE is quite simplistic), and to do that, a source code recompile is necessary. I've had a brief look at the freebasic wrapper (seems like your work is related to that) but it seems the wrapper is a dll, and here it's a lib file. Thanks again for this - it's very interesting.
X
Enthusiast
Enthusiast
Posts: 311
Joined: Tue Apr 04, 2006 6:27 am

Post by X »

I am interested as well.
User avatar
zxtunes.com
Enthusiast
Enthusiast
Posts: 375
Joined: Wed Apr 23, 2008 7:51 am
Location: Saint-Petersburg, Russia
Contact:

Post by zxtunes.com »

Respect neotoma!!

But I have already started to write game under FreeBasic.

However I shall try to translate it under PureBasic.

I have found some bug in you wrapper, details I shall write hardly later.
User avatar
zxtunes.com
Enthusiast
Enthusiast
Posts: 375
Joined: Wed Apr 23, 2008 7:51 am
Location: Saint-Petersburg, Russia
Contact:

Post by zxtunes.com »

Tutorial number 7 have strange code:

Code: Select all

Structure sprObject 
  x.f
  y.f
  dx.f
  dy.f
  scale.f
  rot.f
  dscale.f
  drot.f
  color.l
EndStructure
  
Global *pObjects.sprObject;
Global nObjects.l;


ProcedureCDLL frameFunc()
  dt.f = hge_Timer_GetDelta();
  Define.l i
  
....
  
  ; // Update the scene
  For i = 0 To nObjects-1           
    *p.sprObject = *pObjects + (i * SizeOf(sprObject))
    *p\x = *p\x + *p\dx*dt
    If *p\x > #SCREEN_WIDTH Or *p\x < 0 :  *p\dx= -*p\dx :EndIf
    *p\y = *p\y + *p\dy*dt
    If *p\y > #SCREEN_HEIGHT Or *p\y < 0 : *p\dy = - *p\dy : EndIf
    *p\scale = *p\scale + *p\dscale*dt
    If *p\scale > 2 Or *p\scale < 0.5 : *p\dscale = - *p\dscale : EndIf
    *p\rot = *p\rot + *p\drot*dt
  Next
  
  ProcedureReturn #False
EndProcedure
Anybody known what for here it is necessary "define i" and "*" (pointers)?

I create similar code and all work without "*" and "define".
User avatar
Demivec
Addict
Addict
Posts: 4257
Joined: Mon Jul 25, 2005 3:51 pm
Location: Utah, USA

Post by Demivec »

zxtunes.com wrote:Anybody known what for here it is necessary "define i" and "*" (pointers)?

I create similar code and all work without "*" and "define".
@zxtunes: it looks like they are used with EnableExplicit. In other words, they make the code more understandable and well defined.
neotoma
User
User
Posts: 84
Joined: Sun Dec 14, 2003 6:38 pm
Location: Germany, Mechernich
Contact:

Post by neotoma »

Back from the Netherlands, but still in Holidays... i can't stop looking in the Forum ;-)

@mskuma and x :
I used the Wrapper froim FreeBasic, changed to a static lib and compiled it with vc++ 2003 Toolkit (free). I use no makefile - but it would be easy to make one. My C++-IDE is Codeblocks (free) . Everything has to work from my USB-Stick - so i use not vc++6, 2005, 2008. And i can't build static libs for PB with gcc - so thats my own solution for that problem.

mskuma, you can pm me. If you are interested in improve the HGE-Wrapper we can go and use a svn-server like http://www.assembla.com/ to work together with them. There are also some GUI-Extensions in the HGE-Forums. Maybe we can add them.....

@zxtunes.com
i really dislike FreeBasic (can't say why), but i think PureBasic is better.. ;-) Thats why i write my wrappers.... Hope you come Back with your project.

And Demivec is right. I started with the impression to make the examples as clean as possible. But i ran out of time so the examples not very clean. Sorry for that....

Mike
User avatar
zxtunes.com
Enthusiast
Enthusiast
Posts: 375
Joined: Wed Apr 23, 2008 7:51 am
Location: Saint-Petersburg, Russia
Contact:

Post by zxtunes.com »

neotoma wrote: @zxtunes.com
i really dislike FreeBasic (can't say why), but i think PureBasic is better.. ;-) Thats why i write my wrappers.... Hope you come Back with your project.
Yes, i too love Pure Basic. :)

See my first example on PB+HGE (Lense Effect - Fish eye):

I comment ";hge_DistortionMesh_SetTextureRect(*dis,x_t,y_t,512,512)", but this work on FreeBasic and C++ and not work in Pure Basic (destroy last distortionMesh modification).

full example package: http://zxpk.untergrund.net/temp/spheroid.rar (2mb)

Code: Select all

XIncludeFile #PB_Compiler_Home + "Includes\HGEWrapper_include.pbi"


Global x_mouse.f, y_mouse.f, last_x_mouse.l, last_y_mouse.l, radius=256, texture_nm
Global Size.f=2, x_t.f=256, y_t.f=256, deform.f=0.75


Global nRows=64
Global nCols=64
Global cellw.f=512.0/(nCols-1)
Global cellh.f=512.0/(nRows-1)
Global radius=256
Global tex1.l,tex2.l,tex3.l,tex4.l
Global *dis, *fnt
Global *x_mouse = @x_mouse
Global *y_mouse = @y_mouse

ProcedureCDLL frameFunc()
 
 hge_DistortionMesh_SetTextureRect(*dis,x_t,y_t,512,512)


  For y = -radius To radius Step 8
    For x = -radius To radius Step 8
    	
    	distance.f = Sqr(x*x + y*y)
      
    	If distance < radius:
        z.f = 1.0 - deform + deform * (distance/radius)
      Else:
    		z.f = 1.0 * (distance/radius)
    	EndIf  
      
      a.f = x/z + radius
      b.f = y/z + radius
      hge_DistortionMesh_SetDisplacement(*dis, (radius+x)/8, (radius+y)/8, a, b, #HGEDISP_TOPLEFT)
      
    Next x
  Next y
  

        
  
  a = hge_Input_GetMouseWheel()
  If a>0: deform + 0.01: ElseIf a<0: deform - 0.01: EndIf    
  
  
      If hge_Input_GetKey() = #HGEK_ESCAPE : ProcedureReturn #True: EndIf
          
      hge_Input_GetMousePos(*x_mouse,*y_mouse)    
      If hge_Input_GetKeyState(#HGEK_LBUTTON):   
        x_t + (last_x_mouse - x_mouse)
        y_t + (last_y_mouse - y_mouse)
      EndIf
      
      x_t + 0.02
      y_t + 0.025
      last_x_mouse = x_mouse
      last_y_mouse = y_mouse
      
      If hge_Input_GetKey() = #HGEK_SPACE:
      
        texture_nm + 1: texture_nm & 3
      
        Select texture_nm
          Case 0: hge_DistortionMesh_SetTexture(*dis, tex1) 
          Case 1: hge_DistortionMesh_SetTexture(*dis, tex2) 
          Case 2: hge_DistortionMesh_SetTexture(*dis, tex3) 
          Case 3: hge_DistortionMesh_SetTexture(*dis, tex4) 
        EndSelect  
      
      EndIf
                   
       
       
  ProcedureReturn #False
EndProcedure




ProcedureCDLL RenderFunc() 

  hge_Gfx_BeginScene(#Null)
  hge_Gfx_Clear(0)
 
  ;hge_DistortionMesh_SetTextureRect(*dis,x_t,y_t,512,512)
  hge_DistortionMesh_Render(*dis, 0,0)   
  fps.l =  hge_Timer_GetFPS()
  hge_Font_Render(*fnt,5, 35, #HGETEXT_LEFT,"FPS: " + Str(hge_Timer_GetFPS()))
  hge_Gfx_EndScene()
  
  ProcedureReturn #False
EndProcedure



hge_Create(#HGE_VERSION)
Path$ = GetCurrentDirectory()

hge_System_SetStateString(#hge_LOGFILE, Path$+"spheroid_test.log")
hge_System_SetStateFunc(#HGE_FRAMEFUNC, @frameFunc())
hge_System_SetStateFunc(#hge_RENDERFUNC, @RenderFunc())
hge_System_SetStateString(#HGE_TITLE, "Spheroid test 0.1")
hge_System_SetStateBool(#HGE_USESOUND, #False )
hge_System_SetStateBool(#HGE_WINDOWED, #True )
hge_System_SetStateInt(#hge_SCREENWIDTH, 512)
hge_System_SetStateInt(#hge_SCREENHEIGHT, 512)
hge_System_SetStateInt(#hge_SCREENBPP, 32)
hge_System_SetStateBool(#HGE_SHOWSPLASH,#False)
hge_System_SetStateBool(#HGE_HIDEMOUSE,#False)
hge_System_SetStateBool(#HGE_ZBUFFER,#False)


If (hge_System_Initiate()):

    tex1 = hge_Texture_Load(Path$+"texture_big1.jpg",0,#False)
    tex2 = hge_Texture_Load(Path$+"texture_big2.jpg",0,#False)
    tex3 = hge_Texture_Load(Path$+"texture_big3.jpg",0,#False)
    tex4 = hge_Texture_Load(Path$+"texture_big4.jpg",0,#False)
    
    
    *fnt = hge_Font(Path$+"font1.fnt",0)
    *dis = hge_DistortionMesh(nCols, nRows)
    hge_DistortionMesh_SetTexture(*dis, tex1)
    hge_DistortionMesh_SetTextureRect(*dis,t_x,t_y,512,512)
    hge_DistortionMesh_SetBlendMode(*dis, #BLEND_COLORADD | #BLEND_ALPHABLEND | #BLEND_NOZWRITE)
    hge_DistortionMesh_Clear(*dis,$FF000000,0.5)
    
    
    hge_Input_GetMousePos(*x_mouse, *y_mouse)
    frameFunc()
    hge_System_Start()


    hge_Font_Delete(*fnt)
    hge_Texture_Free(tex1)
    hge_Texture_Free(tex2)
    hge_Texture_Free(tex3)
    hge_Texture_Free(tex4)

    hge_System_Shutdown()
    hge_Release()

EndIf
  
User avatar
Rook Zimbabwe
Addict
Addict
Posts: 4322
Joined: Tue Jan 02, 2007 8:16 pm
Location: Cypress TX
Contact:

Post by Rook Zimbabwe »

Looks like interesting code... I think you need to comment it more.

So I can see what you figured out in the HGE lib! 8)
Binarily speaking... it takes 10 to Tango!!!

Image
http://www.bluemesapc.com/
X
Enthusiast
Enthusiast
Posts: 311
Joined: Tue Apr 04, 2006 6:27 am

Post by X »

Very Interesting. The GUI options are definately something to look forward to. Especially if there was a step-by-step on how you did so. That would allow amateurs like myself to create GUI controls for HGE in VC++, and use them in PB.
neotoma
User
User
Posts: 84
Joined: Sun Dec 14, 2003 6:38 pm
Location: Germany, Mechernich
Contact:

Post by neotoma »

zxtunes.com wrote: I comment ";hge_DistortionMesh_SetTextureRect(*dis,x_t,y_t,512,512)", but this work on FreeBasic and C++ and not work in Pure Basic (destroy last distortionMesh modification).
Hi zxtunes - i looked at the wrapper - but there is nothing special.
The wrapper calls the SetTextureRect(...) on the DistortionMesh.
Can you explain this a little bit mor. So thet i'm able to fix it.

And - great example !

Mike
User avatar
zxtunes.com
Enthusiast
Enthusiast
Posts: 375
Joined: Wed Apr 23, 2008 7:51 am
Location: Saint-Petersburg, Russia
Contact:

Post by zxtunes.com »

some bug in file "HGEWrapper_Import.pbi" in 37 line, сomma instead of a point.

True: "hge_DistortionMesh_SetZ(*hgeDistortionMesh, Col.l, row.l, z.f)"
User avatar
zxtunes.com
Enthusiast
Enthusiast
Posts: 375
Joined: Wed Apr 23, 2008 7:51 am
Location: Saint-Petersburg, Russia
Contact:

Post by zxtunes.com »

I finished my example "Spheroid".

I hope it somebody will be useful.

Many places not are optimized what was more clearly.

http://zxpk.untergrund.net/temp/spheroid_example.rar (700kb)

Image

source:

Code: Select all

;Spheroid by Newart 18.6.2008

XIncludeFile #PB_Compiler_Home + "Includes\HGEWrapper_include.pbi"

#step = 8 ;radius * 2 / cells - Size one cell of deformation grid (Distortion Mesh)
Global cells = 64; Quantity cells in deformation grid (Distortion Mesh) - 
Global radius = 256

Global *dis, *fnt
Global x_mouse.f
Global y_mouse.f
Global *x_mouse = @x_mouse
Global *y_mouse = @y_mouse
Global last_x_mouse.l
Global last_y_mouse.l
Global x_t.f = radius
Global y_t.f = radius
Global mode.l
Global grid.l
Global Dim texture.l(1)
Global Dim deform.f(1)

deform.f(0) = 0.75
deform.f(1) = 1.65



ProcedureCDLL frameFunc()
  
  hge_DistortionMesh_SetTextureRect(*dis, x_t, y_t, radius * 2, radius * 2)
  
  If mode = 0: ; "Lens"
    
    For i = -radius To radius Step #step
      For j = -radius To radius Step #step
        
        distance.f = Sqr(j*j + i*i)
        
        If distance < radius:
          z.f = 1.0 - deform(0) + deform(0) * (distance/radius)
        Else:
          z.f = 1.0 * (distance/radius);hide corners on perimeter of sphere
          ; z.f = 1.0 - most funny 
        EndIf  
        
        a.f = j/z + radius
        b.f = i/z + radius
        hge_DistortionMesh_SetDisplacement(*dis, (radius+j)/#step, (radius+i)/#step, a, b, #HGEDISP_TOPLEFT)
        
      Next j
    Next i
    
  Else  ;"Sphere"
    
    ;fill on quarters, from the center to edges
    
    For i = 0 To -radius Step -#step
      For j = 0 To -radius Step -#step
        
        s.f = Sin(#M_PI/2 + (#M_PI/2) / (radius*deform(1)) * Sqr(i*i+j*j))
        x.f = i*s
        y.f = j*s  
        ;would use Z what to hide corners of a texture under sphere
        hge_DistortionMesh_SetZ(*dis, (radius+i)/#step, (radius+j)/#step, 1-Abs(s) )
        hge_DistortionMesh_SetDisplacement(*dis, (radius+i)/#step, (radius+j)/#step, x+radius, y+radius, #HGEDISP_TOPLEFT)
         
      Next j
    Next i  

    For i = radius To 0 Step -#step
      For j = 0 To -radius Step -#step
        
        s = Sin(#M_PI/2 + (#M_PI/2) / (radius*deform(1)) * Sqr(i*i+j*j))
        x = i*s
        y = j*s  
        hge_DistortionMesh_SetZ(*dis, (radius+i)/#step, (radius+j)/#step, 1-Abs(s) )
        hge_DistortionMesh_SetDisplacement(*dis, (radius+i)/#step, (radius+j)/#step, x+radius, y+radius, #HGEDISP_TOPLEFT)
        
      Next j
    Next i  
    
    For i = 0 To -radius Step -#step
      For j = radius To 0 Step -#step
        
        s = Sin(#M_PI/2 + (#M_PI/2) / (radius*deform(1)) * Sqr(i*i+j*j))
        x = i*s
        y = j*s  
        hge_DistortionMesh_SetZ(*dis, (radius+i)/#step, (radius+j)/#step, 1-Abs(s) )
        hge_DistortionMesh_SetDisplacement(*dis, (radius+i)/#step, (radius+j)/#step, x+radius, y+radius, #HGEDISP_TOPLEFT)
         
      Next j
    Next i  	
    
    For i = 0 To radius Step #step
      For j = 0 To radius Step #step
        
        s = Sin(#M_PI/2 + (#M_PI/2) / (radius*deform(1)) * Sqr(i*i+j*j))
        x = i*s
        y = j*s  
        hge_DistortionMesh_SetZ(*dis, (radius+i)/#step, (radius+j)/#step, 1-Abs(s) )
        hge_DistortionMesh_SetDisplacement(*dis, (radius+i)/#step, (radius+j)/#step, x+radius, y+radius, #HGEDISP_TOPLEFT)
         
      Next j
    Next i  
    
  EndIf
  
  
  
  a = hge_Input_GetMouseWheel()
  
  If a>0: deform(mode) + 0.01: ElseIf a<0: deform(mode) - 0.01: EndIf ; change deformation  
  
  If hge_Input_GetKey() = #HGEK_ESCAPE : ProcedureReturn #True: EndIf
  
  If hge_Input_GetKey() = #HGEK_G: grid ! 1: hge_DistortionMesh_SetTexture(*dis, texture(grid)): EndIf
  
  hge_Input_GetMousePos(*x_mouse,*y_mouse)    
  
  If hge_Input_GetKeyState(#HGEK_LBUTTON):   
    x_t + (last_x_mouse - x_mouse)
    y_t + (last_y_mouse - y_mouse)
  EndIf
  
  x_t + 0.02 ; Moved on subpixel, looked very smoothly!! 
  y_t + 0.025;
  last_x_mouse = x_mouse
  last_y_mouse = y_mouse
  
  If hge_Input_GetKey() = #HGEK_SPACE: mode ! 1: EndIf
  
  ProcedureReturn #False
EndProcedure




ProcedureCDLL RenderFunc() 

  hge_Gfx_BeginScene(#Null)
  hge_Gfx_Clear(0)

  hge_DistortionMesh_Render(*dis, 0,0)   
  fps.l =  hge_Timer_GetFPS()
  hge_Font_SetZ(*fnt, 0)
  hge_Font_Render(*fnt,5, 5, #HGETEXT_LEFT,"FPS: " + Str(hge_Timer_GetFPS()))
  hge_Font_Render(*fnt,5, 35, #HGETEXT_LEFT,"MODE: " + Str(mode))
  hge_Font_Render(*fnt,5, 65, #HGETEXT_LEFT,"DEFORM: " + StrF(deform(mode)))
  hge_Gfx_EndScene()
  
  ProcedureReturn #False
EndProcedure



hge_Create(#HGE_VERSION)
Path$ = GetCurrentDirectory()

hge_System_SetStateString(#hge_LOGFILE, Path$+"spheroid.log")
hge_System_SetStateFunc(#HGE_FRAMEFUNC, @frameFunc())
hge_System_SetStateFunc(#hge_RENDERFUNC, @RenderFunc())
hge_System_SetStateString(#HGE_TITLE, "Spheroid")
hge_System_SetStateBool(#HGE_USESOUND, #False )
hge_System_SetStateBool(#HGE_WINDOWED, #True )
hge_System_SetStateInt(#hge_SCREENWIDTH, 512)
hge_System_SetStateInt(#hge_SCREENHEIGHT, 512)
hge_System_SetStateInt(#hge_SCREENBPP, 32)
hge_System_SetStateBool(#HGE_SHOWSPLASH,#False)
hge_System_SetStateBool(#HGE_HIDEMOUSE,#False)
hge_System_SetStateBool(#HGE_ZBUFFER,#True)


If (hge_System_Initiate()):

    texture(0) = hge_Texture_Load(Path$+"texture_pict.jpg",0,#False)
    texture(1) = hge_Texture_Load(Path$+"texture_grid.png",0,#False)
    *fnt = hge_Font(Path$+"font1.fnt",0)
    *dis = hge_DistortionMesh(cells, cells)
    
    hge_DistortionMesh_SetTexture(*dis, texture(grid))
    hge_DistortionMesh_SetTextureRect(*dis,t_x,t_y, radius*2, radius*2)
    
    hge_Input_GetMousePos(*x_mouse, *y_mouse)
    frameFunc()
    hge_System_Start()

    hge_Font_Delete(*fnt)

    hge_Texture_Free(texture1)
    hge_Texture_Free(texture2)
    hge_System_Shutdown()
    hge_Release()

EndIf
  
User avatar
zxtunes.com
Enthusiast
Enthusiast
Posts: 375
Joined: Wed Apr 23, 2008 7:51 am
Location: Saint-Petersburg, Russia
Contact:

Post by zxtunes.com »

Anybody have ideas how to make more realistic sphere (simulation)?
User avatar
nco2k
Addict
Addict
Posts: 1344
Joined: Mon Sep 15, 2003 5:55 am

Re: 150$ for HGE wrapper

Post by nco2k »

can anyone reupload the wrapper and the examples please?

c ya,
nco2k
If OSVersion() = #PB_OS_Windows_ME : End : EndIf
neotoma
User
User
Posts: 84
Joined: Sun Dec 14, 2003 6:38 pm
Location: Germany, Mechernich
Contact:

Re: 150$ for HGE wrapper

Post by neotoma »

nco2k wrote:can anyone reupload the wrapper and the examples please?
Found a version on my Drive: http://www.file-upload.net/download-308 ... r.zip.html.

But not checked with the actual PB-Version!

Have fun,
Mike
Post Reply