What are BoxF?

This topic contains 3 replies, has 3 voices, and was last updated by  DruggedBunny 2 weeks ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
  • #15547


    I’m trying to understand why when creating a simple cube, I have to use BoxF which receives two parameters, could someone help me with a simple explanation?




    BoxF is an alias for Box<Float>, Box type allow us to set cubic bounds.

    It has many constructors, see the sources:




    I greatly appreciate your response, I just want to understand that, although the examples use it, I can not understand its parameters when creating a cube. A simple explanatory example?, with the objective of understanding the matter better since the documentation does not say much.

    Thank you.



    I’ve only used the form defining opposite corners of a cube/box:

    In real-world use, this might look like:

    … where x0, y0, z0 define one extreme corner — in this case being left 0.5, down 0.5, towards camera 0.5 — and x1, y1, z1 define the opposite corner; in this case right 0.5 (forming total width of 1.0), up 0.5 and forward 0.5.

    For further clarity, you might store the box as a Boxf and pass it to CreateBox:

    As far as I can tell, you only really need 1, 1, 1 for the x, y, z segments — you might pass in more if you want to manipulate the cube’s vertices into another shape.

    So the box is:

    • -0.5 to 0.5 horizontally – New Boxf (x0, -0.5, -0.5, x1, 0.5, 0.5);
    • -0.5 to 0.5 vertically – New Boxf (-0.5, y0, -0.5, 0.5, y1, 0.5);
    • -0.5 to 0.5 depth-wise – New Boxf (-0.5, -0.5, z0, 0.5, 0.5, z1).

    … meaning it measures 1.0 in all directions.

    Another way to define it, if you want to specify a particular size:


    The parameters define opposite corners of the cube:

    … and if you find you still struggle, just wrap Model.CreateBox into a CreateCube function (like Blitz3D!), passing in the width, height, depth and a PbrMaterial (plus potentially the optional parent entity), and returning the Model.

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.