void Entity::SetYaw(float amount) { this->rotation.y = DEGTORAD(amount); }
void Entity::SetRoll(float amount) { this->rotation.z = DEGTORAD(amount); }
void Entity::Roll(float amount) { this->rotation.z += DEGTORAD(amount); this->Rotate(0,0,DEGTORAD(amount)); }
void Entity::SetPitch(float amount) { this->rotation.x = DEGTORAD(amount); }
void Entity::Pitch(float amount) { this->rotation.x += DEGTORAD(amount); this->Rotate(DEGTORAD(amount),0,0); }
void Entity::Yaw(float amount) { this->rotation.y += DEGTORAD(amount); this->Rotate(0,DEGTORAD(amount),0); }
/** Internal method that draws one of the pies in a pie chart. \param painter the QPainter to draw in \param dataset the dataset to draw the pie for \param pie the pie to draw \param the chart to draw the pie in \param regions a pointer to a list of regions that will be filled with regions representing the data segments, if not null */ void KDChartPiePainter::drawOnePie( QPainter* painter, KDChartTableDataBase* /*data*/, uint dataset, uint pie, uint chart, uint threeDPieHeight, KDChartDataRegionList* regions ) { // Is there anything to draw at all? int angleLen = _angleLens[ ( int ) pie ]; if ( angleLen ) { int startAngle = _startAngles[ ( int ) pie ]; KDChartDataRegion* datReg = 0; QRegion* region = 0; bool mustDeleteRegion = false; if ( regions ){ region = new QRegion(); mustDeleteRegion = true; } QRect drawPosition = _position; if ( params()->explode() ) { // need to compute a new position for each or some of the pie QValueList<int> explodeList = params()->explodeValues(); if( explodeList.count() == 0 || // nothing on list, explode all explodeList.find( pie ) != explodeList.end() ) { double explodeAngle = ( startAngle + angleLen / 2 ) / 16; double explodeAngleRad = DEGTORAD( explodeAngle ); double cosAngle = cos( explodeAngleRad ); double sinAngle = -sin( explodeAngleRad ); // find the explode factor for this particular pie double explodeFactor = 0.0; QMap<int,double> explodeFactors = params()->explodeFactors(); if( !explodeFactors.contains( pie ) ) // not on factors list, use default explodeFactor = params()->explodeFactor(); else // on factors list, use segment-specific value explodeFactor = explodeFactors[pie]; double explodeX = explodeFactor * _size * cosAngle; double explodeY = explodeFactor * _size * sinAngle; drawPosition.moveBy( static_cast<int>( explodeX ), static_cast<int>( explodeY ) ); } else drawPosition = _position; } else drawPosition = _position; // The 3D effect needs to be drawn first because it could // otherwise partly hide the pie itself. if ( params()->threeDPies() ) { draw3DEffect( painter, drawPosition, dataset, pie, chart, threeDPieHeight, params()->explode(), region ); } painter->setBrush( params()->dataColor( pie ) ); if ( angleLen == 5760 ) { // full circle, avoid nasty line in the middle painter->drawEllipse( drawPosition ); if ( regions ) { QPointArray hitregion; hitregion.makeEllipse( drawPosition.x(), drawPosition.y(), drawPosition.width(), drawPosition.height() ); datReg = new KDChartDataRegion( region->unite( QRegion( hitregion ) ), dataset, pie, chart ); datReg->points[ KDChartEnums::PosCenter ] = drawPosition.center(); datReg->points[ KDChartEnums::PosCenterRight ] = pointOnCircle( drawPosition, 0 ); datReg->points[ KDChartEnums::PosTopRight ] = pointOnCircle( drawPosition, 720 ); datReg->points[ KDChartEnums::PosTopCenter ] = pointOnCircle( drawPosition, 1440 ); datReg->points[ KDChartEnums::PosTopLeft ] = pointOnCircle( drawPosition, 2160 ); datReg->points[ KDChartEnums::PosCenterLeft ] = pointOnCircle( drawPosition, 2880 ); datReg->points[ KDChartEnums::PosBottomLeft ] = pointOnCircle( drawPosition, 3600 ); datReg->points[ KDChartEnums::PosBottomCenter ] = pointOnCircle( drawPosition, 4320 ); datReg->points[ KDChartEnums::PosBottomRight ] = pointOnCircle( drawPosition, 5040 ); datReg->startAngle = 2880; datReg->angleLen = 5760; regions->append( datReg ); } } else { // draw the top of this piece // Start with getting the points for the arc. const int arcPoints = angleLen; QPointArray collect(arcPoints+2); int i=0; for ( ; i<=angleLen; ++i){ collect.setPoint(i, pointOnCircle( drawPosition, startAngle+i )); } // Adding the center point of the piece. collect.setPoint(i, drawPosition.center() ); painter->drawPolygon( collect ); //if( bHelp ){ // painter->drawPolyline( collect ); //bHelp=false; //} if ( regions ) { QPointArray hitregion; hitregion.makeArc( drawPosition.x(), drawPosition.y(), drawPosition.width(), drawPosition.height(), ( int ) startAngle, ( int ) angleLen ); hitregion.resize( hitregion.size() + 1 ); hitregion.setPoint( hitregion.size() - 1, drawPosition.center() ); datReg = new KDChartDataRegion( region->unite( QRegion( hitregion ) ), dataset, pie, chart ); datReg->points[ KDChartEnums::PosTopLeft ] = pointOnCircle( drawPosition, startAngle + angleLen ); datReg->points[ KDChartEnums::PosTopCenter ] = pointOnCircle( drawPosition, startAngle + angleLen / 2 ); datReg->points[ KDChartEnums::PosTopRight ] = pointOnCircle( drawPosition, startAngle ); datReg->points[ KDChartEnums::PosBottomLeft ] = drawPosition.center(); datReg->points[ KDChartEnums::PosBottomCenter ] = datReg->points[ KDChartEnums::PosBottomLeft ]; datReg->points[ KDChartEnums::PosBottomRight ] = datReg->points[ KDChartEnums::PosBottomLeft ]; datReg->points[ KDChartEnums::PosCenterLeft ] = QPoint( ( datReg->points[ KDChartEnums::PosTopLeft ].x() + datReg->points[ KDChartEnums::PosBottomLeft ].x() ) / 2, ( datReg->points[ KDChartEnums::PosTopLeft ].y() + datReg->points[ KDChartEnums::PosBottomLeft ].y() ) / 2 ); datReg->points[ KDChartEnums::PosCenter ] = QPoint( ( datReg->points[ KDChartEnums::PosTopCenter ].x() + datReg->points[ KDChartEnums::PosBottomCenter ].x() ) / 2, ( datReg->points[ KDChartEnums::PosTopCenter ].y() + datReg->points[ KDChartEnums::PosBottomCenter ].y() ) / 2 ); datReg->points[ KDChartEnums::PosCenterRight ] = QPoint( ( datReg->points[ KDChartEnums::PosTopRight ].x() + datReg->points[ KDChartEnums::PosBottomRight ].x() ) / 2, ( datReg->points[ KDChartEnums::PosTopRight ].y() + datReg->points[ KDChartEnums::PosBottomRight ].y() ) / 2 ); datReg->startAngle = startAngle; datReg->angleLen = angleLen; regions->append( datReg ); } } if( mustDeleteRegion ) delete region; } }
#include "DeathBalls.h" #include "..\utils\util.h" #include "..\Constants.h" const float ANGLES[] = { DEGTORAD(90.0f), DEGTORAD(0.0f), DEGTORAD(270.0f), DEGTORAD(180.0f) }; DeathBalls::DeathBalls(GameContext* context) : _context(context), _world(context->world) { } DeathBalls::~DeathBalls() { } void DeathBalls::start() { v2 pp = _world->getPosition(_context->playerID); v2 p = util::pickSpawnPoint(pp); ds::SID sid = _world->create(p, "death_ball",OBJECT_LAYER); _world->startBehavior(sid, "wiggle_death_ball"); float a = 0.0f; int side = 0; float delta = 2000.0f; if (640.0f - p.y < delta) { delta = 640.0f - p.y; side = 0; } if (1240.0f - p.x < delta) { delta = 1240.0f - p.x; side = 1; } if (p.y - 40.0f < delta) {
void Rotate3 (Point3 * point, Vector3 * vector, float alpha, Vector3 axis, AngleMode mode) { double pointX, pointY, pointZ; // Storage for point coordinates double vectorX, vectorY, vectorZ; // Storage for vector components double cosine, sine; // Storage for cosine and sine of alpha double angle = (double) alpha; // Angle in given mode double A1, A2, A3; // Components of matrix's first column double B1, B2, B3; // Components of matrix's second column double C1, C2, C3; // Components of matrix's third column switch (mode) // Get angle mode { case kDegrees: // Degrees case angle = DEGTORAD(angle); // Convert angle to radians break; // Break out of switch statement case kGradians: // Gradians case angle = GRADTORAD(angle); // Convert angle to radians break; // Break out of switch statement case kRadians: // Radians case break; // Break out of switch statement default: NORET_MESSAGE("Unsupported mode: Rotate3 failed","1"); // Return failure } // Initialization block { double a1a1 = axis.x * axis.x; // Optimize "a1a1" instances double a2a2 = axis.y * axis.y; // Optimize "a2a2" instances double a3a3 = axis.z * axis.z; // Optimize "a3a3" instances double diff; // Optimize "1.0 - cosine" instances cosine = cos (angle); // Get cosine of angle sine = sin (angle); // Get sine of angle diff = 1.0 - cosine; // Store away value in diff // Nested initialization block { double a1a2diff = (axis.x * axis.y) * diff; // Optimize "a1a2 * diff" instances double a1a3diff = (axis.x * axis.z) * diff; // Optimize "a1a3 * diff" instances double a2a3diff = (axis.y * axis.z) * diff; // Optimize "a2a3 * diff" instances double xSine = axis.x * sine; // Optimize "a1 * sine" instances double ySine = axis.y * sine; // Optimize "a2 * sine" instances double zSine = axis.z * sine; // Optimize "a3 * sine" instances A1 = a1a1 + cosine * (1.0 - a1a1); // Row 1, Column 1 of matrix B1 = a1a2diff - zSine; // Row 1, Column 2 of matrix C1 = a1a3diff + ySine; // Row 1, Column 3 of matrix A2 = a1a2diff + zSine; // Row 2, Column 1 of matrix B2 = a2a2 + cosine * (1.0 - a2a2); // Row 2, Column 2 of matrix C2 = a2a3diff - xSine; // Row 2, Column 3 of matrix A3 = a1a3diff - ySine; // Row 3, Column 1 of matrix B3 = a2a3diff + xSine; // Row 3, Column 2 of matrix C3 = a3a3 + cosine * (1.0 - a3a3); // Row 3, Column 3 of matrix } } if (point) // Ensure that point points to something { pointX = point->x; // Store x coordinate of point pointY = point->y; // Store y coordinate of point pointZ = point->z; // Store z coordinate of point point->x = (float) (A1 * pointX + B1 * pointY + C1 * pointZ); point->y = (float) (A2 * pointX + B2 * pointY + C2 * pointZ); point->z = (float) (A3 * pointX + B3 * pointY + C3 * pointZ); // Rotate point through angle radians } if (vector) // Ensure that vector points to something { vectorX = vector->x;// Store x component of vector vectorY = vector->y;// Store y component of vector vectorZ = vector->z;// Store z component of vector Rotate3 (&vector->tail, NULL, (float) angle, axis, kRadians); // Rotate tail of vector through angle radians, recursively vector->x = (float) (A1 * vectorX + B1 * vectorY + C1 * vectorZ); vector->y = (float) (A2 * vectorX + B2 * vectorY + C2 * vectorZ); vector->z = (float) (A3 * vectorX + B3 * vectorY + C3 * vectorZ); // Rotate vector through angle radians } }
void measure_surface_int(const double res, const double radius, const double select_dist, const bool periodic, const double a, const double b, const double c, const double alpha, const double beta, const double gamma, int *indices, float *coords, int count, int **surf, int *n_surf ) { if (periodic) printf("System periodic\n"); else printf("System not periodic\n"); printf("Reading\n"); Vector3D uo; Vector3D ua; Vector3D ub; Vector3D uc; // Set origin to center of box double xmin = coords[0]; double xmax = coords[0]; double ymin = coords[1]; double ymax = coords[1]; double zmin = coords[2]; double zmax = coords[2]; int ind; int i; for(i=1, ind=3; i < count; i++, ind += 3) { if (coords[ind] < xmin) xmin = coords[ind]; if (coords[ind] > xmax) xmax = coords[ind]; if (coords[ind+1] < ymin) ymin = coords[ind+1]; if (coords[ind+1] > ymax) ymax = coords[ind+1]; if (coords[ind+2] < zmin) zmin = coords[ind+2]; if (coords[ind+2] > zmax) zmax = coords[ind+2]; } uo.x = 0.5*(xmin+xmax); uo.y = 0.5*(ymin+ymax); uo.z = 0.5*(zmin+zmax); double cosbc = cos(DEGTORAD(alpha)); double cosac = cos(DEGTORAD(beta)); double cosab = cos(DEGTORAD(gamma)); double sinab = sin(DEGTORAD(gamma)); ua.x = a; ua.y = 0; ua.z = 0; ub.x = b * cosab; ub.y = b * sinab; ub.z = 0; // If sinAB is zero, then we can't determine C uniquely since it's defined // in terms of the angle between A and B. if (sinab > 0) { uc.x = cosac; uc.y = (cosbc - cosac * cosab) / sinab; uc.z = sqrt(1.0 - uc.x*uc.x - uc.y*uc.y); } uc = c * uc; // Now move origin to the bottom corner uo = uo - (0.5 * (ua + ub + uc)); MolData* mol_data = MolData::readData(indices, coords, count, uo, ua, ub, uc, res,radius,select_dist,periodic); printf("Building grid\n"); AtomGrid* atom_grid = new AtomGrid(mol_data); mol_data->wrapCoords(atom_grid); atom_grid->build(mol_data); // atom_grid->print(); // atom_grid->store("grid.dat"); printf("Searching grid\n"); AtomList* atom_list = mol_data->findAtomsGrid(atom_grid); printf("Storing\n"); atom_list->storeData(surf,n_surf); delete atom_list; delete atom_grid; delete mol_data; return; }
void CGameView::Update(const float deltaRealTime) { // If camera movement is being handled by the touch-input system, // then we should stop to avoid conflicting with it if (g_TouchInput.IsEnabled()) return; if (!g_app_has_focus) return; if (m->TrackManager.IsActive() && m->TrackManager.IsPlaying()) { if (! m->TrackManager.Update(deltaRealTime)) { // ResetCamera(); } return; } // Calculate mouse movement static int mouse_last_x = 0; static int mouse_last_y = 0; int mouse_dx = g_mouse_x - mouse_last_x; int mouse_dy = g_mouse_y - mouse_last_y; mouse_last_x = g_mouse_x; mouse_last_y = g_mouse_y; if (HotkeyIsPressed("camera.rotate.cw")) m->RotateY.AddSmoothly(m->ViewRotateYSpeed * deltaRealTime); if (HotkeyIsPressed("camera.rotate.ccw")) m->RotateY.AddSmoothly(-m->ViewRotateYSpeed * deltaRealTime); if (HotkeyIsPressed("camera.rotate.up")) m->RotateX.AddSmoothly(-m->ViewRotateXSpeed * deltaRealTime); if (HotkeyIsPressed("camera.rotate.down")) m->RotateX.AddSmoothly(m->ViewRotateXSpeed * deltaRealTime); float moveRightward = 0.f; float moveForward = 0.f; if (HotkeyIsPressed("camera.pan")) { moveRightward += m->ViewDragSpeed * mouse_dx; moveForward += m->ViewDragSpeed * -mouse_dy; } if (g_mouse_active) { if (g_mouse_x >= g_xres - 2 && g_mouse_x < g_xres) moveRightward += m->ViewScrollSpeed * deltaRealTime; else if (g_mouse_x <= 3 && g_mouse_x >= 0) moveRightward -= m->ViewScrollSpeed * deltaRealTime; if (g_mouse_y >= g_yres - 2 && g_mouse_y < g_yres) moveForward -= m->ViewScrollSpeed * deltaRealTime; else if (g_mouse_y <= 3 && g_mouse_y >= 0) moveForward += m->ViewScrollSpeed * deltaRealTime; } if (HotkeyIsPressed("camera.right")) moveRightward += m->ViewScrollSpeed * deltaRealTime; if (HotkeyIsPressed("camera.left")) moveRightward -= m->ViewScrollSpeed * deltaRealTime; if (HotkeyIsPressed("camera.up")) moveForward += m->ViewScrollSpeed * deltaRealTime; if (HotkeyIsPressed("camera.down")) moveForward -= m->ViewScrollSpeed * deltaRealTime; if (g_Joystick.IsEnabled()) { // This could all be improved with extra speed and sensitivity settings // (maybe use pow to allow finer control?), and inversion settings moveRightward += g_Joystick.GetAxisValue(m->JoystickPanX) * m->ViewScrollSpeed * deltaRealTime; moveForward -= g_Joystick.GetAxisValue(m->JoystickPanY) * m->ViewScrollSpeed * deltaRealTime; m->RotateX.AddSmoothly(g_Joystick.GetAxisValue(m->JoystickRotateX) * m->ViewRotateXSpeed * deltaRealTime); m->RotateY.AddSmoothly(-g_Joystick.GetAxisValue(m->JoystickRotateY) * m->ViewRotateYSpeed * deltaRealTime); // Use a +1 bias for zoom because I want this to work with trigger buttons that default to -1 m->Zoom.AddSmoothly((g_Joystick.GetAxisValue(m->JoystickZoomIn) + 1.0f) / 2.0f * m->ViewZoomSpeed * deltaRealTime); m->Zoom.AddSmoothly(-(g_Joystick.GetAxisValue(m->JoystickZoomOut) + 1.0f) / 2.0f * m->ViewZoomSpeed * deltaRealTime); } if (moveRightward || moveForward) { // Break out of following mode when the user starts scrolling m->FollowEntity = INVALID_ENTITY; float s = sin(m->RotateY.GetSmoothedValue()); float c = cos(m->RotateY.GetSmoothedValue()); m->PosX.AddSmoothly(c * moveRightward); m->PosZ.AddSmoothly(-s * moveRightward); m->PosX.AddSmoothly(s * moveForward); m->PosZ.AddSmoothly(c * moveForward); } if (m->FollowEntity) { CmpPtr<ICmpPosition> cmpPosition(*(m->Game->GetSimulation2()), m->FollowEntity); CmpPtr<ICmpRangeManager> cmpRangeManager(*(m->Game->GetSimulation2()), SYSTEM_ENTITY); if (cmpPosition && cmpPosition->IsInWorld() && cmpRangeManager && cmpRangeManager->GetLosVisibility(m->FollowEntity, m->Game->GetPlayerID(), false) == ICmpRangeManager::VIS_VISIBLE) { // Get the most recent interpolated position float frameOffset = m->Game->GetSimulation2()->GetLastFrameOffset(); CMatrix3D transform = cmpPosition->GetInterpolatedTransform(frameOffset, false); CVector3D pos = transform.GetTranslation(); if (m->FollowFirstPerson) { float x, z, angle; cmpPosition->GetInterpolatedPosition2D(frameOffset, x, z, angle); float height = 4.f; m->ViewCamera.m_Orientation.SetIdentity(); m->ViewCamera.m_Orientation.RotateX((float)M_PI/24.f); m->ViewCamera.m_Orientation.RotateY(angle); m->ViewCamera.m_Orientation.Translate(pos.X, pos.Y + height, pos.Z); m->ViewCamera.UpdateFrustum(); return; } else { // Move the camera to match the unit CCamera targetCam = m->ViewCamera; SetupCameraMatrixSmoothRot(m, &targetCam.m_Orientation); CVector3D pivot = GetSmoothPivot(targetCam); CVector3D delta = pos - pivot; m->PosX.AddSmoothly(delta.X); m->PosY.AddSmoothly(delta.Y); m->PosZ.AddSmoothly(delta.Z); } } else { // The unit disappeared (died or garrisoned etc), so stop following it m->FollowEntity = INVALID_ENTITY; } } if (HotkeyIsPressed("camera.zoom.in")) m->Zoom.AddSmoothly(-m->ViewZoomSpeed * deltaRealTime); if (HotkeyIsPressed("camera.zoom.out")) m->Zoom.AddSmoothly(m->ViewZoomSpeed * deltaRealTime); if (m->ConstrainCamera) m->Zoom.ClampSmoothly(m->ViewZoomMin, m->ViewZoomMax); float zoomDelta = -m->Zoom.Update(deltaRealTime); if (zoomDelta) { CVector3D forwards = m->ViewCamera.m_Orientation.GetIn(); m->PosX.AddSmoothly(forwards.X * zoomDelta); m->PosY.AddSmoothly(forwards.Y * zoomDelta); m->PosZ.AddSmoothly(forwards.Z * zoomDelta); } if (m->ConstrainCamera) m->RotateX.ClampSmoothly(DEGTORAD(m->ViewRotateXMin), DEGTORAD(m->ViewRotateXMax)); FocusHeight(m, true); // Ensure the ViewCamera focus is inside the map with the chosen margins // if not so - apply margins to the camera if (m->ConstrainCamera) { CCamera targetCam = m->ViewCamera; SetupCameraMatrixSmoothRot(m, &targetCam.m_Orientation); CTerrain* pTerrain = m->Game->GetWorld()->GetTerrain(); CVector3D pivot = GetSmoothPivot(targetCam); CVector3D delta = targetCam.m_Orientation.GetTranslation() - pivot; CVector3D desiredPivot = pivot; CmpPtr<ICmpRangeManager> cmpRangeManager(*(m->Game->GetSimulation2()), SYSTEM_ENTITY); if (cmpRangeManager && cmpRangeManager->GetLosCircular()) { // Clamp to a circular region around the center of the map float r = pTerrain->GetMaxX() / 2; CVector3D center(r, desiredPivot.Y, r); float dist = (desiredPivot - center).Length(); if (dist > r - CAMERA_EDGE_MARGIN) desiredPivot = center + (desiredPivot - center).Normalized() * (r - CAMERA_EDGE_MARGIN); } else { // Clamp to the square edges of the map desiredPivot.X = Clamp(desiredPivot.X, pTerrain->GetMinX() + CAMERA_EDGE_MARGIN, pTerrain->GetMaxX() - CAMERA_EDGE_MARGIN); desiredPivot.Z = Clamp(desiredPivot.Z, pTerrain->GetMinZ() + CAMERA_EDGE_MARGIN, pTerrain->GetMaxZ() - CAMERA_EDGE_MARGIN); } // Update the position so that pivot is within the margin m->PosX.SetValueSmoothly(desiredPivot.X + delta.X); m->PosZ.SetValueSmoothly(desiredPivot.Z + delta.Z); } m->PosX.Update(deltaRealTime); m->PosY.Update(deltaRealTime); m->PosZ.Update(deltaRealTime); // Handle rotation around the Y (vertical) axis { CCamera targetCam = m->ViewCamera; SetupCameraMatrixSmooth(m, &targetCam.m_Orientation); float rotateYDelta = m->RotateY.Update(deltaRealTime); if (rotateYDelta) { // We've updated RotateY, and need to adjust Pos so that it's still // facing towards the original focus point (the terrain in the center // of the screen). CVector3D upwards(0.0f, 1.0f, 0.0f); CVector3D pivot = GetSmoothPivot(targetCam); CVector3D delta = targetCam.m_Orientation.GetTranslation() - pivot; CQuaternion q; q.FromAxisAngle(upwards, rotateYDelta); CVector3D d = q.Rotate(delta) - delta; m->PosX.Add(d.X); m->PosY.Add(d.Y); m->PosZ.Add(d.Z); } } // Handle rotation around the X (sideways, relative to camera) axis { CCamera targetCam = m->ViewCamera; SetupCameraMatrixSmooth(m, &targetCam.m_Orientation); float rotateXDelta = m->RotateX.Update(deltaRealTime); if (rotateXDelta) { CVector3D rightwards = targetCam.m_Orientation.GetLeft() * -1.0f; CVector3D pivot = GetSmoothPivot(targetCam); CVector3D delta = targetCam.m_Orientation.GetTranslation() - pivot; CQuaternion q; q.FromAxisAngle(rightwards, rotateXDelta); CVector3D d = q.Rotate(delta) - delta; m->PosX.Add(d.X); m->PosY.Add(d.Y); m->PosZ.Add(d.Z); } } /* This is disabled since it doesn't seem necessary: // Ensure the camera's near point is never inside the terrain if (m->ConstrainCamera) { CMatrix3D target; target.SetIdentity(); target.RotateX(m->RotateX.GetValue()); target.RotateY(m->RotateY.GetValue()); target.Translate(m->PosX.GetValue(), m->PosY.GetValue(), m->PosZ.GetValue()); CVector3D nearPoint = target.GetTranslation() + target.GetIn() * defaultNear; float ground = m->Game->GetWorld()->GetTerrain()->GetExactGroundLevel(nearPoint.X, nearPoint.Z); float limit = ground + 16.f; if (nearPoint.Y < limit) m->PosY.AddSmoothly(limit - nearPoint.Y); } */ m->RotateY.Wrap(-(float)M_PI, (float)M_PI); // Update the camera matrix m->ViewCamera.SetProjection(m->ViewNear, m->ViewFar, m->ViewFOV); SetupCameraMatrixSmooth(m, &m->ViewCamera.m_Orientation); m->ViewCamera.UpdateFrustum(); }
float CGameView::GetCullFOV() const { return m->ViewFOV + DEGTORAD(6.0f); //add 6 degrees to the default FOV for use with the culling frustum; }
void InitDynamicParam() { // Postion des sphères : t & t-1 // sphère 0 sphere_p[0][0] = -13.0; sphere_p[1][0] = R + 1 + Hauteur; sphere_p[2][0] = 13.0; sphere_ip[0][0] = -13.0; sphere_ip[1][0] = R + 1 + Hauteur; sphere_ip[2][0] = 13.0; // sphère 1 sphere_p[0][1] = -5.0; sphere_p[1][1] = R + 1 + Hauteur; sphere_p[2][1] = 5.0; sphere_ip[0][1] = -5.0; sphere_ip[1][1] = R + 1 + Hauteur; sphere_ip[2][1] = 5.0; // sphère 2 sphere_p[0][2] = 10.0; sphere_p[1][2] = R + 1 + Hauteur; sphere_p[2][2] = -10.0; sphere_ip[0][2] = 10.0; sphere_ip[1][2] = R + 1 + Hauteur; sphere_ip[2][2] = -10.0; // Vitesse des sphères : t & t-1 // sphère 0 sphere_v[0][0] = 0.0; sphere_v[1][0] = 0.0; sphere_v[2][0] = 0.0; sphere_iv[0][0] = 0.0; sphere_iv[1][0] = 0.0; sphere_iv[2][0] = 0.0; // sphère 1 sphere_v[0][1] = 0.0; sphere_v[1][1] = 0.0; sphere_v[2][1] = 0.0; sphere_iv[0][1] = 0.0; sphere_iv[1][1] = 0.0; sphere_iv[2][1] = 0.0; // sphère 2 sphere_v[0][2] = 0.0; sphere_v[1][2] = 0.0; sphere_v[2][2] = 0.0; sphere_iv[0][2] = 0.0; sphere_iv[1][2] = 0.0; sphere_iv[2][2] = 0.0; // accélération de la sphère // sphère 0 sphere_a[0][0] = 0.0; sphere_a[1][0] = 0.0; sphere_a[2][0] = 0.0; sphere_ia[0][0] = 0.0; sphere_ia[1][0] = 0.0; sphere_ia[2][0] = 0.0; // sphère 1 sphere_a[0][1] = 0.0; sphere_a[1][1] = 0.0; sphere_a[2][1] = 0.0; sphere_ia[0][1] = 0.0; sphere_ia[1][1] = 0.0; sphere_ia[2][1] = 0.0; // sphère 2 sphere_a[0][2] = 0.0; sphere_a[1][2] = 0.0; sphere_a[2][2] = 0.0; sphere_ia[0][2] = 0.0; sphere_ia[1][2] = 0.0; sphere_ia[2][2] = 0.0; //position de la queue queue_p[0] = Ecart * sin(DEGTORAD(QueueRot)) + (sphere_p[0][0]); queue_p[1] = sphere_p[1][0]; queue_p[2] = Ecart * cos(DEGTORAD(QueueRot)) + (sphere_p[2][0]); queue_ip[0] = Ecart * sin(DEGTORAD(QueueRot)) + (sphere_p[0][0]); queue_ip[1] = sphere_ip[1][0]; queue_ip[2] = Ecart * cos(DEGTORAD(QueueRot)) + (sphere_p[2][0]); // vitesse de la queue queue_v[0] = 0.0; queue_v[1] = 0.0; queue_v[2] = 0.0; queue_iv[0] = 0.0; queue_iv[1] = 0.0; queue_iv[2] = 0.0; // acceleration de la queue // La puissance est une force // a = Force/masse queue_a[0] = - (Puissance / Masse_queue) * sin(DEGTORAD(QueueRot)); queue_a[1] = 0.0; queue_a[2] = - (Puissance / Masse_queue) * cos(DEGTORAD(QueueRot)); queue_ia[0] = - (Puissance / Masse_queue) * sin(DEGTORAD(QueueRot)); queue_ia[1] = 0.0; queue_ia[2] = - (Puissance / Masse_queue) * cos(DEGTORAD(QueueRot)); }
int PS3_initialize(void) { s32 ret,i; void *host_addr = memalign(1024*1024, HOST_SIZE); s32 pressedCounter = 0; Matrix4 rotX,rotY; sysModuleLoad(SYSMODULE_FS); ioPadInit(7); write_log("PS3_initialize...\n"); int videoMode = getVideoMode(); init_screen(host_addr, HOST_SIZE, videoMode); init_shader(); //init_texture(); //init_texture_ui(); quad = createQuad(10.0f, 0.0f); quad_ui = createQuad(10.0f, 0.5f); rotX = Matrix4::rotationX(DEGTORAD(0.0f)); rotY = Matrix4::rotationY(DEGTORAD(180.0f)); modelMatrixBase = rotX * rotY; modelMatrixUi = rotX * rotY; modelMatrix = rotX * rotY; ret = atexit(program_exit_callback); ret = sysUtilRegisterCallback(0,sysutil_exit_callback,NULL); P = transpose(Matrix4::orthographic(-5.0f, 5.0f, -5.0f, 5.0f, -10.0f, 10.0f)); // by default sretch video to 90% of the screen in X axis (compensate output to wide screens) scaler.setX(1.0f); scaler.setY(1.0f); scaler.setZ(1.0f); translator.setX(0.0f); translator.setY(0.0f); translator.setZ(0.0f); setRenderTarget(curr_fb); scanline.setX(200.0f); //desnity scanline.setY(2.0f); //contrast scanline.setZ(0.7f); //brightnes scanline.setW(0.1f); //scanline type -> horizontal lines scanlineUi.setX(0); //no desnsity modifier scanlineUi.setY(0); //no contrast modifier scanlineUi.setZ(1.0f); //full brightnes scanlineUi.setW(0.0f); //scanline type -> no scanlines running = 1; masterVolume = 32768.0f * 2.8f; // 80% volumeMuted = 0; return 0; }
void Renderer::drawMissles() { for (unsigned int i=0; i<game->missles.size(); i++ ) { if(game->missles[i]->type == LASER) { float x = game->missles[i]->position[0]; float y = game->missles[i]->position[1]; glPushMatrix (); glLineWidth (10.0f); glBegin (GL_LINES); glColor3f (1,0,0); glVertex3f (game->missles[i]->positionStart.x,game->missles[i]->positionStart.y,0); glColor3f (0,0,1); glVertex3f (x,y,0); glEnd(); glPopMatrix (); glPushMatrix (); glLineWidth (3.0f); glTranslatef(x,y,0); glBegin(GL_LINE_LOOP); if ( game->missles[i]->m_contacting ) glColor3f(1,0,0);//red else glColor3f(1,1,1);//white for (int j=0; j < 360; j++) { float degInRad = DEGTORAD(j); glVertex2f(cos(degInRad)*game->missles[i]->radius,sin(degInRad)*game->missles[i]->radius); } glEnd(); glPopMatrix (); } else if(game->missles[i]->type == BULLET) { float x = game->missles[i]->position[0]; float y = game->missles[i]->position[1]; glPushMatrix (); glLineWidth (3.0f); glTranslatef(x,y,0); glBegin(GL_LINE_LOOP); if ( game->missles[i]->m_contacting ) glColor3f(1,0,0);//red else glColor3f(1,1,1);//white for (int j=0; j < 360; j++) { float degInRad = DEGTORAD(j); glVertex2f(cos(degInRad)*game->missles[i]->radius,sin(degInRad)*game->missles[i]->radius); } glEnd(); glPopMatrix (); } else if(game->missles[i]->type == PLASMA) { float x = game->missles[i]->position[0]; float y = game->missles[i]->position[1]; glPushMatrix (); glLineWidth (3.0f); glTranslatef(x,y,0); glBegin(GL_LINE_LOOP); if ( game->missles[i]->m_contacting ) glColor3f(1,0,0);//red else glColor3f(1,1,1);//white for (int j=0; j < 360; j++) { float degInRad = DEGTORAD(j); glVertex2f(cos(degInRad)*game->missles[i]->radius,sin(degInRad)*game->missles[i]->radius); } glEnd(); glPopMatrix (); } else if(game->missles[i]->type == ROCKET) { Renderer::getInstance().DrawQuadTexture(2.0f,2.0f,5.0f,5.0f,game->missles[i]->myID); } } }
void CTerrainProperties::LoadXml(XMBElement node, CXeromyces *pFile, const VfsPath& UNUSED(pathname)) { #define ELMT(x) int elmt_##x = pFile->GetElementID(#x) #define ATTR(x) int attr_##x = pFile->GetAttributeID(#x) // Terrain Attribs ATTR(mmap); ATTR(groups); ATTR(movementclass); ATTR(angle); ATTR(size); #undef ELMT #undef ATTR XERO_ITER_ATTR(node, attr) { if (attr.Name == attr_groups) { // Parse a comma-separated list of groups, add the new entry to // each of them CParser parser; CParserLine parserLine; parser.InputTaskType("GroupList", "<_$value_,>_$value_"); if (!parserLine.ParseString(parser, attr.Value)) continue; m_Groups.clear(); for (size_t i=0;i<parserLine.GetArgCount();i++) { std::string value; if (!parserLine.GetArgString(i, value)) continue; CTerrainGroup *pType = g_TexMan.FindGroup(value); m_Groups.push_back(pType); } } else if (attr.Name == attr_mmap) { CColor col; if (!col.ParseString(attr.Value, 255)) continue; // m_BaseColor is BGRA u8 *baseColor = (u8*)&m_BaseColor; baseColor[0] = (u8)(col.b*255); baseColor[1] = (u8)(col.g*255); baseColor[2] = (u8)(col.r*255); baseColor[3] = (u8)(col.a*255); m_HasBaseColor = true; } else if (attr.Name == attr_angle) { m_TextureAngle = DEGTORAD(attr.Value.ToFloat()); } else if (attr.Name == attr_size) { m_TextureSize = attr.Value.ToFloat(); } else if (attr.Name == attr_movementclass) { m_MovementClass = attr.Value; } } }
// generates the vertex coordinates for a dome void skydome::buildDome() { int lat,lon,n=0; m_domeVertexCount = (int)((360/m_delLon)*(90/m_delLat)*4); m_domeVerts = new Vertex[m_domeVertexCount]; for(lat=0;lat <= 90-m_delLat;lat+=m_delLat){ for(lon=0;lon <= 360-m_delLon;lon+=m_delLon){ m_domeVerts[n].x = m_domeRadius * sin(DEGTORAD(lat)) * cos(DEGTORAD(lon)); m_domeVerts[n].y = m_domeRadius * sin(DEGTORAD(lat)) * sin(DEGTORAD(lon)); m_domeVerts[n].z = m_domeRadius * cos(DEGTORAD(lat)); n++; m_domeVerts[n].x = m_domeRadius * sin(DEGTORAD(lat+m_delLat)) * cos(DEGTORAD(lon)); m_domeVerts[n].y = m_domeRadius * sin(DEGTORAD(lat+m_delLat)) * sin(DEGTORAD(lon)); m_domeVerts[n].z = m_domeRadius * cos(DEGTORAD(lat+m_delLat)); n++; m_domeVerts[n].x = m_domeRadius * sin(DEGTORAD(lat)) * cos(DEGTORAD(lon+m_delLon)); m_domeVerts[n].y = m_domeRadius * sin(DEGTORAD(lat)) * sin(DEGTORAD(lon+m_delLon)); m_domeVerts[n].z = m_domeRadius * cos(DEGTORAD(lat)); n++; if(lat > -90 && lat < 90){ m_domeVerts[n].x = m_domeRadius * sin(DEGTORAD(lat+m_delLat)) * cos(DEGTORAD(lon+m_delLon)); m_domeVerts[n].y = m_domeRadius * sin(DEGTORAD(lat+m_delLat)) * sin(DEGTORAD(lon+m_delLon)); m_domeVerts[n].z = m_domeRadius * cos(DEGTORAD(lat+m_delLat)); n++; } } } }