/** * STLデータのロード * @param filename ファイルパス * @retval true 成功 * @retval false 失敗 */ bool STLLoader::Load(const char* filename){ Clear(); SimpleSTLB obj; bool r = obj.Load(filename); mesh.Create(obj.GetVertexNum(), obj.GetIndexNum()); Vec3Buffer* pos = mesh.Position(); Vec3Buffer* normal = mesh.Normal(); FloatBuffer* mat = mesh.Material(); UintBuffer* index = mesh.Index(); Vec2Buffer* texcoord = mesh.Texcoord(); memcpy(pos->GetBuffer(), obj.GetPositionBuffer(), sizeof(float) * 3 * pos->GetNum()); normal->Create(obj.GetVertexNum()); memcpy(normal->GetBuffer(), obj.GetNormalBuffer(), sizeof(float) * 3 * normal->GetNum()); mat->Create(obj.GetVertexNum()); memset(mat->GetBuffer(), 0, sizeof(float) * mat->GetNum()); index->Create(obj.GetIndexNum()); memcpy(index->GetBuffer(), obj.GetIndex(), sizeof(unsigned int) * index->GetNum()); printf("%d\n", pos->GetNum() ); printf("%d\n", normal->GetNum() ); printf("%d\n", mat->GetNum() ); printf("%d\n", index->GetNum() ); return r; }
/** * BufferVolumeDataの作成 * @param w Widthサイズ * @param h Heightサイズ * @param d Depthサイズ * @param component component数 * @param nonUniform flag for non-uniform volume */ void Create(int w, int h, int d, int component, bool nonUniform) { this->m_dim[0] = w; this->m_dim[1] = h; this->m_dim[2] = d; this->m_comp = component; FloatBuffer* buf = new FloatBuffer(); FloatBuffer* spacingX = new FloatBuffer(); FloatBuffer* spacingY = new FloatBuffer(); FloatBuffer* spacingZ = new FloatBuffer(); buf->Create(w * h * d * component); this->m_buffer = buf; spacingX->Create(w+1); spacingY->Create(h+1); spacingZ->Create(d+1); this->m_spacingX = spacingX; this->m_spacingY = spacingY; this->m_spacingZ = spacingZ; this->m_isNonUniform = nonUniform; }