当前位置: 首页>>代码示例>>C++>>正文


C++ vec4类代码示例

本文整理汇总了C++中vec4的典型用法代码示例。如果您正苦于以下问题:C++ vec4类的具体用法?C++ vec4怎么用?C++ vec4使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了vec4类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: mouse_pos

vec3 Camera::pickAgainstPlane(float x, float y, vec4 plane)
{
    float nxPos = x / 1280.0f; //replace these with your screen width and height
    float nyPos = y / 720.0f;

    float sxPos = nxPos - 0.5f;
    float syPos = nyPos - 0.5f;

    float fxPos = sxPos * 2;
    float fyPos = syPos * -2;

    mat4 inv_viewproj = glm::inverse(view_proj); //view_proj is the memeber variable

    vec4 mouse_pos(fxPos, fyPos, 1, 1);
    vec4 world_pos = inv_viewproj * mouse_pos;

    world_pos /= world_pos.w;

    vec3 cam_pos = world[3].xyz(); //world is the member variable
    vec3 dir = world_pos.xyz() - cam_pos;

    float t = -(glm::dot(cam_pos, plane.xyz()) + plane.w)
        / (glm::dot(dir, plane.xyz()));

    vec3 result = cam_pos + dir * t;

    return result;
}
开发者ID:RoyKirk,项目名称:AIEWork,代码行数:28,代码来源:Camera.cpp

示例2:

vec3 vec3::rotate(const vec4&v) const
{
    vec4 i = v.conjugate();
    i.normalize();
    vec4 t = v.multiply(*this);
    vec4 f = t.multiply(i);
    return vec3(f.x, f.y, f.w);
}
开发者ID:neosuperprogrammer,项目名称:nbBlender,代码行数:8,代码来源:nbVector.cpp

示例3: outer_product

mat4 outer_product( const vec4& a, const vec4& b )
{
	mat4 o;
	m128_t* const o128 = o.m128();
	o128[0] = SLMATH_MUL_PS( SLMATH_LOAD_PS1(&a[0]), b.m128() );
	o128[1] = SLMATH_MUL_PS( SLMATH_LOAD_PS1(&a[1]), b.m128() );
	o128[2] = SLMATH_MUL_PS( SLMATH_LOAD_PS1(&a[2]), b.m128() );
	o128[3] = SLMATH_MUL_PS( SLMATH_LOAD_PS1(&a[3]), b.m128() );
	return o;
}
开发者ID:kajala,项目名称:slmath,代码行数:10,代码来源:mat4.cpp

示例4:

vec4 sm4::operator * (vec4 v) {
  vec4 r;

  r.x = v.dot(getColumn(0));
  r.y = v.dot(getColumn(1));
  r.z = v.dot(getColumn(2));
  r.w = v.dot(getColumn(3));

  return r;
}
开发者ID:felipetavares,项目名称:rendertri,代码行数:10,代码来源:sm4.cpp

示例5: materialDiffuse

bool
GroundRenderer::setup(const mat4& projection, unsigned int texture)
{
    projection_ = projection;
    texture_ = texture;

    // Program set up
    static const vec4 materialDiffuse(0.3f, 0.3f, 0.3f, 1.0f);
    static const string vtx_shader_filename(GLMARK_DATA_PATH"/shaders/shadow.vert");
    static const string frg_shader_filename(GLMARK_DATA_PATH"/shaders/shadow.frag");
    ShaderSource vtx_source(vtx_shader_filename);
    ShaderSource frg_source(frg_shader_filename);

    vtx_source.add_const("MaterialDiffuse", materialDiffuse);

    if (!Scene::load_shaders_from_strings(program_, vtx_source.str(), frg_source.str())) {
        return false;
    }
    positionLocation_ = program_["position"].location();

    // Set up the position data for our "quad".
    vertices_.push_back(vec2(-1.0, -1.0));
    vertices_.push_back(vec2(1.0, -1.0));
    vertices_.push_back(vec2(-1.0, 1.0));
    vertices_.push_back(vec2(1.0, 1.0));

    // Set up the VBO and stash our position data in it.
    glGenBuffers(1, &bufferObject_);
    glBindBuffer(GL_ARRAY_BUFFER, bufferObject_);
    glBufferData(GL_ARRAY_BUFFER, vertices_.size() * sizeof(vec2),
                 &vertices_.front(), GL_STATIC_DRAW);
    glBindBuffer(GL_ARRAY_BUFFER, 0);

    // Set up the light matrix with a bias that will convert values
    // in the range of [-1, 1] to [0, 1)], then add in the projection
    // and the "look at" matrix from the light position.
    light_ *= LibMatrix::Mat4::translate(0.5, 0.5, 0.5);
    light_ *= LibMatrix::Mat4::scale(0.5, 0.5, 0.5);
    light_ *= projection_;
    light_ *= LibMatrix::Mat4::lookAt(lightPosition.x(), lightPosition.y(), lightPosition.z(),
                                      0.0, 0.0, 0.0,
                                      0.0, 1.0, 0.0);

    return true;
}
开发者ID:arthurfait,项目名称:glmark2-wl,代码行数:45,代码来源:scene-shadow.cpp

示例6:

void SceneObject::getLightSource1(SceneObjects& sceneObjectColl, vec4& from, vec4& to)
{
	from.set(0);
	to.set(0);

	// let them update model matrix, we'll take translation as mesh centre
	getRoot(sceneObjectColl).update(0, mat4(), mat4());

	// these are mark meshes, not for display, but for light source
	SceneObjects::iterator _from = sceneObjectColl.find("light1/from"), _to = sceneObjectColl.find("light1/to"), light1 = sceneObjectColl.find("light1");
	if(sceneObjectColl.end() == _from || sceneObjectColl.end() == _to || sceneObjectColl.end() == light1)
		return;

	mcemaths_quatcpy(from, &_from->second.m_model[12]);
	mcemaths_quatcpy(to, &_to->second.m_model[12]);
	from.w = to.w = 0;

	light1->second.m_children.clear();
	sceneObjectColl.erase(_from);
	sceneObjectColl.erase(_to);
}
开发者ID:FMX,项目名称:Puresoft3D,代码行数:21,代码来源:loadscene.cpp

示例7: setUniformDirectly

void Program::setUniformDirectly(int nLoc, uint32_t type, const vec4& value)
{
#if !defined(ET_CONSOLE_APPLICATION)
	if (nLoc == -1) return;
	
	(void)type;
	ET_ASSERT(type == GL_FLOAT_VEC4);
	ET_ASSERT(apiHandleValid());
	
	glUniform4fv(nLoc, 1, value.data());
	checkOpenGLError("glUniform4fv");
#endif
}
开发者ID:Loki7979,项目名称:et-engine,代码行数:13,代码来源:program.cpp

示例8:

// Transform (i.e. multiply) a vector by this matrix.
void 
mat4::transform3 (vec4 &v) const
{
  vec4 aux;
  const float *m = this->m_Matrix;

  aux.x = (v.x * m[0]) + (v.y * m[4]) + (v.z * m[8]) ;
  aux.y = (v.x * m[1]) + (v.y * m[5]) + (v.z * m[9]) ;
  aux.z = (v.x * m[2]) + (v.y * m[6]) + (v.z * m[10]);
  aux.w = v.w;
  v.copy(aux);
  
  return;
}
开发者ID:pspkzar,项目名称:Ray-Tracing-plus-Rasterization,代码行数:15,代码来源:mat4.cpp

示例9: assert

void Program::setUniform(int nLoc, uint32_t type, const vec4& value, bool forced)
{
	if (nLoc == -1) return;
	
	(void)type;
	assert(type == GL_FLOAT_VEC4);
	assert(loaded());
	
	if (forced || ((_vec4Cache.count(nLoc) == 0) || (_vec4Cache[nLoc] != value)))
	{
		_vec4Cache[nLoc] = value;
		glUniform4fv(nLoc, 1, value.data());
	}
	
	checkOpenGLError("setUniform - vec4");
}
开发者ID:celesius,项目名称:et-engine,代码行数:16,代码来源:program.cpp

示例10: ET_ASSERT

void Program::setUniform(int nLoc, uint32_t type, const vec4& value, bool forced)
{
#if !defined(ET_CONSOLE_APPLICATION)
	if (nLoc == -1) return;
	
	(void)type;
	ET_ASSERT(type == GL_FLOAT_VEC4);
	ET_ASSERT(apiHandleValid());
	
	if (forced || ((_vec4Cache.count(nLoc) == 0) || (_vec4Cache[nLoc] != value)))
	{
		_vec4Cache[nLoc] = value;
		glUniform4fv(nLoc, 1, value.data());
		checkOpenGLError("glUniform4fv");
	}
	
#endif
}
开发者ID:Loki7979,项目名称:et-engine,代码行数:18,代码来源:program.cpp

示例11: RenderAAQuadAlongXNinePatch

void Mesh::RenderAAQuadAlongXNinePatch(const vec3 &bottom_left,
                                       const vec3 &top_right,
                                       const vec2i &texture_size,
                                       const vec4 &patch_info) {
  static const Attribute format[] = {kPosition3f, kTexCoord2f, kEND};
  static const unsigned short indices[] = {
      0, 2, 1,  1,  2, 3,  2, 4,  3,  3,  4,  5,  4,  6,  5,  5,  6,  7,
      1, 3, 8,  8,  3, 9,  3, 5,  9,  9,  5,  10, 5,  7,  10, 10, 7,  11,
      8, 9, 12, 12, 9, 13, 9, 10, 13, 13, 10, 14, 10, 11, 14, 14, 11, 15,
  };
  auto max = vec2::Max(bottom_left.xy(), top_right.xy());
  auto min = vec2::Min(bottom_left.xy(), top_right.xy());
  auto p0 = vec2(texture_size) * patch_info.xy() + min;
  auto p1 = max - vec2(texture_size) * (mathfu::kOnes2f - patch_info.zw());

  // Check if the 9 patch edges are not overwrapping.
  // In that case, adjust 9 patch geometry locations not to overwrap.
  if (p0.x() > p1.x()) {
    p0.x() = p1.x() = (min.x() + max.x()) / 2;
  }
  if (p0.y() > p1.y()) {
    p0.y() = p1.y() = (min.y() + max.y()) / 2;
  }

  // vertex format is [x, y, z] [u, v]:
  float z = bottom_left.z();
  // clang-format off
  const float vertices[] = {
      min.x(), min.y(), z, 0.0f,           0.0f,
      p0.x(),  min.y(), z, patch_info.x(), 0.0f,
      min.x(), p0.y(),  z, 0.0f,           patch_info.y(),
      p0.x(),  p0.y(),  z, patch_info.x(), patch_info.y(),
      min.x(), p1.y(),  z, 0.0,            patch_info.w(),
      p0.x(),  p1.y(),  z, patch_info.x(), patch_info.w(),
      min.x(), max.y(), z, 0.0,            1.0,
      p0.x(),  max.y(), z, patch_info.x(), 1.0,
      p1.x(),  min.y(), z, patch_info.z(), 0.0f,
      p1.x(),  p0.y(),  z, patch_info.z(), patch_info.y(),
      p1.x(),  p1.y(),  z, patch_info.z(), patch_info.w(),
      p1.x(),  max.y(), z, patch_info.z(), 1.0f,
      max.x(), min.y(), z, 1.0f,           0.0f,
      max.x(), p0.y(),  z, 1.0f,           patch_info.y(),
      max.x(), p1.y(),  z, 1.0f,           patch_info.w(),
      max.x(), max.y(), z, 1.0f,           1.0f,
  };
  // clang-format on
  Mesh::RenderArray(kTriangles, 6 * 9, format, sizeof(float) * 5,
                    reinterpret_cast<const char *>(vertices), indices);
}
开发者ID:ezhangle,项目名称:fplbase,代码行数:49,代码来源:mesh.cpp

示例12: randomHemispherePoint

vec3 randomHemispherePoint(vec4 normal) {
	return randomHemispherePoint(normal.dehomogenize());
}
开发者ID:snarkworks,项目名称:Student-graphics-work,代码行数:3,代码来源:util.cpp

示例13: randomCirclePoint

vec4 randomCirclePoint(vec4 normal) {
	return randomCirclePoint(normal.dehomogenize());
}
开发者ID:snarkworks,项目名称:Student-graphics-work,代码行数:3,代码来源:util.cpp

示例14:

void Graphics::setFloat4(ConstantLocation position, vec4 value) {
	setFloat4(position, value.x(), value.y(), value.z(), value.w());
}
开发者ID:luboslenco,项目名称:blenderbackend_kha,代码行数:3,代码来源:Graphics.cpp

示例15: barycentric

vec3 barycentric(vec4 v1, vec4 v2, vec4 v3, vec4 hitPoint) {
	return barycentric(v1.dehomogenize(), v2.dehomogenize(), v3.dehomogenize(), hitPoint.dehomogenize());
}
开发者ID:snarkworks,项目名称:Student-graphics-work,代码行数:3,代码来源:util.cpp


注:本文中的vec4类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。