ok vertex attachment. You can look at the examples on the Resource site wdl scripts. Also Alex Russell gave a nice little tutorial (also on resource site under tutorials ) on vertex attachment as well, but here is the nutshell
on the pully/moter model assembly i need the vertex Number at point 'A'
so I open the model up in MED, find a vertex at that location ( or place one if need be) select the vertex and bottem left hand border of MED will give me the vertex's number.
now, using the instruction vec_for_vertex I can get the world x/y/z location fo that Vertex by referancing that vertex number.
my cable model, it's origin point placed at its top center, I then change its x/y/z to equal that Vertex x/y/z we referanced above with vec_to_vertex.
so now my cable model top is lined up at point A
ow I need point 'a' depending on how you built the counter weight ) model or map entity ) will determine how we get 'a'
If a map entity then we just align our counterwieghts originpoint to be at 'a' when we build it.
if a model, then we do as above. we need a vertex point (vec_for_vertex)
we now have 2(two) vector points in space
A and a
with 2 vector points we can calculate distance and direction very fast, the engine has instrucitons for these
vec_dist(vector A, vector a) will give us the distance in quants from 'A' to 'a'
vec_diff(vector temp, vector a. vector A) will give us a direction vector result (temp) from 'A' to 'a'. **note the ORDER you place the vectors makes a differance**
read up on these 2 instructions
now for our scale. of my original cable model is made at 100 quants tall ( for example) then i just take the RESULT of vec_dist(A,a) divide it by 100 ( length of our cable) and that will give you the scale value to scale the cable Z value
i.e.
my.scale_z = vec_dist(A,a);
so if the distance from A to a is 100 quants (100/100 = 1) the scale would be 1
if the distance A to a is 200 the scale is 2 (200/100 = 2)( 2 times the original length)
if teh distance A to a is 50 the scale is .5 (50/100 = .5)( half the length)
as the counterwight moves by your movment script, we just recalcualte the vec_dist every frame and reapply the new scale
and so forth
for the correct angle alignment, a little more work is involved because we made trhe model vertical, but not much. ( we can cut the work if we set one end of the model at the origin and then the cabel down the length of the +X axis in MED)
this would make it easier but not necissary
vec_diff will give us a direction vector. vec_diff(temp,a,A) the direction from A to a this is in vector direction so we have to convert it to angles
vec_to_angle will convert our direction vector to pan and tilt angles from A to a
vec_diff(temp,a,A)
vec_to_angle(cable_model.pan,temp)
would point my cable model picture above so it points from A to a
since we built our cable model though as :
the agles will be off by 90 degrees.
so we just subtract 90 off the tilt after we do the above
vec_diff(temp,a,A)
vec_to_angle(cable_model.pan,temp)
cable_model.tilt -90;
now our cable will be in line from A to a
repeat for B to b as well.