CameraFollow() & Node : invalid memory access

Everything related to 3D programming
User avatar
falsam
Enthusiast
Enthusiast
Posts: 635
Joined: Wed Sep 21, 2011 9:11 am
Location: France
Contact:

CameraFollow() & Node : invalid memory access

Post by falsam »

Hello. the problem is in the title but .....the question is why ? :)

Code: Select all

Define.l Event
Define.f NodeSpeed, RotY

InitEngine3D()
InitKeyboard()
InitSprite()
InitMouse()

Window = OpenWindow(#PB_Any, 0,0,1024,768, "Test", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
OpenWindowedScreen(WindowID(Window),0,0,1024,768,0, 0, 0)

KeyboardMode(#PB_Keyboard_International)

;Ambiance
AmbientColor(RGB(127, 127, 127))
CreateLight(#PB_Any,RGB(151, 251, 151), -1.8, 10, 5)

;Camera 
Camera = CreateCamera(#PB_Any,0,0,100,100)
CameraBackColor(Camera, RGB(145, 182, 201))
MoveCamera(Camera, 2, 5, 10, #PB_Absolute)  
CameraLookAt(Camera, 0,0,0)   

;Ground
CreateEntity(#PB_Any, MeshID(CreatePlane(#PB_Any, 40, 40, 1, 1, 1, 1)), #PB_Material_None)

;Entity & Node
Node = CreateNode(#PB_Any)

Entity = CreateEntity(#PB_Any, MeshID(CreateCube(#PB_Any, 1)), #PB_Material_None, 0, 0.50, 0)
AttachNodeObject(Node, EntityID(Entity)) 

Entity = CreateEntity(#PB_Any, MeshID(CreateCylinder(#PB_Any, 0.02, 2)), #PB_Material_None, 0, 1, 0)
AttachNodeObject(Node, EntityID(Entity)) 

Entity = CreateEntity(#PB_Any, MeshID(CreateSphere(#PB_Any, 0.5)), #PB_Material_None, 0, 2, 0)
AttachNodeObject(Node, EntityID(Entity)) 


Repeat
  Repeat
    Event  = WindowEvent()
    Select Event
      Case #PB_Event_CloseWindow
        End
        
    EndSelect
  Until Event = 0
  
  If ExamineKeyboard() 
    If KeyboardPushed (#PB_Key_Escape)
      Break
    EndIf
    
    If KeyboardPushed (#PB_Key_Up)
      NodeSpeed = -0.1
    ElseIf KeyboardPushed (#PB_Key_Down)
      NodeSpeed = 0.1
    Else
      NodeSpeed = 0
    EndIf
    
    If KeyboardPushed (#PB_Key_Left)
      RotY = 1.5
    ElseIf KeyboardPushed (#PB_Key_Right)
      RotY = -1.5
    Else
      RotY = 0
    EndIf
    
  EndIf
  
  RotateNode(Node, 0, RotY, 0, #PB_Relative)
  MoveNode(Node, 0, 0, NodeSpeed, #PB_Absolute|#PB_Local)   
  
  ;Uncomment / Comment this line :)
  ;CameraFollow(Camera, NodeID(Node), -180, NodeY(Node)+2, 6, 0.05, 0.05, #True)  
  
  RenderWorld(80)
  FlipBuffers()  
  
ForEver
Thank:)
Last edited by falsam on Sat Nov 09, 2013 12:58 am, edited 1 time in total.

➽ Windows 11 64-bit - PB 6.21 x64 - AMD Ryzen 7 - NVIDIA GeForce GTX 1650 Ti

Sorry for my bad english and the Dunning–Kruger effect 🤪
marc_256
Addict
Addict
Posts: 859
Joined: Thu May 06, 2010 10:16 am
Location: Belgium
Contact:

Re: CameraFollow() & Node : invalid memory access

Post by marc_256 »

Hi falsam,

tested with WIN8 and PB5.21
Work well, no problems at all

Do you have an old ENGINE3D in your directory ?

marc,

Edit: Sorry, when I Uncomment the line I have the same problem :oops:
Last edited by marc_256 on Fri Nov 08, 2013 4:55 pm, edited 1 time in total.
- every professional was once an amateur - greetings from Pajottenland - Belgium -
PS: sorry for my english I speak flemish ...
User avatar
Comtois
Addict
Addict
Posts: 1432
Joined: Tue Aug 19, 2003 11:36 am
Location: Doubs - France

Re: CameraFollow() & Node : invalid memory access

Post by Comtois »

marc_256 wrote:Hi falsam,

tested with WIN8 and PB5.21
Work well, no problems at all

Do you have an old ENGINE3D in your directory ?

marc,
uncomment this line, i get an IMA, we will have a look.

Code: Select all

;Uncomment / Comment this line :)
  ;CameraFollow(Camera, NodeID(Node), -180, NodeY(Node)+2, 6, 0.05, 0.05, #True)  
Please correct my english
http://purebasic.developpez.com/
User avatar
falsam
Enthusiast
Enthusiast
Posts: 635
Joined: Wed Sep 21, 2011 9:11 am
Location: France
Contact:

Re: CameraFollow() & Node : invalid memory access

Post by falsam »

Comtois wrote:i get an IMA, we will have a look.
Thank Comtois :)
Last edited by falsam on Sat Nov 09, 2013 12:57 am, edited 1 time in total.

➽ Windows 11 64-bit - PB 6.21 x64 - AMD Ryzen 7 - NVIDIA GeForce GTX 1650 Ti

Sorry for my bad english and the Dunning–Kruger effect 🤪
Post Reply