Can someone make a .dts importer for milkshape 3d?
by doaler4 · in General Discussion · 12/09/2011 (4:03 pm) · 12 replies
i found a code
ConsoleFunction(dumpDTStoObj, void, 3, 3, "(string objfile, string dts)")
{
Resource<TSShape> shape;
shape = ResourceManager->load(argv[2]);
const char * str;
if(shape.isNull())
return;
TSShapeInstance *shapeinst = new TSShapeInstance(shape, true);
if(!shapeinst)
return;
FileStream stream;
stream.open(argv[1], FileStream::Write);
TSShape* mShape = shapeinst->getShape();
Con::printf("Dumping %s to %s", argv[2], argv[1]);
dumpLine("#obj file rn");
U32 i;
/*S32 frameCount = 0;
for(i = 0; i < mShape->sequences.size(); i++){
frameCount += mShape->sequences[i].numKeyframes;
}
//dumpLine(avar("Frames: %irn", frameCount));
dumpLine("Frames: 1rn"); //only STATIC meshes for now, kthxbai
dumpLine("Frame: 1rnrn");
dumpLine(avar("Meshes: %irn", mShape->meshes.size()));*/
// mesh: name, flags, material index
i = 0; //make this loopy eventually
TSMesh* tsm = mShape->meshes[i];
// number of vertices
dumpLine(avar("#%irnrn", tsm->verts.size()));
ToolVector<Point2F> uvs;
tsm->getUVs(TSMesh::tDiffuse, uvs);
U32 j; // inner loopiness
for(j = 0; j<tsm->verts.size(); j++){
Point3F xyz = tsm->verts[j];
// vertex: flags, x, y, z, u, v, bone index
dumpLine(avar("v %f %f %frn", xyz.x, xyz.y, xyz.z));
}
dumpLine("rn");
for(j = 0; j<tsm->verts.size(); j++){
Point2F uv = uvs[j];
dumpLine(avar("vt %f %frn", uv.x, uv.y));
}
dumpLine("rn");
// number of normals
U32 normcount = tsm->getFlags(TSMesh::UseEncodedNormals) ? tsm->encodedNorms.size() : tsm->norms.size();
dumpLine(avar("#%irnrn", normcount));
const Point3F * norms = tsm->getNormals(0);
for(j = 0; j<normcount; j++){
Point3F xyz = norms[j];
// normal: x, y, z
dumpLine(avar("vn %f %f %frn", xyz.x, xyz.y, xyz.z));
}
dumpLine("rn");
// number of triangles
U32 tris = 0;
for(j = 0; j<tsm->primitives.size(); j++)
tris += tsm->primitives[j].numElements;
dumpLine(avar("# %irnrn",tris));
dumpLine(avar("g Mesh%irnrn",i));
for(j = 0; j<tsm->primitives.size(); j++){
TSDrawPrimitive draw = tsm->primitives[j];
// triangle: flags, vertex index1, vertex index2, vertex index3, normal index1, normal index 2, normal index 3, smoothing group
if ( (draw.matIndex & TSDrawPrimitive::TypeMask) == TSDrawPrimitive::Triangles)
{
for (S32 k=0; k<draw.numElements; )
{
U32 idx0 = tsm->indices[draw.start + k + 0];
U32 idx1 =tsm->indices[draw.start + k + 1];
U32 idx2 = tsm->indices[draw.start + k + 2];
dumpLine(avar("f %i/%i/%i %i/%i/%i %i/%i/%irn", (idx0+1), (idx0+1), (idx0+1), (idx1+1), (idx1+1), (idx1+1), (idx2+1), (idx2+1), (idx2+1)));
k += 3;
}
} else if((draw.matIndex & TSDrawPrimitive::TypeMask) == TSDrawPrimitive::Strip){
U32 idx0 = tsm->indices[draw.start + 0];
U32 idx1;
U32 idx2 = tsm->indices[draw.start + 1];
U32 * nextIdx = &idx1;
for (S32 k=2; k<draw.numElements; k++)
{
*nextIdx = idx2;
nextIdx = (U32*) ( (dsize_t)nextIdx ^ (dsize_t)&idx0 ^ (dsize_t)&idx1);
idx2 = tsm->indices[draw.start + k];
if (idx0 == idx1 || idx0 == idx2 || idx1 == idx2)
Con::printf("Warning, vertex redundancy: %i, %i, %i", idx0, idx1, idx2);
//continue;
dumpLine(avar("f %i/%i/%i %i/%i/%i %i/%i/%irn", (idx0+1), (idx0+1), (idx0+1), (idx1+1), (idx1+1), (idx1+1), (idx2+1), (idx2+1), (idx2+1)));
}
} else{
dumpLine("# oops--don't really know how to handle thisrn");
}
}
dumpLine("rn");
stream.close();
Con::printf("...dump complete");
}
idk if it will work if not just give me a download for the dts importer for milkshape 3d
ConsoleFunction(dumpDTStoObj, void, 3, 3, "(string objfile, string dts)")
{
Resource<TSShape> shape;
shape = ResourceManager->load(argv[2]);
const char * str;
if(shape.isNull())
return;
TSShapeInstance *shapeinst = new TSShapeInstance(shape, true);
if(!shapeinst)
return;
FileStream stream;
stream.open(argv[1], FileStream::Write);
TSShape* mShape = shapeinst->getShape();
Con::printf("Dumping %s to %s", argv[2], argv[1]);
dumpLine("#obj file rn");
U32 i;
/*S32 frameCount = 0;
for(i = 0; i < mShape->sequences.size(); i++){
frameCount += mShape->sequences[i].numKeyframes;
}
//dumpLine(avar("Frames: %irn", frameCount));
dumpLine("Frames: 1rn"); //only STATIC meshes for now, kthxbai
dumpLine("Frame: 1rnrn");
dumpLine(avar("Meshes: %irn", mShape->meshes.size()));*/
// mesh: name, flags, material index
i = 0; //make this loopy eventually
TSMesh* tsm = mShape->meshes[i];
// number of vertices
dumpLine(avar("#%irnrn", tsm->verts.size()));
ToolVector<Point2F> uvs;
tsm->getUVs(TSMesh::tDiffuse, uvs);
U32 j; // inner loopiness
for(j = 0; j<tsm->verts.size(); j++){
Point3F xyz = tsm->verts[j];
// vertex: flags, x, y, z, u, v, bone index
dumpLine(avar("v %f %f %frn", xyz.x, xyz.y, xyz.z));
}
dumpLine("rn");
for(j = 0; j<tsm->verts.size(); j++){
Point2F uv = uvs[j];
dumpLine(avar("vt %f %frn", uv.x, uv.y));
}
dumpLine("rn");
// number of normals
U32 normcount = tsm->getFlags(TSMesh::UseEncodedNormals) ? tsm->encodedNorms.size() : tsm->norms.size();
dumpLine(avar("#%irnrn", normcount));
const Point3F * norms = tsm->getNormals(0);
for(j = 0; j<normcount; j++){
Point3F xyz = norms[j];
// normal: x, y, z
dumpLine(avar("vn %f %f %frn", xyz.x, xyz.y, xyz.z));
}
dumpLine("rn");
// number of triangles
U32 tris = 0;
for(j = 0; j<tsm->primitives.size(); j++)
tris += tsm->primitives[j].numElements;
dumpLine(avar("# %irnrn",tris));
dumpLine(avar("g Mesh%irnrn",i));
for(j = 0; j<tsm->primitives.size(); j++){
TSDrawPrimitive draw = tsm->primitives[j];
// triangle: flags, vertex index1, vertex index2, vertex index3, normal index1, normal index 2, normal index 3, smoothing group
if ( (draw.matIndex & TSDrawPrimitive::TypeMask) == TSDrawPrimitive::Triangles)
{
for (S32 k=0; k<draw.numElements; )
{
U32 idx0 = tsm->indices[draw.start + k + 0];
U32 idx1 =tsm->indices[draw.start + k + 1];
U32 idx2 = tsm->indices[draw.start + k + 2];
dumpLine(avar("f %i/%i/%i %i/%i/%i %i/%i/%irn", (idx0+1), (idx0+1), (idx0+1), (idx1+1), (idx1+1), (idx1+1), (idx2+1), (idx2+1), (idx2+1)));
k += 3;
}
} else if((draw.matIndex & TSDrawPrimitive::TypeMask) == TSDrawPrimitive::Strip){
U32 idx0 = tsm->indices[draw.start + 0];
U32 idx1;
U32 idx2 = tsm->indices[draw.start + 1];
U32 * nextIdx = &idx1;
for (S32 k=2; k<draw.numElements; k++)
{
*nextIdx = idx2;
nextIdx = (U32*) ( (dsize_t)nextIdx ^ (dsize_t)&idx0 ^ (dsize_t)&idx1);
idx2 = tsm->indices[draw.start + k];
if (idx0 == idx1 || idx0 == idx2 || idx1 == idx2)
Con::printf("Warning, vertex redundancy: %i, %i, %i", idx0, idx1, idx2);
//continue;
dumpLine(avar("f %i/%i/%i %i/%i/%i %i/%i/%irn", (idx0+1), (idx0+1), (idx0+1), (idx1+1), (idx1+1), (idx1+1), (idx2+1), (idx2+1), (idx2+1)));
}
} else{
dumpLine("# oops--don't really know how to handle thisrn");
}
}
dumpLine("rn");
stream.close();
Con::printf("...dump complete");
}
idk if it will work if not just give me a download for the dts importer for milkshape 3d
About the author
BLOCKLAND LOVER!!! =D
#2
12/10/2011 (8:31 am)
UR NOT UNDERSTANDING
#3
12/10/2011 (10:49 am)
U R RIGHT I MISREAD THE INITIAL TITLE I SOZ M8 K
#4
12/10/2011 (11:30 am)
It would be a bad idea to write a DTS IMPORTER for a modeling program. Funny thing about artists, and some developers, is that they like to leave their assets in a protected format.
#5
Being held hostage by an artist is something that id find quite objectionable for all kinds of reasons
12/10/2011 (11:48 am)
I think thats the most horrible excuse tbh, personally ive always thought that a dts importer would be a good idea, if i was a good enough programmer and understood all the bits i'd write one myself, or at the very least write a dts to fbx converter or something.Being held hostage by an artist is something that id find quite objectionable for all kinds of reasons
#6
Even with T3D being able to make use of collada files, you don't expect a finished game to ship the DAE objects do you? That would lead all kinds of greasy developers to borrow and modify some game's artwork. But that's just the most common reason, or excuse if you prefer, presented when this question or topic arises.
Besides, if you use T3D there is a way around the lack of a specific importer if you're being held hostage with sourceless purchased artwork.
... and if you do some research there is an old (no longer in development) tool that can do this very thing ;)
12/10/2011 (12:14 pm)
Being as that we only use custom art, it's a null issue for me. Even with T3D being able to make use of collada files, you don't expect a finished game to ship the DAE objects do you? That would lead all kinds of greasy developers to borrow and modify some game's artwork. But that's just the most common reason, or excuse if you prefer, presented when this question or topic arises.
Besides, if you use T3D there is a way around the lack of a specific importer if you're being held hostage with sourceless purchased artwork.
... and if you do some research there is an old (no longer in development) tool that can do this very thing ;)
#7
and yes i know the program you are referring to, but buying a half finished 5 year old piece of unsupported software is hardly an ideal solution :)
12/10/2011 (4:17 pm)
Some people just don't provide the correct materials to work with, take GG for example, no useful source for models shipped with T3D. a DTS importer or converter to a usable format would be nice.and yes i know the program you are referring to, but buying a half finished 5 year old piece of unsupported software is hardly an ideal solution :)
#8
12/11/2011 (2:05 pm)
Quote:Really? Looks like most, if not all, of the new art is in the collada format. And well, you can't get more "source" than that. The example art has always been adequate enough to prototype with and sometimes learn from, it's just been too damn ugly to want to use ;)
take GG for example, no useful source for models shipped with T3D
#9
I have to take the cached.dts and do the voodoo that I do-do...lol. The TP_Weapon files are somewhat better. The Lurker starts in a T-pose, and moves to an animated state, but the others don't?!?
The Shape Editor has made things so much more palatable to we, Artists; allows for quite a bit of assembling at runtime, which is coolio!
12/11/2011 (3:38 pm)
What I don't like about the DAE files I've opened to date[or evaluated], or at least when I view them in other DCC programs is the 'baked in' root pose; no 'skinning pose', T-pose or inverted Y-pose to rework the figure from a fresh start...so m'eh to DAE as a 'source' file format.I have to take the cached.dts and do the voodoo that I do-do...lol. The TP_Weapon files are somewhat better. The Lurker starts in a T-pose, and moves to an animated state, but the others don't?!?
The Shape Editor has made things so much more palatable to we, Artists; allows for quite a bit of assembling at runtime, which is coolio!
#10
12/11/2011 (3:44 pm)
@Rex: true, collada is far from perfect, or even preferred - but at least it's something and more consistent than past GG effort. I still remember the good ol' days of learning how a shape class was put together and how it all worked by examining a DTS with ShowTool and reading source code.
#11
Steve, Arteria3d
12/12/2011 (3:54 pm)
Unwrap3d has a DTS importer - has had for many years. I use this alotSteve, Arteria3d
#12
12/13/2011 (12:20 am)
Does not parse DTS v26 very well at all....based upon v24.
Torque 3D Owner Bloodknight
Bloodknight Studios