RotateAroundAxis < This thing (3D2D)

SOLVED: Check one of the last comments for the code.
[HR][/HR]
Well, you know this prop:

It’s very nice! Well I wanted to make a terminal with it, so I create the 3D2D Textscreen:

Yeah, so I do some research and I find the godly code: RotateAroundAxis and it works!:

Then, I slightly move it:

It gets worse:

Yeah, so I try some weird Think hooks to update the angle to the prop angle and manage to think hook the cam.Start3D2D and crash my game.
I have done loads of research:

I am at a dead end, here is my code:


include("shared.lua")



function ENT:Draw()

	surface.CreateFont( "Board", {
	font = "Arial", -- This is here to stop some weird error, it would be outside ENT:Draw() but hey
	extended = false,
	size = 130,
	weight = 500,
	blursize = 0,
	scanlines = 0,
	antialias = true,
	underline = false,
	italic = false,
	strikeout = false,
	symbol = false,
	rotary = false,
	shadow = false,
	additive = false,
	outline = false,
} )
	self:DrawModel()
	local pos = self:GetPos() + Vector(25,65,60)
	local ang = self:GetAngles()
	ang:RotateAroundAxis(self:GetAngles():Forward(), 60)
	ang:RotateAroundAxis(self:GetAngles():Up(), 135)
	ang:RotateAroundAxis(self:GetAngles():Right(),0)
	cam.Start3D2D(pos , ang, 0.1)

		draw.RoundedBox(0,0,0,380,370,Color(0,0,0))
		draw.SimpleText("OFF","Board",100,120,Color(255,255,255),0,0)

	cam.End3D2D()

end

I don’t think you will really need the other code so I have only given cl_init.lua . If you need the rest just ask, yes it does have to be this prop, no It isn’t just going to say OFF, it may change so it would be nice If that is still possible, if you need any more info just comment and I will reply shortly, This is my first post btw.

P.S: Pls don’t spoon feed me code, try and explain each part otherwise it is useless and I will have to ask the same question in a different context later.

try doing ang:Forward() instead of self:GetAngles():Forward() etc. You’ll have to change the degrees but I think that will fix it.

Ok, thanks I will check tomorrow

Ok, If you mean this:



	self:DrawModel()
	local pos = self:GetPos() + Vector(25,65,60)
	local ang = self:GetAngles()
	ang:Forward(60)
	ang:Up(135)
	ang:Right(0)
	cam.Start3D2D(pos , ang, 0.1)


or



	self:DrawModel()
	local pos = self:GetPos() + Vector(25,65,60)
	local ang = self:GetAngles()
	ang:Forward(), 60)
	ang:Up(), 135)
	ang:Right(),0)
	cam.Start3D2D(pos , ang, 0.1)


It still does the same thing. If necessary, show me the code in context.

No, it would be ang:RotateAroundAxis(ang:Right(), 90) – or whatever



	local ang = self:GetAngles()
	ang:RotateAroundAxis(ang:Right(), 0)
	ang:RotateAroundAxis(ang:Forward(), 60)
	ang:RotateAroundAxis(ang:Up(), 135)


This still does the same thing

what exactly is the problem? like why did you change the position of the screen, and what are you hoping to accomplish?

I did specify the issue in the start of the thread, I moved it so it would position itself on the screen of the prop (Image 3). Unfortunately, it does not keep the position if the prop changes angle.

I suggest that you drop 3D2D entirely. You can replace the actual materials used on the model with SetSubMaterial, use a custom material with a RenderTarget texture, and just draw to that texture.

It’s a bit complicated and difficult to explain how it’s done exactly, but for what it’s worth, that’s the method the toolgun uses to draw the screen in the view model.

[editline]22nd February 2017[/editline]

However, if you want to just keep using 3D2D, it’s as simple as getting LocalToWorld every time you use Start3D2D.

The issue Is that you are adding ( or in this case multiplying )
vectors to your position

Look at the position of the money printers 3d2d for an example: https://github.com/FPtje/DarkRP/blob/master/entities/entities/money_printer/cl_init.lua

Will that mean I can’t change it later, it needs to be like an output screen

what everyone is saying about using LocalToWorld is right. when you say



local pos = self:GetPos() + Vector(25,65,60)


what you’re doing is positioning the 3d2d display relative to the world’s coordinates. think of it as a big grid covering and aligned with the whole map.
when you rotate the prop, the same place in the world doesn’t line up with the same place on the prop, so you need to use the prop’s local coordinate system. you can accomplish that with either



local pos = self:LocalToWorld(Vector(-33, -61, 59)) 


OR



local pos = self:GetPos() + self:GetForward() * -33 + self:GetRight() * 61 + self:GetUp() * 59


Ent:GetForward() gets the X axis in a prop’s local coordinate system, GetRight() gets the local Y axis, and GetUp() gets the local Z axis.

You can change the numbers to line up the screen a little better, those were just the ones I found while quickly messing around

how has everyone missed my post?

As for Neatnit, that particular model he’s showing only has one material.
You cannot use setsubmaterial on it, son.

Yes, but that’s position, not angle

[editline]24th February 2017[/editline]

This is what I have got so far



local angle = self:LocalToWorld(Vector(-33, -61, 59))
local angle = self:LocalToWorldAngles(Angle(P, Y, R))


[DEL]20 min of work[/DEL] An hour of work for this.


include("shared.lua")

local output = [[root@local:~#
root@local:~# ls
bin dev home root usr boot etc lib run var
root@local:~# echo test
test]]

local fontsize = 1

function ENT:Draw()
    self:DrawModel()
    ang = self:GetAngles()
	pos = self:GetPos() + ang:Up() *56.85- ang:Forward() * 36.1+ ang:Right() * 61.2
    ang:RotateAroundAxis(ang:Forward(),112,3)
    ang:RotateAroundAxis(ang:Up(),20.5)
    ang:RotateAroundAxis(ang:Right(),-139.2)

    cam.Start3D2D( pos, ang, 0.1 * fontsize)
		surface.SetDrawColor( Color( 0,0, 0, 255 ) )
		surface.DrawRect( 0, 0, 356 / fontsize, 347 / fontsize)
		draw.DrawText( output, "TargetID", 5, 0, Color( 255, 255, 255, 255 ), TEXT_ALIGN_LEFT )

	cam.End3D2D()
end

Close your scriptfodder job if you don’t take care of it :wink:

Thanks! For me it said deleted… If you want, I can give you some money over paypal

[editline]25th February 2017[/editline]

Ok, this thread is about to become solved, just one last thing, How do you give entities pictures in the spawn menu?

[editline]25th February 2017[/editline]

Ok, this thread is about to become solved, just one last thing, How do you give entities pictures in the spawn menu?

I think you just make a PNG of the same name or something simple like that

Directory?

materials/entities/<sent_name>.png