Historical forum-msg-id-134055-edit, Revision 1

Original date:2019-07-11 10:00:54 Edited by: ghaberek Subject: Re: Raylib 3D

Icy_Viking said...

When it comes to Euphoria port, I'm not sure how I'd get around that camera stuff. There is no function for something like SetCameraPosition() in RayLib. If anyone has a workaround, that would be great.

Here is the header for the camera stuff: https://github.com/raysan5/raylib/blob/master/src/camera.h

It looks like Camera is just a typedef for struct Camera3D. So when you see Camera camera = {0}, that's just allocating a Camera3D structure on the stack and initializing it to zero. We have to create our structs on the heap with allocate_data().

-- Camera camera = { 0 }; 
atom camera = allocate_data( SIZEOF_CAMERA3D ) 
mem_set( camera, 0, SIZEOF_CAMERA3D ) 

The rest of the values are structure members, some of which are nested structures themselves, in this case Vector3D. So we need to determine the member offsets and then poke values into the allocated memory manually. Here are the structure offsets.

    Vector3__x      =  0, -- float 
    Vector3__y      =  4, -- float 
    Vector3__z      =  8, -- float 
    SIZEOF_VECTOR3  = 12, 
    Camera3D__position  =  0, -- Vector3  
    Camera3D__target    = 12, -- Vector3 
    Camera3D__up        = 24, -- Vector3 
    Camera3D__fovy      = 36, -- float 
    Camera3D__type      = 40, -- int 
    SIZEOF_CAMERA3D     = 44, 
Not Categorized, Please Help


Quick Links

User menu

Not signed in.

Misc Menu