[Closed] Load other file extension into Maps slot
Im writing an exporter and I would like to link an .OGG (extension obviously not supported in MAX) to a texture slot so my exporter can pick up the file path and export it.
Since the extension is not supported even if I select . in the file selection dialog and select my .OGG Im unable to link it.
Is there any way that would allow me to “somehow” link my .OGG to the material maps to be able to export it?
Im writing an exporter and I would like to link an .OGG (extension obviously not supported in MAX) to a texture slot so my exporter can pick up the file path and export it.
If you’re just looking to get the file address of the .OGG file, then you can do something like this:
--# declare a variable to place the file address into
local myFileAddress
--# set file address into variable with button event
on myBtn pressed do
(
--get a file
local any_file = getOpenFileName caption:"Open file" filename:(GetDir #scripts+"\\") types:"any file(*.*)|*.*|"
if any_file != undefined then (myFileAddress = any_file)
)
--#now you can get at the data in the file by reading lines from myFileAddress
Don’t know how to get the data from the file? Here’s a script I use to ‘read data from any file’. Be careful, as running this on a large file can easily fill up the listener window and lock your computer up until it’s done.
any_file = getOpenFileName caption:"Open file" filename:(GetDir #scripts+"\\") types:"script(*.*)|*.*|"
if any_file != undefined then
(
local buffer
local ss = fopen any_file "rb"
if ss != undefined do
(
buffer = #()
while (val = ReadByte ss #unsigned) != undefined do
(append buffer val)
fflush ss
fclose ss
)
local myCharBits = #()
for i = 1 to buffer.count do
(
local charBit = bit.intAsChar buffer[i]
append myCharBits charBit
)
local myCharStream = stringStream ""
for i = 1 to myCharBits.count do (format "%" myCharBits[i] to:myCharStream)
local myCharString = myCharStream as string
print myCharString
) --end if/then
As for loading the .OGG into the map slot, I’m not sure you even need to.
Hope this helps.