void addDynamicOccluder(ZTransform* aTransform) { int i; FOccluderBox obox; tvector3 extend(1,1,1); const tmatrix& boxmat = aTransform->GetWorldMatrix(); for (i=0; i<8; i++) { tvector3 bvt(BoxCorners[i].x, BoxCorners[i].y, BoxCorners[i].z),bvt2; bvt2.TransformPoint((bvt*extend), boxmat); obox.mVertex[i] = vector4(bvt2.x, bvt2.y, bvt2.z, 0); } for (i=0; i<6; i++) { tvector3 cross = obox.mVertex[FaceVertexIndex[i][1]]; cross -= obox.mVertex[FaceVertexIndex[i][0]]; tvector3 cr2 = obox.mVertex[FaceVertexIndex[i][2]]; cr2 -= obox.mVertex[FaceVertexIndex[i][0]]; cross.Cross(cr2); obox.mPlanes[i] = vector4(cross.x, cross.y, cross.z, 0); obox.mPlanes[i].Normalize(); obox.mPlanes[i].w = -DotProduct(obox.mPlanes[i], obox.mVertex[FaceVertexIndex[i][0]]); obox.mVertex[i].w = fabs(obox.mPlanes[i].Dot( cross)); // save area in vertex w component } obox.mCenter = vector4(boxmat.m16[12], boxmat.m16[13], boxmat.m16[14], 0); obox.mCenter.w = Distance(obox.mCenter, obox.mVertex[0]); gOccluderBoxes.push_back(obox); }
GLCamera::GLCamera(float aspect) { near = 0.1f; far = 100.0f; fovy = 67.0f; //aspect = (float)g_gl_width / (float)g_gl_height; this->aspect = aspect; proj_mat = perspective(fovy, this->aspect, near, far); cam_speed = 5.0f; cam_heading_speed = 100.0f; cam_heading = 0.0f; cam_pos = vector3(0.0f, 0.0f, 5.0f); T = identity_mat4().translate( vector3(-cam_pos.v[0], -cam_pos.v[1], -cam_pos.v[2]) ); create_versor(quaternion, -cam_heading, 0.0f, 1.0f, 0.0f); quat_to_mat4(R.m, quaternion); // combine the inverse rotation and transformation to make a view matrix view_mat = R * T; // keep track of some useful vectors that can be used for keyboard movement fwd = vector4(0.0f, 0.0f, -1.0f, 0.0f); rgt = vector4(1.0f, 0.0f, 0.0f, 0.0f); up = vector4(0.0f, 1.0f, 0.0f, 0.0f); cam_yaw = 0.0f; // y-rotation in degrees cam_pitch = 0.0f; cam_roll = 0.0; }
// returns a view matrix using the opengl lookAt style. COLUMN ORDER. void GLCamera::look_at(const vector3& pos, vector3 targ_pos, const vector3& up_v) { this->cam_pos = pos; // inverse translation matriz4x4 p = identity_mat4(); p = p.translate(vector3(-pos.v[0], -pos.v[1], -pos.v[2])); // distance vector vector3 d = targ_pos - pos; // forward vector vector3 f = d.normalise(); // right vector vector3 r = cross(f, up_v).normalise(); // real up vector vector3 u = cross(r, f).normalise(); matriz4x4 ori = identity_mat4(); ori.m[0] = r.v[0]; ori.m[4] = r.v[1]; ori.m[8] = r.v[2]; ori.m[1] = u.v[0]; ori.m[5] = u.v[1]; ori.m[9] = u.v[2]; ori.m[2] = -f.v[0]; ori.m[6] = -f.v[1]; ori.m[10] = -f.v[2]; R = ori; T = p; view_mat = R * T; // recalc axes to suit new orientation mat4_to_quat(quaternion, R.m); fwd = R * vector4(0.0, 0.0, -1.0, 0.0); rgt = R * vector4(1.0, 0.0, 0.0, 0.0); up = R * vector4(0.0, 1.0, 0.0, 0.0); }
//--- Non Standard Singleton Methods bool MyBoundingBoxClass::IsColliding(MyBoundingBoxClass* const a_pOther) { //Get all vectors in global space vector3 v3Min = vector3(m_m4ToWorld * vector4(m_v3Min, 1.0f)); vector3 v3Max = vector3(m_m4ToWorld * vector4(m_v3Max, 1.0f)); vector3 v3MinO = vector3(a_pOther->m_m4ToWorld * vector4(a_pOther->m_v3Min, 1.0f)); vector3 v3MaxO = vector3(a_pOther->m_m4ToWorld * vector4(a_pOther->m_v3Max, 1.0f)); /* Are they colliding? For boxes we will assume they are colliding, unless at least one of the following conditions is not met */ bool bColliding = true; //Check for X if (m_v3MaxG.x < a_pOther->m_v3MinG.x) bColliding = false; if (m_v3MinG.x > a_pOther->m_v3MaxG.x) bColliding = false; //Check for Y if (m_v3MaxG.y < a_pOther->m_v3MinG.y) bColliding = false; if (m_v3MinG.y > a_pOther->m_v3MaxG.y) bColliding = false; //Check for Z if (m_v3MaxG.z < a_pOther->m_v3MinG.z) bColliding = false; if (m_v3MinG.z > a_pOther->m_v3MaxG.z) bColliding = false; return bColliding; }
const vector4 &CCoordSysAxis::Vector4() const{ static const vector4 vs[4] = { vector4(1,0,0,0), vector4(0,1,0,0), vector4(0,0,1,0) }; return vs[m_id]; }
// Returns the debug visualization color which is used in RenderDebug(). // This depends on the state of the rigid body which owns this state (if any): // yellow: no rigid body attached to pShape // green: rigid body is enabled // blue: ridig body is disabled vector4 CShape::GetDebugVisualizationColor() const { return (pRigidBody) ? ((pRigidBody->IsEnabled()) ? vector4(0.0f, 1.0f, 0.0f, 0.75f) : vector4(0.0f, 0.0f, 1.0f, 0.75f)) : vector4(1.0f, 1.0f, 0.0f, 0.3f); }
bool CGizmoTransformMove::GetOpType(MOVETYPE &type, unsigned int x, unsigned int y) { tvector3 rayOrigin, rayDir, df; BuildRay(x, y, rayOrigin, rayDir); m_svgMatrix = *m_pMatrix; tvector3 trss(GetTransformedVector(0).Length(), GetTransformedVector(1).Length(), GetTransformedVector(2).Length()); tmatrix mt; if (mLocation == LOCATE_LOCAL) { mt = *m_pMatrix; mt.V4.position += vector4(m_Offset, 0.0f); mt.Inverse(); } else { // world tvector4 pos = m_pMatrix->V4.position; pos += vector4(m_Offset, 0.0f); mt.Translation(-pos); } // plan 1 : X/Z df = RayTrace2(rayOrigin, rayDir, GetTransformedVector(1), mt, trss, false); if ( ( df.x >= 0 ) && (df.x <= 1) && ( fabs(df.z) < 0.1f ) ) { type = MOVE_X; return true; } else if ( ( df.z >= 0 ) && (df.z <= 1) && ( fabs(df.x) < 0.1f ) ){ type = MOVE_Z; return true; } else if ( (df.x<0.5f) && (df.z<0.5f) && (df.x>0) && (df.z>0)) { type = MOVE_XZ; return true; } else { //plan 2 : X/Y df = RayTrace2(rayOrigin, rayDir, GetTransformedVector(2), mt, trss, false); if ( ( df.x >= 0 ) && (df.x <= 1) && ( fabs(df.y) < 0.1f ) ) { type = MOVE_X; return true; } if ( ( df.y >= 0 ) && (df.y <= 1) && ( fabs(df.x) < 0.1f ) ) { type = MOVE_Y; return true; } else if ( (df.x<0.5f) && (df.y<0.5f) && (df.x>0) && (df.y>0)) { type = MOVE_XY; return true; } else { //plan 3: Y/Z df = RayTrace2(rayOrigin, rayDir, GetTransformedVector(0), mt, trss, false); if ( ( df.y >= 0 ) && (df.y <= 1) && ( fabs(df.z) < 0.1f ) ) { type = MOVE_Y; return true; } else if ( ( df.z >= 0 ) && (df.z <= 1) && ( fabs(df.y) < 0.1f ) ) { type = MOVE_Z; return true; } else if ( (df.y<0.5f) && (df.z<0.5f) && (df.y>0) && (df.z>0)) { type = MOVE_YZ; return true; } } } type = MOVE_NONE; return false; }
void GLCamera::movePitchDown(double elapsed_seconds) { cam_pitch -= cam_heading_speed * elapsed_seconds; float q_pitch[16]; create_versor(q_pitch, cam_pitch, rgt.v[0], rgt.v[1], rgt.v[2]); mult_quat_quat(quaternion, q_pitch, quaternion); // recalc axes to suit new orientation quat_to_mat4(R.m, quaternion); fwd = R * vector4(0.0, 0.0, -1.0, 0.0); rgt = R * vector4(1.0, 0.0, 0.0, 0.0); up = R * vector4(0.0, 1.0, 0.0, 0.0); }
void DecoScene::PointScreen2WorldRay(const vector2& pt, vector3& outOrigin, vector3& outDir) const { vector3 viewVec = PointScreen2Camera(pt); matrix44 invview; RI->GetTransform(TT_WorldToCamera, invview); invview.invert(); if (camera->isOrthogonal()) { vector4 viewOrigin(viewVec); viewOrigin.z = 0.f; vector4 viewDir(0, 0, -1, 0); viewOrigin.w = 1.f; viewOrigin = invview * vector4(viewOrigin); vector4 worldVec = invview * viewDir; outOrigin = vector3(viewOrigin.x, viewOrigin.y, viewOrigin.z); outDir = vector3(worldVec.x, worldVec.y, worldVec.z); } else { viewVec.normalize(); outOrigin = camera->getEye(); vector4 worldVec = invview * vector4(viewVec); outDir = vector3(worldVec.x, worldVec.y, worldVec.z); } }
void GLCamera::rollRight(double elapsed_seconds) { cam_roll += cam_heading_speed * elapsed_seconds; float q_roll[16]; create_versor(q_roll, cam_roll, fwd.v[0], fwd.v[1], fwd.v[2]); mult_quat_quat(quaternion, q_roll, quaternion); // recalc axes to suit new orientation quat_to_mat4(R.m, quaternion); fwd = R * vector4(0.0, 0.0, -1.0, 0.0); rgt = R * vector4(1.0, 0.0, 0.0, 0.0); up = R * vector4(0.0, 1.0, 0.0, 0.0); }
void CTriangle::Render( uint32 i_iPass ) { switch( i_iPass ) { case ePass_Lighting: break; } CGraphics *pGraphics = m_pParent->pGetParent()->pGetGraphics(); CCamera *pCurCamera = pGraphics->pGetCurCamera(); matrix44 matWorld; matMatrix44Identity( matWorld ); pCurCamera->SetWorldMatrix( matWorld ); m_pVertexShader->SetMatrix( m3dsc_worldmatrix, pCurCamera->matGetWorldMatrix() ); m_pVertexShader->SetMatrix( m3dsc_viewmatrix, pCurCamera->matGetViewMatrix() ); m_pVertexShader->SetMatrix( m3dsc_projectionmatrix, pCurCamera->matGetProjectionMatrix() ); m_pVertexShader->SetMatrix( m3dsc_wvpmatrix, pCurCamera->matGetWorldMatrix() * pCurCamera->matGetViewMatrix() * pCurCamera->matGetProjectionMatrix() ); vector3 vCamPos = pCurCamera->vGetPosition(); m_pVertexShader->SetVector( 0, vector4( vCamPos.x, vCamPos.y, vCamPos.z, 0 ) ); CLight *pLight = m_pParent->pGetCurrentLight(); vector3 vLightPos = pLight->vGetPosition(); m_pVertexShader->SetVector( 1, vector4( vLightPos.x, vLightPos.y, vLightPos.z, 0 ) ); m_pPixelShader->SetVector( 0, pLight->vGetColor() ); pGraphics->SetVertexFormat( m_pVertexFormat ); pGraphics->SetVertexStream( 0, m_pVertexBuffer, 0, sizeof( vertexformat ) ); pGraphics->SetVertexShader( m_pVertexShader ); pGraphics->SetPixelShader( m_pPixelShader ); CResManager *pResManager = m_pParent->pGetParent()->pGetResManager(); CTexture *pTexture = (CTexture *)pResManager->pGetResource( m_hTexture ); pGraphics->SetTexture( 0, pTexture->pGetTexture() ); CTexture *pNormalmap = (CTexture *)pResManager->pGetResource( m_hNormalmap ); pGraphics->SetTexture( 1, pNormalmap->pGetTexture() ); for( uint32 i = 0; i < 2; ++i ) { pGraphics->SetTextureSamplerState( i, m3dtss_addressu, m3dta_clamp ); pGraphics->SetTextureSamplerState( i, m3dtss_addressv, m3dta_clamp ); } pGraphics->pGetM3DDevice()->DrawPrimitive( m3dpt_trianglelist, 0, 1 ); }
void AppClass::InitWindow(String a_sWindowName) { super::InitWindow("SLERP - GREG ROZMARYNOWYCZ"); // Window Name //Setting the color to black m_v4ClearColor = vector4(0.0f); }
// outputs vector with: center, height, hwhm, area // returns values corresponding to peak_traits vector<double> Guess::estimate_peak_parameters() const { // find the highest point, which must be higher than the previous point // and not lower than the next one (-> it cannot be the first/last point) int pos = -1; if (!sigma_.empty()) { for (int i = 1; i < (int) yy_.size() - 1; ++i) { int t = (pos == -1 ? i-1 : pos); if (sigma_[t] * yy_[i] > sigma_[i] * yy_[t] && sigma_[i+1] * yy_[i] >= sigma_[i] * yy_[i+1]) pos = i; } } else { for (int i = 1; i < (int) yy_.size() - 1; ++i) { int t = (pos == -1 ? i-1 : pos); if (yy_[i] > yy_[t] && yy_[i] >= yy_[i+1]) pos = i; } } if (pos == -1) throw ExecuteError("Peak outside of the range."); double height = yy_[pos] * settings_->height_correction; double center = xx_[pos]; double area; double hwhm = find_hwhm(pos, &area) * settings_->width_correction; return vector4(center, height, hwhm, area); }
void CGizmoTransformRotate::Rotate1Axe(const tvector3& rayOrigin,const tvector3& rayDir) { tvector3 inters; m_plan=vector4(m_pMatrix->GetTranslation(), m_Axis2); m_plan.RayInter(inters,rayOrigin,rayDir); ptd = inters; tvector3 df = inters - m_pMatrix->GetTranslation(); df.Normalize(); m_LockVertex2 = df; float acosng = df.Dot(m_LockVertex); m_Ng2 = (float)acos(acosng); if (df.Dot(m_Vty)>0) m_Ng2 = -m_Ng2; tmatrix mt,mt2; if (m_bUseSnap) { m_Ng2*=(360.0f/ZPI); SnapIt(m_Ng2,m_AngleSnap); m_Ng2/=(360.0f/ZPI); } mt.RotationAxis(m_Axis,m_Ng2); mt.Multiply(m_InvOrigScale); mt.Multiply(m_svgMatrix); mt2 = m_OrigScale; mt2.Multiply(mt); *m_pMatrix=mt2; if (m_Axis == tvector3::ZAxis) { if (mEditQT) { /* Dans le cadre du jeu, et vu les pb avec les quaternions, le 1er float du quaternion en stockage est l'angle en radian. le stockage reste un quaternion. il y a des pbs de conversion quaternion/matrix */ #if USE_QUATERNION tquaternion gth(*m_pMatrix); gth.Normalize(); gth.UnitInverse(); tquaternion qtg; qtg.RotationAxis(m_Axis,m_Ng2); *mEditQT = gth;//gth+qtg;//tquaternion(mt2); mEditQT->Normalize(); #else mEditQT->z = m_Ng2; #endif } } }
void llquat_test_object_t::test<2>() { LLMatrix4 llmat; LLVector4 vector1(2.0f, 1.0f, 3.0f, 6.0f); LLVector4 vector2(5.0f, 6.0f, 0.0f, 1.0f); LLVector4 vector3(2.0f, 1.0f, 2.0f, 9.0f); LLVector4 vector4(3.0f, 8.0f, 1.0f, 5.0f); llmat.initRows(vector1, vector2, vector3, vector4); ensure("explicit LLQuaternion(const LLMatrix4 &mat) failed", 2.0f == llmat.mMatrix[0][0] && 1.0f == llmat.mMatrix[0][1] && 3.0f == llmat.mMatrix[0][2] && 6.0f == llmat.mMatrix[0][3] && 5.0f == llmat.mMatrix[1][0] && 6.0f == llmat.mMatrix[1][1] && 0.0f == llmat.mMatrix[1][2] && 1.0f == llmat.mMatrix[1][3] && 2.0f == llmat.mMatrix[2][0] && 1.0f == llmat.mMatrix[2][1] && 2.0f == llmat.mMatrix[2][2] && 9.0f == llmat.mMatrix[2][3] && 3.0f == llmat.mMatrix[3][0] && 8.0f == llmat.mMatrix[3][1] && 1.0f == llmat.mMatrix[3][2] && 5.0f == llmat.mMatrix[3][3]); }
void AppClass::InitWindow(String a_sWindowName) { super::InitWindow("SLERP - YOUR USER NAME GOES HERE"); // Window Name //Setting the color to black m_v4ClearColor = vector4(0.0f); }
DecoColor Shading(const vector3& realIntersectPt, const vector3& norm, DecoLight** lights, INT numLights, const vector3& viewPos, DecoMaterial* mat) { DecoColor col(0, 0, 0); vector3 matDiffuse, matSpecular, matAmbient; vector3 lightPos, lightDiffuse, lightSpecular, lightAmbient; if (mat) { matDiffuse = mat->GetDiffuse(); matSpecular = mat->GetSpecular(); matAmbient = mat->GetAmbient(); } else { matDiffuse = vector3(1, 1, 1); matSpecular = vector3(0, 0, 0); matAmbient = vector3(0.5, 0.5, 0.5); } for (INT i = 0; i < numLights; i++) { lightPos = lights[i]->GetPosition(); lightDiffuse = lights[i]->GetDiffuse(); lightSpecular = lights[i]->GetSpecular(); col += Shading(realIntersectPt, norm, lightPos, viewPos, lightDiffuse, lightSpecular, lightAmbient, matDiffuse, matSpecular, matAmbient); } lightAmbient = vector3(0.5, 0.5, 0.5); col += DecoColor(vector4(lightAmbient.x * matAmbient.x, lightAmbient.y * matAmbient.y, lightAmbient.z * matAmbient.z, 1)); return col; }
void LightManager::renderDebugVisualization(const matrix44& viewProjection) { for (size_t i = 0; i < m_lightSources.size(); i++) { if (m_lightSources[i].lightSource.type == LightType::OmniLight) { matrix44 model; model.set_translation(m_lightSources[i].lightSource.position); m_lightSources[i].lineDebugVis->renderWithStandardGpuProgram(model * viewProjection, m_lightSources[i].lightSource.diffuseColor, false); } else { matrix44 model(m_lightSources[i].lightSource.orientation); model.set_translation(m_lightSources[i].lightSource.position); m_lightSources[i].lineDebugVis->renderWithStandardGpuProgram(model * viewProjection, m_lightSources[i].lightSource.diffuseColor, true); auto program = framework::StandardGpuPrograms::getArrowRenderer(); if (program->use()) { program->setVector<StandardUniforms>(STD_UF::ORIENTATION, m_lightSources[i].lightSource.orientation); program->setVector<StandardUniforms>(STD_UF::POSITION, m_lightSources[i].lightSource.position); program->setMatrix<StandardUniforms>(STD_UF::MODELVIEWPROJECTION_MATRIX, viewProjection); program->setVector<StandardUniforms>(STD_UF::COLOR, vector4(m_lightSources[i].lightSource.diffuseColor)); glDrawArrays(GL_POINTS, 0, 1); } } } }
void AppClass::InitWindow(String a_sWindowName) { super::InitWindow("MIDTERM DEMO"); // Window Name m_pSystem->SetWindowWidth(720); //Set window dimensions m_pSystem->SetWindowHeight(720); m_v4ClearColor = vector4(0.4f, 0.6f, 0.9f, 0.0f);//Set clear color }
void AppClass::InitVariables(void) { m_pCameraMngr->SetPositionTargetAndView(vector3(0.0f, 0.0f, 15.0f), ZERO_V3, REAXISY); // Color of the screen m_v4ClearColor = vector4(REBLACK, 1); // Set the clear color to black m_pMeshMngr->LoadModel("Sorted\\WallEye.bto", "WallEye"); m_lPositions.push_back(vector3(-4.0f, -2.0f, 5.0f)); m_lPositions.push_back(vector3(1.0f, -2.0f, 5.0f)); m_lPositions.push_back(vector3(-3.0f, -1.0f, 3.0f)); m_lPositions.push_back(vector3(2.0f, -1.0f, 3.0f)); m_lPositions.push_back(vector3(-2.0f, 0.0f, 0.0f)); m_lPositions.push_back(vector3(3.0f, 0.0f, 0.0f)); m_lPositions.push_back(vector3(-1.0f, 1.0f, -3.0f)); m_lPositions.push_back(vector3(4.0f, 1.0f, -3.0f)); m_lPositions.push_back(vector3(0.0f, 2.0f, -5.0f)); m_lPositions.push_back(vector3(5.0f, 2.0f, -5.0f)); m_lPositions.push_back(vector3(1.0f, 3.0f, -5.0f)); fDuration = 1.0f; }
bool CApp::bCreateWorld() { m_pCamera = 0; m_hCrystal = 0; // Create and setup camera ------------------------------------------------ m_pCamera = new CMyCamera( pGetGraphics() ); if( !m_pCamera->bCreateRenderCamera( iGetWindowWidth(), iGetWindowHeight() ) ) return false; m_pCamera->CalculateProjection( M3D_PI / 6.0f, 2000.0f, 10.0f ); m_pCamera->SetPosition( vector3( 0, 0, -750 ) ); m_pCamera->SetLookAt( vector3( 0, 0, 0 ), vector3( 0, 1, 0 ) ); m_pCamera->CalculateView(); pGetScene()->SetClearColor( vector4( 0, 0, 0.5f, 0 ) ); // Register bubble-entity and create an instance -------------------------- pGetScene()->RegisterEntityType( "crystal", CCrystal::pCreate ); m_hCrystal = pGetScene()->hCreateEntity( "crystal" ); if( !m_hCrystal ) return false; CCrystal *pCrystal = (CCrystal *)pGetScene()->pGetEntity( m_hCrystal ); if( !pCrystal->bInitialize( "headobject.obj", "turtlebase.png", "turtlenormals.png" ) ) return false; return true; }
bool CApp::bCreateWorld() { m_pCamera = 0; m_hBubble = 0; // Create and setup camera ------------------------------------------------ m_pCamera = new CMyCamera( pGetGraphics() ); if( !m_pCamera->bCreateRenderCamera( iGetWindowWidth(), iGetWindowHeight() ) ) return false; m_pCamera->CalculateProjection( M3D_PI / 6.0f, 1000.0f, 1.0f ); m_pCamera->SetPosition( vector3( 0, 0, -100 ) ); m_pCamera->SetLookAt( vector3( 0, 0, 0 ), vector3( 0, 1, 0 ) ); m_pCamera->CalculateView(); pGetScene()->SetClearColor( vector4( 0, 0, 0.5f, 0 ) ); // Register bubble-entity and create an instance -------------------------- pGetScene()->RegisterEntityType( "bubble", CBubble::pCreate ); m_hBubble = pGetScene()->hCreateEntity( "bubble" ); if( !m_hBubble ) return false; CBubble *pBubble = (CBubble *)pGetScene()->pGetEntity( m_hBubble ); if( !pBubble->bInitialize( 20.0f, 16, 16 ) ) return false; return true; }
void AppClass::InitWindow(String a_sWindowName) { super::InitWindow("A07 - SLERP"); // Window Name //Setting the color to black m_v4ClearColor = vector4(0.0f); }
void GLCamera::moveYawLeft(double elapsed_seconds) { cam_yaw += getHeadingSpeed() * elapsed_seconds; // create a quaternion representing change in heading (the yaw) float q_yaw[16]; create_versor(q_yaw, cam_yaw, up.v[0], up.v[1], up.v[2]); // add yaw rotation to the camera's current orientation mult_quat_quat(quaternion, q_yaw, quaternion); // recalc axes to suit new orientation quat_to_mat4(R.m, quaternion); fwd = R * vector4(0.0, 0.0, -1.0, 0.0); rgt = R * vector4(1.0, 0.0, 0.0, 0.0); up = R * vector4(0.0, 1.0, 0.0, 0.0); }
void AppClass::InitWindow(String a_sWindowName) { super::InitWindow("MyEntityClass"); // Window Name //m_pSystem->SetWindowResolution(RESOLUTIONS::HD_1280X720); //m_pSystem->SetWindowFullscreen(); //Sets the window to be fullscreen //m_pSystem->SetWindowBorderless(true); //Sets the window to not have borders m_v4ClearColor = vector4(REBLACK, 1.0f); }
void AppClass::InitWindow(String a_sWindowName) { super::InitWindow("Joseph Horsmann & Veronica Lesnar A08 - Camera Singleton"); // Window Name // Set the clear color based on Microsoft's CornflowerBlue (default in XNA) //if this line is in Init Application it will depend on the .cfg file, if it //is on the InitVariables it will always force it regardless of the .cfg m_v4ClearColor = vector4(0.4f, 0.6f, 0.9f, 0.0f); }
///////////////////////////////////////////////////////////////////// //Method: IsColliding //Usage: Asks if there is a collision with another Bounding Object Object //Arguments: //MyBOClass* const a_pOther -> Other object to check collision with //Output: bool -> check of the collision ///////////////////////////////////////////////////////////////////// bool MyBOClass::IsColliding(MyBOClass* const a_pOther) { //Get all vectors in global space vector3 v3Min = vector3(m_m4ToWorld * vector4(m_v3Min, 1.0f)); vector3 v3Max = vector3(m_m4ToWorld * vector4(m_v3Max, 1.0f)); vector3 v3MinO = vector3(a_pOther->m_m4ToWorld * vector4(a_pOther->m_v3Min, 1.0f)); vector3 v3MaxO = vector3(a_pOther->m_m4ToWorld * vector4(a_pOther->m_v3Max, 1.0f)); /* Are they colliding? For Objects we will assume they are colliding, unless at least one of the following conditions is not met */ //first check the bounding sphere, if that is not colliding we can guarantee that there are no collision //if ((m_fRadius + a_pOther->m_fRadius) < glm::distance(m_v3CenterG, a_pOther->m_v3CenterG)) // return false; //If the distance was smaller it might be colliding //Do precheck with AABO bool bColliding = true; //Check for X if (m_v3MaxG.x < a_pOther->m_v3MinG.x) bColliding = false; if (m_v3MinG.x > a_pOther->m_v3MaxG.x) bColliding = false; //Check for Y if (m_v3MaxG.y < a_pOther->m_v3MinG.y) bColliding = false; if (m_v3MinG.y > a_pOther->m_v3MaxG.y) bColliding = false; //Check for Z if (m_v3MaxG.z < a_pOther->m_v3MinG.z) bColliding = false; if (m_v3MinG.z > a_pOther->m_v3MaxG.z) bColliding = false; if (bColliding == false) return false; return SAT(a_pOther); }
void AppClass::InitWindow(String a_sWindowName) { super::InitWindow("MyBoundingSphereClass example"); // Window Name // Set the clear color based on Microsoft's CornflowerBlue (default in XNA) //if this line is in Init Application it will depend on the .cfg file, if it //is on the InitVariables it will always force it regardless of the .cfg m_v4ClearColor = vector4(0.4f, 0.6f, 0.9f, 0.0f); }
result CMuli3DRenderTarget::ClearDepthBuffer( float32 i_fDepth, const m3drect *i_pRect ) { if( !m_pDepthBuffer ) { FUNC_FAILING( "CMuli3DRenderTarget::ClearDepthBuffer: no depthbuffer has been set.\n" ); return e_invalidstate; } return m_pDepthBuffer->Clear( vector4( i_fDepth, 0, 0, 0 ), i_pRect ); }
tvector3 CGizmoTransformMove::RayTrace(tvector3& rayOrigin, tvector3& rayDir, tvector3& norm) { tvector3 df,inters; m_plan=vector4(m_pMatrix->GetTranslation(), norm); m_plan.RayInter(inters,rayOrigin,rayDir); ptd = inters; df = inters - m_pMatrix->GetTranslation(); df /=GetScreenFactor(); m_LockVertex = inters; return df; }