【发布时间】:2015-11-07 09:42:52
【问题描述】:
希望有更好的 maxscript 知识的人可以帮助解决这个问题。 我有一个 csv 文件驱动 3dsmax 中一些虚拟助手的位置。我遇到的问题是让每个虚拟对象都有一个从 csv 文件驱动的本地旋转。这是我的 csv 文件中的一个示例(实际文件有数百个点):
0, 975.4222, 2181.8731, 0, 267, 360, 75,
第 1 到第 4 列命名该点并将其定位到 x y 和 z 坐标。列 5 6 和 7 表示围绕 x y z 的每个点的旋转值。这就是我挣扎的地方。如果我使用随机值运行我的代码,那么脚本将失败。但是,如果第 5 列的所有值都相同,并且第 6 列和第 7 列的值也相同,则脚本将运行,但每个虚拟对象将具有相同的旋转(显然)。我知道我一定做错了什么。任何帮助将非常感激。我目前的代码如下:
-- open the file as text, read mode
f = openFile "c:\\Testtocsv003c.csv" mode:"rt"
prefabPoint = dummy name:"dummy"
-- if it opened successfully (exists, etc)...
if f != undefined do
(
while not eof f do
(
-- Read a line from the file
l = readline f
-- turn that line into an array of strings using commas as delimiters
lf = filterString l ","
if (lf[1]!=undefined ) do
(
newPoint = instance prefabPoint
newPoint.name = lf[1]
x = lf[2] as float -- bracketed number reads column position from text file
y = lf[3] as float -- bracketed number reads column position from text file
z = lf[4] as float -- bracketed number reads column position from text file
xRot = lf[5] as float
yRot = lf[6] as float
zRot = lf[7] as float
newPoint.pos = [x,y,z]
--creates point objects at xyz coordinates from text file. To offset by distance for example change to : [100*x,100*y,100*z]
rotate newPoint (eulerangles xRot yRot zRot) --rotates point
)
)
close f
delete prefabPoint
)
谢谢大家。哦,如果格式错误,对不起。这是我的第一篇文章。
保罗
【问题讨论】:
标签: csv rotation 3dsmax maxscript