Page 1 of 1

Undocumented function EntityMesh()

Posted: Sun Mar 31, 2019 2:25 pm
by DK_PETER
Hi
What is the purpose of

Code: Select all

EntityMesh(#Entity, MeshID)
?

Re: Undocumented function EntityMesh()

Posted: Sun Mar 31, 2019 5:01 pm
by IdeasVacuum
Hi DK_PETER

Referenced here:
https://github.com/SicroAtGit/PureBasic ... onList.txt

It says:
EntityMesh (#Entity, MeshID) - Change the #Entity mesh with the new one.

...but I'm not sure the description is correct - if it is correct, then surely the function name could be better, to suggest it's purpose.

Re: Undocumented function EntityMesh()

Posted: Sun Mar 31, 2019 6:21 pm
by DK_PETER
Hi IdeasVacuum

That was my initial thought. But unless I'm missing a step somewhere or my interpretation of
what the function should do is wrong, I can't seem to get it working.
It might not work at all and completely redundant. :)

Code: Select all

InitEngine3D()
InitSprite()
InitKeyboard()

OpenWindow(0, 0, 0, 800, 600, "EntityMesh", #PB_Window_ScreenCentered|#PB_Window_SystemMenu)
OpenWindowedScreen(WindowID(0), 0, 0, 800, 600)
CreateCamera(0, 0, 0, 100, 100)
MoveCamera(0, 0, 0, 5)
CreateLight(0, $FF00FF, -2, -3, 0)
CreateSphere(0, 2) ;Mesh 0
CreateCube(1, 2)   ; Mesh 1
CreateTexture(0, 512, 512)
StartDrawing(TextureOutput(0))
DrawingMode(#PB_2DDrawing_AlphaBlend|#PB_2DDrawing_Gradient)
FrontColor($00005200) : BackColor($FF005200)
For y = 0 To 512 Step 16
  For x = 0 To 512 Step 16
    BoxedGradient(x, y, 512, 4)
    Box(0, y, 512, 4)
  Next x
Next y
StopDrawing()
CreateMaterial(0, TextureID(0))
MaterialBlendingMode(0, #PB_Material_Add)
MaterialCullingMode(0, #PB_Material_NoCulling)
CreateEntity(0, MeshID(0), MaterialID(0), 0, 0, 0) ; Entity 0
ScaleMaterial(0, 0.5, 0.5)

Repeat
  Repeat : ev = WindowEvent() : Until  ev = 0
  
  ExamineKeyboard()
  
  If KeyboardReleased(#PB_Key_F1)
    EntityMesh(0, MeshID(1))
    Debug "Swap mesh in entity with Cube"
  ElseIf KeyboardReleased(#PB_Key_F2)
    EntityMesh(0, MeshID(0))
    Debug "Swap mesh in entity with Sphere"
  EndIf
  
  RenderWorld()

  FlipBuffers()
  
Until KeyboardPushed(#PB_Key_Escape)

Re: Undocumented function EntityMesh()

Posted: Thu Mar 12, 2020 12:42 pm
by DK_PETER
Is EntityMesh a deactivated and redundant function?

Re: Undocumented function EntityMesh()

Posted: Thu Mar 12, 2020 1:44 pm
by applePi
Hi DK_PETER
i believe it is a forgotten not working function, should be removed
we can replace it with something like this in your above code

Code: Select all

If KeyboardReleased(#PB_Key_F1)
    ;EntityMesh(0, MeshID(1))
    FreeEntity(0)
    CreateEntity(0, MeshID(1), MaterialID(0), 0, 0, 0) ;
    Debug "Swap mesh in entity with Cube"
  ElseIf KeyboardReleased(#PB_Key_F2)
    ;EntityMesh(0, MeshID(0))
    FreeEntity(0)
    CreateEntity(0, MeshID(0), MaterialID(0), 0, 0, 0) ;
    Debug "Swap mesh in entity with Sphere"
  EndIf

Re: Undocumented function EntityMesh()

Posted: Thu Mar 12, 2020 2:02 pm
by DK_PETER
@applePi
I do think this is a forgotten or redundant function and is easily substituted
by freeing and creating the entity again.
It should be removed/hidden unless we can use it.