bool DX10_Camera_FirstPerson::Initialise(DX10_Renderer* _pRenderer, HINSTANCE _hInstance, HWND _hWnd) { m_pRenderer = _pRenderer; m_pDirectInput = new DirectInput(); VALIDATE(m_pDirectInput->Initialise(_hInstance, _hWnd)); m_position = D3DXVECTOR3(0.0f, 25.0f, -50.0f); m_target = D3DXVECTOR3(0.0f, 0.0f, 0.0f); m_up = D3DXVECTOR3(0.0f, 1.0f, 0.0f); m_forward = D3DXVECTOR3(0.0f, 0.0f, 1.0f); m_right = D3DXVECTOR3(1.0f, 0.0f, 0.0f); m_defaultForward = D3DXVECTOR3(0.0f, 0.0f, 1.0f); m_defaultRight = D3DXVECTOR3(1.0f, 0.0f, 0.0f); m_moveStrafe = 0.0f; m_moveForwards = 0.0f; m_moveFly = 0.0f; m_yaw = 0.0f; m_pitch = DegreesToRadians(30.0f); m_yawChange = 0.0f; m_pitchChange = 0.0f; m_speed = 20.0f; m_rotSpeed = DegreesToRadians(90.0f); m_maxRotation = DegreesToRadians(89.0f); m_minRotation = DegreesToRadians(-89.0f); Process(0.016f); return true; }
Transform* SceneParser::parseTransform() { char token[MAX_PARSER_TOKEN_LENGTH]; Matrix matrix; matrix.SetToIdentity(); Object3D *object = NULL; getToken(token); assert(!strcmp(token, "{")); // read in transformations: // apply to the LEFT side of the current matrix (so the first // transform in the list is the last applied to the object) getToken(token); while (1) { if (!strcmp(token, "Scale")) { matrix *= Matrix::MakeScale(readVec3f()); } else if (!strcmp(token, "UniformScale")) { float s = readFloat(); matrix *= Matrix::MakeScale(Vec3f(s, s, s)); } else if (!strcmp(token, "Translate")) { matrix *= Matrix::MakeTranslation(readVec3f()); } else if (!strcmp(token, "XRotate")) { matrix *= Matrix::MakeXRotation(DegreesToRadians(readFloat())); } else if (!strcmp(token, "YRotate")) { matrix *= Matrix::MakeYRotation(DegreesToRadians(readFloat())); } else if (!strcmp(token, "ZRotate")) { matrix *= Matrix::MakeZRotation(DegreesToRadians(readFloat())); } else if (!strcmp(token, "Rotate")) { getToken(token); assert(!strcmp(token, "{")); Vec3f axis = readVec3f(); float degrees = readFloat(); matrix *= Matrix::MakeAxisRotation(axis, DegreesToRadians(degrees)); getToken(token); assert(!strcmp(token, "}")); } else if (!strcmp(token, "Matrix")) { Matrix matrix2; matrix2.SetToIdentity(); getToken(token); assert(!strcmp(token, "{")); for (int j = 0; j < 4; j++) { for (int i = 0; i < 4; i++) { float v = readFloat(); matrix2.Set(i, j, v); } } getToken(token); assert(!strcmp(token, "}")); matrix = matrix2 * matrix; } else { // otherwise this must be an object, // and there are no more transformations object = parseObject(token); break; } getToken(token); } assert(object != NULL); getToken(token); assert(!strcmp(token, "}")); return new Transform(matrix, object); }
void Magick::Options::transformRotation(double angle_) { AffineMatrix affine, current=_drawInfo->affine; affine.sx=1.0; affine.rx=0.0; affine.ry=0.0; affine.sy=1.0; affine.tx=0.0; affine.ty=0.0; affine.sx=cos(DegreesToRadians(fmod(angle_,360.0))); affine.rx=(-sin(DegreesToRadians(fmod(angle_,360.0)))); affine.ry=sin(DegreesToRadians(fmod(angle_,360.0))); affine.sy=cos(DegreesToRadians(fmod(angle_,360.0))); _drawInfo->affine.sx=current.sx*affine.sx+current.ry*affine.rx; _drawInfo->affine.rx=current.rx*affine.sx+current.sy*affine.rx; _drawInfo->affine.ry=current.sx*affine.ry+current.ry*affine.sy; _drawInfo->affine.sy=current.rx*affine.ry+current.sy*affine.sy; _drawInfo->affine.tx=current.sx*affine.tx+current.ry*affine.ty+current.tx; _drawInfo->affine.ty=current.rx*affine.tx+current.sy*affine.ty+current.ty; }
void WeaponHUD::addPortalGun() { ref_ptr<Node> portalGun = osgDB::readNodeFile("../BlenderFiles/exports/Portalgun.ive"); /* * rotating and translating the portal gun to the lower * right of the screen */ ref_ptr<MatrixTransform> portalGunTransform = new MatrixTransform; portalGunTransform->setMatrix( Matrix::rotate(osg::DegreesToRadians(0.0), X_AXIS) *Matrix::rotate(DegreesToRadians(0.0), Y_AXIS) *Matrix::rotate(DegreesToRadians(90.0), Z_AXIS) *Matrix::translate(osg::Vec3(0.7f, 1.5f, -1.3f)) ); portalGunTransform->addChild(portalGun); /* * Set proper lighting and reflection */ brtr::ModifyMaterialVisitor mmv; mmv.setAmbient(Vec4(1.3, 1.3, 1.3, 1)).setShininess(42).setSpecular(Vec4(0.4, 0.4, 0.4, 1)); portalGun->accept(mmv); _switcher->setAllChildrenOff(); _switcher->addChild(portalGunTransform, true); }
/* Method: Magick::Draw#rotation=degrees Purpose: set rotation attribute value Notes: Taken from Magick++'s Magick::Image::annotate method Copyright Bob Friesenhahn, 1999, 2000, 2001, 2002 */ VALUE Draw_rotation_eq(VALUE self, VALUE deg) { Draw *draw; double degrees; AffineMatrix affine, current; rb_check_frozen(self); Data_Get_Struct(self, Draw, draw); degrees = NUM2DBL(deg); if (fabs(degrees) > DBL_EPSILON) { affine.sx=1.0; affine.rx=0.0; affine.ry=0.0; affine.sy=1.0; affine.tx=0.0; affine.ty=0.0; current = draw->info->affine; affine.sx=cos(DegreesToRadians(fmod(degrees,360.0))); affine.rx=sin(DegreesToRadians(fmod(degrees,360.0))); affine.ry=(-sin(DegreesToRadians(fmod(degrees,360.0)))); affine.sy=cos(DegreesToRadians(fmod(degrees,360.0))); draw->info->affine.sx=current.sx*affine.sx+current.ry*affine.rx; draw->info->affine.rx=current.rx*affine.sx+current.sy*affine.rx; draw->info->affine.ry=current.sx*affine.ry+current.ry*affine.sy; draw->info->affine.sy=current.rx*affine.ry+current.sy*affine.sy; draw->info->affine.tx=current.sx*affine.tx+current.ry*affine.ty+current.tx; } return self; }
VCPoint2D* ViceGeom::PlacePointFrom(VCPoint2D* point, float angle, float distance) { VCPoint2D* result = new VCPoint2D(); result->x = point->x + sin(DegreesToRadians(angle)) * distance; result->y = point->y + cos(DegreesToRadians(angle)) * distance; return result; }
Transform * SceneParser::parseTransform() { char token[MAX_PARSER_TOKEN_LENGTH]; Matrix4f matrix = Matrix4f::identity(); Object3D *object = NULL; getToken(token); assert(!strcmp(token, "{")); // read in transformations: // apply to the LEFT side of the current matrix (so the first // transform in the list is the last applied to the object) getToken(token); while (true) { if (!strcmp(token,"Scale")) { Vector3f s = readVector3f(); matrix = matrix * Matrix4f::scaling( s[0], s[1], s[2] ); } else if (!strcmp(token,"UniformScale")) { float s = readFloat(); matrix = matrix * Matrix4f::uniformScaling( s ); } else if (!strcmp(token,"Translate")) { matrix = matrix * Matrix4f::translation( readVector3f() ); } else if (!strcmp(token,"XRotate")) { matrix = matrix * Matrix4f::rotateX((float) DegreesToRadians(readFloat())); } else if (!strcmp(token,"YRotate")) { matrix = matrix * Matrix4f::rotateY((float) DegreesToRadians(readFloat())); } else if (!strcmp(token,"ZRotate")) { matrix = matrix * Matrix4f::rotateZ((float) DegreesToRadians(readFloat())); } else if (!strcmp(token,"Rotate")) { getToken(token); assert(!strcmp(token, "{")); Vector3f axis = readVector3f(); float degrees = readFloat(); float radians = (float) DegreesToRadians(degrees); matrix = matrix * Matrix4f::rotation(axis,radians); getToken(token); assert(!strcmp(token, "}")); } else if (!strcmp(token,"Matrix4f")) { Matrix4f matrix2 = Matrix4f::identity(); getToken(token); assert(!strcmp(token, "{")); for (int j = 0; j < 4; j++) { for (int i = 0; i < 4; i++) { float v = readFloat(); matrix2( i, j ) = v; } } getToken(token); assert(!strcmp(token, "}")); matrix = matrix2 * matrix; } else { // otherwise this must be an object, // and there are no more transformations object = parseObject(token); break; } getToken(token); } assert(object != NULL); getToken(token); assert(!strcmp(token, "}")); return new Transform(matrix, object); }
Vector VRotate2D( float angle, Vector u) { float x,y; x = u.x * cos(DegreesToRadians(-angle)) + u.y * sin(DegreesToRadians(-angle)); y = -u.x * sin(DegreesToRadians(-angle)) + u.y * cos(DegreesToRadians(-angle)); return Vector( x, y, 0); }
void CShapeRenderer::DrawSphere(const CVec3& pos, float fRadius, float fElliptical, CColor color, uint32_t uGridCnt, bool bWireFrame) const { if (BEATS_FLOAT_GREATER(fRadius, 0.0F)) { const uint32_t uVertexCnt = uGridCnt + 1; std::vector<CVertexPC> vertices; std::vector<unsigned short> indices; // Generate vertex. for (uint32_t y = 0; y < uVertexCnt; y++) { for (uint32_t x = 0; x < uVertexCnt; x++) { CVertexPC vertex; vertex.color = color; vertex.position.X() = sinf(DegreesToRadians((float)y / (float)(uVertexCnt - 1) * 180.0F)) * cosf(DegreesToRadians((float)x / (float)(uVertexCnt - 1) * 360.0F)) * fRadius; vertex.position.Y() = cosf(DegreesToRadians((float)y / (float)(uVertexCnt - 1) * 180.0F)) * fRadius * fElliptical; vertex.position.Z() = sinf(DegreesToRadians((float)y / (float)(uVertexCnt - 1) * 180.0F)) * sinf(DegreesToRadians((float)x / (float)(uVertexCnt - 1) * 360.0F)) * fRadius; vertex.position += pos; vertices.push_back(vertex); } } // Generate index. for (uint32_t z = 0; z < uGridCnt; z++) { for (uint32_t x = 0; x < uGridCnt; x++) { indices.push_back((unsigned short)(z * uVertexCnt + x)); indices.push_back((unsigned short)((z + 1) * uVertexCnt + x + 1)); indices.push_back((unsigned short)((z + 1) * uVertexCnt + x)); indices.push_back((unsigned short)(z * uVertexCnt + x)); indices.push_back((unsigned short)(z * uVertexCnt + x + 1)); indices.push_back((unsigned short)((z + 1) * uVertexCnt + x + 1)); } } if (bWireFrame) { CRenderManager::GetInstance()->RenderLines(vertices, indices, 1.0f, true); } else { CRenderManager::GetInstance()->RenderTriangle(vertices, indices, true); } } }
// calculates the distance between two coordinates in nautical miles static double GetDistance(double latiudeA, double longitudeA, double latiudeB, double longitudeB) { double dLatitude = latiudeB - latiudeA; double dLongitude = longitudeB - longitudeA; double a = pow(sin(DegreesToRadians(dLatitude / 2.0)), 2) + cos(DegreesToRadians(latiudeA)) * cos(DegreesToRadians(latiudeB)) * pow(sin(DegreesToRadians(dLongitude / 2.0)), 2); double c = 2.0 * atan2(sqrt(a), sqrt(1.0 - a)); return c * RADIUS_EARTH; }
void Lights::SetLightSpotLight(int index, float radius, const Vector3Df& dir, float outAngle, float inAngle) { if(IsIndexValid(index)) { m_radius[index] = radius; m_dir[index] = dir; m_angleInnerCone[index] = cos(DegreesToRadians(inAngle)); m_angleOuterCone[index] = cos(DegreesToRadians(outAngle)); } }
tCamera::tCamera(): tEulerCamera() { m_MinElevation = DegreesToRadians(1); m_MaxElevation = DegreesToRadians(90); m_MinX = -19970325L; m_MaxX = 19970325L; m_MinY = -20616952L; m_MaxY = 17947623L; }
double Elbow::GetCurrentArbFeedForward(void) { double wristEffectiveAngle; double wristArbFF; double curArbFeedForward; // Wrist adjustment for effect on Elbow wristEffectiveAngle = Robot::wrist->GetCurrentDegrees() + m_curDegrees - 180.0; wristArbFF = sin(DegreesToRadians(wristEffectiveAngle)) * m_wristArbFF; curArbFeedForward = sin(DegreesToRadians(m_curDegrees)) * (m_arbFeedForward + wristArbFF); return curArbFeedForward; }
void tSonar3D::ResetCameraToHome() { m_CameraDistanceMeters = cDefaultCameraDistanceMeters; m_CameraRelativeAngleDegrees = 0; m_TrackBallInteractor .SetTarget(m_Target) .SetAzimuth(DegreesToRadians(HeadingToCartesianAngle(m_SceneSettings.vesselHeading))) .SetElevation(DegreesToRadians(cDefaultElevationDegrees)) .SetDistance(m_CameraDistanceMeters) .UpdateCamera(); }
float MathHelper::Sin(float angle, bool radians) { if ( !radians ) angle = DegreesToRadians( angle ); return float( sin( angle ) ); }
// Method using yPos double KauaibotsTarget::GetDistanceToGoalFeet() { double dDistanceInches = ( (cTargetCenterHeightInches - cCameraLensHeightInches) / tan( DegreesToRadians ( fabs ( GetRobotVerticalAngle())))) / 12; return dDistanceInches; }
void DrawCube(void) { float CubeAngle; clock_t Now = clock(); if (LastTime == 0) LastTime = Now; CubeRotation += 45.0f * ((float)(Now - LastTime) / CLOCKS_PER_SEC); CubeAngle = DegreesToRadians(CubeRotation); LastTime = Now; ModelMatrix = IDENTITY_MATRIX; RotateAboutY(&ModelMatrix, CubeAngle); RotateAboutX(&ModelMatrix, CubeAngle); glUseProgram(ShaderIds[0]); ExitOnGLError("ERROR: Could not use the shader program"); glUniformMatrix4fv(ModelMatrixUniformLocation, 1, GL_FALSE, ModelMatrix.m); glUniformMatrix4fv(ViewMatrixUniformLocation, 1, GL_FALSE, ViewMatrix.m); ExitOnGLError("ERROR: Could not set the shader uniforms"); glBindVertexArray(BufferIds[0]); ExitOnGLError("ERROR: Could not bind the VAO for drawing purposes"); glDrawElements(GL_TRIANGLES, 36, GL_UNSIGNED_INT, (GLvoid*)0); ExitOnGLError("ERROR: Could not draw the cube"); glBindVertexArray(0); glUseProgram(0); }
void CShapeModule::InitParticleForCone(CVec3& localPos, CVec3& direction, float fParticleScale) const { CVec3 finalPos, finalDirection; float fClipAngle = m_fAngle; BEATS_CLIP_VALUE(fClipAngle, 0, 89.99f); float fRadius = m_fRadius * fParticleScale; float fConeLength = m_fConeLength * fParticleScale; float fTopRadius = fRadius + fConeLength * tanf(DegreesToRadians(fClipAngle)); CVec3 randomDirection(PARTICLE_RAND_RANGE(-1, 1), PARTICLE_RAND_RANGE(-1, 1), 0); randomDirection.Normalize(); float fRadiusOnBase = m_bEmitFromShell ? fRadius : PARTICLE_RAND_RANGE(0, fRadius); finalPos = randomDirection * fRadiusOnBase; BEATS_ASSERT(!BEATS_FLOAT_EQUAL(fRadius, 0)); fTopRadius *= (fRadiusOnBase / fRadius); CVec3 topPos = (m_bRandomDirection ? GetRandomDirection() : randomDirection) * fTopRadius; topPos.Z() = fConeLength; finalDirection = topPos - finalPos; if (!m_bEmitFromBaseOrVolume) { finalPos += (finalDirection * PARTICLE_RAND_RANGE(0, 1)); if (m_bRandomDirection) { finalDirection = GetRandomDirection(); } } finalDirection.Normalize(); localPos = finalPos; direction = finalDirection; }
mat4x4 CreateProjectionMatrix( float fovy, float aspect_ratio, float near_plane, float far_plane ) { mat4x4 out = { { 0 } }; const float y_scale = Cotangent(DegreesToRadians(fovy / 2)); const float x_scale = y_scale / aspect_ratio; const float frustum_length = far_plane - near_plane; out.m[0] = x_scale; out.m[5] = y_scale; out.m[10] = -((far_plane + near_plane) / frustum_length); out.m[11] = -1; out.m[14] = -((2 * near_plane * far_plane) / frustum_length); return out; }
void CPlayAreaManager::GetPlayAreaPlaneAt(CVector vPos,CVector *pPlayAreaMins,CVector *pPlayAreaMaxs) { if(m_CameraWrapper.m_piCamera==NULL){return;} double dCameraDistance=(m_vCameraRouteStart.c[1]+m_dCameraDistanceFromPlayer)-vPos.c[1]; double dViewAngle=m_CameraWrapper.m_piCamera->GetViewAngle(); double dAspectRatio=m_CameraWrapper.m_piCamera->GetAspectRatio(); CVector vOffset; vOffset.c[0]=dCameraDistance*tan(DegreesToRadians(dViewAngle*0.5)); vOffset.c[2]=dCameraDistance*tan(DegreesToRadians((dViewAngle*0.5)))*dAspectRatio; *pPlayAreaMins=vPos; *pPlayAreaMaxs=vPos; pPlayAreaMins->c[0]-=vOffset.c[0]; pPlayAreaMaxs->c[0]+=vOffset.c[0]; pPlayAreaMins->c[2]-=vOffset.c[2]; pPlayAreaMaxs->c[2]+=vOffset.c[2]; }
// code based on examples found at http://www.songho.ca/opengl/gl_matrix.html //--------------------------------------------------------------------------- void Matrix4::SetPerspective( const float fovy, const float aspect, const float zNear, const float zFar ) { float tangent = tan( DegreesToRadians( fovy / 2.f ) ); float height = zNear * tangent; float width = height * aspect; SetFrustum( -width, width, -height, height, zNear, zFar ); }
void XWing::ReadyForGame() { matrix = Matrix3D(); matrix = rotate(DegreesToRadians(180)); scalar = 0.5; position = Vector3D(800, 450); rotation = 0; hasAstromechDroid = true; }
void MatrixStack::Perspective(float fov, float aspect, float zNear, float zFar) { const float FOVRadians = DegreesToRadians(fov * 0.5f); float maxY = zNear * tanf(FOVRadians); float maxX = maxY * aspect; Frustum(-maxX, maxX, -maxY, maxY, zNear, zFar); m_frustum.UpdateData(fov, aspect, zNear, zFar); m_frustum.UpdateFrustum(Vector3Df(), Vector3Df(0.0f, 0.0f, -1.0f)); }
void Step(float angle) { float anglerad=DegreesToRadians(angle); glLoadIdentity(); glTranslatef(0, -4, 0); glRotatef(1, 0,0,angle-20); glTranslatef(0, 4, 0); glRotatef(1, 0,0,-(angle-20)); }
double Wrist::GetCurrentArbFeedForward(void) { double wristEffectiveAngle; double curArbFeedForward; // Elbow adjustment for effect on Wrist wristEffectiveAngle = Robot::elbow->GetCurrentDegrees() + m_curDegrees - 180.0; curArbFeedForward = sin(DegreesToRadians(wristEffectiveAngle)) * m_arbFeedForward; return curArbFeedForward; }
void CLiveBonus::SetInitialVelocity() { if(m_pType->m_PlayAreaManager.m_piPlayAreaManager==NULL){return;} CMatrix m; double dInitialAngle=45.0-drand()*90.0; m_dCurrentAngularVelocity=dInitialAngle>0?m_pType->m_dAngularVelocity:0-m_pType->m_dAngularVelocity; m.R(AxisPosY,DegreesToRadians(dInitialAngle)); m_vCurrentForwardDirection=AxisPosX; m_vCurrentForwardDirection*=m; }
void CLiveBonus::ProcessFrame(unsigned int dwCurrentTime,double dTimeFraction) { CEntityBase::ProcessFrame(dwCurrentTime,dTimeFraction); if(m_pType->m_PlayAreaManager.m_piPlayAreaManager==NULL){return;} CVector vMins,vMaxs; m_pType->m_PlayAreaManager.m_piPlayAreaManager->GetCurrentVisibleArea(&vMins,&vMaxs); if(m_PhysicInfo.vPosition.c[0]+m_dRadius<vMins.c[0]) { Remove(); return; } if(m_PhysicInfo.vPosition.c[2]-m_dRadius<vMins.c[2] && m_vCurrentForwardDirection.c[2]<0) { CMatrix m; double dInitialAngle=drand()*(-25.0)-20.0; m.R(AxisPosY,DegreesToRadians(dInitialAngle)); m_dCurrentAngularVelocity=0-m_pType->m_dAngularVelocity; m_vCurrentForwardDirection=AxisPosX; m_vCurrentForwardDirection*=m; } if(m_PhysicInfo.vPosition.c[2]+m_dRadius>vMaxs.c[2] && m_vCurrentForwardDirection.c[2]>0) { CMatrix m; double dInitialAngle=drand()*25.0+20.0; m.R(AxisPosY,DegreesToRadians(dInitialAngle)); m_dCurrentAngularVelocity=m_pType->m_dAngularVelocity; m_vCurrentForwardDirection=AxisPosX; m_vCurrentForwardDirection*=m; } CMatrix m; m.R(AxisPosY,DegreesToRadians(m_dCurrentAngularVelocity*dTimeFraction)); m_vCurrentForwardDirection*=m; m_vCurrentForwardDirection.N(); double dCameraFollow=(m_pType->m_PlayAreaManager.m_piPlayAreaManager->GetCameraSpeed()-m_pType->m_dExitVelocity); m_PhysicInfo.vVelocity=m_vCurrentForwardDirection*m_pType->m_dForwardVelocity+AxisPosX*dCameraFollow; }
void ViewContext::SetProjectionMatrix(const Matrix4x4 &m) { if (!IgnoringScreenRotation() && m_screenOrientation != SCREEN_ANGLE_0) { // apply a rotation immediately _after_ the projection matrix transform float angle = (float)m_screenOrientation; Matrix4x4 adjusted = Matrix4x4::CreateRotationZ(-DegreesToRadians(angle)) * m; m_projectionStack.top = adjusted; } else m_projectionStack.top = m; }
void DrawLineCircle(const Vector2Df& pos, float spaceing, float radius) { float radSpacing = DegreesToRadians(spaceing); DrawBegin(CL_LINES); for(float i = 0; i <= 2 * 3.1415f; i += radSpacing) { clVertex3(pos.x + cos(i) * radius, pos.y + sin(i) * radius, 0.0f); clVertex3(pos.x + cos(i + radSpacing) * radius, pos.y + sin(i + radSpacing) * radius, 0.0f); } DrawEnd(); }
void Light::Render() { GLint ShaderProgram = renderShader->ShaderProgram; Lights.push_back(this); float DiffuseT[Lights.size()*4]; float AmbientT[Lights.size()*4]; float SpecularT[Lights.size()*4]; float PositionT[Lights.size()*3]; float DirectionT[Lights.size()*3]; float CAttenT[Lights.size()]; float LAttenT[Lights.size()]; float QAttenT[Lights.size()]; float SCUTT[Lights.size()]; float SEXPT[Lights.size()]; for(int i=0;i<Lights.size();++i){ DiffuseT[i*4] = Lights[i]->DiffuseColor.x; DiffuseT[i*4+1] = Lights[i]->DiffuseColor.y; DiffuseT[i*4+2] = Lights[i]->DiffuseColor.z; DiffuseT[i*4+3] = Lights[i]->DiffuseColor.w; AmbientT[i*4] = Lights[i]->AmbientColor.x; AmbientT[i*4+1] = Lights[i]->AmbientColor.y; AmbientT[i*4+2] = Lights[i]->AmbientColor.z; AmbientT[i*4+3] = Lights[i]->AmbientColor.w; SpecularT[i*4] = Lights[i]->SpecularColor.x; SpecularT[i*4+1] = Lights[i]->SpecularColor.y; SpecularT[i*4+2] = Lights[i]->SpecularColor.z; SpecularT[i*4+3] = Lights[i]->SpecularColor.w; PositionT[i*3] = Lights[i]->Position.x; PositionT[i*3+1] = Lights[i]->Position.y; PositionT[i*3+2] = Lights[i]->Position.z; DirectionT[i*3] = Lights[i]->Direction.x; DirectionT[i*3+1] = Lights[i]->Direction.y; DirectionT[i*3+2] = Lights[i]->Direction.z; CAttenT[i] = Lights[i]->ConstantAttenuation; LAttenT[i] = Lights[i]->LinearAttenuation; QAttenT[i] = Lights[i]->QuadraticAttenuation; SCUTT[i] = cosf(DegreesToRadians(Lights[i]->SpotCutoff)); ///Convert from degrees into cos of the angle, for faster pixel shader SEXPT[i] = Lights[i]->SpotExponent; } glUniform1i(glGetUniformLocation(ShaderProgram,"lightCount"),Lights.size()); glUniform4fv(glGetUniformLocation(ShaderProgram,"LightDiffuses"),Lights.size()*4,DiffuseT); glUniform4fv(glGetUniformLocation(ShaderProgram,"LightAmbients"),Lights.size()*4,AmbientT); glUniform4fv(glGetUniformLocation(ShaderProgram,"LightSpeculars"),Lights.size()*4,SpecularT); glUniform3fv(glGetUniformLocation(ShaderProgram,"LightPositions"),Lights.size()*3,PositionT); glUniform3fv(glGetUniformLocation(ShaderProgram,"LightDirections"),Lights.size()*3,DirectionT); glUniform1fv(glGetUniformLocation(ShaderProgram,"LightConstantAttenuations"),Lights.size(),CAttenT); glUniform1fv(glGetUniformLocation(ShaderProgram,"LightLinearAttenuations"),Lights.size(),LAttenT); glUniform1fv(glGetUniformLocation(ShaderProgram,"LightQuadraticAttenuations"),Lights.size(),QAttenT); glUniform1fv(glGetUniformLocation(ShaderProgram,"LightCutoffs"),Lights.size(),SCUTT); glUniform1fv(glGetUniformLocation(ShaderProgram,"LightSpotExponents"),Lights.size(),SEXPT); }