How to write text in the viewport in real-time

   3435   8   3
User Avatar
Member
20 posts
Joined: Feb. 2022
Offline
Hi all, I have this setup that uses the font sop to display text in the camera view. The trouble is, for my use case I need this to update in real time to give immediate feedback of what's being written. Any ideas?

Attachments:
live_typing.hiplc (145.3 KB)

User Avatar
Member
20 posts
Joined: Feb. 2022
Offline
So I've made a bit of progress. I've managed to assign different letters to points as an alphabet. But just need to be able to control the letters in a sequence. Anyone have ideas to complete this?

Attachments:
live_typing 2.hiplc (172.9 KB)

User Avatar
Member
72 posts
Joined: Oct. 2018
Offline
How about this snippet?

string tMsg="The Message";
for (int i=0;i<len(tMsg) && i<@Frame;i++){              #tweakpoint 3
   int np=addpoint(0,set(i,0,0))            #tweakpoint 1
   setpointattrib(0,"L",np,tMsg[i],"set")   #tweakpoint 2

}

Assuming this is what you want to achieve:
Edited by GOgraphR - May 11, 2023 13:18:16

Attachments:
202030511_topic_90190.A.mp4 (28.5 KB)

User Avatar
Member
20 posts
Joined: Feb. 2022
Offline
GOgraphR
How about this snippet?

string tMsg="The Message";
for (int i=0;i<len(tMsg) && i<@Frame;i++){              #tweakpoint 3
   int np=addpoint(0,set(i,0,0))            #tweakpoint 1
   setpointattrib(0,"L",np,tMsg[i],"set")   #tweakpoint 2

}

Assuming this is what you want to achieve:
Sorry, I don't quite understand how to implement this, could you send the hip file?
User Avatar
Member
72 posts
Joined: Oct. 2018
Offline
bashorton
Sorry, I don't quite understand how to implement this, could you send the hip file?

Ok, I am backing down...

It is quite identical to your setup. And that led to the assumption I made.

Attachments:
202030511_topic_90190.A.hipnc (109.8 KB)

User Avatar
Member
20 posts
Joined: Feb. 2022
Offline
GOgraphR
bashorton
Sorry, I don't quite understand how to implement this, could you send the hip file?

Ok, I am backing down...

It is quite identical to your setup. And that led to the assumption I made.
Thanks so much! It's not quite what I was looking for but interesting technique.

I actually figured out a way to do what I wanted in python which reads text from an external text file. This is written in visual studio with auto save set to 10ms.

Attachments:
text_in_view.hiplc (150.9 KB)

User Avatar
Member
72 posts
Joined: Oct. 2018
Offline
Just noticed. You can save a few sops:
The match size sop can save you a transform.
  • Set "Target" position to (0.5 ; 0.5 ; 0) and size (1;1;1)
  • Set Scale to fit
  • Unset Uniform scale
This transforms your Input 1 to the "uniform" coordinates.

and I have instead of the VOP this pointWrangle which is pretty much to the same effect
vector Pt=@P;
Pt.z-=chf("dist");
@P=fromNDC("/obj/cam1",Pt);
to project to the camera. "dist" is a slider, that moves the "HUD" near/far.

I have done my HUD with a COP. That saves geometry count. Your Font-SOP approach increases geometry count


I store the Text in detail attribs, which are read in by a COP-Font, some adds,to compose final HUD image and taht's it.
COP-SOP is set to quad with UVs, UV quickshade get its texture from "op:/obj/HUD/cop/OUT_HUD_TXT" then the match size and a Wrangle as described above.

In the HUD, currently I have a Python-SOP and a SOP Solver, to "compute" time between two frames, and display "UL" shows elapsed rendertime,current Date/Time and Start Date/Time. Which gets "rendered".
Image Not Found




Could you explain what exactly you want to achieve as I think I don't got it... (*sorry*) :S
Edited by GOgraphR - May 11, 2023 16:20:49

Attachments:
202030511_topic_90190.B.jpg (124.4 KB)
202030511_topic_90190.B.mp4 (61.4 KB)

User Avatar
Member
20 posts
Joined: Feb. 2022
Offline
GOgraphR
Just noticed. You can save a few sops:
The match size sop can save you a transform.
  • Set "Target" position to (0.5 ; 0.5 ; 0) and size (1;1;1)
  • Set Scale to fit
  • Unset Uniform scale
This transforms your Input 1 to the "uniform" coordinates.

and I have instead of the VOP this pointWrangle which is pretty much to the same effect
vector Pt=@P;
Pt.z-=chf("dist");
@P=fromNDC("/obj/cam1",Pt);
to project to the camera. "dist" is a slider, that moves the "HUD" near/far.

I have done my HUD with a COP. That saves geometry count. Your Font-SOP approach increases geometry count
Image Not Found


I store the Text in detail attribs, which are read in by a COP-Font, some adds,to compose final HUD image and taht's it.
COP-SOP is set to quad with UVs, UV quickshade get its texture from "op:/obj/HUD/cop/OUT_HUD_TXT" then the match size and a Wrangle as described above.

In the HUD, currently I have a Python-SOP and a SOP Solver, to "compute" time between two frames, and display "UL" shows elapsed rendertime,current Date/Time and Start Date/Time. Which gets "rendered".
Image Not Found




Could you explain what exactly you want to achieve as I think I don't got it... (*sorry*) :S
Interesting approach! Quite a bit over my head honestly without the hip file.

Basically with my approach, I have an external text file in visual studio that auto saves as I type in it. Then I have a python node in houdini that reads this text then inputs it into the text box of the font sop. If I type in the external text file while the playbar is running, the text appears in real time in the font sop. Hope that makes sense.
User Avatar
Member
72 posts
Joined: Oct. 2018
Offline
bashorton
Interesting approach! Quite a bit over my head honestly without the hip file.

Don't worry that's really not that far away from your solution.

You want my *hipnc? It's more suitable for render time, not really comparable to your solution. Would need some cleanup.

I just noticed the FontCOP has an option to read a file.

I do not know how much text you want to do this way, so you might run into an "overflow" that may ruin your layout.

You might want to figure out how much text fits in there, and then
with open(file_path, 'r') as f:
    text = f.read()[-500:-1] # If the fontSOP setup allows for max 500 chars

Or read the file line by line, and then leave the last few lines that still fit in text.
Otherwise I don't know how/what to improve on your solution.

OTOH, if it does what you intend to do. Be it!! (So it is coded! So it shall be done!!)

Hope I could help you
  • Quick Links