Notifications
Clear all

[Closed] Aling shape Text to camera

Hi every one !!

Im trying to do an aling of some shape text creating via maxscirpt , this is the code i finded
in some good people post.


cadena = maxfilename
positionshot = findstring cadena “shot”

nombrearchivo = maxfilename

aa= nombrearchivo
aaa = substring aa positionshot 8

textoshot=text name: “ControlledText” wirecolor:yellow
textoshot.text = aaa


t=text name:“FrameCounter” wirecolor:yellow

t.baseobject.renderable=false –set the shape to renderable

theCtrl = float_script() –create a float script controller

theCtrl.addNode “TheText” t –add a variable, connect to the Text node

–Set the expression to assign the height of the box as string to the

–.text property of the text shape, then return 0 on the next line:

theCtrl.SetExpression “TheText.text = currentTime as string
0”

t.kerning.controller=theCtrl –assign the controller to the kerning

This code create 2 shape text one with the name of the shot and other with frame umber.

Im trying to align this 2 shapes into camera , but i dont know were to start or what to search. I thougt may be i would have some problems with the scale of the shapes and the fov of the camera, i dont know if there are a mathematic formula to solve this.

Do you have some other solutions ? or know any code to do this?

Thank you very much in advance !!

8 Replies

Any one? some search parameter for google it ?
I dont know were to star to search. Thx man !!

Using this the Z axis of the slected object will points to center of the viewport


selection[1].dir = (Inverse(getViewTM()))[3]

Ey man !! thank you very much !! its a step !!

This align the direction of the object to active viewport, but i need to get the item more close to camera, will be more set objects and if the text shape is on the 0,0,0 surely will be items in the foreground of the shape text. How i could get close the shape text to camera , and how can scale the shape text to adjust to the corner of the viewport ?

Thank you for your reply

I get so close but i have the problem of the camera fov.


selectedCamera = viewport.getCamera()
selection[1].dir = selectedCamera.pos
selection[1].pos = selectedCamera.pos shotname = $ControlledText
in coordsys local move shotname [0, 0, -10]
in coordsys local scale shotname [0.008, 0.008, 0.008]

The local move and local scale it depends of the fov of the camera. Do you know if there are some mathematical formula to adjust the position and scale of the object ?

Thank you for your coment man , opens me a way to solve this

Hi all !!

i think i got it. but i have the problem of the fov camera.


delete $ControlledText
delete $FrameCounter


cadena = maxfilename 
positionshot = findstring cadena "shot"
nombrearchivo = maxfilename
aa= nombrearchivo
aaa = substring aa positionshot 8
textoshot=text name: "ControlledText" wirecolor:yellow
textoshot.text = aaa 

---------------------------------------------------------------------------------------------
t=text name:"FrameCounter" wirecolor:yellow
t.baseobject.renderable=false --set the shape to renderable
theCtrl = float_script() --create a float script controller
theCtrl.addNode "TheText" t --add a variable, connect to the Text node
--Set the expression to assign the height of the box as string to the
--.text property of the text shape, then return 0 on the next line:
theCtrl.SetExpression "TheText.text = currentTime as string
0"
t.kerning.controller=theCtrl --assign the controller to the kerning
select $ControlledText
selectedCamera = viewport.getCamera()
selection[1].dir = selectedCamera.pos
selection[1].pos = selectedCamera.pos 
shotname = $ControlledText 
in coordsys local move shotname [-2.5, -1.5, -10] 
in coordsys local scale shotname [0.005, 0.005, 0.005] 
clearselection 
select $FrameCounter 
selection[1].dir = selectedCamera.pos 
selection[1].pos = selectedCamera.pos
framecounter = $FrameCounter
in coordsys local move framecounter [3, -1.5, -10]
in coordsys local scale framecounter [0.005, 0.005, 0.005] 
clearselection

The code of the frame count i get from this forum LINK , but they didnt aling the shapes to camera.

Have any idea please ? i know this code is so dirt, i dont have more idea of maxscript , but i try to understan it . thanks in advance guys

it’s not easy. it will get a distortion for not orthogonal views…
i’m sure that will be easier and better to do a composition

Ey DenisT, may be when the preview is created ? i need the shapes or the info in the preview. Thanks for the advice man

you can render shapes if you want to make some sort of a fake presence the title in the scene (lighting, shadow, reflection, etc.) but do it from orthographic camera