I am creating a 3D graphics engine, and one of the requirements is ropes that behave like in a Valve source engine.
Thus, in the source engine, the rope section is an ATV that rotates along its axis of direction to the camera, so if the section of the rope is in the + Z direction, it will rotate along the Z axis, so that the face refers to the center position of the camera.
At the moment I have certain sections of the ropes, so I can have a good curved rope, but now I'm trying to build a matrix that will rotate it along the direction vector.
I already have a matrix for rendering billboards based on this poster: Building a matrix of billboards And at the moment I'm trying to redo it so that the Right, Up, Forward vector matches the direction vector of the rope segment.
My rope consists of several sections, each section is a rectangle consisting of two triangles, as I said above, I can get the position and sections perfectly, it rotates towards the camera, which causes me a lot of problems.
This is in OpenGL ES2 and is written in C.
I studied the Doom 3 ray rendering code in Model_beam.cpp, the method used there is to calculate the offset based on the normals, and not to use the matrices, so I created a similar method in my C code and its kinds of work, at least It works as much as I need now.
So, for those who are also trying to figure it out, use the cross product of the middle of the rope against the position of the camera, normalize this, and then multiply it by how wide you want the rope to be, then when building vertices we shift each vertex to + or - direction of the resulting vector.
Further help would be great, although this is not perfect!
thanks