本文整理汇总了C++中vec4类的典型用法代码示例。如果您正苦于以下问题:C++ vec4类的具体用法?C++ vec4怎么用?C++ vec4使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了vec4类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: addPoint
void Bounds::addPoint(const vec4& v) {
addPoint(v.xyz());
}
开发者ID:151706061,项目名称:Voreen,代码行数:3,代码来源:bounds.cpp
示例17:
vec4 operator/(vec4 left, const vec4& right)
{
return left.Divide(right);
}
开发者ID:TheCherno,项目名称:AnimatedSpriteCompression,代码行数:4,代码来源:vec4.cpp
示例18:
Ray::Ray(vec4 a, vec4 b, int i) {
pos = a;
dir = b.normalize();
lastIndex = i;
}
开发者ID:snarkworks,项目名称:Student-graphics-work,代码行数:5,代码来源:classes.cpp
示例19: clip
MeshGeometry MeshGeometry::clip(const vec4& clipplane, double epsilon) {
// Clip all faces...
for (iterator it = begin(); it != end(); ++it)
it->clip(clipplane, epsilon);
// Remove empty faces...
for (size_t i = 0; i < faces_.size(); ++i) {
// Is face empty?
if (faces_.at(i).getVertexCount() < 3)
faces_.erase(faces_.begin() + i--);
}
// Close convex polyhedron if necessary...
typedef std::pair<VertexGeometry, VertexGeometry> EdgeType;
typedef std::vector<EdgeType> EdgeListType;
typedef std::vector<VertexGeometry> VertexListType;
EdgeListType edgeList;
FaceGeometry closingFace;
// Search all face edges on the clipping plane...
for (size_t i = 0; i < faces_.size(); ++i) {
FaceGeometry face = faces_.at(i);
VertexListType verticesOnClipplane;
for (size_t j = 0; j < face.getVertexCount(); ++j) {
if (face.getVertex(j).getDistanceToPlane(clipplane, epsilon) == 0)
verticesOnClipplane.push_back(face.getVertex(j));
// Is face in the same plane as the clipping plane?
if (verticesOnClipplane.size() > 2)
break;
}
// Does one face edge corresponds with clipping plane?
if (verticesOnClipplane.size() == 2)
edgeList.push_back(std::make_pair(verticesOnClipplane[0], verticesOnClipplane[1]));
}
// Is closing necessary?
if (edgeList.size() > 1) {
// Sort edges to produce contiguous vertex order...
bool reverseLastEdge = false;
for (size_t i = 0; i < edgeList.size() - 1; ++i) {
for (size_t j = i + 1; j < edgeList.size(); ++j) {
VertexGeometry connectionVertex;
if (reverseLastEdge)
connectionVertex = edgeList.at(i).first;
else
connectionVertex = edgeList.at(i).second;
if (edgeList.at(j).first.equals(connectionVertex, epsilon)) {
std::swap(edgeList.at(i + 1), edgeList.at(j));
reverseLastEdge = false;
break;
}
else if (edgeList.at(j).second.equals(connectionVertex, epsilon)) {
std::swap(edgeList.at(i + 1), edgeList.at(j));
reverseLastEdge = true;
break;
}
}
}
// Convert sorted edge list to sorted vertex list...
VertexListType closingFaceVertices;
for (size_t i = 0; i < edgeList.size(); ++i) {
bool reverseEdge = i != 0 && !closingFaceVertices.at(closingFaceVertices.size() - 1).equals(edgeList.at(i).first);
VertexGeometry first = (reverseEdge ? edgeList.at(i).second : edgeList.at(i).first);
VertexGeometry second = (reverseEdge ? edgeList.at(i).first : edgeList.at(i).second);
if (i == 0)
closingFaceVertices.push_back(first);
else
closingFaceVertices.at(closingFaceVertices.size() - 1).combine(first);
if (i < (edgeList.size() - 1))
closingFaceVertices.push_back(second);
else
closingFaceVertices[0].combine(second);
}
// Convert vertex order to counter clockwise if necessary...
vec3 closingFaceNormal(0, 0, 0);
for (size_t i = 0; i < closingFaceVertices.size(); ++i)
closingFaceNormal += tgt::cross(closingFaceVertices[i].getCoords(), closingFaceVertices[(i + 1) % closingFaceVertices.size()].getCoords());
closingFaceNormal = tgt::normalize(closingFaceNormal);
if (tgt::dot(clipplane.xyz(), closingFaceNormal) < 0)
std::reverse(closingFaceVertices.begin(), closingFaceVertices.end());
// Close convex polyhedron...
for (VertexListType::iterator it = closingFaceVertices.begin(); it != closingFaceVertices.end(); ++it) {
// TODO(b_bolt01): Remove debug message...
//std::cout << " cfv " << it->getCoords() << std::endl;
closingFace.addVertex(*it);
}
addFace(closingFace);
//.........这里部分代码省略.........
开发者ID:marwan-abdellah,项目名称:voreen,代码行数:101,代码来源:meshgeometry.cpp
示例20:
double vec4::operator<=(const vec4& v)
{
return this->length()<=v.length();
}
开发者ID:jmoborn,项目名称:fluid-solver,代码行数:4,代码来源:vec4.cpp
注:本文中的vec4类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论