1.Datapool赋值操作
(1)文字赋值
dim text = “text”
SendCommand("MAIN_SCENE*FUNCTION*DataPool*Data SET datapool_name="&text)
(2)图片赋值
①外部路径赋值(加后缀)
dim image = "D:\\2.png"
SendCommand("MAIN_SCENE*FUNCTION*DataPool*Data SET datapool_name="&image)
②内部路径赋值(不加后缀)
dim image = "FIBA/Player_Photo/393433"
SendCommand("MAIN_SCENE*FUNCTION*DataPool*Data SET datapool_name="&image)
(3)材质球赋值(需要该组有材质插件)
dim datapool_value = "MATERIAL MATERIAL*FIBA/01"
SendCommand("MAIN_SCENE*FUNCTION*DataPool*Data SET datapool_name="&datapool_value)
(4)Alpha赋值(需要该组有透明度插件,0为全透明,100为不透明)
dim datapool_value = "0"
SendCommand("MAIN_SCENE*FUNCTION*DataPool*Data SET datapool_name="&datapool_value)
(5)结构体赋值
dim datapool_value = "text1=111;text2=222"
SendCommand("MAIN_SCENE*FUNCTION*DataPool*Data SET datapool_name={"&datapool_value&"}")
(6)Selector赋值
dim datapool_value = "1"
SendCommand("MAIN_SCENE*FUNCTION*DataPool*Data SET datapool_name="&datapool_value)
(7)位移赋值
dim datapool_value = "10 20 30"
SendCommand("MAIN_SCENE*FUNCTION*DataPool*Data SET datapool_name="&datapool_value)
(8)旋转赋值
dim datapool_value = "10 20 30"
SendCommand("MAIN_SCENE*FUNCTION*DataPool*Data SET datapool_name="&datapool_value)
(9)缩放赋值
dim datapool_value = "10 20 30"
SendCommand("MAIN_SCENE*FUNCTION*DataPool*Data SET datapool_name="&datapool_value)
(10)Object赋值(需要该组有geometry插件)
dim datapool_value = "FIBA/111"
SendCommand("MAIN_SCENE*FUNCTION*DataPool*Data SET datapool_name="&datapool_value)
2.动画逻辑控制
(1)动画跳到某一秒
Scene.Stage.FindDirector("Animation_Name").Show(1.0)
(2)动画继续播放
Scene.Stage.FindDirector("Animation_Name").ContinueAnimation()
(3)动画倒放
Scene.Stage.FindDirector("Animation_Name").ContinueAnimationReverse()
(4)动画从头开始播放
Scene.Stage.FindDirector("Animation_Name").StartAnimation()
3.本地文本读取
dim filename = "D:\\1.txt"
dim result as string
dim list as Array[string]
result = ""
list.clear()
if(system.LoadTextFile(filename, result)) then
result.Split(chr(10), list)
println list[1]
println list.size
else
println "error"
end if
4.事件
Index中Callback Procedures
5.编程逻辑
定义变量
CInt(str) \\字符串型
CStr(int) \\整形
dim str as String
dim number as Integer
dim str_array as Array[String]
If语句 (=判断相等 or 或 and且 <> 不等)
if sum = 0 then
elseif sum = 1 then
else
end if
For语句
for i=0 to 10
next
无返回值函数
sub test2()
end sub
有返回值函数
function test(str as string) as String
test = str
end function
函数调用
sub OnLButtonDown()
println test("test")
end sub
System.MouseX //获取鼠标当前x位置
sub OnExecPerField()
println(system.mousex) //每秒都执行
Scene.FindContainer("Rectangle").Active = true //隐藏
System.GetClipChannel(0).CurrentFrame //获取当前的帧数
System.GetClipChannel(0).Duration //获取视频总长度
System.GetClipChannel(0).Continue() //视频停止
System.GetClipChannel(0).Pause() //视频暂停
Scene.FindContainer("INIT").Active = true //找组
//'访问主函数的全局变量需要加Scene
6.Action点控制(需在主函数中 INVOKE 后为函数名)
THIS_SCENE*SCRIPT INVOKE start 1
7.Control值控制
SendCommand("MAIN_SCENE*TREE*@control_name SET 10,20,30,0")
8.视频控制
System.GetClipChannel(0).Continue()
System.GetClipChannel(0).Pause()
dim time_slider as Container = Scene.FindContainer("time_s")
dim time_slider_flag = false
dim movie_flag = true
dim viz_x_min = -220
dim viz_x_max = 220
dim p_x_min = 444.0
dim p_x_max =1473.0
sub OnLButtonDown()
System.GetClipChannel(0).Pause()
time_slider_flag = true
movie_flag = false
dim total_frame = System.GetClipChannel(0).Duration
SendCommand("MAIN_SCENE*TREE*@time SET 00:00:00:"&CStr(CInt(CDbl(System.MouseX-p_x_min)*total_frame/(p_x_max-p_x_min))))
time_slider.Position.x = CDbl(System.MouseX-p_x_min)*(viz_x_max-viz_x_min)/(p_x_max-p_x_min)+ viz_x_min
end sub
sub OnExecPerField()
println system.mousex
if movie_flag then
dim total_frame_movie = System.GetClipChannel(0).Duration
dim this_frame = System.GetClipChannel(0).CurrentFrame
time_slider.Position.x = CDbl(this_frame *(viz_x_max-viz_x_min))/total_frame_movie+ viz_x_min
end if
if time_slider_flag and System.MouseX>=p_x_min and System.MouseX<=p_x_max then
dim total_frame = System.GetClipChannel(0).Duration
SendCommand("MAIN_SCENE*TREE*@time SET 00:00:00:"&CStr(CInt(CDbl(System.MouseX-p_x_min)*total_frame/(p_x_max-p_x_min))))
time_slider.Position.x = CDbl(System.MouseX-p_x_min)*(viz_x_max-viz_x_min)/(p_x_max-p_x_min)+ viz_x_min
end if
end sub
sub OnLButtonUp()
time_slider_flag = false
movie_flag = true
end sub
9.图形化控制
//模板导入
dim re = Scene.FindContainer("lineup_brush_click")
//撤回
re.GetFunctionPluginInstance("GraffiTex").PushButton("Undo")
//清空
re.GetFunctionPluginInstance("GraffiTex").PushButton("Clear")
Scene.FindContainer("lineup_tools").GetFirstActiveChildContainer().Delete()
Scene.FindContainer("lineup_tools").DeleteChildren()
dim arrow_source as Container = Scene.FindContainer("lineup_arrow_source")
dim lineup_tools as Container = Scene.FindContainer("lineup_tools")
dim tools_this as Container
dim flag_arrow = false
dim flag_line = false
dim flag_hide = false
dim oldx = 0.0
dim oldy = 0.0
sub OnButtonDown6DOF(button As Integer, pos As Vertex, rot As Vertex)
if pos.x > -250 and pos.x < 260 and pos.y > -123 and pos.y < 168 then
if Scene.lineup_tools_type == 2 then
tools_this = arrow_source.CopyTo(lineup_tools, TL_DOWN)
tools_this.Geometry.SetParameterDouble("Point1X",pos.x)
tools_this.Geometry.SetParameterDouble("Point1Y",pos.y)
tools_this.Geometry.SetParameterDouble("Point2X",pos.x)
tools_this.Geometry.SetParameterDouble("Point2Y",pos.y)
flag_arrow = true
end if
end if
end sub
sub OnButtonUp6DOF(button As Integer, pos As Vertex, rot As Vertex)
flag_arrow = false
println "3"
end sub
sub OnMove6DOF(button As Integer, pos As Vertex, rot As Vertex)
' println "x:"&pos.x&";y:"&pos.y
if Scene.lineup_tools_type == 2 then
if flag_arrow then
tools_this.Geometry.SetParameterDouble("Point2X",pos.x)
tools_this.Geometry.SetParameterDouble("Point2Y",pos.y)
end if
end if
'println "x:"&pos.x
println "y:"&pos.y
end sub
10.外部控制(H5/PHP)
<?php
$Command = $_POST["Command"];
$insert = "0 REND*SCRIPT INVOKE test_fnc ".$Command;
error_reporting(E_ALL);
set_time_limit(0);
$port = 6100;
$ip = "127.0.0.1";
$socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP) or die("Could not create socket\n");
$result = socket_connect($socket, $ip, $port) or die("Could not connet server\n");
socket_write($socket, $insert, strlen($insert));
socket_close($socket);
?>
11.图文控制
1禁止写
dim flog = 1
sub OnLButtonDown()
if flog = 1 then
SendCommand("MAIN_SCENE*TREE*@write SET false")
flog = 0
println flog
elseif flog = 0 then
println "true"
SendCommand("MAIN_SCENE*TREE*@write SET true")
flog = 1
println flog
end if
end sub
2.清除
sub OnLButtonDown()
dim re = Scene.FindContainer("write")
re.GetFunctionPluginInstance("GraffiTex").PushButton("Clear")
end sub
3.撤回
dim flog = 1
sub OnLButtonDown()
dim re = Scene.FindContainer("write")
re.GetFunctionPluginInstance("GraffiTex").PushButton("Undo")
end sub
12.外部传参修改Viz全局变量
VizCommunication.Map["str_lucky"]
"1 VIZ_COMMUNICATION*MAP SET_STRING_ELEMENT \"str_lucky\" ".$str."\0";
// 拿Guess_Datas_Count 传入VIZ数据
total_control("1 VIZ_COMMUNICATION*MAP SET_STRING_ELEMENT \""+"Guess_Datas_Count"+"\" "+ count_canvas.ToString());
//根据名称赋值
total_control("1 VIZ_COMMUNICATION*MAP SET_STRING_ELEMENT \"" + "Guess_Datas" + "\" " + datas);
//动画初始化
total_control("1 RENDERER*MAIN_LAYER SET_OBJECT SCENE*Default/12345678");
//动画开始
total_control("-1 SCENE*Default/12345678*STAGE START");
//结束动画
total_control("- 1 RENDERER* MAIN_LAYER*STAGE CONTINUE");