本文整理汇总了C++中Vec4f函数的典型用法代码示例。如果您正苦于以下问题:C++ Vec4f函数的具体用法?C++ Vec4f怎么用?C++ Vec4f使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Vec4f函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: set_batcher_active
void RenderBatchTriangle::fill(const CanvasPtr &canvas, float x1, float y1, float x2, float y2, const Colorf &color)
{
int texindex = set_batcher_active(canvas);
vertices[position + 0].position = to_position(x1, y1);
vertices[position + 1].position = to_position(x2, y1);
vertices[position + 2].position = to_position(x1, y2);
vertices[position + 3].position = to_position(x2, y1);
vertices[position + 4].position = to_position(x2, y2);
vertices[position + 5].position = to_position(x1, y2);
for (int i = 0; i < 6; i++)
{
vertices[position + i].color = Vec4f(color.x, color.y, color.z, color.w);
vertices[position + i].texcoord = Vec2f(0.0f, 0.0f);
vertices[position + i].texindex = texindex;
}
position += 6;
}
示例2: Plane
void Frustum::buildViewFrustum( const Matrix4f &viewMat, const Matrix4f &projMat )
{
// This routine works with the OpenGL projection matrix
// The view matrix is the inverse camera transformation matrix
// Note: Frustum corners are not updated!
Matrix4f m = projMat * viewMat;
_planes[0] = Plane( -(m.c[0][3] + m.c[0][0]), -(m.c[1][3] + m.c[1][0]),
-(m.c[2][3] + m.c[2][0]), -(m.c[3][3] + m.c[3][0]) ); // Left
_planes[1] = Plane( -(m.c[0][3] - m.c[0][0]), -(m.c[1][3] - m.c[1][0]),
-(m.c[2][3] - m.c[2][0]), -(m.c[3][3] - m.c[3][0]) ); // Right
_planes[2] = Plane( -(m.c[0][3] + m.c[0][1]), -(m.c[1][3] + m.c[1][1]),
-(m.c[2][3] + m.c[2][1]), -(m.c[3][3] + m.c[3][1]) ); // Bottom
_planes[3] = Plane( -(m.c[0][3] - m.c[0][1]), -(m.c[1][3] - m.c[1][1]),
-(m.c[2][3] - m.c[2][1]), -(m.c[3][3] - m.c[3][1]) ); // Top
_planes[4] = Plane( -(m.c[0][3] + m.c[0][2]), -(m.c[1][3] + m.c[1][2]),
-(m.c[2][3] + m.c[2][2]), -(m.c[3][3] + m.c[3][2]) ); // Near
_planes[5] = Plane( -(m.c[0][3] - m.c[0][2]), -(m.c[1][3] - m.c[1][2]),
-(m.c[2][3] - m.c[2][2]), -(m.c[3][3] - m.c[3][2]) ); // Far
_origin = viewMat.inverted() * Vec3f( 0, 0, 0 );
// Calculate corners
Matrix4f mm = m.inverted();
Vec4f corner = mm * Vec4f( -1, -1, 1, 1 );
_corners[0] = Vec3f( corner.x / corner.w, corner.y / corner.w, corner.z / corner.w );
corner = mm * Vec4f( 1, -1, 1, 1 );
_corners[1] = Vec3f( corner.x / corner.w, corner.y / corner.w, corner.z / corner.w );
corner = mm * Vec4f( 1, 1, 1, 1 );
_corners[2] = Vec3f( corner.x / corner.w, corner.y / corner.w, corner.z / corner.w );
corner = mm * Vec4f( -1, 1, 1, 1 );
_corners[3] = Vec3f( corner.x / corner.w, corner.y / corner.w, corner.z / corner.w );
corner = mm * Vec4f( -1, -1, -1, 1 );
_corners[4] = Vec3f( corner.x / corner.w, corner.y / corner.w, corner.z / corner.w );
corner = mm * Vec4f( 1, -1, -1, 1 );
_corners[5] = Vec3f( corner.x / corner.w, corner.y / corner.w, corner.z / corner.w );
corner = mm * Vec4f( 1, 1, -1, 1 );
_corners[6] = Vec3f( corner.x / corner.w, corner.y / corner.w, corner.z / corner.w );
corner = mm * Vec4f( -1, 1, -1, 1 );
_corners[7] = Vec3f( corner.x / corner.w, corner.y / corner.w, corner.z / corner.w );
}
示例3: Vec4f
Vec3f Matrix4::TransformNormal(const Vec3f &Normal) const
{
Vec4f UnprojectedResult = Vec4f(Normal, 0.0f) * (*this);
if(UnprojectedResult.w == 0.0f)
{
UnprojectedResult.w = 1.0f;
}
Vec3f Result(UnprojectedResult.x / UnprojectedResult.w,
UnprojectedResult.y / UnprojectedResult.w,
UnprojectedResult.z / UnprojectedResult.w);
if(UnprojectedResult.w < 0.0f)
{
Result = -Result;
}
return Result;
}
示例4: Cedric_TransformVerts
/*!
* Transform object vertices
*/
static void Cedric_TransformVerts(EERIE_3DOBJ * eobj, const Vec3f & pos) {
Skeleton & rig = *eobj->m_skeleton;
// Transform & project all vertices
for(size_t i = 0; i != rig.bones.size(); i++) {
Bone & bone = rig.bones[i];
glm::mat4x4 matrix = glm::toMat4(bone.anim.quat);
// Apply Scale
matrix[0][0] *= bone.anim.scale.x;
matrix[0][1] *= bone.anim.scale.x;
matrix[0][2] *= bone.anim.scale.x;
matrix[1][0] *= bone.anim.scale.y;
matrix[1][1] *= bone.anim.scale.y;
matrix[1][2] *= bone.anim.scale.y;
matrix[2][0] *= bone.anim.scale.z;
matrix[2][1] *= bone.anim.scale.z;
matrix[2][2] *= bone.anim.scale.z;
Vec3f vector = bone.anim.trans;
for(size_t v = 0; v != bone.idxvertices.size(); v++) {
size_t index = bone.idxvertices[v];
Vec3f & inVert = eobj->vertexlocal[index];
EERIE_VERTEX & outVert = eobj->vertexlist3[index];
outVert.v = Vec3f(matrix * Vec4f(inVert, 1.f));
outVert.v += vector;
outVert.vert.p = outVert.v;
}
}
if(eobj->sdata) {
for(size_t i = 0; i < eobj->vertexlist.size(); i++) {
eobj->vertexlist[i].vert.p = eobj->vertexlist3[i].v - pos;
}
}
}
示例5: Mat4x4f
void PointLight::setupLight(unsigned int glLightId)
{
Transform & transform = *(object.getComponent<Transform>());
Mat4x4f localToWorld = Mat4x4f(transform.getLocalToWorld());
Vec4f position = localToWorld * Vec4f(0,0,0,1);
GLfloat pos[] = { position[0], position[1], position[2], 1 };
glLightfv(glLightId, GL_POSITION, pos);
GLfloat ambientLight[] = { 0.0f, 0.0f, 0.0f, 1.0f };
GLfloat diffuseLight[] = { 1.0f, 1.0f, 1.0f, 1.0f };
GLfloat specularLight[] = { 1.0f, 1.0f, 1.0f, 1.0f };
// Assign created components to GL_LIGHT_?
glLightfv(glLightId, GL_AMBIENT, ambientLight);
glLightfv(glLightId, GL_DIFFUSE, diffuseLight);
glLightfv(glLightId, GL_SPECULAR, specularLight);
}
示例6: if
Vec4f Meteor::getColorFromName(QString colorName)
{
int R, G, B; // 0-255
if (colorName == "violet")
{ // Calcium
R = 176;
G = 67;
B = 172;
}
else if (colorName == "blueGreen")
{ // Magnesium
R = 0;
G = 255;
B = 152;
}
else if (colorName == "yellow")
{ // Iron
R = 255;
G = 255;
B = 0;
}
else if (colorName == "orangeYellow")
{ // Sodium
R = 255;
G = 160;
B = 0;
}
else if (colorName == "red")
{ // atmospheric nitrogen and oxygen
R = 255;
G = 30;
B = 0;
}
else
{ // white
R = 255;
G = 255;
B = 255;
}
return Vec4f(R/255.f, G/255.f, B/255.f, 1);
}
示例7: Perlin
void LSystem::updateList() {
mPerlin = Perlin( 8, Rand::randInt( 0, 100000 ) );
mSteps = mProduction.length();
if( mSteps > mProduction.length() ) {
mSteps = mProduction.length();
}
gl::pushModelView();
gl::translate( mLoc );
gl::pushModelView();
int countFood = 0;
for( int i = 0; i < mSteps; i++ ) {
char step = mProduction.at(i);
if( step == 'F' || step == '|' ) {
Vec2f current_loc = (gl::getModelView() * Vec4f( 0.0f, 0.0f, 0.0f, 1.0f )).xy();
current_loc -= mStartLength;
current_loc += mLoc;
boost::shared_ptr<Food> add_food( new Food( current_loc, ColorA( ColorA::black() ) ) );
mFood.push_back( add_food );
if( countFood > 0 ) {
boost::weak_ptr<Food> weakFood(add_food);
mFood[countFood-1]->setNext( weakFood );
}
countFood++;
gl::translate( 0, -mDrawLength + mPerlin.fBm( app::getElapsedFrames()*1.0f, i, 0.001f )*20000.0f );
}
else if( step == '+' ) {
gl::rotate( mTheta + mPerlin.fBm( app::getElapsedFrames()*1.0f, i, 0.001f )*(2000.0f * i/30.0f));
}
else if( step == '-' ) {
gl::rotate( -1*(mTheta + mPerlin.fBm( app::getElapsedFrames()*1.0f, i, 0.001f )*(2000.0f * i/30.0f)));
}
else if( step == '[' ) {
gl::pushModelView();
}
else if( step == ']' ) {
gl::popModelView();
}
}
gl::popModelView();
gl::popModelView();
}
示例8: gaussianBlurV
static void gaussianBlurV(const T * __srcp, float * dstp, const float * weights, const int width, const int height, const int srcStride, const int dstStride,
const int radius, const float offset) noexcept {
const int diameter = radius * 2 + 1;
const T ** _srcp = new const T *[diameter];
_srcp[radius] = __srcp;
for (int i = 1; i <= radius; i++) {
_srcp[radius - i] = _srcp[radius - 1 + i];
_srcp[radius + i] = _srcp[radius] + srcStride * i;
}
for (int y = 0; y < height; y++) {
for (int x = 0; x < width; x += 4) {
Vec4f sum = zero_4f();
for (int i = 0; i < diameter; i++) {
if (std::is_same<T, uint8_t>::value) {
const Vec4f srcp = to_float(Vec4i().load_4uc(_srcp[i] + x));
sum = mul_add(srcp, weights[i], sum);
} else if (std::is_same<T, uint16_t>::value) {
const Vec4f srcp = to_float(Vec4i().load_4us(_srcp[i] + x));
sum = mul_add(srcp, weights[i], sum);
} else {
const Vec4f srcp = Vec4f().load_a(_srcp[i] + x);
sum = mul_add(srcp + offset, weights[i], sum);
}
}
sum.stream(dstp + x);
}
for (int i = 0; i < diameter - 1; i++)
_srcp[i] = _srcp[i + 1];
if (y < height - 1 - radius)
_srcp[diameter - 1] += srcStride;
else if (y > height - 1 - radius)
_srcp[diameter - 1] -= srcStride;
dstp += dstStride;
}
delete[] _srcp;
}
示例9: getSppCount
void UniformResamplingRecursiveMISBPTRenderer::processTile(uint32_t threadID, uint32_t tileID, const Vec4u& viewport) const {
auto spp = getSppCount();
TileProcessingRenderer::processTilePixels(viewport, [&](uint32_t x, uint32_t y) {
auto pixelID = getPixelIndex(x, y);
// Add a new sample to the pixel
for(auto i = 0u; i <= getFramebuffer().getChannelCount(); ++i) {
accumulate(i, pixelID, Vec4f(0, 0, 0, 1));
}
// Process each sample
for(auto sampleID = 0u; sampleID < spp; ++sampleID) {
processSample(threadID, tileID, pixelID, sampleID, x, y);
}
});
// Compute contributions for 1-length eye paths (connection to sensor)
connectLightVerticesToSensor(threadID, tileID, viewport);
}
示例10: invariant
void StelQGLRenderer::drawWindow(StelViewportEffect* const effect)
{
// At this point, FBOs have been released (if using FBOs), so we're drawing
// directly to the screen. The StelViewportEffect::drawToViewport call
// actually draws puts the rendered result onto the viewport.
invariant();
//Warn about any GL errors.
checkGLErrors("drawWindow() start");
//Effects are ignored when FBO is not supported.
//That might be changed for some GPUs, but it might not be worth the effort.
viewport.prepareToDrawViewport();
if(NULL == effect)
{
// If using FBO, we still need to put it on the screen.
if(viewport.useFBO())
{
StelTextureNew* screenTexture = getViewportTexture();
const QSize size = screenTexture->getDimensions();
glDisable(GL_BLEND);
setGlobalColor(Vec4f(1.0f, 1.0f, 1.0f, 1.0f));
screenTexture->bind();
drawTexturedRect(0, 0, size.width(), size.height());
delete screenTexture;
}
// If not using FBO, the result is already drawn to the screen.
}
else
{
effect->drawToViewport(this);
}
viewport.disablePainting();
checkGLErrors("drawWindow() end");
invariant();
}
示例11: RainParticleSystem
void MenuBackground::createRainParticleSystem() {
//printf("In MenuBackground::createRainParticleSystem() rps = %p\n",rps);
if(rps == NULL) {
rps= new RainParticleSystem();
rps->setSpeed(12.f/GameConstants::updateFps);
rps->setEmissionRate(25);
rps->setWind(-90.f, 4.f/GameConstants::updateFps);
rps->setPos(Vec3f(0.f, 25.f, 0.f));
rps->setColor(Vec4f(1.f, 1.f, 1.f, 0.2f));
rps->setRadius(30.f);
Renderer &renderer= Renderer::getInstance();
renderer.manageParticleSystem(rps, rsMenu);
for(int i=0; i<raindropCount; ++i){
raindropStates[i]= random.randRange(0.f, 1.f);
raindropPos[i]= computeRaindropPos();
}
}
}
示例12: msg
render::Mesh MorphableModel::drawSample(vector<float> shapeCoefficients, vector<float> colorCoefficients)
{
render::Mesh mean;
mean.tvi = shapeModel.getTriangleList();
mean.tci = colorModel.getTriangleList();
Mat shapeSample;
Mat colorSample;
if (shapeCoefficients.empty()) {
shapeSample = shapeModel.getMean();
} else {
shapeSample = shapeModel.drawSample(shapeCoefficients);
}
if (colorCoefficients.empty()) {
colorSample = colorModel.getMean();
} else {
colorSample = colorModel.drawSample(colorCoefficients);
}
unsigned int numVertices = shapeModel.getDataDimension() / 3;
unsigned int numVerticesColor = colorModel.getDataDimension() / 3;
if (numVertices != numVerticesColor) {
string msg("MorphableModel: The number of vertices of the shape and color models are not the same: " + lexical_cast<string>(numVertices) + " != " + lexical_cast<string>(numVerticesColor));
Loggers->getLogger("shapemodels").debug(msg);
throw std::runtime_error(msg);
}
mean.vertex.resize(numVertices);
for (unsigned int i = 0; i < numVertices; ++i) {
mean.vertex[i].position = Vec4f(shapeSample.at<float>(i*3 + 0), shapeSample.at<float>(i*3 + 1), shapeSample.at<float>(i*3 + 2), 1.0f);
mean.vertex[i].color = Vec3f(colorSample.at<float>(i*3 + 0), colorSample.at<float>(i*3 + 1), colorSample.at<float>(i*3 + 2)); // order in hdf5: RGB. Order in OCV: BGR. But order in vertex.color: RGB
}
mean.hasTexture = false;
return mean;
}
示例13: UniTransform3fDirection
void UniTransform3fDirection(const UniTransform3f& transf,const Direction3f& direction, Direction3f* outDirection) {
//reference: pag. 200 Essential Mathematics for Games and Interactive Applications A Programmer’s Guide Second Edition
//outDirection = quat * (scale * direction) * inverseQuaternion + translate
Vec4f scaleD = Vec4f(transf.scale * direction.dir.x, transf.scale * direction.dir.y, transf.scale * direction.dir.z, 0.f);
Quatf quatD;
QuatfInitWithValues(scaleD.x, scaleD.y, scaleD.z, 0.f, &quatD);
Quatf ris;
QuatfMult(transf.rotation, quatD, &ris);
Quatf invquat;
QuatfInverse(transf.rotation, &invquat);
Quatf ris1;
QuatfMult(ris, invquat, &ris1);
//traslation don't change direction
outDirection->dir.x = ris1.qX; //+ transf.translation.x;
outDirection->dir.y = ris1.qY; //+ transf.translation.y;
outDirection->dir.z = ris1.qZ; //+ transf.translation.z;
}
示例14: UniTransform3fPoint
void UniTransform3fPoint(const UniTransform3f& transf,const Point3f& point, Point3f* outPoint) {
//reference: pag. 200 Essential Mathematics for Games and Interactive Applications A Programmer’s Guide Second Edition
//outPoint = quat * (scale * point) * inverseQuaternion + translate
//scaleP = scale * point
Vec4f scaleP = Vec4f(transf.scale * point.point.x, transf.scale * point.point.y, transf.scale * point.point.z, 1.f);
Quatf quatP;
QuatfInitWithValues(scaleP.x, scaleP.y, scaleP.z, 0.f, &quatP);
Quatf ris;
QuatfMult(transf.rotation, quatP, &ris);
Quatf invquat;
QuatfInverse(transf.rotation, &invquat);
Quatf ris1;
QuatfMult(ris, invquat, &ris1);
outPoint->point.x = ris1.qX + transf.translation.x;
outPoint->point.y = ris1.qY + transf.translation.y;
outPoint->point.z = ris1.qZ + transf.translation.z;
}
示例15: Vec4f
bool Program::update()
{
GraphicContext gc = window.get_gc();
InputDevice mouse = window.get_ic().get_mouse();
float time = System::get_time() / 1000.0f;
uniforms.time = time;
auto pos = mouse.get_position();
uniforms.mouse = Vec4f(pos.x / 800.0f, pos.y / 600.0f, 0, 0);
for(int i=0; i< uniforms.particle_count; ++i)
{
uniforms.positions[i].x += sinf(time + i * 2.0f) / 40.0f;
uniforms.positions[i].y += cosf(time + i * 2.0f) / 40.0f;
}
uniformVector.upload_data(gc, &uniforms, 1);
effect.draw(gc);
window.flip(1);
return !exit;
}