ewinemiller
New member
Hi folks,
I've got a node shader where when I originally wrote the save code, I did not wrap all the parameter functions with LWSAVE_BEGIN and LWSAVE_END. This works fine for saving objects and scenes, but doesn't work for using the nodes as displacement or exporting and importing nodes because there's no name on that input.
Basically the save files look like this
{ VariantParameter
3
0
{ ParameterValue
1
0
}
}
{ VariantParameter
3
0
{ ParameterValue
1 1 1
0
}
}
instead of this
{ Noise
{ VariantParameter
3
0
{ ParameterValue
1
0
}
}
}
{ Base Color
{ VariantParameter
3
0
{ ParameterValue
0.74901962 0 0
0
}
}
}
So I'd like to fix that, but so far I haven't had any luck doing that without breaking compatibility with existing saved files. It looks like that LWLoadState object wraps a stream of some sort and if I could get it to move backwards or reset to the beginning of a block, I think i'd be good, but I don't see anything like that. Here's what I've tried, any other suggestions?
1. Use LWLOAD_ID first to see if I have a named block. Works good to identify new format, but leaves old format in a bad state because it wants LWVParmFuncs.load called first. Can't reset the stream so done.
2. Use LWLOAD_FIND to see what's the first block I have. Again, works good to identify new format, and takes me to the first block I did wrap in the old format, but then I can't go backwards to pull my parameter values.
3. Tried saving a throwaway parameter value without wrapping in the new format. On load, create a dummy parameter, evaluated it immediately, and if it's a magic number for its value, it's the new formation, else old. This actually seems to work, but the parameter functions getVal doesn't like being called from there and you end up with a stack corruption run time error.
4. Tried using LWLoadState.read to just see what was ahead of me, but again that pushes the stream ahead so everything down the line is broken.
5. Tried using LWVParmFuncs.load first, check the error code, if successful old, else new, but I seem to end up in a bad state so can't LWLOAD_FIND doesn't work for the new format.
Thanks,
Eric
I've got a node shader where when I originally wrote the save code, I did not wrap all the parameter functions with LWSAVE_BEGIN and LWSAVE_END. This works fine for saving objects and scenes, but doesn't work for using the nodes as displacement or exporting and importing nodes because there's no name on that input.
Basically the save files look like this
{ VariantParameter
3
0
{ ParameterValue
1
0
}
}
{ VariantParameter
3
0
{ ParameterValue
1 1 1
0
}
}
instead of this
{ Noise
{ VariantParameter
3
0
{ ParameterValue
1
0
}
}
}
{ Base Color
{ VariantParameter
3
0
{ ParameterValue
0.74901962 0 0
0
}
}
}
So I'd like to fix that, but so far I haven't had any luck doing that without breaking compatibility with existing saved files. It looks like that LWLoadState object wraps a stream of some sort and if I could get it to move backwards or reset to the beginning of a block, I think i'd be good, but I don't see anything like that. Here's what I've tried, any other suggestions?
1. Use LWLOAD_ID first to see if I have a named block. Works good to identify new format, but leaves old format in a bad state because it wants LWVParmFuncs.load called first. Can't reset the stream so done.
2. Use LWLOAD_FIND to see what's the first block I have. Again, works good to identify new format, and takes me to the first block I did wrap in the old format, but then I can't go backwards to pull my parameter values.
3. Tried saving a throwaway parameter value without wrapping in the new format. On load, create a dummy parameter, evaluated it immediately, and if it's a magic number for its value, it's the new formation, else old. This actually seems to work, but the parameter functions getVal doesn't like being called from there and you end up with a stack corruption run time error.
4. Tried using LWLoadState.read to just see what was ahead of me, but again that pushes the stream ahead so everything down the line is broken.
5. Tried using LWVParmFuncs.load first, check the error code, if successful old, else new, but I seem to end up in a bad state so can't LWLOAD_FIND doesn't work for the new format.
Thanks,
Eric