Open LeeMcQueen opened 3 years ago
Node getNode(int x, int y) //得到点 根据 (y16 + x)y的行数 { return nodes[y*nodesPerRow+x]; }
fix -> { return nodes[y*nodesPerCol+x]; }
void init() { 16 nodesPerRow = width nodesDensity; 16 nodesPerCol = height nodesDensity;
pin1 = Vec2(0, 0);
pin2 = Vec2(nodesPerRow-1, 0);
/** Add nodes **/
printf("Init cloth with %d nodes\n", nodesPerRow*nodesPerCol);
//0-15 x轴
for (int i = 0; i < nodesPerRow; i ++) {
//0-15 y轴
for (int j = 0; j < nodesPerCol; j ++) {
/** Create node by position **/
//0.25为一个单位生成 0(0, 0, 0)1(0, 0.25, 0) 一共256个点
Node* node = new Node(Vec3((double)j/nodesDensity, -((double)i/nodesDensity), 0));
/** Set texture coordinates **/
node->texCoord.x = (double)j/(nodesPerRow-1);
node->texCoord.y = (double)i/(1-nodesPerCol);
/** Add node to cloth **/
nodes.push_back(node);
printf("\t[%d, %d] (%f, %f, %f) - (%f, %f)\n", i, j, node->position.x, node->position.y, node->position.z, node->texCoord.x, node->texCoord.y);
}
std::cout << std::endl;
}
//0-14 x轴 for (int i = 0; i < nodesPerRow-1; i ++) { //0-14 y轴 for (int j = 0; j < nodesPerCol-1; j ++) { // Left upper triangle 左上三角形 faces.push_back(getNode(i+1, j)); faces.push_back(getNode(i, j)); faces.push_back(getNode(i, j+1)); // Right bottom triangle 右下三角形 faces.push_back(getNode(i+1, j+1)); faces.push_back(getNode(i+1, j)); faces.push_back(getNode(i, j+1)); } }
Node getNode(int x, int y) //得到点 根据 (y16 + x)y的 { return nodes[y*nodesPerRow+x]; }
加上与没有有什么区别