本文整理汇总了C++中glm::i32vec2方法的典型用法代码示例。如果您正苦于以下问题:C++ glm::i32vec2方法的具体用法?C++ glm::i32vec2怎么用?C++ glm::i32vec2使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类glm
的用法示例。
在下文中一共展示了glm::i32vec2方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
static inline bool test_blocks(int b1, i32vec2 b2_tl, i32vec2 b2_br)
{
i32vec2 b1_tl = blockpos[b1];
i32vec2 b1_br = blockpos[b1] + blocksize[b1] - i32vec2(1, 1);
// 111 111 11111 111
// 222 222 222 22222
b1_tl -= i32vec2(millrad);
b1_br += i32vec2(millrad);
b2_tl -= i32vec2(millrad);
b2_br += i32vec2(millrad);
return !(b2_tl.x > b1_br.x || b2_br.x < b1_tl.x || b2_tl.y > b1_br.y || b2_br.y < b1_tl.y);
}
示例2: randomize_blocks
static void randomize_blocks()
{
int i;
for (i = 0; i < block_count; i++)
{
i32vec2 basesize = i32vec2(rand() & 255, rand() & 255);
blocksize[i].x = (basesize.x / 16) * 9 + 10;
blocksize[i].y = (basesize.y / 16) * 9 + 10;
}
}
示例3: validate_blocks
static void validate_blocks()
{
int i;
i32 total_area = 0;
i32 total_area_mill = 0;
i32 wood_area = area_func(woodsize);
printf("wood is %i,%i. area %i\n", woodsize.x, woodsize.y, wood_area);
for (i = 0; i < block_count; i++)
{
total_area += area_func(blocksize[i]);
total_area_mill += area_func(blocksize[i] + i32vec2(millrad, millrad) * 2);
if (blocksize[i].x > woodsize.x)
printf("block %i is too wide. (%i)\n", i, blocksize[i].x);
if (blocksize[i].y > woodsize.y)
printf("block %i is too tall. (%i)\n", i, blocksize[i].y);
}
printf("total area of blocks is %i. about %i with tolerances.\n", total_area, total_area_mill);
}
示例4: draw_blocks
static void draw_blocks()
{
int i;
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glBegin(GL_QUADS);
for (i = 1; i < drillpoint_draw_count; i++)
{
if (i % 5 == 0)
i++;
/*
1 1
2 2
*/
vec3 tmpcol = woodcolor - (float)(drillpoint_draw_count - i) * vec3(0.1f);
if (drillpoint_draw_count == drillpoint_count)
tmpcol = vec3(0.0f);
glColor3fv(glm::value_ptr(tmpcol));
i32vec2 dp_lu = drilling_path[i - 1];
i32vec2 dp_rd = drilling_path[i];
i32vec2 tmp;
if (dp_rd.x < dp_lu.x || dp_rd.y < dp_lu.y)
{
tmp = dp_lu;
dp_lu = dp_rd;
dp_rd = tmp;
}
dp_lu -= i32vec2(millrad);
dp_rd += i32vec2(millrad);
glVertex2f(dp_lu.x, dp_lu.y);
glVertex2f(dp_rd.x, dp_lu.y);
glVertex2f(dp_rd.x, dp_rd.y);
glVertex2f(dp_lu.x, dp_rd.y);
}
glEnd();
for (i = 0; i < block_count; i++)
{
if (!blockdone[i])
continue;
if (blockdone[i] == 1)
glColor3f(0.6f, 0.6f, 0.6f);
else
glColor3f(1.0f, 1.0f, 1.0f);
i32vec2 thispos = blockpos[i];
i32vec2 thissize = blocksize[i];
glLoadIdentity();
glTranslatef(thispos.x, thispos.y, 0.0);
glBegin(GL_QUADS);
glVertex2f(0.0, 0.0);
glVertex2f(thissize.x, 0.0);
glVertex2f(thissize.x, thissize.y);
glVertex2f(0.0, thissize.y);
glEnd();
}
/*
if (drillpoint_draw_count > 1 && drillpoint_draw_count % 5 == 1)
{
glLineWidth(5);
glBegin(GL_LINES);
glColor3f(1.0f, 0.0f, 0.0f);
i32vec2 p1 = drilling_path[drillpoint_draw_count - 2];
i32vec2 p2 = drilling_path[drillpoint_draw_count - 1];
glVertex2f(p1.x, p1.y);
glVertex2f(p2.x, p2.y);
glEnd();
}
*/
}
示例5: if
//.........这里部分代码省略.........
if (block_y > (woodsize.y - blocksize[block_i].y - 1) || block_y < 0)
{
blockdone[block_i] = 0;
state = 2;
return;
}
}
else if (state == 2)
{
bool all_done = true;
for (i = 0; i < block_count; i++)
{
if (blockdone[i] != 2)
all_done = false;
}
if (all_done)
{
state = 6;
return;
}
while(1)
{
//block_i++;
//if (block_i >= block_count)
if (block_i_meta >= slowness)
{
// if even the lowest xr is over, no blocks can fit
if (lowest_block_xr >= woodsize.x)
{
state = 5;
return;
}
blockdone[lowest_block_i] = 2;
blockpos[lowest_block_i].x = lowest_block_x;
blockpos[lowest_block_i].y = lowest_block_y;
i32vec2 dp_lu = blockpos[lowest_block_i] - millrad;
i32vec2 dp_rd = blockpos[lowest_block_i] + blocksize[lowest_block_i] + millrad;
drilling_path[drillpoint_count++] = i32vec2(dp_lu.x, dp_lu.y);
drilling_path[drillpoint_count++] = i32vec2(dp_rd.x, dp_lu.y);
drilling_path[drillpoint_count++] = i32vec2(dp_rd.x, dp_rd.y);
drilling_path[drillpoint_count++] = i32vec2(dp_lu.x, dp_rd.y);
drilling_path[drillpoint_count++] = i32vec2(dp_lu.x, dp_lu.y);
state = 0;
return;
}
block_i = rand() % block_count;
if (blockdone[block_i] == 0)
{
if (iterdir)
block_y = 0;
else
block_y = woodsize.y - blocksize[block_i].y - 1;
blockdone[block_i] = 1;
block_area = area_func(blocksize[block_i]);
//printf("this block is %i. area %i\n", block_i, block_area);
block_i_meta++;
state = 1;
return;
}
}
}
else if (state == 3)
{
printf("finished.\n");
output_gcode();
output_remaining();
state = 4;
finished_flag = true;
}
else if (state == 4)
{
}
else if (state == 5)
{
setwood(vec3(1.0f, 0.f, 0.f));
state = 3;
return;
}
else if (state == 6)
{
setwood(vec3(0.f, 1.f, 0.f));
state = 3;
return;
}
}
示例6: setwood
#include "glm/gtc/type_ptr.hpp"
using glm::i32vec2;
using glm::i32;
using glm::vec2;
using glm::vec3;
vec3 woodcolor;
static void setwood(vec3 col)
{
woodcolor = col;
glClearColor(woodcolor.x, woodcolor.y, woodcolor.z, 0.0);
}
i32vec2 woodsize = i32vec2(1000, 500);
//i32vec2 woodsize = i32vec2(800, 600);
i32 millrad = 6;
int block_count = 0;
i32vec2 *blocksize;
i32vec2 *blockpos;
int *blockdone;
i32vec2 *drilling_path;
int drillpoint_count = 0;
int slowness = 3;
static void output_gcode()