Jump to content
  • Advertisement
Sign in to follow this  
noatom

Help with simple algorithm to split mesh

This topic is 2132 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

class mesh{
public:
	vector<int> vertices;
	int inplus;
	mesh() { inplus = 0; }
};

int data[10][5];
void split(int total_rows, int total_columns, int wanted_rows, int wanted_columns){
	//create the right amount of meshes
	int req_meshes = (total_rows * total_columns) / (wanted_rows * wanted_columns);
	vector<mesh>meshes;
	int r = req_meshes;
	while (req_meshes){
		mesh temp;
		meshes.push_back(temp);
		req_meshes--;
	}
	int index = 0;

	for (int i = 0; i < total_rows; i++){
		index = 0;
		for (int w = 0; w < total_columns; w+= total_columns/wanted_columns){
			if (w != 0){
				meshes.at(index).vertices.push_back(data[i][w - 1]);
				meshes.at(index).inplus++;
			}
			for (int es = 0; es <= total_columns / wanted_columns; es++){
				meshes.at(index).vertices.push_back(data[i][w + es]);
			}
			

			


			if (meshes.at(index).vertices.size() == wanted_columns * wanted_rows + meshes.at(index).inplus){

				for (int r = 0; r < wanted_columns + 1; r++){
					if (i != 0){
						meshes.at(index).vertices.push_back(data[i - wanted_rows][(w - (wanted_columns + 1)) + r]);
					}
				}
				for (int za = 0; za < meshes.at(index).vertices.size(); za++)
					cout << meshes.at(index).vertices.at(za);
				cout << endl;
				meshes.erase(meshes.begin());
			}
			else{

				index++;
				if (index >= r)
					index = 0;
				index;
			}
				

		}

	}
	

}

What I'm trying to do: split a big mesh into smaller ones that fit it entirely.However...i can't manage to get anything good out of it....what's wrong?

Share this post


Link to post
Share on other sites
Advertisement
  • Variable data is uninitialized, but you read from it.
  • Variable data has an arbitrary size.
  • You don't read from the input mesh, and you don't return the newly created ones. You should probably return a collection of meshes from a method of the mesh class.
  • There doesn't seem to be any connectivity information in your meshes, only a bunch of vertices; and the vertices are ints, not anything resembling a point. Can you explain how the meshes should work?
  • Why do you want to split meshes in the first place?

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!