Main Menu

Building a basic 3D Engine

Started by stevmjon, December 28, 2016, 03:43:19 AM

Previous topic - Next topic

stevmjon

well kev, thanks for the homework, lol.

interesting setup. i have never used private arrays then referenced their handle, all while referencing this handle inside a typed array.
so it's like pointing to a location in memory and read/write data, rather than using an array itself to read/write data.

just wondering, since all the data is still there, whether using dynamically created array handle method or making an array for the data, i assume that pointing to the data using handles method works faster?

oh, and i will add escape key to exit 3D game demo. on my rig pressing ecs key exits. didn't realise on some computers this doesn't do the same. thanks for the heads up.

  stevmjon
It's easy to start a program, but harder to finish it...

I think that means i am getting old and get side tracked too easy.

kevin

#61

  Updated the example on the previous page.


Quoteinteresting setup. i have never used private arrays then referenced their handle, all while referencing this handle inside a typed array.
so it's like pointing to a location in memory and read/write data, rather than using an array itself to read/write data.

   Here i'm using PRIVATE to denote that these functions are for use within the library and not meant to be called by users.  Ill often call such functions names, so they are not easily guessed,  so i'll put some crap at the head of the function name so they wont clash with any other code is the library / include was inserted within another program.      Other than that it has no impact on anything,  we do have a PRIVATE keyword but it's not in use in PB today.      


    eg..

PlayBASIC Code: [Select]
  /*
---------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------
------------------------------->> PUBLIC FUNCTIONS <<-----------------------------------------------
---------------------------------------------------------------------------------------------------------------

*/




function MakeSomething()


// in here we call our helper function that does some job we might commonly need across the library, but don't want the user calling directly

result=zzzzzzz_MakeSomething(Param1,parma2)

etc etc

endfunction

/*
---------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------
------------------------------->> PRIVATE FUNCTIONS <<-----------------------------------------------
---------------------------------------------------------------------------------------------------------------

*/


function zzzzzzz_MakeSomething(Param1,parma2)

// do some commonly used stuff for us
endfunction result









Quote
just wondering, since all the data is still there, whether using dynamically created array handle method or making an array for the data, i assume that pointing to the data using handles method works faster?


  nah, it's the same.  Just like passing an array into a function,  the so called passed local function is just a copy of the passed arrays handle.   Once inside the function, it's basically identical to accessing the original array.  



stevmjon

here is the mipmap test updated to calculate the actual polygons on screen, then choose a mipmap image the closest size the polygon. i made the image darker the smaller the image that is selected for easier viewing.
also you can go upwards with the camera to watch the textures change the further you get. looks cool. i may need to adjust the clipped polygons mipmap though, as it calcs the image based on the clipped polygon size.

kev, i noticed that if you get too small an image, especially using the grass texture, the polygon textures don't look as smooth. there must be another calculation on top of mipmaps? anyway, it was fun to impliment in game, as i never done this before.

have fun testing, stevmjon
It's easy to start a program, but harder to finish it...

I think that means i am getting old and get side tracked too easy.