MAXScript101_2.4 Values and Classes
大s汪小菲于3.23,2011,海南三亚海棠湾大酒店婚礼
1. Value Class:
- Number: eg. 23, 42.6
- String: eg. "text", "foo"
- Sphere: eg. $sphere01, $ball
- Point3D
- OmniLight
- ...and hundreds more..
- plugins can ass classes
For example:
input: classof 23
ans: Integer
input: classof 42.6
ans: Float
input: classof $Sphere01
ans: Sphere
-- 将场景中所有球的半径输出来;类具有将物体分门别类的作用
for o in objects do
if classOf o == sphere do print o.radius
注:
1)Value Class,它是所有MAXScript类的根类(root class),他提供的方法(methods)和操作符(operators),任何类都可以
使用。
2. Class-based Operations & Properties
1)数字(number)和字符(string)串可以相加
2 + 2
"cam1" + ".avi"
2)材质和相机不可加
$box01.mat + $box02.mat -- wrong
$camera1 + $camera2 -- wrong
3) 相机与灯光可用于move函数
move $cam1 [10, 0, 0]
move $omni2 [0,0,-1]
4)但是数字和字符串不适用于move函数
move 23 [1, 1, 1] -- wrong
move "foo" [0, 2, 2] -- wrong
3. Class Hierachy
Integer 和 Float 合称为 Number, 即Number是前两者的父类,子类可以继承父类的操作。
Integer(whole numbers): +, -, sin, cos,...
Float(real numbers): +, -, sin, cos,...
注:有关Number类的操作,请查阅MAXScript Reference, 输入关键字number, float。
4. MAX Objects Class Hierachy
MAXWrapper
- Material - StandardMaterial, Blend, MultiMaterial, RaytraceMaterial
- Controller
- Modifier
- Atmospheric
- ...
- Node - GeometryClass, Camera, Light, Helper, Spacewarp,...
注意:
1) 这里MAXWrapper是父类,下面几项是它的子类;其中每一个子类又有子类,如Material类还可以有子类
StandardMaterial, Blend, MultiMaterial, RaytraceMaterial
2) Node类,它的子类有:GeometryClass, Camera, Light, Helper, Spacewarp,... ; 其中GeometryClass拥有子类:Box,
Sphere, Cylinder...; Camera拥有子类:FreeCamera, TargetCamera
注:有关node的一般属性,请参阅MAXScript Reference, 输入关键字general node properties
3) 用showClass命令查询所属类
--仅仅查询sphere所属类
showClass "sphere"
Sphere : GeometryClass {11,0}
OK
--查询sphere所属类,
showClass "sphere*" -- name pattern, 查询以sphere开头的名字的类别
Sphere : GeometryClass {11,0}
SphereGizmo : helper {3bc31904,67d74ec7}
OK
--查询sphere及其属性的所属类
showClass "sphere*.*"
Sphere : GeometryClass {11,0}
.smooth : boolean
.radius : float
.segs : integer
.mapcoords : boolean
.slice : boolean
.hemisphere : float
.sliceFrom : angle
.sliceTo : angle
.chop : integer
.recenter : boolean
SphereGizmo : helper {3bc31904,67d74ec7}
.radius : float
.seed : integer
.hemisphere : boolean
OK
-- 查询材质的属性
showClass "checker"
showClass "checker*"
showClass "checker*.*"
showClass "*checker*.*"
4)在MAXScript Reference中,在See also下面,显示的是当前物体父类的相关信息。
5. Interface
--调用menu函数
MenuMan.loadMenuFile "myMenus.mnu"
--调用材质纹理函数
$sphere.material.diffuseMap.reload()
showInterfaces $sphere.material.diffuseMap
showInterface <interface> [ to:<stream> ] : 显示<interface>参数的interface信息。该信息包括三部分:Properties, Methods, and Actions;
showInterfaces {<maxwrapper> | <maxclass> | node} [ to:<stream> ]:Do not show the Interfaces of the transform controllers, modifiers, or materials applied to the object.
注: 更多有关showInterface() 及 showInterfaces() 函数的信息,请查阅MAXScript Reference。
6. Generic Functions - 父类的方法及操作符子类都可以用
+ Number, String, Vector
move Box, Sphere, Light, Camera --查阅MAXScript Reference, Node Common Properties, Operators and Methods
教程地址:http://vimeo.com/19300699