Rotate Text Toward Camera + keep the same screen text size


#1

Continuing the discussion from Callback on viewport/camera move?:

I like that the text is pointing toward camera, but can I keep the size of the text unchanged no matter do I go far or close to the text. This means, the text size should change according to getViewTM()

I found this scaleFactor feature that I was thinking it could help

scaleFactor = gw.nonScalingObjectSize() * (gw.getVPWorldWidth [0,0,0]) / 360.0
and tried to scale the object like this:

scale node [scaleFactor,scaleFactor,scaleFactor]

but it seams not to work as needed.

Can you help me please to solve this?


#2

Wouldn’t be just using distance between camera and text assuming it is already looking at camera?


#3

No, I need the text just in viewport without camera!


#4

there is no way to do this via viewport callback that isn’t “choppy”

but here’s a possible solution for you…

plugin Helper ViewportPoint
name:"ViewportPoint" 
classID:#(0x47db14fb, 0x4e9b5f95) 
category:"Scripted" 
extends:point 
( 
	local tnode;
	
	fn vpconst = if tnode != undefined and IsValidNode tnode then 
	(
		tm = inverse(getViewTM());
		if not viewport.IsPerspView() then tm[4] = tm[4] + tm[3] * 999999.0;	
		tnode.transform = tm;
	)

	on attachedToNode n do	
	(
		tnode = n;	
		registerRedrawViewsCallback vpconst;
	)	
	on deleted do 
	(	
		tnode = undefined;	
		UnregisterRedrawViewsCallback vpconst;
	)
	on create do completeRedraw();
	
	on load do
	(	
		tnode = refs.dependentNodes this firstOnly:true baseObjectOnly:false;
		registerRedrawViewsCallback vpconst;
	)	
)

this create a helper that is “pinned” to the viewport center. you can the parent a text object to it and position it relative to the helper so as to appear fixed and camera facing

using the type in area and the parent reference coordinate system works best for moving or screen once you’ve got the depth sorted. Also it’s worth noting that the text will be z sorted so if you want it on top make it small with a small z but this makes it more choppy during viewport navigation


#5

Hey, Klvnk!
Thank you so much! I think now I can go on with this, thank you ))