Пример #1
0
unsigned int WavefrontObj::loadObj(const char *fname) // load a wavefront obj returns number of triangles that were loaded.  Data is persists until the class is destructed.
{

	unsigned int ret = 0;

	delete mVertices;
	mVertices = 0;
	delete mIndices;
	mIndices = 0;
	mVertexCount = 0;
	mTriCount = 0;

	OBJ obj;

	obj.LoadMesh(fname);

	mVertexCount = (int)obj.mVerts.size()/3;
	mTriCount = (int)obj.mTriIndices.size()/3;

	if ( mVertexCount )
	{
		mVertices = new float[mVertexCount*3];
		memcpy(mVertices, &obj.mVerts[0], sizeof(float)*mVertexCount*3);
	}
	if ( mTriCount )
	{
		mIndices = new int[mTriCount*3];
		memcpy(mIndices,&obj.mTriIndices[0],mTriCount*3*sizeof(int));
	}
	ret = mTriCount;

	return ret;
}
Пример #2
0
unsigned int WavefrontObj::loadObj(const char *fname, bool textured) // load a wavefront obj returns number of triangles that were loaded.  Data is persists until the class is destructed.
{
	unsigned int ret = 0;
	delete []mVertices;
	mVertices = 0;
	delete []mIndices;
	mIndices = 0;
	mVertexCount = 0;
	mTriCount = 0;

	BuildMesh bm;
	OBJ obj;
	obj.LoadMesh(fname, &bm, textured);

	if (bm.GetNumVertices())
	{
		mVertexCount = bm.GetNumVertices()/3;
		mVertices = new float[mVertexCount*3];
		memcpy(mVertices, bm.GetVertices(), sizeof(float)*mVertexCount*3);

		if (textured)
		{
			mTexCoords = new float[mVertexCount * 2];
			memcpy(mTexCoords, bm.GetTexCoords(), sizeof(float) * mVertexCount * 2);
		}

		mTriCount = bm.GetNumIndices()/3;
		mIndices = new int[mTriCount*3];
		memcpy(mIndices, bm.GetIndices(), sizeof(int)*mTriCount*3);
		ret = mTriCount;
	}

	return ret;
}
Пример #3
0
	//ÉîËÑpage tree
	int parsePageTree()
	{
		OBJ *obj = new OBJ();
		streamoff pageroot_off;
		obj->setIdx(catalog_->Pages->idx());
		parsePageTreeNode(obj);
		pageRoot_ = (PageTreeNode*) vecObj[catalog_->Pages->idx()];
		return 0;
	}
Пример #4
0
NxU32 WavefrontObj::loadObj(const char *fname, bool textured) // load a wavefront obj returns number of triangles that were loaded.  Data is persists until the class is destructed.
{

	NxU32 ret = 0;

	delete mVertices;
	mVertices = 0;
	delete mIndices;
	mIndices = 0;
	mVertexCount = 0;
	mTriCount = 0;


  BuildMesh bm;

  OBJ obj;

  obj.LoadMesh(fname,&bm, textured);


	const FloatVector &vlist = bm.GetVertices();
	const IntVector &indices = bm.GetIndices();
	if ( vlist.size() )
	{
		mVertexCount = (NxI32)vlist.size()/3;
		mVertices = new NxF32[mVertexCount*3];
		memcpy( mVertices, &vlist[0], sizeof(NxF32)*mVertexCount*3 );

		if (textured)
		{
			mTexCoords = new NxF32[mVertexCount * 2];
			const FloatVector& tList = bm.GetTexCoords();
			memcpy( mTexCoords, &tList[0], sizeof(NxF32) * mVertexCount * 2);
		}

		mTriCount = (NxI32)indices.size()/3;
		mIndices = new NxU32[mTriCount*3*sizeof(NxU32)];
		memcpy(mIndices, &indices[0], sizeof(NxU32)*mTriCount*3);
		ret = mTriCount;
	}


	return ret;
}
Пример #5
0
	void parsePageTreeNode(OBJ * node)
	{
		if (node == NULL)return;
		int node_idx = node->idx();
		cout << "this->" << node_idx << endl;
		streamoff node_off = vecCrossRef[node_idx].off;
		string sType;
		node->getType(readpdf_, node_off, sType);
		if (sType == "Page")
		{
			Page * p = new Page();
			p->parse(readpdf_, node_off);
			vecObj[node_idx] = p;
			int cont_idx = p->Contents->idx();
			node_off = vecCrossRef[cont_idx].off;
			Stream * cont = new Stream();
			cont->parse(readpdf_, node_off);
			vecObj[cont_idx] = cont;
			cout << "page " << node_idx << endl << endl << endl << endl << endl;
			cout << cont->decodeData << endl;
			return;
		}
		if (sType == "Pages")
		{
			PageTreeNode * pt = new PageTreeNode();
			pt->parse(readpdf_, node_off);
			vecObj[node_idx] = pt;
			for (int i = 0; i < pt->Kids.arr.size(); i++)
			{
				node_idx = pt->Kids.arr[i].idx();
				OBJ * obj = new OBJ();
				obj->setIdx(node_idx);
				parsePageTreeNode(obj);
			}
		}
		return;
	}
Пример #6
0
unsigned int WavefrontObj::loadObj(const char *fname) // load a wavefront obj returns number of triangles that were loaded.  Data is persists until the class is destructed.
{

	unsigned int ret = 0;

	delete [] mVertices;
	mVertices = 0;
	delete [] mIndices;
	mIndices = 0;
	mVertexCount = 0;
	mTriCount = 0;


  BuildMesh bm;

  OBJ obj;

  obj.LoadMesh(fname,&bm);


	const FloatVector &vlist = bm.GetVertices();
	const IntVector &indices = bm.GetIndices();
	if ( vlist.size() )
	{
		mVertexCount = vlist.size()/3;
		mVertices = new float[mVertexCount*3];
		memcpy( mVertices, &vlist[0], sizeof(float)*mVertexCount*3 );
		mTriCount = indices.size()/3;
		mIndices = new int[mTriCount*3*sizeof(int)];
		memcpy(mIndices, &indices[0], sizeof(int)*mTriCount*3);
		ret = mTriCount;
	}


	return ret;
}