About Store Forum Documentation Contact



Post Reply 
Mesh Format Change?
Author Message
Brainache Offline
Member

Post: #1
Mesh Format Change?
Hey there.. back to it after brief hiatus...

Upgraded to the latest version and running into an issue with my custom mesh importer...

All compiles correctly, and does not generate any runtime errors... but meshes created are not rendering (either in code or in mesh editor)...

If I render the mesh parts by cycling the Mesh.part(x).render(material).. the individual parts will render ( but loks like some texture coord issues..)

However, rendering via Mesh.render() results in nothing being drawn...

I've been digging into this for several days without much success... any chance there is something extra I need to do with the new mesh format?

( basic steps are.. for each material in my source model, create the material, create a new meshbase, create a vert array for each face... use Triangulation(poly,meshpart) to convert the vert array to a MeshPart... add this MeshPart to the MeshBase )

(Away from code atm - might be confused on wether im using meshpart or meshbase...)

Anyway.. any clue you can give me would help me cut down my debug time... ( this was working perfectly before changing to the new version of the engine btw )

Thanks!
11-18-2009 08:04 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #2
RE: Mesh Format Change?
Hi,

please make sure to use the latest engine headers, lib file, engine.pak file

after setting the mesh data, please use Mesh::setRender,Mesh::setBox (like in some tutorials),
after creating custom material, please call Material::validate

if you will still experience some trouble, I would need a sample .mesh file, and look into the codes which you're using to create meshes.
11-18-2009 08:38 PM
Find all posts by this user Quote this message in a reply
Brainache Offline
Member

Post: #3
RE: Mesh Format Change?
Heya... been pulling out my hair on this... tried everything I can think of it get it working again ( it was working perfectly previous to changing to new version of esenthel library )

I've attached the .mesh and .phys file generated from this code... the .phys is correct, the .mesh does not render either in code or mesh editor. If you turn on the box rendering in mesh editor and cycle through the parts - the box is rendering over what should be the mesh parts... and in code, if you render each individual mesh part - it renders correctly...


Here is the main code that builds the mesh: ( cut from the class handling all the import of data )



Mesh eMesh;
eMesh.create( mMaterials.elms() );

for (int m=0;m < mMaterials.elms(); m++)
{
MeshPart &part = eMesh.part(m);
MeshBase &em = part.base;

for (int b=0;b < mBrushes.elms();b++)
{
c3dwBrush *brush = &mBrushes[b];
for (int f=0;f<brush->faces.elms();f++)
{
c3dwFace *face = &brush->faces[f];
if (face->materialIdx != m+1) continue;

MeshBase helper;
Memb<Memc<VtxFull>> all_poly;
Memc<VtxFull> &poly = all_poly.New();

for (int x=face->indexCount-1;x>-1;x--)
{
int idx = face->indices[x];
VtxFull &vert = poly.New();
vert.pos.x = brush->verts[idx].v[0];
vert.pos.y = brush->verts[idx].v[1];
vert.pos.z = brush->verts[idx].v[2];
vert.tex0.x = face->texCoords[x].v[0];
vert.tex0.y = face->texCoords[x].v[1];
vert.tex1.x = face->texCoords[x].v[0];
vert.tex1.y = face->texCoords[x].v[1];
vert.color.set(255,255,255,255);
}

Triangulate(all_poly,helper);

em += helper;
Material *mat = Materials.get("data/mtrl/brick/0.mtrl");
part.setMaterial( mat );

}
}
}

eMesh.setNormals();
eMesh.setTangents();
eMesh.scale( Vec(0.001,0.001,0.001) );
//eMesh.scale( cfg->mScale );
eMesh.setRender().setBox();

Phys phys;
phys.create(eMesh.parts());
for (int p=0;p<eMesh.parts();p++)
{
PhysPart &pp = phys.part(p);
MeshPart &part = eMesh.part(p);
MeshBase &em = part.base;
pp.createMesh(em);
}

Game::ObjParams op; // create object parameters variable
op.type(true,"OBJ_STATIC");
op.sortParams();

if (SaveAll)
{

Str saveName = baseName;

eMesh.save(cfg->mMeshPath+saveName+".mesh");
phys.save(cfg->mPhysPath+saveName+".phys");

op.mesh(true,Meshs(cfg->mMeshPath+saveName+".mesh"));
op.phys(true,Physs(cfg->mPhysPath+saveName+".phys"));

op.save(cfg->mObjPath+saveName+".obj");
}


Attached File(s)
.7z  cvtest.7z (Size: 18.33 KB / Downloads: 6)
12-07-2009 07:30 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #4
RE: Mesh Format Change?
hello,

Code:
void Triangulate(Memb<Memc<VtxFull>> &polys,MeshBase &mshb,UInt flag_and=~0,..
in this function please specify the 'flag_and' paramter (give only used parameters, like this "VTX_POS|VTX_TEX0|VTX_TEX1|VTX_NRM")
12-07-2009 10:05 PM
Find all posts by this user Quote this message in a reply
Brainache Offline
Member

Post: #5
RE: Mesh Format Change?
Great - That solved the issue with the mesh itself...

Im now having an issue with the materials:

gfx files are being created correctly
mtrl files are being created... and appear correct when loaded...
but only SOME are rendering...
unless I do this:
load the mesh, go to material mode
cycle through each part, click "GET"... and the material starts rendering correctly... but even if I save the mesh after doing that... and reload...
same thing happens...


Here is how I am creating the .mtrl files:
mat.mat.reset();
mat.mat.ambient.set(255,255,255);
mat.mat.color.set(255,255,255,255);

Str dest_path = "data/cGfx/";
texName = texName + ".jpg";
nortexName = nortexName + ".jpg";
if (mat.mat.importTextures(texName,"",nortexName,nortexName,"","",dest_path,false))
{
logger.putLine(S+"import true: "+texName);
}
else
{
logger.putLine(S+"import false: "+texName);
}
mat.mat.validate();
mat.mat.save(matName);

Where am I going wrong?
(This post was last modified: 12-08-2009 12:42 AM by Brainache.)
12-08-2009 12:42 AM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #6
RE: Mesh Format Change?
please type here "Str dest_path = "data/cGfx/";" the full path (including drive letter)
12-08-2009 02:04 AM
Find all posts by this user Quote this message in a reply
Brainache Offline
Member

Post: #7
RE: Mesh Format Change?
I had it that way originaly ( and changed it back again just now)... same result...
the images are being located and imported correctly... the .gfx files are being created...
12-08-2009 05:22 AM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #8
RE: Mesh Format Change?
could you please send me again the new version of the files? thank you
12-08-2009 03:34 PM
Find all posts by this user Quote this message in a reply
Brainache Offline
Member

Post: #9
RE: Mesh Format Change?
Ive attached all the .gfx, .mtrl, the .mesh and .phys created... Thanks for taking a look!
Couldnt attach it for some reason... ( 4.5mb .7z file...)

Thanks!
(This post was last modified: 12-08-2009 07:03 PM by Brainache.)
12-08-2009 06:58 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #10
RE: Mesh Format Change?
you're using 0..255 scale on Vec color,ambient
on Vec it is 0..1 scale

and the paths to textures point to c:/dev/watch/data/xxx..

you should use IOPath so they will point to xxx/
12-08-2009 09:11 PM
Find all posts by this user Quote this message in a reply
Brainache Offline
Member

Post: #11
RE: Mesh Format Change?
Perfect - the 255 to 1 based change was what I was missing.. thanks!
12-09-2009 06:03 PM
Find all posts by this user Quote this message in a reply
Post Reply