Random 3d Text field with depth fade

All things .jsx

Moderator: Paul Tuersley

Post Reply
byronnash
Posts: 321
Joined: July 7th, 2004, 2:30 pm
Location: Charlotte, NC
Contact:

This script reads a user specified text file and
creates a text layer for each line of text in a
new comp called "Text Comp", or it uses the active comp.
- adds expression to control a random placement in 3d space
- adds expression to control a depth fade as the layer recedes from the camera
- creates a new camera and a null with sliders to control the effect

It's pretty basic but I hope someone can find it useful.

http://armoredsquirrel.com/scripts/Rand ... _depth.jsx

Image
JoshBertrand
Posts: 2
Joined: May 16th, 2007, 11:37 am

This script is AWESOME and is almost just what I needed.

I have about 500 text layers that I need to fly through in a more or less straight Z fashion (with some X and Y distribution to the layers for variety). Thus I really need a separate slider to control the X Spread, Y Spread and Z Spread. Is that possible? I'm attempting to modify the script myself to do that but I know I am making a mess of things and haven't gotten to work yet so I figured I'd ask.

Thanks SO MUCH for making such a useful utility!
JoshBertrand
Posts: 2
Joined: May 16th, 2007, 11:37 am

I got it to work. I should have been more persistent prior to posting. Here's the file if anyone else needs to do that.

http://thoth.edo.usf.edu/mitvideo/Rando ... th_xyz.jsx

I can't say how long that will be up as our IT guys make us clear that folder out now and then.

Thanks again!
Josh.[/url]
User avatar
lloydalvarez
Enhancement master
Posts: 460
Joined: June 17th, 2004, 9:27 am
Location: New York City, NY
Contact:

JoshBertrand wrote:I got it to work. I should have been more persistent prior to posting. Here's the file if anyone else needs to do that.

http://thoth.edo.usf.edu/mitvideo/Rando ... th_xyz.jsx

I can't say how long that will be up as our IT guys make us clear that folder out now and then.

Thanks again!
Josh.[/url]
Hey Josh,

You use the Code tag and paste the whole script here so it doesnt have to be hosted on your servers.

-Lloyd
pants
Posts: 22
Joined: October 8th, 2004, 8:35 am

yes please post the code, i'd love to check this out.

thanks
User avatar
Atomic
Posts: 157
Joined: April 30th, 2007, 5:55 am
Location: United States, Ohio

I just tried it and it does create a composition with text, but I see nothing. :(

How do you make the text actually appear?
User avatar
Atomic
Posts: 157
Joined: April 30th, 2007, 5:55 am
Location: United States, Ohio

I have been playing around with the script as it stands and I was able to get text to appear.

The problem lies in the default values. They produce a black screen.

To see my text I had to set the Start Fade to -500, the End Fade to 500, the Spread to 250 and then move the camera around until something appears.

Also, set the z-position of the point of interest of the camera to something large like 1000-5000.

Hope this helps anyone new who is going to try this script.
byronnash
Posts: 321
Joined: July 7th, 2004, 2:30 pm
Location: Charlotte, NC
Contact:

Glad to hear that the script was helpful. I wrote that one a l o n g time ago and I'm sure it's very messy. I haven't opened it in a while.
tobystecker
Posts: 2
Joined: October 16th, 2007, 6:43 am
Location: berlin, germany
Contact:

byronnash wrote:Glad to hear that the script was helpful. I wrote that one a l o n g time ago and I'm sure it's very messy. I haven't opened it in a while.
i just found your first script about this 3dtext-thing - and read the posts to it, but i could'nt find the modified script for the xyz-spread of the textlayers - i would really appreciate if someone could post it here or post a link where to find it!
it would be so much help for me, because i'm doing exactly something like this - a camera move through a field of keywords...

thanks a lot!

toby
User avatar
lloydalvarez
Enhancement master
Posts: 460
Joined: June 17th, 2004, 9:27 am
Location: New York City, NY
Contact:

Don't know why he never posted his code, but it's an easy enough tweak.. I have not had a chance to test this so tell me if you run into any problems..

-Lloyd

Code: Select all

//
// Random3dText_w_depth_xyz.jsx
//
//Byron Nash 01/05
//The text reading/creating was borrowed from createTextLayersFromFile.jsx
// by Dan Ebberts
//
// This script reads a user specified text file and
// creates a text layer for each line of text in a 
// new comp called "Text Comp", or it uses the active comp.
// - adds expression to control a random placement in 3d space
// - adds expression to control a depth fade as the layer recedes from the camera
// - creates a new camera and a null with sliders to control the effect
//
// added x,y,z sliders 10/2007 lloyd alvarez
//



{

  // create undo group

  app.beginUndoGroup("Create Text Layers From File");

  // Prompt user to select text file

  var myFile = fileGetDialog("Select a text file to open.");
  if (myFile != null){

    // open file
    var fileOK = myFile.open("r","TEXT","????");
    if (fileOK){

      // create project if necessary

      var proj = app.project;
      if(!proj) proj = app.newProject();
      
		//set currently selected comp to variable
        var myComp = app.project.activeItem; 

		//check to see if selected item is a comp, if not, make a new comp      
        if(proj.activeItem instanceof CompItem) {
        	var myComp = proj.activeItem;
        	}else{
      // create new comp named 'my text comp'
      var compW = 720; // comp width
      var compH = 486; // comp height
      var compL = 15;  // comp length (seconds)
      var compRate = 29.97; // comp frame rate
      var compBG = [0/255,0/255,0/255] // comp background color
  
      var myItemCollection = app.project.items;
      var myComp = myItemCollection.addComp('Text Comp',compW,compH,1,compL,compRate);
      myComp.bgColor = compBG;
		}
		
		//setup controller null and add expression sliders
    	var controlLayer = myComp.layers.addNull();
    	controlLayer.startTime = 0;
    	controlLayer.enabled = false;
    	controlLayer.source.name = "Controller";
    	var theControl = controlLayer.Effects.addProperty("ADBE Slider Control");
    	theControl.name = "X_Spread";
    	theControl.property(1).setValue(0);
		var theControl = controlLayer.Effects.addProperty("ADBE Slider Control");
    	theControl.name = "Y_Spread";
    	theControl.property(1).setValue(0);
		var theControl = controlLayer.Effects.addProperty("ADBE Slider Control");
    	theControl.name = "Z_Spread";
    	theControl.property(1).setValue(0);
    	var opacityMin = controlLayer.Effects.addProperty("ADBE Slider Control");
    	opacityMin.name = "Start Fade";
    	opacityMin.property(1).setValue(0);
        var opacityMax = controlLayer.Effects.addProperty("ADBE Slider Control");
    	opacityMax.name = "End Fade";
    	opacityMax.property(1).setValue(1000);
    	  
      	var cam = myComp.layers.addCamera("Camera 1",[360,243]);//make a new camera
      // read text lines and create text layer for each
      // until end-of-file is reached

      var text;
      while (!myFile.eof){
        text = myFile.readln();
        if (text != "") {
        var curLayer = myComp.layers.addText(text);
        curLayer.threeDLayer = true;
        //define expressions on position and opacity
    	var posExp = 'seedRandom(index,true);\r'+ 
            		'x_slider = thisComp.layer("Controller").effect("X_Spread")("Slider");\r'+
					'y_slider = thisComp.layer("Controller").effect("Y_Spread")("Slider");\r'+
					'z_slider = thisComp.layer("Controller").effect("Z_Spread")("Slider");\r'+
                	'midWidth = thisComp.width/2; midHeight = thisComp.height/2;\r'+
                    'x = random(x_slider,x_slider*-1);\r'+
                    'y = random(y_slider,y_slider*-1);\r'+s
                    'z = random(z_slider,z_slider*-1);\r'+
                    '[x+midWidth,y+midHeight,z];\r';
        var opacExp = 'depth = length(position,thisComp.layer("Camera 1").position);\r'+
                      'min = thisComp.layer("Controller").effect("Start Fade")("Slider");\r'+
                      'max = thisComp.layer("Controller").effect("End Fade")("Slider");\r'+
                      'linear(depth,min,max,100,0)';
     	//add expressions on position and opacity
     	curLayer.property("position").expression = posExp;
    	curLayer.property("opacity").expression = opacExp;
		}      
      }
 
 controlLayer.moveToBeginning();//moves the null to the top of the stack
 cam.moveToBeginning();//moves the cam to the top of the stack
      // close the file before exiting

      myFile.close();

    }else{
      alert("File open failed!");
    }
 
  }else{
    alert("No text file selected.");
  }

  app.endUndoGroup();
}
tobystecker
Posts: 2
Joined: October 16th, 2007, 6:43 am
Location: berlin, germany
Contact:

my spamfilter was blocking the mail from ae enhancers - so i just got it now - in the meantime i figured out a script by myself and it works - but i will try yours too - i let you know about how irt works, but thanks anyway!!!!
and here is my script - if you are using a english version of ae you should replace "Schieberegler" with "slider", because i'm using a german version of ae...

//
// Random3dText_w_depth.jsx - changed and extended by toby mory 10/07
//
//Byron Nash 01/05
//The text reading/creating was borrowed from createTextLayersFromFile.jsx
// by Dan Ebberts
//
// This script reads a user specified text file and
// creates a text layer for each line of text in a
// new comp called "Text Comp", or it uses the active comp.
// - adds expression to control a random placement in 3d space
// - adds expression to control a depth fade as the layer recedes from the camera
// - creates a new camera and a null with Schiebereglers to control the effect
{

// create undo group

app.beginUndoGroup("Create Text Layers From File");

// Prompt user to select text file

var myFile = fileGetDialog("Select a text file to open.", "TEXT txt");
if (myFile != null){

// open file
var fileOK = myFile.open("r","TEXT","????");
if (fileOK){

// create project if necessary

var proj = app.project;
if(!proj) proj = app.newProject();

//set currently selected comp to variable
var myComp = app.project.activeItem;

//check to see if selected item is a comp, if not, make a new comp
if(proj.activeItem instanceof CompItem) {
var myComp = proj.activeItem;
}else{
// create new comp named 'my text comp'
var compW = 768; // comp width
var compH = 576; // comp height
var compL = 60; // comp length (seconds)
var compRate = 25; // comp frame rate
var compBG = [255/255,255/255,255/255] // comp background color

var myItemCollection = app.project.items;
var myComp = myItemCollection.addComp('Text Comp',compW,compH,1,compL,compRate);
myComp.bgColor = compBG;
}

//setup controller null and add expression Schiebereglers
var controlLayer = myComp.layers.addNull();
controlLayer.startTime = 0;
controlLayer.enabled = false;
controlLayer.source.name = "Controller";
var theControl = controlLayer.Effects.addProperty("ADBE Slider Control");
theControl.name = "SpreadX";
theControl.property(1).setValue(0);
var theControl = controlLayer.Effects.addProperty("ADBE Slider Control");
theControl.name = "SpreadY";
theControl.property(1).setValue(0);
var theControl = controlLayer.Effects.addProperty("ADBE Slider Control");
theControl.name = "SpreadZ";
theControl.property(1).setValue(0);
var opacityMin = controlLayer.Effects.addProperty("ADBE Slider Control");
opacityMin.name = "Start Fade";
opacityMin.property(1).setValue(0);
var opacityMax = controlLayer.Effects.addProperty("ADBE Slider Control");
opacityMax.name = "End Fade";
opacityMax.property(1).setValue(1000);

var cam = myComp.layers.addCamera("Camera 1",[360,243]);//make a new camera
// read text lines and create text layer for each
// until end-of-file is reached

var text;
while (!myFile.eof){
text = myFile.readln();
if (text != "") {
var curLayer = myComp.layers.addText(text);
curLayer.threeDLayer = true;
//define expressions on position and opacity
var posExp = 'seedRandom(index,true);\r'+
'SchiebereglerX = thisComp.layer("Controller").effect("SpreadX")("Schieberegler");\r'+
'midWidth = thisComp.width/2;\r'+
'x = random(SchiebereglerX,SchiebereglerX*-1);\r'+
'SchiebereglerY = thisComp.layer("Controller").effect("SpreadY")("Schieberegler");\r'+
'midHeight = thisComp.height/2;\r'+
'y = random(SchiebereglerY,SchiebereglerY*-1);\r'+
'SchiebereglerZ = thisComp.layer("Controller").effect("SpreadZ")("Schieberegler");\r'+
'z = random(SchiebereglerZ,SchiebereglerZ*-1);\r'+
'[x+midWidth,y+midHeight,z];\r';
var opacExp = 'depth = length(position,thisComp.layer("Camera 1").position);\r'+
'min = thisComp.layer("Controller").effect("Start Fade")("Schieberegler");\r'+
'max = thisComp.layer("Controller").effect("End Fade")("Schieberegler");\r'+
'linear(depth,min,max,0,100)';
//add expressions on position and opacity
curLayer.property("position").expression = posExp;
curLayer.property("opacity").expression = opacExp;
}
}
controlLayer.moveToBeginning();//moves the null to the top of the stack
cam.moveToBeginning();//moves the cam to the top of the stack
// close the file before exiting

myFile.close();

}else{
alert("File open failed!");
}
}else{
alert("No text file selected.");
}

app.endUndoGroup();
}
habla
Posts: 3
Joined: July 3rd, 2008, 4:57 am

i just tried to use all different scripts that are posted here but so far none of them works...is there an update or is this a dead topic?
User avatar
lloydalvarez
Enhancement master
Posts: 460
Joined: June 17th, 2004, 9:27 am
Location: New York City, NY
Contact:

The scripts work, what exactly are you experiencing? You can also try this script:

http://aescripts.com/3d-text-creator/

-Lloyd
habla
Posts: 3
Joined: July 3rd, 2008, 4:57 am

getting errors on Line 2 and 5..but this one now from your site is working as always :-) biig thanks!
Post Reply