Advertisement Jump to content
Sign in to follow this  
noatom

Problem creating heightmap

This topic is 1814 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

So,I already have the heightmap vertices extracted.All I need to do is pass the data to PhysX so it can construct a shape after them. To see if the shape looks correctly,I use PVD.

 

The problem is,it doesn't look correctly at all:

10dtgzk.png

 

 

Remember,I already have the vertices in perfect order(the same vertices are used for rendering)

        const PxReal heightScale = 1.0f;
	PxU32 hfNumVerts = data->grid_sizex * data->grid_sizey;

	PxHeightFieldSample* samples = new PxHeightFieldSample[hfNumVerts];
	memset(samples, 0, hfNumVerts*sizeof(PxHeightFieldSample));

	for (int z = 0; z < hfNumVerts; z++)
	{
		samples[z].height = (PxI16)data->points[z].y;
		samples[z].materialIndex0 = 0;
		samples[z].materialIndex1 = 0;
		
	}

	PxHeightFieldDesc hfDesc;
	hfDesc.format = PxHeightFieldFormat::eS16_TM;
	hfDesc.nbColumns = data->grid_sizex;
	hfDesc.nbRows = data->grid_sizey;
	hfDesc.thickness = -2;
	hfDesc.samples.data = samples;
	hfDesc.samples.stride = sizeof(PxHeightFieldSample);
	
	PxHeightField* heightField = gPhysics->createHeightField(hfDesc);
	

	
	PxTransform pose(PxVec3(0,0,0),
		PxQuat(PxIdentity));
	body_static = gPhysics->createRigidStatic(pose);


	PxHeightFieldGeometry hfGeom(heightField, PxMeshGeometryFlags(), heightScale, 18, 18);

points is just a vertex structure that contains the xyz of every vertex in float format. Keep in mind that the every y component of every vertex has been already scaled.

Edited by noatom

Share this post


Link to post
Share on other sites
Advertisement
Just because your vertex data is correct for your renderer does not mean it's correct for the physics engine.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!