void OGF::PreSave (u32 tree_id) { // if (20==tree_id || 18==tree_id) __asm int 3; //. Shader_xrLC* SH = pBuild->shaders.Get (pBuild->materials[material].reserved); bool bVertexColored = (SH->flags.bLIGHT_Vertex); // X-vertices/faces if (x_vertices.size() && x_faces.size()) { clMsg ("%4d: v(%3d)/f(%3d)",tree_id,x_vertices.size(),x_faces.size()); VDeclarator x_D; x_D.set (x_decl_vert); x_VB.Begin (x_D); for (itXV V=x_vertices.begin(); V!=x_vertices.end(); V++) { x_vert v (V->P); x_VB.Add (&v,sizeof(v)); } x_VB.End (&xvb_id,&xvb_start); x_IB.Register (LPWORD(&*x_faces.begin()),LPWORD(&*x_faces.end()),&xib_id,&xib_start); } // Vertices VDeclarator D; if (bVertexColored){ // vertex-colored D.set (r1_decl_vert); g_VB.Begin (D); for (itOGF_V V=vertices.begin(); V!=vertices.end(); V++) { r1v_vert v (V->P,V->N,V->T,V->B,V->Color,V->UV[0]); g_VB.Add (&v,sizeof(v)); } g_VB.End (&vb_id,&vb_start); }else{ // lmap-colored D.set (r1_decl_lmap); g_VB.Begin (D); for (itOGF_V V=vertices.begin(); V!=vertices.end(); V++) { r1v_lmap v (V->P,V->N,V->T,V->B,V->Color,V->UV[0],V->UV[1]); g_VB.Add (&v,sizeof(v)); } g_VB.End (&vb_id,&vb_start); } // Faces g_IB.Register (LPWORD(&*faces.begin()),LPWORD(&*faces.end()),&ib_id,&ib_start); }
void xrMU_Model::export_geometry () { // Declarator VDeclarator D; D.set (decl); // RT-check, BOX, low-point, frac-size Fbox BB; BB.invalidate (); for (v_vertices_it vit=m_vertices.begin(); vit!=m_vertices.end(); vit++) BB.modify ((*vit)->P); Fvector frac_low; float frac_Ysize; BB.getcenter (frac_low); frac_low.y = BB.min.y; frac_Ysize = BB.max.y - BB.min.y; // Begin building for (v_subdivs_it it=m_subdivs.begin(); it!=m_subdivs.end(); it++) { // Vertices { g_VB.Begin (D); vecOGF_V& verts = it->ogf->vertices; for (u32 v_it=0; v_it<verts.size(); v_it++) { OGF_Vertex& oV = verts[v_it]; // Position g_VB.Add (&oV.P,3*sizeof(float)); // Normal { base_color_c oV_c; oV.Color._get(oV_c); Fvector N = oV.N; N.add (1.f); N.mul (.5f*255.f); s32 nx = iFloor(N.x); clamp(nx,0,255); s32 ny = iFloor(N.y); clamp(ny,0,255); s32 nz = iFloor(N.z); clamp(nz,0,255); s32 cc = iFloor(oV_c.hemi*255.f); clamp(cc,0,255); u32 uN = color_rgba(nx,ny,nz,cc); g_VB.Add (&uN,4); } // Tangent { u32 uT = color_rgba(oV.T.x,oV.T.y,oV.T.z,0); g_VB.Add (&uT,4); } // Binormal { u32 uB = color_rgba(oV.B.x,oV.B.y,oV.B.z,0); g_VB.Add (&uB,4); } // TC s16 tu,tv,frac,dummy; tu = QC(oV.UV.begin()->x); tv = QC(oV.UV.begin()->y); g_VB.Add (&tu,2); g_VB.Add (&tv,2); // frac float f1 = (oV.P.y - frac_low.y) /frac_Ysize; float f2 = oV.P.distance_to(frac_low)/frac_Ysize; frac = QC((f1+f2)/2.f); dummy = 0; g_VB.Add (&frac, 2); g_VB.Add (&dummy,2); } g_VB.End (&it->vb_id,&it->vb_start); } // Indices g_IB.Register (LPWORD(&*it->ogf->faces.begin()),LPWORD(&*it->ogf->faces.end()),&it->ib_id,&it->ib_start); // SW if (it->ogf->progressive_test()) g_SWI.Register (&it->sw_id,&it->ogf->m_SWI); } }