本文整理汇总了C++中vec4::normalize方法的典型用法代码示例。如果您正苦于以下问题:C++ vec4::normalize方法的具体用法?C++ vec4::normalize怎么用?C++ vec4::normalize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vec4
的用法示例。
在下文中一共展示了vec4::normalize方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: user_init
virtual void user_init()
{
tex::initialise();
msh.fill(5.0f, 2.5f, vec3::ZERO_VEC3, 90, color4::WHITE4);
Lightangx = ang = 0.0f;
fr = 0;
fpsstr = "Wait for results...";
aniso.load("aniso.tga");
texture_settings sett = { RWWM_MIRRORED_REPEAT, RWWM_CLAMP, RWWM_CLAMP,
RWMAGFT_LINEAR, RWMINFT_LINEAR, RWTIF_RGBA, RWTOF_RGBA };
aniso.generate(sett);
FONTMANAGER.add("fps", 12, "cour.ttf");
CGPROGRAMMANAGER.open_program("anisoV.cg", "basicV", RWCP_VERTEX);
CGPROGRAMMANAGER.open_program("anisoF.cg", "basicF", RWCP_FRAGMENT);
pos = vec3(8.0f, 0.0f, 0.0f);
LightDir.x = pos.x;
LightDir.y = pos.y;
LightDir.z = pos.z;
LightDir.w = 1.0f;
LightDir.normalize();
eye = vec3(0.0f, 5.0f, 30.0f);
RENDERER.disable(RWS_LIGHTING);
RENDERER.enable(RWS_TEXTURE_2D);
RENDERER.enable(RWS_DEPTH_TEST);
}
示例2:
Ray::Ray(vec4 a, vec4 b, int i) {
pos = a;
dir = b.normalize();
lastIndex = i;
}
示例3: draw
virtual void draw()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
RENDERER.identity_matrix();
gluLookAt(eye.x, eye.y, eye.z,
0.0f, 0.0f, 0.0f,
0.0f, 1.0f, 0.0f);
if (key_state('F')) ang += 0.2f;
if (key_state('V')) ang -= 0.2f;
if (key_state('Z'))
{
Lightangx += 0.1f;
pos.x = 8.0f * sinf(Lightangx);
pos.z = 8.0f * cosf(Lightangx);
LightDir.x = pos.x;
LightDir.y = pos.y;
LightDir.z = pos.z;
LightDir.w = 1.0f;
LightDir.normalize();
}
if (key_state('X'))
{
Lightangx -= 0.1f;
pos.x = 8.0f * sinf(Lightangx);
pos.z = 8.0f * cosf(Lightangx);
LightDir.x = pos.x;
LightDir.y = pos.y;
LightDir.z = pos.z;
LightDir.w = 1.0f;
LightDir.normalize();
}
if (key_state('D'))
{
pos.y += 0.2f;
LightDir.x = pos.x;
LightDir.y = pos.y;
LightDir.z = pos.z;
LightDir.w = 1.0f;
LightDir.normalize();
}
if (key_state('C'))
{
pos.y -= 0.2f;
LightDir.x = pos.x;
LightDir.y = pos.y;
LightDir.z = pos.z;
LightDir.w = 1.0f;
LightDir.normalize();
}
if (key_state('Q')) RENDERER.polygon_draw_mode(RWPS_FRONT_AND_BACK, RWPDM_LINES);
if (key_state('W')) RENDERER.polygon_draw_mode(RWPS_FRONT_AND_BACK, RWPDM_FILL);
FONTMANAGER["fps"].print(-400.0f, 330.0f, fpsstr, color4::WHITE4);
CGPROGRAMMANAGER["basicV"].enable_profile();
CGPROGRAMMANAGER["basicV"].bind_program();
CGPROGRAMMANAGER["basicF"].enable_profile();
CGPROGRAMMANAGER["basicF"].bind_program();
CGPROGRAMMANAGER["basicV"].set_parameter("EyePos", eye);
CGPROGRAMMANAGER["basicV"].set_parameter("LightVec", LightDir);
CGPROGRAMMANAGER["basicF"].set_texture("tex0", aniso.ID());
RENDERER.disable(RWS_TEXTURE_2D);
glPointSize(4.0f);
glBegin(GL_POINTS);
glVertex3f(pos.x, pos.y, pos.z);
glEnd();
RENDERER.enable(RWS_TEXTURE_2D);
RENDERER.bind_texture(RWTT_TEXTURE_2D, aniso.ID());
glPushMatrix();
glRotatef(ang, 1.0f, 0.0f, 0.0f);
CGPROGRAMMANAGER["basicV"].set_renderer_matrix("WorldViewProj");
CGPROGRAMMANAGER["basicV"].set_world_inverted_transposed_matrix("WorldIT");
CGPROGRAMMANAGER["basicV"].set_world_transposed_matrix("World");
msh.draw(CGPROGRAMMANAGER["basicV"]);
glPopMatrix();
CGPROGRAMMANAGER["basicV"].disable_profile();
CGPROGRAMMANAGER["basicF"].disable_profile();
}