AggrorJorn Posted June 21, 2013 Share Posted June 21, 2013 Inside the collisionhook parameters we can access the normal and the position: void CollisionHook(Entity* entity0, Entity* entity1, float* position, float* normal, float speed) Shouldn't the normal and position be Vec3? If not, can someone explain why they are floats instead of vec3? I want to calculate the perpendicular (which is the normal) vector on two given vectors, which I can easily do with the velocity and the collision position. I use the cross product to do this but that would require an actual position and not a float. Quote Link to comment Share on other sites More sharing options...
Furbolg Posted June 21, 2013 Share Posted June 21, 2013 Then create a Vec3 and fill it with position[0] (x) position[1] (y) and position[2] (z), tada Quote Link to comment Share on other sites More sharing options...
AggrorJorn Posted June 21, 2013 Author Share Posted June 21, 2013 Thanks for answering, I am not sure what you mean with 'fill it'. With what data? I could get the position of the objects colliding but those are not the position of colliding Quote Link to comment Share on other sites More sharing options...
Rick Posted June 21, 2013 Share Posted June 21, 2013 Those parameters are arrays. Well they are pointing to an array so position[0] = x, position[1] = y, position[2] = z I believe. I don't know why Josh did it this way instead of just making them Vec3 types instead. Quote Link to comment Share on other sites More sharing options...
AggrorJorn Posted June 21, 2013 Author Share Posted June 21, 2013 A like that. thanks Rick and furbolg. Quote Link to comment Share on other sites More sharing options...
Tim Shea Posted June 21, 2013 Share Posted June 21, 2013 You probably don't want to take the cross product of the position and the velocity, but rather, the delta between the collision position and the object position crossed with the velocity. That is possibly also why position is given as a float* rather than a Vec3, as position is a point not (directly) a vector. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.