Page 1 of 2

MeshFace() with 4 parameters does not work here

Posted: Sun Apr 16, 2023 12:38 pm
by Psychophanta
This tip shows that MeshFace() with 4 parameters does not work:

Code: Select all

InitEngine3D():InitSprite():InitKeyboard():InitMouse()
OpenWindowedScreen(OpenWindow(0,0,0,1024,768,"no va cara de 4 vertices",#PB_Window_BorderLess|#PB_Window_ScreenCentered),0,0,1024,768,1,0,0,#PB_Screen_WaitSynchronization)

CreateLight(0,$EEEEEE,-1,1,6,#PB_Light_Point)
CreateCamera(0,0,0,100,100)
MoveCamera(0,0,0,4,#PB_Absolute)
CreateMaterial(0,0,$55DDEE)
CreateSphere(1,0.02)
          
CreateMesh(0,#PB_Mesh_TriangleList,#PB_Mesh_Static)
MeshVertex(-1,1,0,0,0,$EEEEEE,0,0,1)
MeshVertex(-1,-1,0,1,0,$EEEEEE,0,0,1)
MeshVertex(1,-1,0,0,1,$EEEEEE,0,0,1)
MeshVertex(1,1,0,0,1,$EEEEEE,0,0,1)
MeshFace(0,1,3):MeshFace(1,2,3); <- this one does work but MeshFace(0,1,2,3) does not work !!!!!!! (O_O)
MeshFace(3,1,0):MeshFace(3,2,1)
FinishMesh(1)
CreateEntity(0,MeshID(0),MaterialID(0),0,0,0)
Repeat:While WindowEvent()<>#PB_Event_None:Wend
  ExamineMouse():ExamineKeyboard()
  RotateEntity(0,MouseDeltaY(),MouseDeltaX(),MouseWheel(),#PB_Relative)
  RenderWorld()
  FlipBuffers()
Until KeyboardPushed(#PB_Key_Escape)

Re: MeshFace() with 4 parameters does not work here

Posted: Sun Apr 16, 2023 12:54 pm
by STARGĂ…TE
Why should it work with 4 vertices if you create a mesh based on a list of triangles (#PB_Mesh_TriangleList, 3 vertices)?
You need then a quad list or quad stripe.

Re: MeshFace() with 4 parameters does not work here

Posted: Sun Apr 16, 2023 1:39 pm
by Psychophanta
Aha, an what is the appropiate flag then?

Re: MeshFace() with 4 parameters does not work here

Posted: Tue Apr 18, 2023 8:52 am
by pf shadoko
it works
pay attention to the vertex order

Code: Select all

InitEngine3D():InitSprite():InitKeyboard():InitMouse()
OpenWindowedScreen(OpenWindow(0,0,0,1024,768,"no va cara de 4 vertices",#PB_Window_BorderLess|#PB_Window_ScreenCentered),0,0,1024,768,1,0,0,#PB_Screen_WaitSynchronization)

CreateLight(0,$EEEEEE,-1,1,6,#PB_Light_Point)
CreateCamera(0,0,0,100,100)
MoveCamera(0,0,0,4,#PB_Absolute)
CreateMaterial(0,0,$55DDEE)
CreateSphere(1,0.02)
          
CreateMesh(0,#PB_Mesh_TriangleList,#PB_Mesh_Static)
MeshVertex(-1,1,0,0,0,$EEEEEE,0,0,1)
MeshVertex(-1,-1,0,1,0,$EEEEEE,0,0,1)
MeshVertex(1,-1,0,0,1,$EEEEEE,0,0,1)
MeshVertex(1,1,0,0,1,$EEEEEE,0,0,1)
MeshFace(0,1,2,3)
MeshFace(3,2,1,0)
FinishMesh(1)
CreateEntity(0,MeshID(0),MaterialID(0),0,0,0)
Repeat:While WindowEvent()<>#PB_Event_None:Wend
  ExamineMouse():ExamineKeyboard()
  RotateEntity(0,MouseDeltaY(),MouseDeltaX(),MouseWheel(),#PB_Relative)
  RenderWorld()
  FlipBuffers()
Until KeyboardPushed(#PB_Key_Escape) Or MouseButton(3)

Re: MeshFace() with 4 parameters does not work here

Posted: Tue Apr 18, 2023 1:01 pm
by Psychophanta
@pf shadoko, your tip does not work here. It tries to write at address 0 in the first 'MeshFace()' sentence. The same as my code.

Re: MeshFace() with 4 parameters does not work here

Posted: Tue Apr 18, 2023 5:26 pm
by pf shadoko
@Psychophanta
What is your configuration ?

others have this problem ?

Re: MeshFace() with 4 parameters does not work here

Posted: Tue Apr 18, 2023 5:32 pm
by Caronte3D
For me, it works without problems

Re: MeshFace() with 4 parameters does not work here

Posted: Tue Apr 18, 2023 11:33 pm
by SPH
It's ok here (pb 6.00LTS)

Re: MeshFace() with 4 parameters does not work here

Posted: Tue Apr 18, 2023 11:33 pm
by SPH
It's ok here (pb 6.00LTS)

Re: MeshFace() with 4 parameters does not work here

Posted: Wed Apr 19, 2023 8:01 am
by Psychophanta
@pf shadoko:

With debugger enabled: message is the typical "try to write in address 0".
Without debugger it just hangs.
PB 6.01LTS 64bit in win 8.1 on a AMD A8-7410 radeon R5. 4k screen desktop resolution.

Re: MeshFace() with 4 parameters does not work here

Posted: Wed Apr 19, 2023 8:19 am
by Caronte3D
The only case I get this error, is when I try to compile with a different compiler version, in example, inside PB 6.01 I try to compile with 6.02 compiler.

Re: MeshFace() with 4 parameters does not work here

Posted: Wed Apr 19, 2023 8:38 am
by Fred
Works as well

Re: MeshFace() with 4 parameters does not work here

Posted: Thu Apr 20, 2023 9:51 am
by Psychophanta
Damn!
With the PB6.02B1 x86
I found it is not able to pass this line:

Code: Select all

If InitEngine3D()=0:MessageRequester("Error","The 3D Engine can't be initialized",0):End:EndIf
It Returns the error :shock:

Re: MeshFace() with 4 parameters does not work here

Posted: Sat Apr 22, 2023 3:09 pm
by Psychophanta
Now it works with PB602beta2 x86
@pf shadoko, your tip with 4 vertex face already works, buuuuuut
i must do:
InitEngine3D(#PB_Engine3D_DebugOutput,"C:\Program Files (x86)\PureBasic\Compilers\Engine3d.dll")
instead of:
InitEngine3D()

And I must say another thing: the 4 vertex face is a fake because there is builded 2 triangles instead a squared face.
Look yourself:

Code: Select all

InitEngine3D(#PB_Engine3D_DebugOutput,"C:\Program Files (x86)\PureBasic\Compilers\Engine3d.dll"):InitSprite():InitKeyboard():InitMouse()
OpenWindowedScreen(OpenWindow(0,0,0,1024,768,"no va cara de 4 vertices",#PB_Window_BorderLess|#PB_Window_ScreenCentered),0,0,1024,768,1,0,0,#PB_Screen_WaitSynchronization)

CreateLight(0,$EEEEEE,-1,1,6,#PB_Light_Point)
CreateCamera(0,0,0,100,100)
CameraRenderMode(0,#PB_Camera_Wireframe)
MoveCamera(0,0,0,4,#PB_Absolute)
CreateMaterial(0,0,$55DDEE)
CreateSphere(1,0.02)
          
CreateMesh(0,#PB_Mesh_TriangleList,#PB_Mesh_Static)
MeshVertex(-1,1,0,0,0,$EEEEEE,0,0,1)
MeshVertex(-1,-1,0,1,0,$EEEEEE,0,0,1)
MeshVertex(1,-1,0,0,1,$EEEEEE,0,0,1)
MeshVertex(1,1,0,0,1,$EEEEEE,0,0,1)
MeshFace(0,1,2,3)
FinishMesh(1)
CreateEntity(0,MeshID(0),MaterialID(0),0,0,0)
Repeat:While WindowEvent()<>#PB_Event_None:Wend
  ExamineMouse():ExamineKeyboard()
  RotateEntity(0,MouseDeltaY(),MouseDeltaX(),MouseWheel(),#PB_Relative)
  RenderWorld()
  FlipBuffers()
Until KeyboardPushed(#PB_Key_Escape) Or MouseButton(3)

Re: MeshFace() with 4 parameters does not work here

Posted: Sun Apr 23, 2023 9:32 am
by pf shadoko
it seems to me that it is clear, InitEngine3D loads an old DLL
look in the folder where the unsaved codes are executed

of course, the faces with 4 parameters are made of 2 triangles (the 3d engine only eat triangles)
I had specified it when I made the doc, but it has been deleted...
MeshFace(t1, t2, t3 [, t4])
t4 : optional parameter to create 2 triangles (quad)
same as:
MeshFace(t1,t2,t3)
MeshFace(t1,t3,t4)