Linear spread of object

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

THREAD CLOSED
 
Thread Tools Search this Thread Display Modes
  05 May 2003
Question Linear spread of object

Hye,
I'm working on a script to spread object linearly... As if a ramp existed. It's a bit as the probality in maths, the chance for the object to be spread in the white is very low, in the black, very high.

How to code it? And how to make a thresold, to make the white concept : x=20 (in axis).

Note : I don't want use ramptexture as possible.
Attached Images
File Type: gif rependre.gif (14.6 KB, 86 views)
 
  05 May 2003
do you want to use it for particles? .. then you can give every particle a random lifetime when it get emitted .. the random number is your max threasold.
__________________
| xt_textureStudio | xt_prefabLibrary |xt_normalis | Get it @ Fuchtelworld V.3 |
 
  05 May 2003
It's object like mesh. Notice : no animation.

Look at the script i've now. Follow the comments, I'm working on the part 3 "manipulate" (here translate ramdomly lineary)


int $nbLetters = 10; //Integral value sat by the user.


for ($n = 0; $n < $nbLetters; $n++) {
	
	// Choose randomly the letter.
	string $alpha[] = {"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"};
	int $randomLetter = `rand 0 25`;
	string $letter = $alpha[$randomLetter];


	// Choose randomly the font.
	string $fontList[] = `fontDialog -FontList`;
	int $nbFonts = `size $fontList`;
	int $randomFont = `rand 0 $nbFonts`;
	string $font = $fontList[$randomFont];


	// Build and manipulate the letter object.
	string $letterObject[] = `textCurves -t $letter -font $font`;
	
	float $randMoveX = `rand 0 20`;
	float $randMoveY = `rand -5 5`;
	move $randMoveX $randMoveY 0 $letterObject;

	float $randRotate = `rand 0 360`;
	rotate 0 0 $randRotate $letterObject;

	float $randScale = `rand 0.5 1.5`;
	move 0 $randScale $randScale $letterObject;

}
 
  05 May 2003
try this. i dont know if it work .. its early in the moring an the night was long ...


$max_x = 4234; //your maximum x value

float $random = rand(100); // get a random value ..

float $sqr = sqrt $random; //make a sqare root of the randowm number
$sqr /= 100; // divide it by 100 to get a value between 0 and 1
$final_x_pos = $sqr * $max_x; //mutiply it with your max_x value the get the final possition


put thw whole shit into an loop to create for every object a rand x pos ..
__________________
| xt_textureStudio | xt_prefabLibrary |xt_normalis | Get it @ Fuchtelworld V.3 |
 
  05 May 2003
It doesn't work :(
So I'm obliged to show what I want obtain for this grraphic project. It's to get 2d images, and if I use mel, it's because I've not illustrator, and people say scripting in illustrator isn't powerful

So help me to h ad the line I need in the third part of my script

1001 thanks
Attached Images
File Type: gif letter.gif (3.2 KB, 50 views)
 
  05 May 2003
k .. i used thic code


int $nbLetters = 5000; //Integral value sat by the user.

	for ($n = 0; $n < $nbLetters; $n++) {
	string $alpha[] = {"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"}; 
	int $randomLetter = `rand 0 25`;
	string $letter = $alpha[$randomLetter];

	string $fontList[] = `fontDialog -FontList`;
	int $nbFonts = `size $fontList`;
	int $randomFont = `rand 0 $nbFonts`;
	string $font = $fontList[0];


	select -r (`textCurves -t $letter -font $font`);
	string $chart[] = (`ls -sl`);
	
	$max_x = 5000;

	float $random = rand(100);

	float $sqr = `sqrt $random`;
	$sqr /= 100;
	$final_x_pos = ($sqr * $max_x);
	float $randMoveY = `rand -100 100`; 
	move -r $final_x_pos $randMoveY 0;
};


to get this:
|
V
Attached Images
File Type: gif spread.gif (5.7 KB, 41 views)
__________________
| xt_textureStudio | xt_prefabLibrary |xt_normalis | Get it @ Fuchtelworld V.3 |
 
  05 May 2003
It's exactly what I need! Right done! You've coded it as a master!
 
  05 May 2003
No Prob!
__________________
| xt_textureStudio | xt_prefabLibrary |xt_normalis | Get it @ Fuchtelworld V.3 |
 
  05 May 2003
Arrow Finished

Thanks again to X-tender.
This is evidently an application I needed for a graphic project. Imagine the time to build this type of image.

Use it as code example !


int $nbLetters = 50; //Integral value sat by the user.

for ($n = 0; $n < $nbLetters; $n++) {
	
	// Choose randomly the letter.
	string $alpha[] = {"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", 

"q", "r", "s", "t", "u", "v", "w", "x", "y", "z"};
	int $randomLetter = `rand 0 25`;
	string $letter = $alpha[$randomLetter];


	// Choose randomly the font.
	string $fontList[] = `fontDialog -FontList`;
	int $nbFonts = `size $fontList`;
	int $randomFont = `rand 0 $nbFonts`;
	string $font = $fontList[$randomFont];


	// Build and manipulate the letter object.
	string $letterObject[] = `textCurves -t $letter -font $font`;
	select -r $letterObject;

	int $maxXMoveValue = 1000;
	float $sqrt = `sqrt(rand(100))`;
	$sqrt /= 100;
	float $randMoveX = ($sqrt * $maxXMoveValue);
	float $randMoveY = `rand -10 10`;
	move $randMoveX $randMoveY 0;

	float $randScale = `rand 1 3`;
	scale $randScale $randScale 1;

	float $randRotate = `rand 0 360`;
	rotate 0 0 $randRotate;
	
	planarSrf $letterObject;
	delete $letterObject;

    print ("Letter randomly chosen : " + $letter + " | Font randomly chosen : " + $font + "\n");
}
 
  05 May 2003
just one thing:

you will never select the letter "z" in your scripts - at least very very very seldom, since your random range has to hit 25 exactely to see the letter..
i think, that a rand will even never hit its upper limit (unfortunately that is not clear after reading the manuals).
(after testing a bit i am quite sure about it)..

so you should set your range of rand from 0 to 26 to get return int values from 0 to 25

cheers

alexx

btw.. nice one x-tender
 
  05 May 2003
ok, it's true Thanks.
 
  01 January 2006
Thread automatically closed

This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
__________________
CGTalk Policy/Legalities
Note that as CGTalk Members, you agree to the terms and conditions of using this website.
 
Thread Closed share thread



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
CGSociety
Society of Digital Artists
www.cgsociety.org

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump
Miscellaneous

All times are GMT. The time now is 07:44 PM.


Powered by vBulletin
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.