Seite 1 von 2

mit n3xtd lässt sich auch leicht programmieren

Verfasst: 01.04.2010 12:01
von super_castle
Das Paket n3xtd lässt sich einfach handhaben.
Also n3xtd installieren und probieren.

Ein Quadro Heli mit n3xtd.
Für die Bemalung fertige kurz noch 3 Bmp-Bilder an 128x128 (rot,gruen,blau).

Mit den Tasten "R,T" Triebwerk an/aus.
Bei Umdrehung 5000 kannste mit den Tasten "D,C" vor und zurück fliegen und mit den Tasten "QWES" das Ding neigen.
Mit den Tasten "F,V" muss man erst mindestens die Höhe 300 erreichen bevor es los geht mit dem Fliegen!

Gruss

Code: Alles auswählen


IncludePath "includes"   
IncludeFile "n3xtD_PB.pbi"

Enumeration
  #Window_0
  #Container_0
  #Button_0
EndEnumeration

Declare make_container()
Declare make_mesh()

#NBPivot   = 7
#NbBranche = 7

Global *obj2.IObject , *plane.IMesh ,*cam.ICamera
Global dx.f,dx0.f,xno.f,yno.f,zno.f,ty.f,tt.f,tt1.f,td.f,td1.f,tz.f

Global Dim *mesh.IMesh(#NbBranche, #NBPivot)
Global Dim *pivot.IPivot(#NbBranche, #NBPivot)

SetCurrentDirectory("media/") 
  
OpenWindow(0, 0, 0, 800,600, "test", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  
ButtonGadget(#Button_0, 20, 40, 110, 40, "QUIT ")
  
text1=TextGadget(#PB_Any, 20,200,100,20, "Triebwerk : "+Str(dx))  
text3=TextGadget(#PB_Any, 20,220,100,20, "Antrieb : "+Str(ty))
text2=TextGadget(#PB_Any, 20,240,100,20, "Höhe : " +Str(dy1))  
  
xno=0
yno=1
zno=0
td=0.2
td1=0.2
  
make_container()
make_mesh()
 
*plane.IMesh = iCreateCube(1) 
iScaleMeshBuffer(iMeshGeometry(*plane), 50.0,0.2,50.0)  
iLoadTextureNode(*plane, "wall.jpg") 

*cam.ICamera = iCreateCamera( )
iPositionNode(*cam, 0,25,-40)
iTurnNode(*cam, 20,0,0)

  Repeat
   
  Event = WaitWindowEvent(0)
 
  If EventGadget() = #Button_0
    End
  EndIf
  
  If GetAsyncKeyState_(#VK_R) And dx=0
    te=1
  EndIf  
  
  If GetAsyncKeyState_(#VK_T) And yno< 1.1
    te=0
  EndIf 
  
  If GetAsyncKeyState_(#VK_C) And yno >3.0
    If te=2
      ty=0
      tz=tz-0.0001
      If tz < -0.01 : tz=-0.01 : EndIf
      SetGadgetText(text3,"Antrieb :             ")  
      SetGadgetText(text3,"Antrieb : "+Str(tz*1000))  
    EndIf     
  EndIf
  
  If GetAsyncKeyState_(#VK_D) And yno >3.0
    If te=2
      ty=0
      tz=tz+0.0001
      If tz > 0.01 : tz=0.01 : EndIf
      SetGadgetText(text3,"Antrieb :             ")  
      SetGadgetText(text3,"Antrieb : "+Str(tz*1000))  
    EndIf  
  EndIf
  
  If GetAsyncKeyState_(#VK_F)
    If te=2
      ty=ty+0.0001
      If ty > 0.01 : ty=0.01 : EndIf
    EndIf  
  EndIf
  
  If GetAsyncKeyState_(#VK_V)
    If te=2
      ty=ty-0.0001
      If ty < -0.025 : ty=-0.025 : EndIf
    EndIf  
  EndIf
  
  If GetAsyncKeyState_(#VK_G)
    If te=2 And  ty < 0.004
      ty=0
    EndIf  
  EndIf
  
  If GetAsyncKeyState_(#VK_W) And yno >3.0
    iTurnAirNode(*pivot(0,0), td,0,0)
  EndIf 
  
  If GetAsyncKeyState_(#VK_S) And yno >3.0
    iTurnAirNode(*pivot(0,0),-td,0,0)
  EndIf  
  
  If GetAsyncKeyState_(#VK_Q) And yno >3.0
    iTurnAirNode(*pivot(0,0), 0,0,td1)
  EndIf 
  
  If GetAsyncKeyState_(#VK_E) And yno >3.0
    iTurnAirNode(*pivot(0,0), 0,0,-td1)  
  EndIf    
  
  If te=1 And dx < 5.0
    dx=dx+0.005
    dx0=dx0+0.005
    If dx > 5
      te=2
    EndIf  
    SetGadgetText(text1,"Triebwerk :")  
    SetGadgetText(text1,"Triebwerk : "+Str(dx*1000))   
  EndIf 
    
  If te=0 And dx > 0.0 
    dx=dx-0.005
    dx0=dx0-0.005
    If dx < 0
      te=3
    EndIf 
    If dx < 0.1 : dx=0.0:EndIf
    SetGadgetText(text1,"Triebwerk :")  
    SetGadgetText(text1,"Triebwerk : "+Str(dx*1000))   
  EndIf   
  
  iMovenode(*pivot(0,0), 0,-ty,tz)
  iTurnNode(*pivot(0,1),0,dx,0)
  iTurnNode(*pivot(0,2),0,dx,0)
  iTurnNode(*pivot(0,4),0,dx,0)
  iTurnNode(*pivot(0,5),0,dx,0)
  
  yno=inodey(*pivot(0,0)) 
  SetGadgetText(text2,"Höhe : ")  
  SetGadgetText(text2,"Höhe : " +Str(yno*100))
  
   SetGadgetText(text3,"Antrieb : "+StrF(ty))  
  If yno < 1 
    iMovenode(*pivot(0,0), 0,-0.01,tz)
    ty=0 
    tz=0
    iMovenode(*pivot(0,0), 0,ty,tz)
  EndIf  
  
  iBeginScene(200,200,200)
    iDrawScene()
  iEndScene()
 
  ForEver
  iFreeEngine()
End

Procedure make_mesh()
  *pivot(0, 0) = iCreatePivot()
  ipositionnode( *pivot(0, 0), xno,yno,zno)
  *mesh(0, 0) = iCreateCube(1, *pivot(0, 0))
  iScaleMeshBuffer(iMeshGeometry(*mesh(0, 0)), 0.2,0.2,5)
  iPositionNode( *mesh(0, 0),0 ,0, 0)
  iMaterialTypeNode(*mesh(0, 0), #EMT_TRANSPARENT_ALPHA_CHANNEL_REF  )
  
  *pivot(0,1) = iCreatePivot(*mesh(0,0))
  iTranslateNode(*pivot(0,1), 0.0, 0.05, 2.5)
  *mesh(0,1) = iCreateCube(1 , *pivot(0,1)) 
  iScaleMeshBuffer(iMeshGeometry(*mesh(0,1)),  0.3,0.05,2)
  iPositionNode( *mesh(0, 1),0 ,0, 0)
  iMaterialTypeNode(*mesh(0, 1), #EMT_TRANSPARENT_ALPHA_CHANNEL_REF  )
  iPositionNode( *mesh(0, 1),0.0 ,0.2, 0.0)
  
  *pivot(0,2) = iCreatePivot(*mesh(0,0))
  iTranslateNode(*pivot(0,2), 0.0, 0.05, -2.5)
  *mesh(0,2) = iCreateCube(1 , *pivot(0,2)) 
  iScaleMeshBuffer(iMeshGeometry(*mesh(0,2)),  0.3,0.05,2)
  iPositionNode( *mesh(0, 2),0 ,0, 0)
  iMaterialTypeNode(*mesh(0, 2), #EMT_TRANSPARENT_ALPHA_CHANNEL_REF  )
  iPositionNode( *mesh(0, 2),0.0 ,0.2, 0.0)  
  
  *pivot(0, 3) =iCreatePivot(*mesh(0,0))
  iPositionNode( *pivot(0, 3),0,0,0)
  *mesh(0, 3) = iCreateCube(1, *pivot(0, 3))
  iScaleMeshBuffer(iMeshGeometry(*mesh(0, 3)), 0.2,0.2,5)
  iPositionNode( *mesh(0, 3),0 ,0, 0)
  irotateNode(*pivot(0,3) , 0,90,0)
  iMaterialTypeNode(*mesh(0, 3), #EMT_TRANSPARENT_ALPHA_CHANNEL_REF  )
  
  *pivot(0,4) = iCreatePivot(*mesh(0,0))
  iTranslateNode(*pivot(0,4), 2.5, 0.05, 0.0)
  *mesh(0,4) = iCreateCube(1 , *pivot(0,4)) 
  iScaleMeshBuffer(iMeshGeometry(*mesh(0,4)),  0.3,0.05,2)
  iPositionNode( *mesh(0, 4),0 ,0, 0)
  iMaterialTypeNode(*mesh(0, 4), #EMT_TRANSPARENT_ALPHA_CHANNEL_REF  )
  iPositionNode( *mesh(0, 4),0.0 ,0.2, 0.0)
  
  *pivot(0,5) = iCreatePivot(*mesh(0,0))
  iTranslateNode(*pivot(0,5), -2.5, 0.05, 0.0)
  *mesh(0,5) = iCreateCube(1 , *pivot(0,5)) 
  iScaleMeshBuffer(iMeshGeometry(*mesh(0,5)),  0.3,0.05,2)
  iPositionNode( *mesh(0, 5),0 ,0, 0)
  iMaterialTypeNode(*mesh(0, 5), #EMT_TRANSPARENT_ALPHA_CHANNEL_REF  )
  iPositionNode( *mesh(0, 5),0.0 ,0.2, 0.0)
  
  *pivot(0,6) = iCreatePivot(*mesh(0,0))
  iTranslateNode(*pivot(0,6), 0,0,0)
  *mesh(0,6) = iCreateSphere(0.8 ,8, *pivot(0,6)) 
  iScaleMeshBuffer(iMeshGeometry(*mesh(0,6)),  0.5,0.5,0.5)
  iPositionNode( *mesh(0, 6),0 ,0, 0)
  iMaterialTypeNode(*mesh(0, 6), #EMT_TRANSPARENT_ALPHA_CHANNEL_REF  )
  iPositionNode( *mesh(0, 6),0.0 ,0.1, 0.0)
  
  iLoadTextureNode(*mesh(0, 0), "rot.bmp") 
  iLoadTextureNode(*mesh(0, 1), "blau.bmp") 
  iLoadTextureNode(*mesh(0, 2), "blau.bmp") 
  iLoadTextureNode(*mesh(0, 3), "rot.bmp") 
  iLoadTextureNode(*mesh(0, 4), "blau.bmp") 
  iLoadTextureNode(*mesh(0, 5), "blau.bmp") 
  iLoadTextureNode(*mesh(0, 6), "gruen.bmp") 
EndProcedure  

Procedure make_container()
  ContainerGadget(#Container_0, 140,10, 640,550)
  iGraphics3DGadget(800,550, GadgetID(#Container_0))
EndProcedure  


Re: mit n3xtd lässt sich auch leicht programmieren

Verfasst: 18.07.2010 22:59
von Darie
Wird n3xtd eigentlich noch weiterentwickelt? Leider tut sich ja auf der offiziellen Seite nichts. Suche nämlich noch Tutorials oder ein paar mehr Infos zu dem Wrapper.

Re: mit n3xtd lässt sich auch leicht programmieren

Verfasst: 19.07.2010 13:21
von bobobo
musst du dann dort fragen und nicht hier.
Irrlicht kannst Du auch selber wrappen .. guckst du mal nach dokus
auf der Irrlicht-Seite

Re: mit n3xtd lässt sich auch leicht programmieren

Verfasst: 19.07.2010 14:33
von Darie
Oh, ich Depp dachte die Seite wäre Under Construction..... :lamer:

Re: mit n3xtd lässt sich auch leicht programmieren

Verfasst: 19.07.2010 22:23
von Lebostein
Was ist an dem GetAsyncKeyState_() so besonderes? Kann ich den mit PB ersetzen?

Re: mit n3xtd lässt sich auch leicht programmieren

Verfasst: 20.07.2010 01:05
von c4s
Die meisten können es und manche eben nicht. ;)

Re: mit n3xtd lässt sich auch leicht programmieren

Verfasst: 20.07.2010 17:04
von jojo1541
GetAsyncKeyState_(#Key) isz ein Api Aufruf der in etwa KeyboardPushed() in PB entspricht. Der Vorteil ist, dass man dafür nicht die komplette DirectX-Umgebung für die Tastatur intialisieren muss und deshalb wird der Befehl oft bei Fensteranwendungen benutzt. (Die Tastatur soll ja auch für andere Programme verfügbar sein)

Re: mit n3xtd lässt sich auch leicht programmieren

Verfasst: 21.07.2010 14:51
von bobobo
c4s hat geschrieben:Die meisten können es und manche eben nicht. ;)
eben

Code: Alles auswählen

OpenWindow(0,0,0,400,200,"DeppenFenster",#PB_Window_ScreenCentered)
Repeat
  event=WaitWindowEvent()
  eventlist=eventlist+event
  SetWindowTitle(0,Str(eventlist))
Until schlau

Re: mit n3xtd lässt sich auch leicht programmieren

Verfasst: 21.07.2010 15:57
von Fluid Byte
Darie hat geschrieben:Wird n3xtd eigentlich noch weiterentwickelt ???
Nein und ein Fragezeichen reicht völlig. Außerdem plenkst du.

Aber sein Post ist sowieso nur wieder ein Trollpost. Er hat ja PB schon lange den Rücken gekehrt und macht alles mit seinem fantastischen GFA Basic.

Der Spinner lernt es in diesem Leben einfach nicht mehr ...

Re: mit n3xtd lässt sich auch leicht programmieren

Verfasst: 22.07.2010 00:16
von Darie
Kann es sein, dass du mich mit jemandem verwechselst? Sorry, das mit den Satzzeichen hab ich mir schon zu sehr angewöhnt.