您还没有登陆到CGPAD.COM   现在登录   注册新用户
搜索 CGPAD.COM
 
 
 
 浏览论坛    搜索论坛    规章制度    帮助  
社区成员: 23570   主题总数: 1374   回复总数: 3307   帖子总数: 4681   论坛跳转:  
 
 
论坛 分形艺术软件 Apophysis (超强的IFS算法渲染技术) 本版斑竹:shor luoyx2008
 
   帖子列表  原创作品  共享资源  
 
脚本     教程     代码    
发表新主题
帖子搜索:  
 
Writing Scripts Part #1
查看:958  |  回复:1  |  创建:2008-06-20 15:00:05
 
SPAN (张友邦)
注册: 2008-04-24
积分: 12335 分
等级:
尘世如潮人如水 只叹江湖几人回

Load the script editor and press the New button at the top of the toolbar. Running a blank script
will force the main flame to recalculate, but nothing will change. Before you go any further load
the transform editor and position it so that you can watch it as you run scripts. Type "Rotate(45);"
(without the quotes, but take note of the semi-colon at the end) into the script editor and press
the Run button. You'll see the triangle that's selected in the transform editor rotate by 45 degrees.
If you keep hitting the Run button the triangle will continue to rotate until it gets back its starting
point.

By default scripts are set up to operate on the selected transform, and there are a number of
functions that you can use to change it.

  • Rotate(n) rotates the transform by n degrees. Any value for n is acceptable. Positive values
    rotate the transform clockwise and negative values rotate it counter-clockwise.
  • Scale(n) scales the transform by n. A value of 0.5, for instance, would create a triangle half
    the size of the original. Keep the value of n within reasonable bounds. If the triangle of the
    selected transform is already close to the size of the reference triangle then you wouldn't it to
    get much bigger, and really small transforms don't usually improve the look of a flame.
  • Translate(x, y) moves the transform...but not necessarily by x and y.

Here the documentation is going to get fuzzy because the functions mentioned so far use matrix
multiplication, and I'm not up to explaining that at the moment (if I ever will be!). One thing that
it means is that the order of operations is important. Translate(1, 1) will move a triangle of the
same size and position as the reference triangle one unit to the right and one unit upward, but if
you've already scaled the transform by 0.5 then it would only move the transform half a unit to the
right, and half a unit upward. Transforms with triangles that are off to the side, rotated and scaled
arbitrarily, will move in an unpredictable manner. There is a way to move transforms predictably,
but I'll get to that later.

These functions can operate on any transform in the flame, not just the one selected in transform
editor, but you have to tell the script which one you want to be the "active transform". You do this
with the SetActiveTransform method. The format is...

SetActiveTransform(i);

...where i is the index of the transform that you intend to alter. Indexing starts from zero, so to
work on the transform that is labeled 1 in the transform editor you would type
"SetActiveTransform(0);". Once you've done that all further operations will affect only that
transform, until you call SetActiveTransform again with a different index.

Usually you wouldn't use SetActiveTransform with a fixed number (a "constant"), but with a
variable that changes as the script progresses. You see this in most of the example scripts I
supplied. Here's how you would perform the same operation on all of the transforms in a flame
(in this case scaling):

for i := 0 to Transforms - 1 do
begin
  SetActiveTransform(i);
  Scale(1.1);
end;

You can copy that and paste it into the script editor to see what is does, if you like (there's a
pop-up menu in the script editor with a paste function--Ctrl+V won't work, but Shift+Insert
will). You could also try changing Scale to one of the other functions I've mentioned, or put a
few of them in there (make sure they come after the SetActiveTransform statement, and before the
"end", and don't forget to put the semi-colon at the end of the line).

From http://www.apophysis.org/tutorials/scripts1.html





删除
 
编辑
 
标签:
 
附件:请登陆后查看附件内容!
 
声明:CGPAD文章版权属于作者,受法律保护。没有作者书面许可不得转载。
 
 <<上一页 1 下一页>>   

 注册: 2009-11-10
 积分: 452 分
 等级:
 向你致敬


  2009-11-11 00:30:15 #1
黑夜里的乌鸦!




 
 <<上一页 1 下一页>>   
 
 
版权所有 © 2005-2008 CGPAD.COM,湘ICP备07500998号,兼容浏览器:IE6IE7FireFoxOperaSafariChrome
Total Requests: 5275976, Total Visits: 3085179, Processing Time: 501ms,