Rotate Vehicle models based on Yaw, Pitch and Roll values #36

Open
opened 2026-05-13 10:15:17 +00:00 by halbear · 0 comments
Owner

Code snippet to be added to the {EntityName}Renderer class for vehicle entities
An example of the code to implement (i have been testing this with a test plane, but the actual implementation will need to use something other than NBT that syncs with server and client, and have it so it sets rotate angles instantly so it can do multiple instances seamlessly):

//this is an example for a plane, thus the prop speed attribute
float DegToRad = (float)(Math.PI/180.0);
        float TargetRotX = (float)e.getPersistentData().getDouble("Pitch") * DegToRad;
        float TargetRotY = (float)e.getPersistentData().getDouble("Yaw") * DegToRad;
                float TargetRotZ = (float)e.getPersistentData().getDouble("Roll") * DegToRad;
        if(TargetRotX > Body.rotateAngleX) Body.rotateAngleX += 1* DegToRad;
        if(TargetRotX < Body.rotateAngleX) Body.rotateAngleX -= 1* DegToRad;
                if(TargetRotY > Body.rotateAngleY) Body.rotateAngleY += 1* DegToRad;
        if(TargetRotY < Body.rotateAngleY) Body.rotateAngleY -= 1* DegToRad;
                if(TargetRotZ> Body.rotateAngleZ) Body.rotateAngleZ += 1* DegToRad;
        if(TargetRotZ < Body.rotateAngleZ) Body.rotateAngleZ -= 1* DegToRad;
        
            propeller.rotateAngleZ = (float)e.getPersistentData().getDouble("PropSpeed") * (float)(Math.PI/180.0);
Code snippet to be added to the {EntityName}Renderer class for vehicle entities An example of the code to implement (i have been testing this with a test plane, but the actual implementation will need to use something other than NBT that syncs with server and client, and have it so it sets rotate angles instantly so it can do multiple instances seamlessly): ``` //this is an example for a plane, thus the prop speed attribute float DegToRad = (float)(Math.PI/180.0); float TargetRotX = (float)e.getPersistentData().getDouble("Pitch") * DegToRad; float TargetRotY = (float)e.getPersistentData().getDouble("Yaw") * DegToRad; float TargetRotZ = (float)e.getPersistentData().getDouble("Roll") * DegToRad; if(TargetRotX > Body.rotateAngleX) Body.rotateAngleX += 1* DegToRad; if(TargetRotX < Body.rotateAngleX) Body.rotateAngleX -= 1* DegToRad; if(TargetRotY > Body.rotateAngleY) Body.rotateAngleY += 1* DegToRad; if(TargetRotY < Body.rotateAngleY) Body.rotateAngleY -= 1* DegToRad; if(TargetRotZ> Body.rotateAngleZ) Body.rotateAngleZ += 1* DegToRad; if(TargetRotZ < Body.rotateAngleZ) Body.rotateAngleZ -= 1* DegToRad; propeller.rotateAngleZ = (float)e.getPersistentData().getDouble("PropSpeed") * (float)(Math.PI/180.0);
halbear added this to the Vehicle Framework project 2026-05-13 10:15:17 +00:00
halbear added this to the Vehicle Rendering milestone 2026-05-13 10:17:49 +00:00
halbear moved this to Vehicle Rendering in Vehicle Framework on 2026-05-13 10:19:38 +00:00
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: halbear/Hals-Exploration-Mod#36