SetEntityFriction() fehlerhaft?

Anfängerfragen zum Programmieren mit PureBasic.
Brügge
Beiträge: 359
Registriert: 28.05.2006 16:40
Wohnort: Rheine

SetEntityFriction() fehlerhaft?

Beitrag von Brügge »

hi
ich Arbeite im moment an meinen Desktop rum...
ich baue mir einen 3D Desktop, bei dem man die Icons wegschießen kann...

ich habe meine Icons mit #PB_Entity_BoxBody definiert.
dazu gebe ich ihnen eine Mass, und eine Friction.
Leider gleiten meine Icons Minutenlang durch die Welt, bevor sie zum stehen kommen.

wenn ich die Masse erhöhe, dann fallen die entitys langsam aber sicher durch den boden.

die Friction verändert bei mir nichts.


woran kann das liegen?
Benutzeravatar
Fluid Byte
Beiträge: 3110
Registriert: 27.09.2006 22:06
Wohnort: Berlin, Mitte

Beitrag von Fluid Byte »

Code?
Brügge
Beiträge: 359
Registriert: 28.05.2006 16:40
Wohnort: Rheine

Beitrag von Brügge »

ui der ist sehr lang...
aber ok

Code: Alles auswählen

InitEngine3D()
InitSprite()
InitKeyboard()
InitMouse()
InitSprite3D()
Define Desktop$, shInfo.SHFILEINFO ,i.l
EnableWorldPhysics(1)
    
Global mem.l
Mem = AllocateMemory(1024) 
reibung = 1

Procedure.l DesktopOutput() 
  PokeL(Mem, 1) 
  ProcedureReturn Mem 
EndProcedure 

  Structure file
    an.b
    name.s
    billboardid.l
    billboardmaterialid.l
    billboardtextureid.l
    textureid.l
    materialid.l
    entityid.l
    iconid.l
    x.f
    y.f
    z.f
  EndStructure

  Dim file.file(1000)
  anzahl = 100
  Desktop$ = "C:\Dokumente und Einstellungen\Brügge\Desktop\"

  If ExamineDirectory(0, "C:\Dokumente und Einstellungen\Brügge\Desktop\", "")  
    While NextDirectoryEntry(0) 
      If DirectoryEntryName(0) <> "." And DirectoryEntryName(0) <>".."
        SHGetFileInfo_(Desktop$+DirectoryEntryName(0), 0, shInfo, SizeOf(SHFILEINFO), #SHGFI_ICON) 
        If shInfo\hIcon <> 0
          file(i)\iconid = shInfo\hIcon
          file(i)\an = 1
          file(i)\name = DirectoryEntryName(0)
          i = i +1
        EndIf
    
        If shInfo\hIcon = 0
          SHGetFileInfo_(Desktop$+DirectoryEntryName(0)+".lnk", 0, shInfo, SizeOf(SHFILEINFO), #SHGFI_ICON) 
          If shInfo\hIcon <> 0
            file(i)\iconid = shInfo\hIcon
            file(i)\an = 1
            file(i)\name = DirectoryEntryName(0)
            i = i +1
          EndIf
        EndIf
      EndIf
    Wend 
    FinishDirectory(0) 
  EndIf 
  
  ExamineDesktops()
  height= DesktopHeight(0)
  width = DesktopWidth(0)

  
  OpenWindow(0,-3,0,width,height-50,"Desktop",#PB_Window_MaximizeGadget)
  OpenWindowedScreen(WindowID(0),0,0,width,height,width*4,0,0)
  Add3DArchive("data\", #PB_3DArchive_FileSystem)

  LoadMesh(0,"chip.mesh")
  LoadMesh(1,"muelleimer.mesh")
  LoadTexture(1,"muelleimer.jpg")
  CreateMaterial(1,TextureID(1))
  MaterialBlendingMode(1, 1)

  CreateEntity(1,MeshID(1),MaterialID(1))
  ScaleEntity(1,50, 50, 50)

  EntityPhysicBody(1, #PB_Entity_BoxBody)

  CreateCamera(0,0,0,100,100)
  ;CameraRenderMode(0, 2)

  For i = 0 To anzahl
    If file(i)\an = 1
      file(i)\textureid = CreateTexture(#PB_Any,35,35)
      StartDrawing(TextureOutput(file(i)\textureid))
        FillArea(2, 2, 2 ,RGB(15,15,15))

        DrawImage(file(i)\iconid,15,15)
      StopDrawing()
      If file(i)\textureid
        file(i)\materialid = CreateMaterial(#PB_Any,TextureID(file(i)\textureid))
        file(i)\entityid = CreateEntity(#PB_Any,MeshID(0),MaterialID(file(i)\materialid))
        RotateEntity(file(i)\entityid, Random(90),Random(90),Random(90))
        EntityLocate(file(i)\entityid, Random(300)-150, Random(300)-150, Random(300)-150)
        ;EntityLocate(file(i)\entityid, 0, i*5-900, 0)
        ScaleEntity(file(i)\entityid, 10, 15, 10)
        ;ScaleEntity(file(i)\entityid, 30, 30, 30)
        MaterialBlendingMode(file(i)\Materialid, 1)
  ;      EntityRenderMode(file(i)\entityid, 4)
        EntityPhysicBody(file(i)\entityid, #PB_Entity_BoxBody)
        SetEntityFriction(file(i)\entityid, 100)
        SetEntityMass(file(i)\entityid,80)
        DisableMaterialLighting(file(i)\materialid,1)
      EndIf
    EndIf
  Next i
  
 
 ;:::::::::::namens-anzeige:::::::::
For i = 0 To anzahl
  If file(i)\an = 1
    file(i)\billboardtextureid = CreateTexture(#PB_Any,128,128)
    StartDrawing(TextureOutput(file(i)\billboardtextureid))
      DrawText(0, 0, file(i)\name,RGB(255,255,255),RGB(0,0,0))
    StopDrawing()
    file(i)\billboardmaterialid = CreateMaterial(#PB_Any,TextureID(file(i)\billboardtextureid)) 
    MaterialBlendingMode(file(i)\billboardmaterialid, 1)

    file(i)\billboardid = CreateBillboardGroup(#PB_Any, MaterialID(file(i)\billboardmaterialid), 200,200)
    AddBillboard(0,file(i)\billboardid, 0, -1000, 0)

  EndIf
Next i
 
 ;:::::::::::namens-anzeige ende:::::::::
 
  ;::::::::::Map:::::::::::::

map = 2000

LoadTexture(101,"wand.png")
;CreateTexture(101,256,256)
LoadMesh(101,"wand.mesh")
CreateMaterial(101,TextureID(101))
DisableMaterialLighting(101, 0)
;MaterialBlendingMode(101, #PB_Material_Add)

;MaterialShadingMode(101, 4)


CreateEntity(map,MeshID(101),MaterialID(101))
ScaleEntity(map, 1000, 10000, 1000)
EntityLocate(map,0,1000,0)
EntityPhysicBody(map, #PB_Entity_StaticBody)
SetEntityFriction(map, reibung)
  
CreateEntity(map+1,MeshID(101),MaterialID(101))
ScaleEntity(map+1, 1000, 100, 1000)
EntityLocate(map+1,0,-1000,0)
EntityPhysicBody(map+1, #PB_Entity_StaticBody)
SetEntityFriction(map+1, reibung)
SetEntityMass(map+1,100)
EntityRenderMode(1, 0) 

CreateEntity(map+2,MeshID(101),MaterialID(101))
ScaleEntity(map+2, 1000, 10000, 1000)
EntityLocate(map+2,0,0,1000)
RotateEntity(map+2,0,90,0)
EntityPhysicBody(map+2, #PB_Entity_StaticBody)
SetEntityFriction(map+2, reibung)

CreateEntity(map+3,MeshID(101),MaterialID(101))
ScaleEntity(map+3, 1000, 10000, 1000)
EntityLocate(map+3,0,0,-1000)
RotateEntity(map+3,0,90,0)
EntityPhysicBody(map+3, #PB_Entity_StaticBody)
SetEntityFriction(map+3, reibung)


CreateEntity(map+4,MeshID(101),MaterialID(101))
ScaleEntity(map+4, 1000, 10000, 1000)
EntityLocate(map+4,1000,0,0)
RotateEntity(map+4,0,0,90)
EntityPhysicBody(map+4, #PB_Entity_StaticBody)
SetEntityFriction(map+4, reibung)


CreateEntity(map+5,MeshID(101),MaterialID(101))
ScaleEntity(map+5, 1000, 10000, 1000)
EntityLocate(map+5,-1000,0,0)
RotateEntity(map+5,0,0,90)
EntityPhysicBody(map+5, #PB_Entity_StaticBody)
SetEntityFriction(map+5, reibung)

;::::::::::Map ende::::::::::
 
CameraLocate(0,0,1000,1000)
RotateCamera(0, 0, -65.75, 0)

WorldGravity(2000)


;::::::::::maus-klick::::::::::
Global maus3dX.f
Global maus3dY.f
Global maus3dZ.f

Procedure klick(x.f,y.f)
  
  
EndProcedure
  

;::::::::::maus-klick ende:::::




  Repeat
    Delay(10)
      
    RenderWorld()
    x = WindowMouseX(0)
    y = WindowMouseY(0)
    
    StartDrawing(ScreenOutput())
      DrawText(0,0,Str(x)+":"+Str(y),RGB(255,255,255),RGB(0,0,0))
    StopDrawing()
    
    FlipBuffers()
    
    For i = 0 To anzahl
      If file(i)\an = 1
        BillboardLocate(0, file(i)\billboardid, EntityX(file(i)\entityid),EntityY(file(i)\entityid), EntityZ(file(i)\entityid))

      EndIf
    Next i
    
    
    
    event = WindowEvent()
    If event = #PB_Event_CloseWindow
      esc = 1
    EndIf
    
  Until esc = 1
  
  
euch fehlen jetzt nur noch ein Würfel, eine mülltonne (da reicht auch ein Würfel und einen zusammengepressten würfel)
Brügge
Beiträge: 359
Registriert: 28.05.2006 16:40
Wohnort: Rheine

Beitrag von Brügge »

wenn ich einen entitybefehl nutze, dann verändere ich ja einen Wert in einer structure, die das Entity hat.
z.B. RotateEntity(). Jetzt wird doch irgendwo abgespeichert, das das Entity gedreht ist. Wie komme ich an die Informationen heran?

also wie viel grad das Entity gedreht ist, an welcher Position es ist, wie viel schwung es in welche Richtung hat und die ganzen anderen Variablen.

wenn ich das wüsste, könnte ich mir die Reibung auch selber programmieren, weil das bei mir nicht ganz so funktioniert

thx!
Brügge
Beiträge: 359
Registriert: 28.05.2006 16:40
Wohnort: Rheine

Beitrag von Brügge »

gibt es keine möglichkeit an die informationen heranzukommen?
Benutzeravatar
R4z0r1989
Beiträge: 521
Registriert: 12.06.2005 18:06
Kontaktdaten:

Beitrag von R4z0r1989 »

hey brügge stell mal bitte ein zip archiv on würd es gerne testen ohne groß rumzubasteln ^^

vl find ich durch meinen drang noch was....
Brügge
Beiträge: 359
Registriert: 28.05.2006 16:40
Wohnort: Rheine

Beitrag von Brügge »

hi R4z0r1989

natürlich mach ich das ^^
kennst du eine gute Seite wo man etwas hochladen kann?


MFG brügge
Benutzeravatar
R4z0r1989
Beiträge: 521
Registriert: 12.06.2005 18:06
Kontaktdaten:

hmm

Beitrag von R4z0r1989 »

Rapidshare.com oder uploadet.to
da gibts massig!
Benutzeravatar
Kiffi
Beiträge: 10714
Registriert: 08.09.2004 08:21
Wohnort: Amphibios 9

Beitrag von Kiffi »

Brügge hat geschrieben:kennst du eine gute Seite wo man etwas hochladen kann?
http://www.purebasic.fr/german/viewtopi ... 978#173978

Grüße ... Kiffi
a²+b²=mc²
Brügge
Beiträge: 359
Registriert: 28.05.2006 16:40
Wohnort: Rheine

Beitrag von Brügge »

ok folgende zwei links gehen:
http://root.q-soft.ch/3D%20Desktop.zip
http://web56.login-1.loginserver.ch/3D%20Desktop.zip


VIELEN DANK an PMTheQuick!!!
Antworten