• Dear Cerberus X User!

    As we prepare to transition the forum ownership from Mike to Phil (TripleHead GmbH), we need your explicit consent to transfer your user data in accordance with our amended Terms and Rules in order to be compliant with data protection laws.

    Important: If you accept the amended Terms and Rules, you agree to the transfer of your user data to the future forum owner!

    Please read the new Terms and Rules below, check the box to agree, and click "Accept" to continue enjoying your Cerberus X Forum experience. The deadline for consent is April 5, 2024.

    Do not accept the amended Terms and Rules if you do not wish your personal data to be transferred to the future forum owner!

    Accepting ensures:

    - Continued access to your account with a short break for the actual transfer.

    - Retention of your data under the same terms.

    Without consent:

    - You don't have further access to your forum user account.

    - Your account and personal data will be deleted after April 5, 2024.

    - Public posts remain, but usernames indicating real identity will be anonymized. If you disagree with a fictitious name you have the option to contact us so we can find a name that is acceptable to you.

    We hope to keep you in our community and see you on the forum soon!

    All the best

    Your Cerberus X Team

MiniB3D up, forward and right

SLotman

Active member
3rd Party Module Dev
Tutorial Author
Joined
Jul 3, 2017
Messages
261
As I was watching some math tutorials for gamedev, one concept always mentioned are those 3 vectors that are extracted from every GameObject: the up, right and forward vectors, which as their names indicate, are vectors pointing (in local space) up, right and forward. Engines like Unity and Unreal provides this out of the box for every object in the engine.

This can be easily achieved on MiniB3D, just add those lines below "public" on TEntity:

Code:
    Method Up:Vector()
        Return New Vector(mat.grid[1][0], mat.grid[1][1], mat.grid[1][2])
    End Method
   
    Method Right:Vector()
        Return New Vector(mat.grid[0][0], mat.grid[0][1], mat.grid[0][2])
    End Method
   
    Method Forward:Vector()
        Return New Vector(mat.grid[2][0], mat.grid[2][1], mat.grid[2][2])
    End Method

And that's it!

But... why, you ask? Well, this is useful to test, for example, if two entities can see each other. Take their forward vectors, normalize them and calc the dot product. Result closer to -1 they're facing each other. Closer to 1 they're facing the same direction. Results closer to 0, they're looking at perpendicular directions.

This is just one example. You could use the forward, up or right vectors to move the entity forwards, upwards or sideways (just like MoveEntity).

Anyway, after adding those lines, you can just call any entity (even pivots) with .Up(), .Right() or .Forward() to get those vectors.
 
Back
Top Bottom