📄 export_fb3d_mob_v1.1.ms
字号:
-- =========================================================================================
-- Mobile Model (mob) BINARY File Export v1.1
-- Written by Vander Nunes
-- =========================================================================================
--
-- this version will export all scene objects to the same file,
-- in the following format:
--
-- BYTE Format ; 0==not from 3ds, 1==from 3ds
--
-- DWORD VertexCount ; Number of vertices (32.0)
-- int X Y Z ; Coordinates (16.16)
-- BYTE R G B A ; Color (8.0)
-- DWORD U V ; UV coordinates (16.16)
-- ... ; repeat VertexCount times.
--
-- DWORD FaceCount ; Number of faces (32.0)
-- DWORD V1 V2 V3 ; vertex indexes (base 0, 32.0)
-- ... ; repeat FaceCount times.
--
-- DWORD LightCount ; Number of lights in the object
-- DWORD X Y Z ; Coordinates (16.16)
-- ...
-- (repeat the structure exportation for each object in the scene)
--
--
-- as seen, texture coordinates are exported as well, but no texture file is mentioned,
-- so the engine will select and load the desired texture file at run-time.
--
(
fname = getSaveFileName caption:"Mobile MOB Export" types:"Mobile MOB Model (*.mob)|*.mob|All Files (*.*)|*.*|"
if (fname != undefined) then
(
output_file = fopen fname "wb"
for o in geometry do
(
format "Mobile MOB export Copyright (C)2004/2005, Vander Nunes\n"
format "Exporting: % ... " o.name
defaultVCFaces o
vcount = o.numverts
fcount = o.numfaces
format "Topology: % vertices and % faces ... " vcount fcount
-- build the uv list for the vertices
-- (note: only the FIRST UV for each vertex will be considered!)
tu = #()
tv = #()
if (true) then
(
-- generate list of object's texture coordinates
for t = 1 to fcount do
(
face = getFace o t
vi = #()
vi[1] = face.x
vi[2] = face.y
vi[3] = face.z
tex = getTVFace o t
ti = #()
ti[1] = tex.x
ti[2] = tex.y
ti[3] = tex.z
for k = 1 to 3 do
(
uv = getTVert o ti[k]
tu[vi[k]] = uv.x
tv[vi[k]] = uv.y
)
)
)
else
(
-- dummy texture coordinates
for t = 1 to vcount do
(
tu[t] = 0
tv[t] = 0
)
)
-- file format
WriteByte output_file 1 -- converted from 3DS format
-- vertices
WriteLong output_file vcount
for v = 1 to vcount do
(
vert = getVert o v
color = getVertColor o v
WriteLong output_file ( vert.x * 65536) -- 16.16 fp
WriteLong output_file ( vert.z * 65536) -- 16.16 fp
WriteLong output_file (-vert.y * 65536) -- 16.16 fp
WriteByte output_file color.r
WriteByte output_file color.g
WriteByte output_file color.b
WriteByte output_file (255 - color.a)
WriteLong output_file ( tu[v] * 65536) -- 16.16 fp
WriteLong output_file ( tv[v] * 65536) -- 16.16 fp
)
-- faces
WriteLong output_file fcount
for f = 1 to fcount do
(
face = getFace o f
WriteLong output_file (face.x-1)
WriteLong output_file (face.y-1)
WriteLong output_file (face.z-1)
)
-- lights
clearSelection()
select lights
WriteLong output_file selection.count
for n = 1 to selection.count do
(
l = selection[n]
WriteLong output_file ( l.pos.x * 65536) -- 16.16 fp
WriteLong output_file ( l.pos.z * 65536) -- 16.16 fp
WriteLong output_file (-l.pos.y * 65536) -- 16.16 fp
)
clearSelection()
format "OK\n"
)
fclose output_file
format "FINISHED.\n\n"
)
)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -