>>>>> PB 6.20 -Bugs <<<<<

All bugs related to the 3D engine
User avatar
Psychophanta
Always Here
Always Here
Posts: 5153
Joined: Wed Jun 11, 2003 9:33 pm
Location: Anare
Contact:

Re: >>>>> PB 6.20 -Bugs <<<<<

Post by Psychophanta »

Psychophanta wrote: Sat Dec 14, 2024 8:51 pm Be aware when the camera is attached to a node or any.
Test yourself in PB6.20b2. It works as expected when rotating the camera, but it does not work when rotating the node where the cam is attached to:

Code: Select all

#CameraSpeed = 0.05

InitEngine3D(#PB_Engine3D_NoLog,#PB_Compiler_Home+"Compilers\Engine3d.dll")
InitSprite()
InitKeyboard()
InitMouse()

ExamineDesktops():dx=800:dy=600
OpenWindow(0,0,0,dx,dy, " ConvertLocalToWorldPosition - [Esc] quit",#PB_Window_ScreenCentered|#PB_Window_BorderLess)
OpenWindowedScreen(WindowID(0), 0, 0, dx, dy, 0, 0, 0)

Add3DArchive(#PB_Compiler_Home + "examples/3d/Data/Textures", #PB_3DArchive_FileSystem)
Add3DArchive(#PB_Compiler_Home + "examples/3d/Data/Models", #PB_3DArchive_FileSystem)
Add3DArchive(#PB_Compiler_Home + "examples/3d/Data/Packs/skybox.zip", #PB_3DArchive_Zip)
Add3DArchive(#PB_Compiler_Home + "examples/3d/Data/Scripts", #PB_3DArchive_FileSystem)
Parse3DScripts()
CreateCube(0, 5)
CreateMaterial(0, LoadTexture(0, "Dirt.jpg"))
CreateEntity(0, MeshID(0), MaterialID(0)):Pitch(EntityID(0),30,#PB_Relative|#PB_World)
SkyBox("stevecube.jpg")
CreateCamera(0,0,0,100,100)
CreateNode(0):AttachNodeObject(0,CameraID(0))
MoveCamera(0,0,0,30, #PB_Absolute)

Repeat
  While WindowEvent():Wend
  ExamineKeyboard():ExamineMouse()
  If KeyboardPushed(#PB_Key_Right)
    If KeyboardPushed(#PB_Key_LeftShift)
      RotateCamera(0,0,0.1,0,#PB_Relative)
    Else
      RotateNode(0,0,0.1,0,#PB_Relative)
    EndIf
  ElseIf KeyboardPushed(#PB_Key_Left)
    If KeyboardPushed(#PB_Key_LeftShift)
      RotateCamera(0,0,-0.1,0,#PB_Relative)
    Else
    RotateNode(0,0,-0.1,0,#PB_Relative)
    EndIf
  ElseIf KeyboardPushed(#PB_Key_Up)
    If KeyboardPushed(#PB_Key_LeftShift)
      RotateCamera(0,-0.1,0,0,#PB_Relative)
    Else
      RotateNode(0,-0.1,0,0,#PB_Relative)
    EndIf
  ElseIf KeyboardPushed(#PB_Key_Down)
    If KeyboardPushed(#PB_Key_LeftShift)
      RotateCamera(0,0.1,0,0,#PB_Relative)
    Else
      RotateNode(0,0.1,0,0,#PB_Relative)
    EndIf
  ElseIf KeyboardPushed(#PB_Key_PageUp)
    If KeyboardPushed(#PB_Key_LeftShift)
      RotateCamera(0,0,0,0.1,#PB_Relative)
    Else
      RotateNode(0,0,0,0.1,#PB_Relative)
    EndIf
  ElseIf KeyboardPushed(#PB_Key_PageDown)
    If KeyboardPushed(#PB_Key_LeftShift)
      RotateCamera(0,0,0,-0.1,#PB_Relative)
    Else
      RotateNode(0,0,0,-0.1,#PB_Relative)
    EndIf
  EndIf
  MouseX.f = -MouseDeltaX() * #CameraSpeed
  MouseY.f = -MouseDeltaY() * #CameraSpeed
  ConvertLocalToWorldPosition(CameraID(0),0,0,-30); <- GetZ() should be 0.0
  debug StrF(GetX(),2)+","+StrF(GetY(),2)+","+StrF(GetZ(),2); <- GetZ() should be 0.0
  ;MoveEntity(0,GetX(),GetY(),GetZ(),#PB_Absolute)
  RenderWorld()
  FlipBuffers()
Until KeyboardPushed(#PB_Key_Escape)
http://www.zeitgeistmovie.com

while (world==business) world+=mafia;
User avatar
pf shadoko
Enthusiast
Enthusiast
Posts: 386
Joined: Thu Jul 09, 2015 9:07 am

Re: >>>>> PB 6.20 -Bugs <<<<<

Post by pf shadoko »

@skinkairewalker
I suggested the problem to fred, but he didn't correct it for b2
it will be for b3


@Psychophanta
normal, you do a :
MoveCamera(0,0,0,30, #PB_Absolute)
the camera and node are not in the same place
if you replace with :
MoveNode(0,0,0,30, #PB_Absolute)
node and camera movements are identical
note: after AttachNodeObject, MoveCamera is relative to node position
User avatar
Psychophanta
Always Here
Always Here
Posts: 5153
Joined: Wed Jun 11, 2003 9:33 pm
Location: Anare
Contact:

Re: >>>>> PB 6.20 -Bugs <<<<<

Post by Psychophanta »

pf shadoko wrote: Mon Dec 23, 2024 3:55 pm note: after AttachNodeObject, MoveCamera is relative to node position
ConvertLocalToWorldPosition() should take the absolute position of the Object, imo.
http://www.zeitgeistmovie.com

while (world==business) world+=mafia;
User avatar
pf shadoko
Enthusiast
Enthusiast
Posts: 386
Joined: Thu Jul 09, 2015 9:07 am

Re: >>>>> PB 6.20 -Bugs <<<<<

Post by pf shadoko »

yes, but when you rotate according to node or camera the center of rotation is not the same
User avatar
Psychophanta
Always Here
Always Here
Posts: 5153
Joined: Wed Jun 11, 2003 9:33 pm
Location: Anare
Contact:

Re: >>>>> PB 6.20 -Bugs <<<<<

Post by Psychophanta »

You are right.
The fact is that if you rotate the node, the object (camera) orbitates the node, which means the object (camera in this case) not only moves around the world , but also rotates over itself, and so: its own world position and world orientation is changed.
But yes , in this case, since the local z axis of the camera (view point) does not change, then is logical the result is 0,0,0.
I will take a better view to other circumstances.
http://www.zeitgeistmovie.com

while (world==business) world+=mafia;
User avatar
Psychophanta
Always Here
Always Here
Posts: 5153
Joined: Wed Jun 11, 2003 9:33 pm
Location: Anare
Contact:

Re: >>>>> PB 6.20 -Bugs <<<<<

Post by Psychophanta »

Request:
We can not attach a node to an entity, which is interesting for some cases. And also a mesh to an entity.
http://www.zeitgeistmovie.com

while (world==business) world+=mafia;
User avatar
skinkairewalker
Enthusiast
Enthusiast
Posts: 782
Joined: Fri Dec 04, 2015 9:26 pm

Re: >>>>> PB 6.20 -Bugs <<<<<

Post by skinkairewalker »

pf shadoko wrote: Mon Dec 23, 2024 3:55 pm @skinkairewalker
I suggested the problem to fred, but he didn't correct it for b2
it will be for b3
awesome !!
thanks by u support :)
User avatar
Psychophanta
Always Here
Always Here
Posts: 5153
Joined: Wed Jun 11, 2003 9:33 pm
Location: Anare
Contact:

Re: >>>>> PB 6.20 -Bugs <<<<<

Post by Psychophanta »

I decide to put this here, because may be a bug but not sure.
The line that cuts an entity after using RayCast() deviates. So i had to finally make a simple tip to demonstrate this fact.
Notice the line used in RayCast() and the deviation produced in it when a collision occurs against an entity.
Just after run this code, by simply moving the mouse slightly up or down you can see the deviation effect. The white ray is the correct one.

Really i believe it is a bug! :o

Code: Select all

Global.f MouseX,MouseY,MouseZ,rayx,rayy,rayz
InitEngine3D(#PB_Engine3D_NoLog,#PB_Compiler_Home+"Compilers\Engine3d.dll")
InitSprite():InitKeyboard():InitMouse()

OpenWindow(0,0,0,800,600," RayCast - [Esc] quit",#PB_Window_ScreenCentered)
OpenWindowedScreen(WindowID(0),0,0,800,600,0,0,0)

CreateMaterial(0,0,$EE4847)
CreateMaterial(1,0,$48EE77)
CreateMaterial(2,0,$4847EE)
CreateMaterial(3,0,$32F2EE)
CreateCylinder(2,0.5,2)
CreateCylinder(5,0.2,1):TransformMesh(5,0,0,0,1,1,1,-90,0,0); <- I just rotate the mesh to get correct values of EntityDirectionX/Y/Z()
CreateEntity(2, MeshID(2), MaterialID(2))
CreateEntity(5, MeshID(5), MaterialID(2),-4,0,0,0) ; <---- PickMask = 0 for RayCast invisibility
RotateEntity(5,0,-90,0)

;Camera
CreateCamera(0, 0, 0, 100, 100)
CreateNode(8):AttachNodeObject(8,CameraID(0))
CameraBackColor(0, RGB(40, 30, 60))
MoveCamera(0,0,0,15, #PB_Absolute)

;Light
CreateLight(0, RGB(255, 255, 255), 1560, 900, 500)
AmbientColor(RGB(50, 50, 50))

CameraRenderMode(0,#PB_Camera_Wireframe)
Repeat
  While WindowEvent():Wend
  ExamineMouse():ExamineKeyboard()
  MouseX=MouseDeltaX()/60:MouseY=MouseDeltaY()/60:MouseZ=MouseWheel()
  If KeyboardPushed(#PB_Key_LeftControl):RotateNode(8,MouseY, MouseX, 0, #PB_Relative)
  ElseIf MouseButton(#PB_MouseButton_Right):RotateEntity(5,MouseY,MouseX,MouseZ,#PB_Relative)
  Else:MoveEntity(5,MouseX/10,-MouseY/10,-MouseZ/10,#PB_Relative|#PB_World)
  EndIf
  rayx=EntityDirectionX(5)*5:rayy=EntityDirectionY(5)*5:rayz=EntityDirectionZ(5)*5
  Entity = RayCast(EntityX(5), EntityY(5), EntityZ(5),EntityX(5)+rayx,EntityY(5)+rayy,EntityZ(5)+rayz,-1)
  CreateLine3D(9, EntityX(5), EntityY(5), EntityZ(5), RGB(255, 255, 255),EntityX(5)+rayx,EntityY(5)+rayy,EntityZ(5)+rayz, RGB(255, 255, 255))
  If Entity>=0
    CreateLine3D(10, EntityX(5), EntityY(5), EntityZ(5), RGB(0, 255, 255), PickX(), PickY(), PickZ(), RGB(0, 255, 255))
    CreateLine3D(11, PickX(), PickY(), PickZ(), RGB(255,0,0), PickX() + NormalX(), PickY() + NormalY(), PickZ() + NormalZ(), RGB(255,0,0))
  Else
    If IsMesh(11):FreeMesh(11):EndIf
    If IsMesh(10):FreeMesh(10):EndIf
  EndIf
  RenderWorld()
  FlipBuffers()
Until KeyboardPushed(#PB_Key_Escape) Or Quit = 1

http://www.zeitgeistmovie.com

while (world==business) world+=mafia;
miso
Enthusiast
Enthusiast
Posts: 466
Joined: Sat Oct 21, 2023 4:06 pm
Location: Hungary

Re: >>>>> PB 6.20 -Bugs <<<<<

Post by miso »

@Psychophanta

Your raycast vectorlength (*5) is too small. Test it with bigger number, and it will work.
User avatar
Psychophanta
Always Here
Always Here
Posts: 5153
Joined: Wed Jun 11, 2003 9:33 pm
Location: Anare
Contact:

Re: >>>>> PB 6.20 -Bugs <<<<<

Post by Psychophanta »

Yes, i really knew that fact @miso, thanks. :wink:
However, i think it should work even the ray is short. :?
http://www.zeitgeistmovie.com

while (world==business) world+=mafia;
User avatar
pf shadoko
Enthusiast
Enthusiast
Posts: 386
Joined: Thu Jul 09, 2015 9:07 am

Re: >>>>> PB 6.20 -Bugs <<<<<

Post by pf shadoko »

no, it's an error in the documentation

the destination coordinate is actually relative to the 1st point
in your example, you'd write:
RayCast(EntityX(5), EntityY(5), EntityZ(5),rayx,rayy,rayz,-1)

I haven't corrected it because for the next version I'll make a function that takes care of :
- relative/absolute for the 2nd point
- collision with boundingbox / mesh / body
this will replace the current 3 collision test functions
User avatar
Psychophanta
Always Here
Always Here
Posts: 5153
Joined: Wed Jun 11, 2003 9:33 pm
Location: Anare
Contact:

Re: >>>>> PB 6.20 -Bugs <<<<<

Post by Psychophanta »

Damn! that way the parameters for RayCast() etc., make much more sense. :o
Again return to ConvertWorldToLocalPosition():
If i understand correctly that function, then in this piece of code the yellow line should be ortogonal to the white one at any time, whatever it be the orientation of the entity, but it is not. Just move and rotate the entity, and watch the lines orbitating camera (while pressing left control key) to look at it.

Code: Select all

Global.f MouseX,MouseY,MouseZ,rayx,rayy,rayz
InitEngine3D(#PB_Engine3D_NoLog,#PB_Compiler_Home+"Compilers\Engine3d.dll")
InitSprite():InitKeyboard():InitMouse()

OpenWindow(0,0,0,800,600,"",#PB_Window_ScreenCentered)
OpenWindowedScreen(WindowID(0),0,0,800,600,0,0,0)

CreateMaterial(0,0,$EE4847)
CreateCylinder(5,0.2,1):TransformMesh(5,0,0,0,1,1,1,-90,0,0)
CreateEntity(5, MeshID(5), MaterialID(0),-4,0,0,0)
RotateEntity(5,0,-90,0)
CreateCamera(0, 0, 0, 100, 100)
CreateNode(8):AttachNodeObject(8,CameraID(0))
CameraBackColor(0, RGB(40, 30, 60))
MoveCamera(0,0,0,15, #PB_Absolute)
CreateLight(0, RGB(255, 255, 255), 1560, 900, 500)
AmbientColor(RGB(50, 50, 50))

;CameraRenderMode(0,#PB_Camera_Wireframe)
Repeat
  While WindowEvent():Wend
  ExamineMouse():ExamineKeyboard()
  MouseX=MouseDeltaX()/60:MouseY=MouseDeltaY()/60:MouseZ=MouseWheel()
  If KeyboardPushed(#PB_Key_LeftControl):RotateNode(8,MouseY, MouseX, 0, #PB_Relative)
  ElseIf MouseButton(#PB_MouseButton_Right):RotateEntity(5,MouseY,MouseX,MouseZ,#PB_Relative)
  Else:MoveEntity(5,MouseX/10,-MouseY/10,-MouseZ/10,#PB_Relative|#PB_World)
  EndIf
  rayx=EntityDirectionX(5)*5:rayy=EntityDirectionY(5)*5:rayz=EntityDirectionZ(5)*5
  CreateLine3D(9, EntityX(5), EntityY(5), EntityZ(5),$EEEEEE,EntityX(5)+rayx,EntityY(5)+rayy,EntityZ(5)+rayz,$EEEEEE)
  
  ConvertWorldToLocalPosition(EntityID(5),1,0,0)
  CreateLine3D(10,EntityX(5), EntityY(5), EntityZ(5),$22BBAA,EntityX(5)+GetX(),EntityY(5)+GetY(),EntityZ(5)+GetZ(),$88F3FA)
  
  RenderWorld()
  FlipBuffers()
Until KeyboardPushed(#PB_Key_Escape)
http://www.zeitgeistmovie.com

while (world==business) world+=mafia;
Ziltch
User
User
Posts: 61
Joined: Sun Aug 03, 2003 12:05 am
Location: Australia

Re: >>>>> PB 6.20 -Bugs <<<<<

Post by Ziltch »

I have Noticed Rotatelight now needs mode.
If no mode is given;
[ERROR] RotateLight(): invalid value specified For parameter 'Mode'.
User avatar
MikeHart
User
User
Posts: 17
Joined: Sat Sep 02, 2017 7:29 pm
Location: Germany

Re: >>>>> PB 6.20 -Bugs <<<<<

Post by MikeHart »

In 6.20B2 the 3D example demo/Materialscripts.pb crashes with
[20:22:57] Waiting for executable to start...
[20:22:57] Executable type: Windows - x64 (64bit, Unicode)
[20:22:57] Executable started.
[20:22:58] [ERROR] MaterialScripts.pb (Line: 535)
[20:22:58] [ERROR] The specified #Material is not initialised.
[20:23:28] The Program was killed.
Edit: Never mind, it was reported on Dec 12th 2024 already. But with me, shaders work. Just that script not.
User avatar
MikeHart
User
User
Posts: 17
Joined: Sat Sep 02, 2017 7:29 pm
Location: Germany

Re: >>>>> PB 6.20 -Bugs <<<<<

Post by MikeHart »

Example 3D/SkyDome.pb crashes with
[20:41:52] [COMPILER] Line 55: SkyDome(): Incorrect number of parameters.
Locked