您当前的位置: 首页 > 

开发游戏的老王

暂无认证

  • 3浏览

    0关注

    803博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

Houdini图文笔记:VEX知识点小结(一)

开发游戏的老王 发布时间:2021-03-20 11:11:42 ,浏览量:3

对于码农出身的老王,找到VEX就如同在Houdini中找到了组织。

文章目录
    • 什么是VEX、VOP和Python
    • VEX的编写
    • VEX的变量、属性及通道
      • 局部变量声明和初始化(Local Variable)
      • 创建属性(Attribute)
      • 创建通道(Channel)
    • VEX的函数

什么是VEX、VOP和Python

Houdini有三种编程语言:

  • VEX 即 Vector Expression Language ,Houdini内置的脚本语言
  • VOP 即 Vector Operation Language,Houdini提供的可视化编程语言
  • Python 即 Python,通过Houdini提供的接口使用Python编程

VEX是Houdini原生的,因此它的契合度最好,底层也经过优化,所以是三种语言中速度最快的,应该作为Houdini开发的首选语言。

VEX的编写

VEX代码的编写一般在Attribute Wrangle节点(按Tab-A-W可以快速检索到该节点)中进行

在这里插入图片描述

  • Group Type : 指定处理对象所属的组名
  • Group Type : 指定处理对象所属的组类型
  • Run Over : 该脚本处理的属性所属类型
VEX的变量、属性及通道

VEX的形式很像C语言

局部变量声明和初始化(Local Variable)
int x = 10;
float y = 100.0;
vector z = set(1,0,1);
创建属性(Attribute)
int @box_id = 1;//创建Integer属性
vector @offset = (1,2,3);//创建Vector属性
string @p_name = "hello_vex";//创建String属性

或者

i@point_id = 1;//创建Integer属性
v@offset = (1,2,3);//创建Vector属性
s@p_name = "hello_vex";//创建String属性
创建通道(Channel)
int seed = chi("seed");//chi表示创建或引用integer类型通道
float vertical = chf("vertical");//chi表示创建或引用float类型通道,同理还有chv等

如果已经存在了名为"seed"的Channel则直接引用过来,如果没有则创建一个

在这里插入图片描述

VEX的函数
vector move_to(vector pos; float offset){
    pos.x += offset;
    pos.x += offset;
    pos.x += offset;
    return pos;
}

v@P = move_to(v@P,1);

为了便于阅读,函数定义前面可以加上function关键字

function vector move_to(vector pos; float offset){
    pos.x += offset;
    pos.x += offset;
    pos.x += offset;
    return pos;
}

v@P = move_to(v@P,1);

注意: 和C语言不同的是,参数之间需要用;隔开,如果是相同类型的参数可以简写为


vector move_to(vector pos; float offsetx,offsety,offsetz){
    pos.x += offsetx;
    pos.x += offsety;
    pos.x += offsetz;
    return pos;
}

v@P = move_to(v@P,1,2,3);
关注
打赏
1656935939
查看更多评论
立即登录/注册

微信扫码登录

0.0435s