void SparseMatrix::build_and_renormalise_transform(SpinBlock *big, const opTypes &ot, const std::vector<Matrix>& rotate_matrix, const StateInfo *newStateInfo) { boost::shared_ptr<SparseMatrix> tmp; if (orbs.size() == 0) tmp = big->get_op_rep(ot, deltaQuantum); if (orbs.size() == 1) tmp = big->get_op_rep(ot, deltaQuantum, orbs[0]); if (orbs.size() == 2) tmp = big->get_op_rep(ot, deltaQuantum, orbs[0], orbs[1]); tmp->built = true; this->allocate(*newStateInfo); this->built = true; int newQ = 0; for (int Q = 0; Q < rotate_matrix.size (); ++Q) if (rotate_matrix[Q].Ncols () != 0) { int newQPrime = 0; for (int QPrime = 0; QPrime < rotate_matrix.size (); ++QPrime) if (rotate_matrix[QPrime].Ncols () != 0) { if (this->allowedQuantaMatrix (newQ, newQPrime)) { MatrixRotate (rotate_matrix[Q], tmp->operatorMatrix(Q, QPrime), rotate_matrix[QPrime], this->operatorMatrix (newQ, newQPrime) ); } ++newQPrime; } ++newQ; } }
//----------------------------------------------------------------------------- // Returns the attachment render origin + origin //----------------------------------------------------------------------------- void C_VGuiScreen::GetAimEntOrigin( IClientEntity *pAttachedTo, Vector *pOrigin, QAngle *pAngles ) { C_BaseEntity *pEnt = pAttachedTo->GetBaseEntity(); const char* panelName = PanelName(); vgui::Panel panel = m_PanelWrapper.GetPanel(); if ( Q_strcmp(panelName, "health_screen") == 0 ) { QAngle weapAngles = pEnt->GetAbsAngles(); Vector weapForward, weapRight, weapUp; AngleVectors(weapAngles, &weapForward, &weapRight, &weapUp); VMatrix worldFromPanel; AngleMatrix(weapAngles, worldFromPanel.As3x4()); MatrixRotate(worldFromPanel, Vector(0, 0, 1), 180.f); MatrixRotate(worldFromPanel, Vector(1, 0, 0), -90.f); MatrixAngles(worldFromPanel.As3x4(), *pAngles); // move it right and over *pOrigin = pEnt->GetAbsOrigin() + weapRight*1.75 + weapUp*2.3 + weapForward*5; return; } //todo: set alpha per view ... m_PanelWrapper.GetPanel()->SetAlpha(200); if (pEnt && (m_nAttachmentIndex > 0)) { { C_BaseAnimating::AutoAllowBoneAccess boneaccess( true, true ); pEnt->GetAttachment( m_nAttachmentIndex, *pOrigin, *pAngles ); } if ( IsAttachedToViewModel() ) { FormatViewModelAttachment( *pOrigin, true ); } } else { BaseClass::GetAimEntOrigin( pAttachedTo, pOrigin, pAngles ); } // Msg("%s origin %.1f %.1f %.1f angles %.1f %.1f %.1f \n", PanelName(), pOrigin->x, pOrigin->y, pOrigin->z, pAngles->x, pAngles->y, pAngles->z); }
void TexturedLine::Render() { if(!lineTexture) return; Vect lineDir = (pointB-pointA).Norm(); float halfWidth = width*0.5f; Camera *viewCam = level->GetCurrentCamera(); Vect camPos = viewCam->GetWorldPos(); Vect crossLine; DepthWriteEnable(FALSE); EnableBlending(TRUE); if(lineTexture->HasAlpha()) BlendFunction(GS_BLEND_SRCALPHA, GS_BLEND_INVSRCALPHA); else BlendFunction(GS_BLEND_ONE, GS_BLEND_ONE); LoadTexture(lineTexture); LoadDefault3DSampler(); MatrixPush(); MatrixTranslate(GetWorldPos()); MatrixRotate(GetWorldRot()); RenderStart(); Vect endAdjust = (lineDir*halfWidth); Vect backEnd = (pointA-endAdjust); Vect frontEnd = (pointB+endAdjust); Color(color); crossLine = (camPos-backEnd).Cross(lineDir).Norm() * halfWidth; Vertex(backEnd+crossLine); TexCoord(1.0f, 0.0f); Vertex(backEnd-crossLine); TexCoord(0.0f, 0.0f); crossLine = (camPos-pointA).Cross(lineDir).Norm() * halfWidth; Vertex(pointA+crossLine); TexCoord(1.0f, 0.5f); Vertex(pointA-crossLine); TexCoord(0.0f, 0.5f); crossLine = (camPos-pointB).Cross(lineDir).Norm() * halfWidth; Vertex(pointB+crossLine); TexCoord(1.0f, 0.5f); Vertex(pointB-crossLine); TexCoord(0.0f, 0.5f); crossLine = (camPos-frontEnd).Cross(lineDir).Norm() * halfWidth; Vertex(frontEnd+crossLine); TexCoord(1.0f, 1.0f); Vertex(frontEnd-crossLine); TexCoord(0.0f, 1.0f); RenderStop(GS_TRIANGLESTRIP); MatrixPop(); LoadTexture(NULL); }
//Renormalization functions for core and virtual operators void SparseMatrix::renormalise_transform(const std::vector<Matrix>& rotate_matrix, const StateInfo *stateinfo) { ObjectMatrix<Matrix> tmp = operatorMatrix; //cannot instantiate a SparseMatrix and so instantiating a Cre this->allocate(*stateinfo); // new allocations int newQ = 0; for (int Q = 0; Q < rotate_matrix.size (); ++Q) if (rotate_matrix[Q].Ncols () != 0) { int newQPrime = 0; for (int QPrime = 0; QPrime < rotate_matrix.size (); ++QPrime) if (rotate_matrix[QPrime].Ncols () != 0) { if (this->allowedQuantaMatrix (newQ, newQPrime)) MatrixRotate (rotate_matrix[Q], tmp(Q, QPrime), rotate_matrix[QPrime], this->operatorMatrix (newQ, newQPrime) ); ++newQPrime; } ++newQ; } }
void RotationManipulator::RenderScaled(const Vect &cameraDir, float scale) { traceInFast(RotationManipulator::RenderScaled); DWORD i; Shader *rotManipShader = GetVertexShader(TEXT("Editor:RotationManipulator.vShader")); LoadVertexShader(rotManipShader); LoadPixelShader(GetPixelShader(TEXT("Base:SolidColor.pShader"))); rotManipShader->SetVector(rotManipShader->GetParameter(2), cameraDir); MatrixPush(); MatrixTranslate(GetWorldPos()); MatrixScale(scale, scale, scale); for(i=0; i<3; i++) { Vect axisColor(0.0f, 0.0f, 0.0f); axisColor.ptr[i] = 1.0f; if(i == activeAxis) axisColor.Set(1.0f, 1.0f, 0.0f); else axisColor.ptr[i] = 1.0f; rotManipShader->SetVector(rotManipShader->GetParameter(1), axisColor); LoadVertexBuffer(axisBuffers[i]); LoadIndexBuffer(NULL); Draw(GS_LINESTRIP); } LoadVertexBuffer(NULL); //---------------------------------------------------- Shader *solidShader = GetVertexShader(TEXT("Base:SolidColor.vShader")); LoadVertexShader(solidShader); MatrixPush(); MatrixRotate(Quat().SetLookDirection(cameraDir)); LoadVertexBuffer(axisBuffers[2]); LoadIndexBuffer(NULL); solidShader->SetColor(solidShader->GetParameter(1), 0.5, 0.5, 0.5, 0.5); Draw(GS_LINESTRIP); MatrixScale(1.25f, 1.25f, 1.25f); //--------------- if(activeAxis == 4) solidShader->SetColor(solidShader->GetParameter(1), 1.0f, 1.0f, 0.0, 1.0f); else solidShader->SetColor(solidShader->GetParameter(1), 0.8, 0.8, 0.8, 0.8); Draw(GS_LINESTRIP); MatrixPop(); MatrixPop(); LoadVertexShader(NULL); LoadPixelShader(NULL); traceOutFast; }
static int vmatrix_MatrixRotate (lua_State *L) { MatrixRotate(luaL_checkvmatrix(L, 1), luaL_checkvector(L, 2), luaL_checknumber(L, 3)); return 0; }