How would I rotate text in garry's mod? Specifically draw.DrawText or draw.SimpleText?
[QUOTE=CGHippo;49190922]How would I rotate text in garry's mod? Specifically draw.DrawText or draw.SimpleText?[/QUOTE]
First search on google.
[url]https://facepunch.com/showthread.php?t=1232753[/url]
[QUOTE=tzahush;49190951]First search on google.
[url]https://facepunch.com/showthread.php?t=1232753[/url][/QUOTE]
Not sure I understand that. Anyone here got a different example?
[CODE]
local sSetTextPos = surface.SetTextPos;
local sDrawText = surface.DrawText;
local cPushModelMatrix = cam.PushModelMatrix;
local cPopModelMatrix = cam.PopModelMatrix;
local mat = Matrix();
local matAng = Angle(0, 0, 0);
local matTrans = Vector(0, 0, 0);
local matScale = Vector(0, 0, 0);
local function drawSpecialText(txt, posX, posY, scaleX, scaleY, ang)
matAng.y = ang;
mat:SetAngle(matAng);
matTrans.x = posX;
matTrans.y = posY;
mat:SetTranslation(matTrans);
matScale.x = scaleX;
matScale.y = scaleY;
mat:Scale(matScale);
sSetTextPos(0, 0);
cPushModelMatrix(mat);
sDrawText(txt);
cPopModelMatrix();
end
[/CODE]
Stolen from Wizard of Ass.
What don't you understand?
[QUOTE=SkellyR;49191108][CODE]
local sSetTextPos = surface.SetTextPos;
local sDrawText = surface.DrawText;
local cPushModelMatrix = cam.PushModelMatrix;
local cPopModelMatrix = cam.PopModelMatrix;
local mat = Matrix();
local matAng = Angle(0, 0, 0);
local matTrans = Vector(0, 0, 0);
local matScale = Vector(0, 0, 0);
local function drawSpecialText(txt, posX, posY, scaleX, scaleY, ang)
matAng.y = ang;
mat:SetAngle(matAng);
matTrans.x = posX;
matTrans.y = posY;
mat:SetTranslation(matTrans);
matScale.x = scaleX;
matScale.y = scaleY;
mat:Scale(matScale);
sSetTextPos(0, 0);
cPushModelMatrix(mat);
sDrawText(txt);
cPopModelMatrix();
end
[/CODE]
Stolen from Wizard of Ass.
What don't you understand?[/QUOTE]
How it works, would you comment each line to tell me how it functions? Sorry for the spoonfeeding.
So the first few lines are just setup, to compensate for the call overhead (I called the function a lot when I wrote it).
First it sets the yaw component of the matrix, which in 2D space corresponds to the rotation around the normal of your screen.
Then you have to set the translation of the matrix, this may seem weird but there were some conflicts involving surface.SetTextPos back then(hence text pos is always 0,0 here), then after that I apply the scale.
Then push the matrix, draw text, pop matrix.
[QUOTE=Wizard of Ass;49191217]So the first few lines are just setup, to compensate for the call overhead (I called the function a lot when I wrote it).
First it sets the yaw component of the matrix, which in 2D space corresponds to the rotation around the normal of your screen.
Then you have to set the translation of the matrix, this may seem weird but there were some conflicts involving surface.SetTextPos back then(hence text pos is always 0,0 here), then after that I apply the scale.
Then push the matrix, draw text, pop matrix.[/QUOTE]
Bookmarked, thanks for the help!
[editline]26th November 2015[/editline]
Sorry I was being dumb. I thought rotating text in 2d was the same as 3d2d. How would I rotate text in 3d2d instead?
[editline]26th November 2015[/editline]
Solved. Thanks for the help guys!
Sorry, you need to Log In to post a reply to this thread.