@@ -14,13 +14,23 @@ class TestInteraction : public Interaction
1414public:
1515 TestInteraction () : Interaction()
1616 {
17- // addInteractorComponentType();
18- // addInteracteeComponentType();
17+ addInteractorComponentType (TransformComponent::ID);
18+ addInteractorComponentType (ColliderComponent::ID);
19+ addInteractorComponentType (MotionComponent::ID);
20+ addInteracteeComponentType (TransformComponent::ID);
21+ addInteracteeComponentType (ColliderComponent::ID);
22+ addInteracteeComponentType (MotionComponent::ID);
1923 }
2024
2125 virtual void interact (float delta, BaseECSComponent** interactorComponents, BaseECSComponent** interacteeComponents)
2226 {
23- DEBUG_LOG_TEMP2 (" Interacting!!" );
27+ Transform& transform = ((TransformComponent*)interactorComponents[0 ])->transform ;
28+ MotionComponent* motionComponent = ((MotionComponent*)interactorComponents[2 ]);
29+
30+ motionComponent->velocity = motionComponent->velocity * -1 .1f ;
31+
32+ // transform.setRotation((transform.getRotation()*Quaternion(Vector3f(0.0f,0.0f,1.0f), delta)).normalized());
33+ // DEBUG_LOG_TEMP2("Interacting!!");
2434 }
2535};
2636
@@ -139,8 +149,8 @@ int Game::loadAndRunScene(RenderDevice& device)
139149 transformComponent.transform .setTranslation (Vector3f (0 .0f , 0 .0f , 20 .0f ));
140150
141151 MovementControlComponent movementControl;
142- movementControl.movementControls .push_back (std::make_pair (Vector3f (1 .0f ,0 .0f ,0 .0f ) * 10 .0f , &horizontal));
143- movementControl.movementControls .push_back (std::make_pair (Vector3f (0 .0f ,1 .0f ,0 .0f ) * 10 .0f , &vertical));
152+ movementControl.movementControls .push_back (MovementControl (Vector3f (1 .0f ,0 .0f ,0 .0f ) * 30 .0f , &horizontal));
153+ movementControl.movementControls .push_back (MovementControl (Vector3f (0 .0f ,1 .0f ,0 .0f ) * 30 .0f , &vertical));
144154
145155 RenderableMeshComponent renderableMesh;
146156 renderableMesh.vertexArray = &vertexArray;
@@ -149,7 +159,7 @@ int Game::loadAndRunScene(RenderDevice& device)
149159 MotionComponent motionComponent;
150160 MegaCubeComponent megaCubeComp;
151161 // Create entities
152- ecs.makeEntity (transformComponent, movementControl, renderableMesh, colliderComponent);
162+ ecs.makeEntity (transformComponent, movementControl, motionComponent, renderableMesh, colliderComponent);
153163 for (uint32 i = 0 ; i < 1 ; i++) {
154164 transformComponent.transform .setTranslation (Vector3f (Math::randf ()*10 .0f -5 .0f , Math::randf ()*10 .0f -5 .0f , 20 .0f ));
155165 // Math::randf()*10.0f-5.0f + 20.0f));
@@ -159,16 +169,16 @@ int Game::loadAndRunScene(RenderDevice& device)
159169
160170 float vf = -4 .0f ;
161171 float af = 5 .0f ;
162- motionComponent.acceleration = Vector3f (Math::randf (-af, af), Math::randf (-af, af), Math::randf (-af, af));
163- motionComponent.velocity = motionComponent.acceleration * vf;
172+ // motionComponent.acceleration = Vector3f(Math::randf(-af, af), Math::randf(-af, af), Math::randf(-af, af));
173+ // motionComponent.velocity = motionComponent.acceleration * vf;
164174// for(uint32 i = 0; i < 3; i++) {
165175// megaCubeComp.pos[i] = transformComponent.transform.getTranslation()[i];
166176// megaCubeComp.vel[i] = motionComponent.velocity[i];
167177// megaCubeComp.acc[i] = motionComponent.acceleration[i];
168178// megaCubeComp.texIndex = Math::randf() > 0.5f ? 0 : 1;
169179// }
170180 // ecs.makeEntity(megaCubeComp);
171- ecs.makeEntity (transformComponent, renderableMesh, colliderComponent);
181+ ecs.makeEntity (transformComponent, renderableMesh, motionComponent, colliderComponent);
172182 }
173183
174184 // Create the systems
0 commit comments