Vehicle Actor WIP

This commit is contained in:
n00b87
2026-02-20 03:25:25 -06:00
parent ddfd6b8838
commit b0f09c3aae
7 changed files with 1496 additions and 61 deletions

Binary file not shown.

View File

@@ -4453,7 +4453,7 @@ int main(int argc, char * argv[])
//ogles2 test //ogles2 test
#ifdef RC_TESTING #ifdef RC_TESTING
rc_intern_dirChange("/home/n00b/Music/v47/RCBasic_v47_Linux64/examples/Sprite_Test"); rc_intern_dirChange("/home/n00b/Music/test_v48_1/test_v48");
//rc_intern_dirChange(""); //rc_intern_dirChange("");
rc_filename = "main.cbc"; rc_filename = "main.cbc";

File diff suppressed because it is too large Load Diff

View File

@@ -525,6 +525,7 @@ irr::core::array<rc_an8_obj> rc_an8;
#define RC_NODE_TYPE_STMESH 8 #define RC_NODE_TYPE_STMESH 8
#define RC_NODE_TYPE_PROJECTOR 9 #define RC_NODE_TYPE_PROJECTOR 9
#define RC_NODE_TYPE_COMPOSITE 10 #define RC_NODE_TYPE_COMPOSITE 10
#define RC_NODE_TYPE_VEHICLE 11
#define RC_NODE_SHAPE_TYPE_NONE 0 #define RC_NODE_SHAPE_TYPE_NONE 0
@@ -537,6 +538,7 @@ irr::core::array<rc_an8_obj> rc_an8;
#define RC_NODE_SHAPE_TYPE_TRIMESH 7 #define RC_NODE_SHAPE_TYPE_TRIMESH 7
#define RC_NODE_SHAPE_TYPE_HEIGHTFIELD 8 #define RC_NODE_SHAPE_TYPE_HEIGHTFIELD 8
#define RC_NODE_SHAPE_TYPE_COMPOSITE 9 #define RC_NODE_SHAPE_TYPE_COMPOSITE 9
#define RC_NODE_SHAPE_TYPE_IMPACT_MESH 10
struct rc_node_physics_collision struct rc_node_physics_collision
{ {
@@ -553,6 +555,8 @@ struct rc_node_physics
{ {
IRigidBody* rigid_body; IRigidBody* rigid_body;
int impact_mesh_id;
int shape_type; int shape_type;
bool isSolid; bool isSolid;
double mass; double mass;
@@ -616,6 +620,26 @@ struct rc_actor_fx_material_obj
int actor_material_index = -1; //index from node->getMaterial() int actor_material_index = -1; //index from node->getMaterial()
}; };
struct rc_composite_child
{
int id;
irr::core::matrix4 child_transform;
ICollisionShape* shape;
};
struct rc_vehicle_wheel
{
int actor_id;
irr::core::matrix4 offset_transform;
};
struct rc_vehicle_properties
{
int chassis_actor_id;
IRaycastVehicle* vehicle;
irr::core::array<rc_vehicle_wheel> wheels;
};
struct rc_scene_node struct rc_scene_node
{ {
int node_type = 0; int node_type = 0;
@@ -641,11 +665,15 @@ struct rc_scene_node
irr::core::array<int> deleted_animation; irr::core::array<int> deleted_animation;
irr::core::array<rc_actor_animation_obj> animation; irr::core::array<rc_actor_animation_obj> animation;
irr::core::array<int> child_actors; // Only used for composite actor types int parent_id;
irr::core::array<rc_composite_child> child_actors; // Only used for composite actor types
rc_vehicle_properties vehicle_properties;
}; };
irr::core::array<rc_scene_node> rc_actor; irr::core::array<rc_scene_node> rc_actor;
irr::core::array<int> rc_projector_actors; irr::core::array<int> rc_projector_actors;
irr::core::array<int> rc_vehicle_actors;
irr::core::array<int> rc_transition_actor; irr::core::array<int> rc_transition_actor;

View File

@@ -2,6 +2,8 @@
#define RC_SCENE_H_INCLUDED #define RC_SCENE_H_INCLUDED
#include "rc_gfx_core.h" #include "rc_gfx_core.h"
#include "rc_base_actor.h"
#include "rc_constraint.h"
void rc_addSceneSkyBox(int img_top, int img_bottom, int img_left, int img_right, int img_front, int img_back) void rc_addSceneSkyBox(int img_top, int img_bottom, int img_left, int img_right, int img_front, int img_back)
{ {
@@ -78,35 +80,14 @@ void rc_clearScene()
{ {
for(int i = 0; i < rc_physics3D.constraints.size(); i++) for(int i = 0; i < rc_physics3D.constraints.size(); i++)
{ {
if(rc_physics3D.constraints[i].constraint) rc_deleteConstraint(i);
{
rc_physics3D.world->getPointer()->removeConstraint(rc_physics3D.constraints[i].constraint);
rc_physics3D.constraints[i].constraint = NULL;
rc_physics3D.constraints[i].type = 0;
}
} }
rc_projector_actors.clear(); rc_projector_actors.clear();
for(int i = 0; i < rc_actor.size(); i++) for(int i = 0; i < rc_actor.size(); i++)
{ {
if(rc_actor[i].mesh_node) rc_deleteActor(i);
{
if(rc_actor[i].physics.rigid_body)
rc_physics3D.world->removeCollisionObject(rc_actor[i].physics.rigid_body, false);
rc_actor[i].physics.rigid_body = NULL;
rc_actor[i].physics.collisions.clear();
rc_actor[i].mesh_node->remove();
rc_actor[i].mesh_node = NULL;
rc_actor[i].shadow = NULL;
rc_actor[i].node_type = 0;
rc_actor[i].transition = false;
rc_actor[i].transition_time = 0;
rc_actor[i].material_ref_index = -1;
}
} }
rc_removeSceneSky(); rc_removeSceneSky();

View File

@@ -520,11 +520,12 @@ bool rc_update()
i++; i++;
} }
} }
} }
if(!manual_render_control) //if(!manual_render_control)
VideoDriver->beginScene(true, true); // VideoDriver->beginScene(true, true);
if(rc_physics3D.enabled && (!hasPreUpdated)) if(rc_physics3D.enabled && (!hasPreUpdated))
{ {
@@ -536,6 +537,31 @@ bool rc_update()
rc_physics3D.world->stepSimulation(rc_physics3D.DeltaTime*0.001f, rc_physics3D.maxSubSteps, fixed_timestep); rc_physics3D.world->stepSimulation(rc_physics3D.DeltaTime*0.001f, rc_physics3D.maxSubSteps, fixed_timestep);
} }
for(int i = 0; i < rc_vehicle_actors.size(); i++)
{
int vehicle_actor = rc_vehicle_actors[i];
for(int wheel_index = 0; wheel_index < rc_actor[vehicle_actor].vehicle_properties.wheels.size(); wheel_index++)
{
SWheelInfo &info = rc_actor[vehicle_actor].vehicle_properties.vehicle->getWheelInfo(wheel_index);
int wheel_actor = rc_actor[vehicle_actor].vehicle_properties.wheels[wheel_index].actor_id;
if(wheel_actor < 0 || wheel_actor >= rc_actor.size())
continue;
rc_actor[wheel_actor].physics.rigid_body->setWorldTransform(info.worldTransform);
irr::core::matrix4 actor_transform = rc_actor[wheel_actor].physics.rigid_body->getWorldTransform();
rc_actor[wheel_actor].mesh_node->setPosition( actor_transform.getTranslation() );
rc_actor[wheel_actor].mesh_node->setRotation( actor_transform.getRotationDegrees() );
rc_actor[wheel_actor].mesh_node->updateAbsolutePosition();
}
}
if(!manual_render_control)
VideoDriver->beginScene(true, true);
if(!manual_render_control) if(!manual_render_control)
{ {
for(int canvas_id = 0; canvas_id < rc_canvas.size(); canvas_id++) for(int canvas_id = 0; canvas_id < rc_canvas.size(); canvas_id++)

View File

@@ -1,5 +1,5 @@
# depslib dependency file v1.0 # depslib dependency file v1.0
1771296134 source:/home/n00b/Projects/RCBASIC4/rcbasic_runtime/main.cpp 1771311954 source:/home/n00b/Projects/RCBASIC4/rcbasic_runtime/main.cpp
"rc_os_defines.h" "rc_os_defines.h"
<emscripten.h> <emscripten.h>
<sys/param.h> <sys/param.h>
@@ -1275,7 +1275,7 @@
"rc_post_fx.h" "rc_post_fx.h"
<irrtheora.h> <irrtheora.h>
1771041726 /home/n00b/Projects/RCBASIC4/rcbasic_runtime/rc_gfx_core.h 1771574063 /home/n00b/Projects/RCBASIC4/rcbasic_runtime/rc_gfx_core.h
"SDL.h" "SDL.h"
"btBulletDynamicsCommon.h" "btBulletDynamicsCommon.h"
"BulletSoftBody/btSoftRigidDynamicsWorld.h" "BulletSoftBody/btSoftRigidDynamicsWorld.h"
@@ -2341,7 +2341,7 @@
"irrBulletCollisionObject.h" "irrBulletCollisionObject.h"
<vector3d.h> <vector3d.h>
1760243468 source:/home/n00b/Projects/irrBullet/src/irrBulletCollisionShape.cpp 1771381630 source:/home/n00b/Projects/irrBullet/src/irrBulletCollisionShape.cpp
<btBulletDynamicsCommon.h> <btBulletDynamicsCommon.h>
<btBulletCollisionCommon.h> <btBulletCollisionCommon.h>
<BulletCollision/Gimpact/btGImpactCollisionAlgorithm.h> <BulletCollision/Gimpact/btGImpactCollisionAlgorithm.h>
@@ -2387,7 +2387,7 @@
"irrBulletCompileConfig.h" "irrBulletCompileConfig.h"
"irrBulletWorld.h" "irrBulletWorld.h"
1760243468 source:/home/n00b/Projects/irrBullet/src/irrBulletGImpactMeshShape.cpp 1771492413 source:/home/n00b/Projects/irrBullet/src/irrBulletGImpactMeshShape.cpp
<btBulletDynamicsCommon.h> <btBulletDynamicsCommon.h>
<btBulletCollisionCommon.h> <btBulletCollisionCommon.h>
<BulletCollision/Gimpact/btGImpactCollisionAlgorithm.h> <BulletCollision/Gimpact/btGImpactCollisionAlgorithm.h>
@@ -2533,7 +2533,7 @@
1758412944 /home/n00b/Projects/RCBASIC4/rcbasic_runtime/rc_physics3D_base.h 1758412944 /home/n00b/Projects/RCBASIC4/rcbasic_runtime/rc_physics3D_base.h
"rc_gfx_core.h" "rc_gfx_core.h"
1771135335 /home/n00b/Projects/RCBASIC4/rcbasic_runtime/rc_base_actor.h 1771579368 /home/n00b/Projects/RCBASIC4/rcbasic_runtime/rc_base_actor.h
"ProjectiveTextures.h" "ProjectiveTextures.h"
"rc_matrix.h" "rc_matrix.h"
@@ -2550,12 +2550,14 @@
1758412944 /home/n00b/Projects/RCBASIC4/rcbasic_runtime/rc_particles.h 1758412944 /home/n00b/Projects/RCBASIC4/rcbasic_runtime/rc_particles.h
1764140917 /home/n00b/Projects/RCBASIC4/rcbasic_runtime/rc_scene.h 1771479046 /home/n00b/Projects/RCBASIC4/rcbasic_runtime/rc_scene.h
"rc_gfx_core.h" "rc_gfx_core.h"
"rc_base_actor.h"
"rc_constraint.h"
1758412944 /home/n00b/Projects/RCBASIC4/rcbasic_runtime/rc_camera.h 1758412944 /home/n00b/Projects/RCBASIC4/rcbasic_runtime/rc_camera.h
1769130046 /home/n00b/Projects/RCBASIC4/rcbasic_runtime/rc_windowclose.h 1771572803 /home/n00b/Projects/RCBASIC4/rcbasic_runtime/rc_windowclose.h
1650940764 /usr/include/bullet/BulletCollision/NarrowPhaseCollision/btRaycastCallback.h 1650940764 /usr/include/bullet/BulletCollision/NarrowPhaseCollision/btRaycastCallback.h
"BulletCollision/CollisionShapes/btTriangleCallback.h" "BulletCollision/CollisionShapes/btTriangleCallback.h"
@@ -2749,7 +2751,7 @@
<sstream> <sstream>
"rc_steam.h" "rc_steam.h"
1764140917 /home/n00b/Projects/RCBASIC4/rcbasic_runtime/rc_render_control.h 1771572779 /home/n00b/Projects/RCBASIC4/rcbasic_runtime/rc_render_control.h
<irrlicht.h> <irrlicht.h>
"rc_gfx_core.h" "rc_gfx_core.h"
"rc_post_fx.h" "rc_post_fx.h"
@@ -2759,11 +2761,11 @@
<cstdlib> <cstdlib>
"rc_gfx_core.h" "rc_gfx_core.h"
1771135300 /home/n00b/Projects/irrBullet/include/irrBulletCompoundShape.h 1771366010 /home/n00b/Projects/irrBullet/include/irrBulletCompoundShape.h
"irrBulletCollisionShape.h" "irrBulletCollisionShape.h"
<vector> <vector>
1771135300 source:/home/n00b/Projects/irrBullet/src/irrBulletCompoundShape.cpp 1771391831 source:/home/n00b/Projects/irrBullet/src/irrBulletCompoundShape.cpp
<ISceneNode.h> <ISceneNode.h>
"btBulletDynamicsCommon.h" "btBulletDynamicsCommon.h"
"btBulletCollisionCommon.h" "btBulletCollisionCommon.h"