ColorI read from and write to dts problem
by Konrad Wojton; · in Torque Game Engine · 03/03/2009 (7:25 am) · 0 replies
How can I read from and write to dts ToolVector<ColorI>?
here is fragment of my code:
In TSMesh::assemble():
if (TSShape::smReadVersion >= 26) {
numVertsColors = alloc.get32();
if(numVertsColors > 0) {
S8 * vc_ptr8 = alloc.copyToShape8(4*numVertsColors, true);
vertsColors.set((ColorI*)vc_ptr8,numVertsColors);
}
else
numVertsColors = 0;
and in TSMesh::disassemble():
alloc.set32(vertsColors.size());
alloc.copyToBuffer8((S8*)vertsColors.address(), 4*vertsColors.size());
If I change ColorI to ColorF, code in assemble() to
if (TSShape::smReadVersion >= 26) {
numVertsColors = alloc.get32();
if(numVertsColors > 0) {
S32 * vc_ptr32 = alloc.copyToShape32(4*numVertsColors, true);
vertsColors.set((ColorF*)vc_ptr32,numVertsColors);
}
else
numVertsColors = 0;
and in dissasemble() to
// VertexColor
alloc.set32(vertsColors.size());
alloc.copyToBuffer32((S32*)vertsColors.address(), 4*vertsColors.size());
it works great, but when I use ColorI it crashes during loading dts on next get32() function in TSMesh::assemble()
here is fragment of my code:
In TSMesh::assemble():
if (TSShape::smReadVersion >= 26) {
numVertsColors = alloc.get32();
if(numVertsColors > 0) {
S8 * vc_ptr8 = alloc.copyToShape8(4*numVertsColors, true);
vertsColors.set((ColorI*)vc_ptr8,numVertsColors);
}
else
numVertsColors = 0;
and in TSMesh::disassemble():
alloc.set32(vertsColors.size());
alloc.copyToBuffer8((S8*)vertsColors.address(), 4*vertsColors.size());
If I change ColorI to ColorF, code in assemble() to
if (TSShape::smReadVersion >= 26) {
numVertsColors = alloc.get32();
if(numVertsColors > 0) {
S32 * vc_ptr32 = alloc.copyToShape32(4*numVertsColors, true);
vertsColors.set((ColorF*)vc_ptr32,numVertsColors);
}
else
numVertsColors = 0;
and in dissasemble() to
// VertexColor
alloc.set32(vertsColors.size());
alloc.copyToBuffer32((S32*)vertsColors.address(), 4*vertsColors.size());
it works great, but when I use ColorI it crashes during loading dts on next get32() function in TSMesh::assemble()
About the author