yes I noticed that yesterday, I am debuging it.
doe it happen every time for you?
I am adding a unttility funtion to save NewtonMesh in OFF format so that I can save inetmediate phase of teh prossess to see where teh Bug Happens.
Moderators: Sascha Willems, walaber
Julio Jerez wrote:yes I noticed that yesterday, I am debuging it.
doe it happen every time for you?
can you try a textured mesh to see if thatorks
Bird wrote:although I wouldn't be surprised if this was a problem on my side as finding the uv values per polygon per vertex is surprisingly difficult in LW.
-Bird
Julio Jerez wrote:looking at the tow meshes it looks liek the is a special case it seems tha a coren of the Box touches a face i\on teh convex, and it may be that teh algorith doe no how to handle that.
This is somethong I have to write.
can you save the to meshe that make the algorithn go into an infinite loop? maybe that is a different Bug and I can debug that first.
why? I though it was well defined. It is in fact very much like teh Netwon Mesh work. althogh It seem the Newton Mesh is a little more flexible for some things
I like abput lightwave is that is use channel whiel I use flat vertex.
I was considering to chneg teh flat format to channet as well, but that will be when I am adding shader and oteh things. for nwo a falt vertex with two UV seem sufficient.
does lightwave have plugin for loading OFF files. If is does, here is an example of what I am doing to debu the code..
Bird wrote:I couldn't find one. It looks like such a simple format maybe a hack together a quick OFF import/export tool.-Bird
dgMeshEffect::dgMeshEffect(dgMemoryAllocator* const allocator, const char* const fileName)
:dgPolyhedra (allocator)
{
class ParceOFF
{
public:
enum Token
{
m_off,
m_value,
m_end,
};
ParceOFF (FILE* const file)
:m_file (file)
{
}
Token GetToken(char* const buffer) const
{
while (!feof (m_file)) {
fscanf (m_file, "%s", buffer);
if (buffer[0] == '#') {
SkipLine();
} else {
if (!stricmp (buffer, "OFF")) {
return m_off;
}
return m_value;
}
}
return m_end;
}
void SkipLine() const
{
char tmp[1024];
fgets (tmp, sizeof (tmp), m_file);
}
dgInt32 GetInteger() const
{
char buffer[1024];
Token token = GetToken(buffer);
_ASSERTE (token == m_value);
return atoi (buffer);
}
dgFloat64 GetFloat() const
{
char buffer[1024];
Token token = GetToken(buffer);
_ASSERTE (token == m_value);
return atof (buffer);
}
FILE* m_file;
};
Init();
FILE* const file = fopen (fileName, "rb");
if (file) {
ParceOFF parcel (file);
dgInt32 vertexCount = 0;
dgInt32 faceCount = 0;
dgInt32 edgeCount = 0;
char buffer[1024];
bool stillData = true;
while (stillData) {
ParceOFF::Token token = parcel.GetToken(buffer);
switch (token)
{
case ParceOFF::m_off:
{
vertexCount = parcel.GetInteger();
faceCount = parcel.GetInteger();
edgeCount = parcel.GetInteger();
parcel.SkipLine();
dgVertexAtribute attribute;
memset (&attribute, 0, sizeof (dgVertexAtribute));
attribute.m_normal_y = 1.0f;
AddAtribute(attribute);
for (dgInt32 i = 0; i < vertexCount; i ++) {
dgBigVector point;
point.m_x = parcel.GetFloat();
point.m_y = parcel.GetFloat();
point.m_z = parcel.GetFloat();
point.m_w = 0.0;
parcel.SkipLine();
AddVertex(point);
}
BeginFace();
for (dgInt32 i = 0; i < faceCount; i ++) {
dgInt32 face[256];
dgInt32 faceVertexCount = parcel.GetInteger();
for (dgInt32 j = 0; j < faceVertexCount; j ++) {
face[j] = parcel.GetInteger();
}
parcel.SkipLine();
AddFace(faceVertexCount, face);
}
EndFace();
stillData = false;
break;
}
default:;
}
}
fclose (file);
}
}
Users browsing this forum: No registered users and 21 guests