Goal: Spawn "models/weapons/w_eq_sensorgrenade.mdl" with correct rotaion for surface.
If just spawn with default rotation
My environment has next parameters:
PHP Code:
methodmap System
{
public static int Place(const float pos[3], const float normal[3])
{
PrintToChatAll("{%.2f, %.2f, %.2f}", normal[0], normal[1], normal[2]);
float origin[3], ang[3], vec[3];
vec = normal; // this is for get angle by normal without rotation
//GetVectorVectors(normal, vec, NULL_VECTOR); // this is for get angle by normal with rotation
GetVectorAngles(vec, ang);
origin = pos;
// this is offsets for place model like red glass will in point of spawn
// if not rotate it
//origin[0] += 5.0;
//origin[1] -= 1.0;
//origin[2] -= 2.75;
float posx[3], posy[3], posz[3];
GetAngleVectors(ang, posx, posy, posz);
ScaleVector(posx, 8.0);
ScaleVector(posy, 8.0);
ScaleVector(posz, 8.0);
AddVectors(pos, posx, posx);
AddVectors(pos, posy, posy);
AddVectors(pos, posz, posz);
DrawObject draw = DrawObject();
draw.AddLine(pos, posx, {255, 0, 0, 255});
draw.AddLine(pos, posy, {0, 255, 0, 255});
draw.AddLine(pos, posz, {0, 0, 255, 255});
return UTILS.CreatePropDynamic("models/weapons/w_eq_sensorgrenade.mdl", origin, ang);
}
}
If i get normal vector angels and set it for model
Next i tried to get right vector for normal
It's work ok for walls but not for floor.
Probably i needed to rotate it along the Z axis for 90 degrees,
Or maybe you know better way to do what i want.