THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 30/10/2003 at 10:25, xxxxxxxx wrote:
This is how far i have proceded:
i can get a list of the bones
for a bone i can get the parent bone
but i cannot access other bone values like position,rotation etc.
Maybe it is in a container, or not? How do i properly access such a container?
Below is the code i came up with. It is a modified pov exporter.
basemsa.coh
var fac = 1.0;
var tab = 1;
WriteIt(file,p1,p2,p3)
{
var t;
p1 /= fac;
p2 /= fac;
p3 /= fac;
t = tostring(p1.x);
t=stradd(t," ",tostring(p1.y));
t=stradd(t," ",tostring(p1.z));
t=stradd(t," ",tostring(p2.x));
t=stradd(t," ",tostring(p2.y));
t=stradd(t," ",tostring(p2.z));
t=stradd(t," ",tostring(p3.x));
t=stradd(t," ",tostring(p3.y));
t=stradd(t," ",tostring(p3.z));
t = stradd(t,GeGetLineEnd());
file->WriteString(t);
}
WriteMyBone(file,p1,p2)
{
var t;
p1 /= fac;
p2 /= fac;
t = tostring(p1.x);
t=stradd(t," ",tostring(p1.y));
t=stradd(t," ",tostring(p1.z));
t=stradd(t," ",tostring(p2.x));
t=stradd(t," ",tostring(p2.y));
t=stradd(t," ",tostring(p2.z));
t = stradd(t,GeGetLineEnd());
file->WriteString(t);
}
SaveObject(op,file)
{
var parentop;
while (op)
{
if (getclass(op)==PolygonObject)
{
var i;
var name,p1,p2,p3,p4;
var padr = op->GetPoints();
var vadr = op->GetPolygons();
var vanz = op->GetPolygonCount();
// write objects name
file->WriteString(stradd(op->GetName(),GeGetLineEnd()));
var mg = op->GetMg();
// write triangles
for (i=0; i<vanz; i++)
{
p1 = mg->GetMulP(padr[vadr[i*4]]);
p2 = mg->GetMulP(padr[vadr[i*4+1]]);
p3 = mg->GetMulP(padr[vadr[i*4+2]]);
p4 = mg->GetMulP(padr[vadr[i*4+3]]);
if (vadr[i*4+2]==vadr[i*4+3])
WriteIt(file,p1,p2,p3);
else
{
WriteIt(file,p1,p2,p3);
WriteIt(file,p3,p4,p1);
}
}
}
if (getclass(op)==BoneObject)
{
var pos;
var rot;
// write objects name
file->WriteString(stradd(op->GetName(),GeGetLineEnd()));
// write objects parent name
parentop = op->GetUp();
file->WriteString(stradd(parentop->GetName(),GeGetLineEnd()));
var data = op->GetConTainer();
if (data)
{
pos.x = 0.0;
pos.y = 0.0;
pos.z = 0.0;
rot.x = 0.0;
rot.y = 0.0;
rot.z = 0.0;
pos = data->GetVector(BONEOBJECT_FIXPOSITION);
rot = data->GetVector(BONEOBJECT_FIXROTATION);
writemybone(file,pos,rot);
}
}
//recursive here... (find all children if available)
if (!SaveObject(op->GetDown(),file)) return FALSE;
//get the next object...
op = op->GetNext();
}
return TRUE;
}
msa.cof
// Simple Saver for Milkshape ascii (MSA) files
include "basemsa.coh"
class MyFilter: FilterPlugin
{
public:
MyFilter();
GetID();
GetName();
Identify(probe,fname);
Save(doc,fname,obj,mat,env,dialog);
Edit();
}
MyFilter::GetID()
{
// be sure to use a unique ID obtained from [www.plugincafe.com](http://www.plugincafe.com)
return 1000001;
// be sure to use a unique ID obtained from [www.plugincafe.com](http://www.plugincafe.com)
}
MyFilter::GetName()
{
return "MSA";
}
MyFilter::Identify(probe,fname)
{
return fname->CheckSuffix("MSA");
}
MyFilter::Save(doc,fname,obj,mat,env,dialog)
{
var ok;
var file = new(BaseFile); if (!file) return FILEERROR_MEMORY;
println("Saving MSA");
fname->SetSuffix("TXT");
if (!file->Open(fname,GE_WRITE)) return FALSE;
ok=SaveObject(doc->GetFirstObject(),file);
file->Close();
println("Ready");
return FILEERROR_NONE;
}
MyFilter::Edit()
{
println("plug",GeGetRootFilename()->GetFullString());
}
main()
{
Register(MyFilter);
}