本文整理汇总了C++中Vector4D函数的典型用法代码示例。如果您正苦于以下问题:C++ Vector4D函数的具体用法?C++ Vector4D怎么用?C++ Vector4D使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Vector4D函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Vector4D
void matrix4x4::Identity( void )
{
mat[0] = Vector4D( 1, 0, 0, 0 );
mat[1] = Vector4D( 0, 1, 0, 0 );
mat[2] = Vector4D( 0, 0, 1, 0 );
mat[3] = Vector4D( 0, 0, 0, 1 );
}
示例2: glLightf
// functie care plaseaza efectivl umina in scena
void Light::Render()
{
// atenuari standard
glLightf(GL_LIGHT0 + id,GL_CONSTANT_ATTENUATION,1);
glLightf(GL_LIGHT0 + id,GL_LINEAR_ATTENUATION,0.2f);
// culoarea luminii
glLightfv(GL_LIGHT0 + id, GL_DIFFUSE, Vector4D(diffuse.x, diffuse.y, diffuse.z, diffuse.a).Array());
// culoarea ambientala
glLightfv(GL_LIGHT0 + id, GL_AMBIENT, ambient.Array());
// culoarea speculara
glLightfv(GL_LIGHT0 + id, GL_SPECULAR, specular.Array());
// pozitia luminii
glLightfv(GL_LIGHT0 + id, GL_POSITION, Vector4D(translation.x,translation.y,translation.z,1).Array());
// daca este de tip spot , setam parametrii de spot ( se vor folosi valori default )
if(LightType == IlluminationType::Spot)
{
// directia spotului va fi in jos
glLightfv(GL_LIGHT0 + id , GL_SPOT_DIRECTION, (Vector3D(-1.0,0.0,0.0)).Array());
// deschidere de 45 de grade
glLightf(GL_LIGHT0 + id , GL_SPOT_CUTOFF, 45.0);
glLightf(GL_LIGHT0 + id , GL_SPOT_EXPONENT, 2);
}
// activam lumina
glEnable(GL_LIGHT0 + id);
}
示例3: Vector4D
void Box::Init()
{
m_MeshData = (char*)malloc(sizeof(Avni_Vertex_pos_diffuse)*4);
Avni_Vertex_pos_diffuse* mesh = (Avni_Vertex_pos_diffuse*)(m_MeshData);
Avni_Vertex_pos_diffuse vert[4];
vert[0].vertex = Vector4D(-1.0f, 1.0f, 0.0f,1.0f);
vert[1].vertex = Vector4D( 1.0f, 1.0f, 0.0f,1.0f);
vert[2].vertex = Vector4D( 1.0f,-1.0f, 0.0f,1.0f);
vert[3].vertex = Vector4D(-1.0f,-1.0f, 0.0f,1.0f);
vert[0].diffuseColor = Vector3D(1.0f,0.0f,0.0f);
vert[1].diffuseColor = Vector3D(0.0f,1.0f,0.0f);
vert[2].diffuseColor = Vector3D(0.0f,0.0f,1.0f);
vert[3].diffuseColor = Vector3D(1.0f,0.0f,1.0f);
u32 indices[] =
{
0, 1, 3,
3, 1, 2,
};
m_Mesh = SINGLETONMANAGER->GetRenderer()->CreateMesh(VERTEXTYPE_POS_DIFFUSE, 4, vert,indices, 6);
m_Material = SINGLETONMANAGER->GetMaterialManager()->GetMaterial(MATERIALNAME_BASIC);
}
示例4: a4_get_unproject_matrix
Matrix4x4 a4_get_unproject_matrix(int width, int height, double fov, double d, Point3D eye, Vector3D view, Vector3D up)
{
double fov_r = fov * M_PI / 180.0;
double h = 2.0*d*tan(fov_r / 2.0); // height of projection plane based field of view and distance to the plane
// First translate the pixel so that it is centered at the origin in the projection plane (origin is in the middle of the screen)
Matrix4x4 viewport_translate = Matrix4x4().translate(-(double)width / 2.0, -(double)height / 2.0, d);
// Then scale it to the projection plane such that aspect ratio is maintained and we have a right handed coordinate system
Matrix4x4 viewport_scale = Matrix4x4().scale(-h / (double)height, -h / (double)height, 1.0);
// Calculate the basis for the view coordinate system
view.normalize();
up.normalize();
Vector3D u = up.cross(view);
u.normalize();
Vector3D v = view.cross(u);
v.normalize();
// Create the view rotation and translation matrix
Matrix4x4 view_rotate = Matrix4x4(Vector4D(u, 0.0), Vector4D(v, 0.0), Vector4D(view, 0.0), Vector4D(0.0, 0.0, 0.0, 1.0)).transpose();
Matrix4x4 view_translate = Matrix4x4().translate(Vector3D(eye));
// Now multiply these together to form the pixel to 3D point transformation matrix
Matrix4x4 unproject = view_translate * view_rotate * viewport_scale * viewport_translate;
return unproject;
}
示例5: Matrix4x4
void SceneNode::scale(const Vector3D& amount)
{
Matrix4x4 t = Matrix4x4(
Vector4D(amount[0], 0.0, 0.0, 0.0),
Vector4D(0.0, amount[1], 0.0, 0.0),
Vector4D(0.0, 0.0, amount[2], 0.0),
Vector4D(0.0, 0.0, 0.0, 1.0)
);
set_transform(m_trans * t);
}
示例6: Vector4D
int COpenGLGrassRenderer::Sorter::compareElements( SGPVertex_GRASS_Cluster first, SGPVertex_GRASS_Cluster second ) noexcept
{
float firstDistance = -(m_pRD->getOpenGLCamera()->m_CameraPos - Vector4D(first.vPosition[0], first.vPosition[1], first.vPosition[2])).GetLengthSquared();
float secondDistance = -(m_pRD->getOpenGLCamera()->m_CameraPos - Vector4D(second.vPosition[0], second.vPosition[1], second.vPosition[2])).GetLengthSquared();
if( firstDistance < secondDistance )
return -1;
if( firstDistance > secondDistance )
return 1;
return 0;
}
示例7: Vector4D
Matrix4D::Matrix4D( float m00, float m10, float m20, float m30,
float m01, float m11, float m21, float m31,
float m02, float m12, float m22, float m32,
float m03, float m13, float m23, float m33 )
{
m[0] = Vector4D( m00, m10, m20, m30 );
m[1] = Vector4D( m01, m11, m21, m31 );
m[2] = Vector4D( m02, m12, m22, m32 );
m[3] = Vector4D( m03, m13, m23, m33 );
}
示例8: Vector4D
void CustomObject3D::setDefault()
{
// Default lighting
diffuse = Vector4D(1,1,1,1);
ambient = Vector4D(0,0,0,0);
specular = Vector4D(1,1,1,1);
color = Vector3D(1,1,1);
scale = Vector3D(1.0,1.0,1.0);
// Default, it's not wireframe
Wireframe = false;
}
示例9: Vector4D
void Satellite::setParameters(GLuint size){
explosion = NULL;
ambient4f1= Vector4D(0.9, 0.4, 0.1, 1);
diffuse4f1=Vector4D(0.9, 0.4, 0.1, 1);
specular4f1=Vector4D(0.9, 0.9, 0.9, 1.0);
Vector4D emmision4f1(0, 0, 0, 1);
static GLint shininess1 = 64;
GLfloat ast_color [][5] = { {0.5, 0.2, 0.2, 2},
{0.55, 0.55, 0.55, 2},
{0.01, 0.3, 0.1, 2},
{0.7, 0.4, 0.3, 2},
{0.7, 0.3, 0.5, 2},
{0, 0, 0.2, 2}
};
int pick = rand() % 6;
//setare pozitie + culoare asteroid
for(int i = 0; i < 4; i++)
color[i] = ast_color[pick][i];
box = size;
posx = rand() % box;
posy = rand() % box;
posz = rand() % box;
Size = (rand() % 5+3)/2.0;
time = 0;
dx = (double) (rand() % RAND_MAX) / RAND_MAX * 2;
int sign=rand()%2-1;
dx*=sign;
{
dz = (double) (rand() % RAND_MAX) / RAND_MAX;
dy = (double) (rand() % RAND_MAX) / RAND_MAX;
sign=rand()%2-1;
// dy*=sign;
}
v0 = (double) (rand() % RAND_MAX) / RAND_MAX;
//acc = (double) (rand() % RAND_MAX) / RAND_MAX;
//v0 = 0;
}
示例10: scale
void scale(Matrix4x4 &mat,double x,double y,double z)
{
Matrix4x4 temp;
Vector4D r1,r2,r3,r4;
r1=Vector4D(x,0,0,0);
r2=Vector4D(0,y,0,0);
r3=Vector4D(0,0,z,0);
r4=Vector4D(0,0,0,1);
temp=Matrix4x4(r1,r2,r3,r4);
mat=temp*mat;
}
示例11: translate
void translate(Matrix4x4 &mat,double x,double y,double z)
{
Matrix4x4 temp;
Vector4D r1,r2,r3,r4;
r1=Vector4D(1,0,0,x);
r2=Vector4D(0,1,0,y);
r3=Vector4D(0,0,1,z);
r4=Vector4D(0,0,0,1);
temp=Matrix4x4(r1,r2,r3,r4);
mat=mat*temp;
}
示例12: Point
void SonarMonitor::draw()
{
Point point = m_hud->project(m_point);
int radius = (m_hud->project(m_point + Point(0, m_radius)) - point).y;
float scale = static_cast<float>(radius)/m_scale;
PointF center = PointF(point) - PointF(1.5f);
RectF rect = RectF(center, SizeF(4, 4));
Matrix m(1);
m = glm::scale(m, Vector3D(1, -1, 0));
m = glm::rotate(m, m_hud->scenario()->yaw(), Vector3D(0, 0, 1));
m = glm::translate(m, -m_hud->scenario()->position());
m_hud->fontGreen().draw("T", point + Point(-2, -radius));
m_hud->fontGreen().draw(QString("%1M").arg(m_scale), Rect(point + Point(-100, radius - 8), SizeF(200, -1)), true, false);
m_center.draw(rect);
for (fight::NavPoint *navPoint : m_hud->scenario()->navPoints())
if (navPoint->isEnabled())
{
Vector2D dir = Vector2D(m * Vector4D(navPoint->position(), 1));
float distance = glm::length(dir);
if (distance < m_scale)
{
rect.setPos(center - dir*scale);
m_nav.draw(rect);
}
}
for (const auto &entry : m_hud->scenario()->sonar())
{
Vector2D dir = Vector2D(m * Vector4D(entry.object->position(), 1));
float distance = glm::length(dir);
if (distance < m_scale)
{
rect.setPos(center - dir*scale);
(entry.isFriend ? m_friend : m_enemy).draw(rect);
}
}
fight::Target &target = m_hud->scenario()->target();
if (target.isLocked())
{
Vector2D dir = Vector2D(m * Vector4D(target.position(), 1));
float distance = glm::length(dir);
if (distance < m_scale)
{
rect.setPos(center - dir*scale);
m_target.draw(rect);
}
}
}
示例13: Object3D
// constructor care primeste ca parametru latura cubului
Cube::Cube() : Object3D()
{
// valori default
diffuse = Vector4D(1,1,1,1);
ambient = Vector4D(0,0,0,0);
specular = Vector4D(1,1,1,1);
color = Vector3D(1,1,1);
scale = Vector3D(1.0,1.0,1.0);
// default , nu este wireframe
Wireframe = false;
latura = 1.0;
}
示例14: tri1_
Quad::Quad(const Point3D& point1,
const Point3D& point2,
const Point3D& point3,
const Point3D& point4,
const Material& material)
: tri1_(point1, point2, point4, material)
, tri2_(point2, point3, point4, material)
{
// Verify that it is on the
if (tri1_.normal(Vector4D()) != tri2_.normal(Vector4D()))
{
std::cout << "All points of quad must be in the same plane." << std::endl;
std::exit(-1);
}
}
示例15: CatmullRom
Vector4D CatmullRom(const Vector4D &a, const Vector4D &b,
const Vector4D &c, const Vector4D &d, Float t) {
return Vector4D(Math::CatmullRom(a.mX, b.mX, c.mX, d.mX, t),
Math::CatmullRom(a.mY, b.mY, c.mY, d.mY, t),
Math::CatmullRom(a.mZ, b.mZ, c.mZ, d.mZ, t),
Math::CatmullRom(a.mW, b.mW, c.mW, d.mW, t));
}