DemoEntity::DemoEntity(DemoEntityManager& world, const dScene* scene, dScene::dTreeNode* rootSceneNode, dTree<DemoMesh*, dScene::dTreeNode*>& meshCache, DemoEntityManager::EntityDictionary& entityDictionary, DemoEntity* parent) :dClassInfo() ,dHierarchy<DemoEntity>() ,m_matrix(GetIdentityMatrix()) ,m_curPosition (0.0f, 0.0f, 0.0f, 1.0f) ,m_nextPosition (0.0f, 0.0f, 0.0f, 1.0f) ,m_curRotation (1.0f, 0.0f, 0.0f, 0.0f) ,m_nextRotation (1.0f, 0.0f, 0.0f, 0.0f) ,m_lock (0) ,m_mesh (NULL) { // add this entity to the dictionary entityDictionary.Insert(this, rootSceneNode); // if this is a child mesh set it as child of th entity dMatrix parentMatrix (GetIdentityMatrix()); if (parent) { Attach (parent); dScene::dTreeNode* parentNode = scene->FindParentByType(rootSceneNode, dSceneNodeInfo::GetRttiType()); dSceneNodeInfo* parentInfo = (dSceneNodeInfo*) parentNode; parentMatrix = parentInfo->GetTransform(); } dSceneNodeInfo* info = (dSceneNodeInfo*) scene->GetInfoFromNode (rootSceneNode); // SetMatrix(info->GetTransform() * parentMatrix.Inverse4x4()); dMatrix matrix (info->GetTransform() * parentMatrix.Inverse4x4()); dQuaternion rot (matrix); // set the matrix twice in oder to get cur and next position SetMatrix(world, rot, matrix.m_posit); SetMatrix(world, rot, matrix.m_posit); // if this node has a mesh, find it and attach it to this entity dScene::dTreeNode* meshNode = scene->FindChildByType(rootSceneNode, dMeshNodeInfo::GetRttiType()); if (meshNode) { DemoMesh* mesh = meshCache.Find(meshNode)->GetInfo(); SetMesh(mesh); } // add all of the children nodes as child nodes for (void* child = scene->GetFirstChild(rootSceneNode); child; child = scene->GetNextChild (rootSceneNode, child)) { dScene::dTreeNode* node = scene->GetNodeFromLink(child); dNodeInfo* info = scene->GetInfoFromNode(node); if (info->GetTypeId() == dSceneNodeInfo::GetRttiType()) { new DemoEntity (world, scene, node, meshCache, entityDictionary, this); } } }
void SetUp (void* gptr, int type) { int i,allocsize; Graph g=NULL; EuclidGraph xy=NULL; MatrixGraph matg=NULL; if (type==1) { g = (Graph) gptr; U = Degree(g,0); V = NumEdges(g); } else if (type==2) { xy = (EuclidGraph) gptr; U = xy[0][0]; V = U*(U-1)/2; } else if (type==3) { matg = (MatrixGraph) gptr; U = matg[0]; V = U*(U-1)/2; } allocsize = (U+2*V+2)*sizeof(int); A = (int *) malloc(allocsize); END = (int *) malloc(allocsize); WEIGHT = (int *) malloc(allocsize); for (i=0; i<U+2*V+2; i++) A[i]=END[i]=WEIGHT[i]=0; if (type == 1) SetStandard(g); else if (type == 2) SetEuclid(xy); else if (type == 3) SetMatrix(matg); }
void CSTransform::TransformByType(TransformType type, const double* args, bool concatenate) { //Keep this in sync with GetTypeByName and TransformType!!! switch (type) { case SCALE: return Scale(args[0], concatenate); case SCALE3: return Scale(args, concatenate); case TRANSLATE: return Translate(args,concatenate); case ROTATE_ORIGIN: return RotateOrigin(args,args[3],concatenate); case ROTATE_X: return RotateX(args[0],concatenate); case ROTATE_Y: return RotateY(args[0],concatenate); case ROTATE_Z: return RotateZ(args[0],concatenate); case MATRIX: return SetMatrix(args,concatenate); default: return; } }
TDSPLmmse::TDSPLmmse(TDSPMatrix* H, TDSPMatrix* Cx, TDSPMatrix* Cn) { _init(); SetMatrix(H); SetXCovariance(Cx); SetNoiseCovariance(Cn); }
void RenderManager::PrepareRealMatrix() { if (mappingMatrixChanged) { mappingMatrixChanged = false; Vector2 realDrawScale(viewMappingDrawScale.x * userDrawScale.x, viewMappingDrawScale.y * userDrawScale.y); Vector2 realDrawOffset(viewMappingDrawOffset.x + userDrawOffset.x * viewMappingDrawScale.x, viewMappingDrawOffset.y + userDrawOffset.y * viewMappingDrawScale.y); if (realDrawScale != currentDrawScale || realDrawOffset != currentDrawOffset) { currentDrawScale = realDrawScale; currentDrawOffset = realDrawOffset; Matrix4 glTranslate, glScale; glTranslate.glTranslate(currentDrawOffset.x, currentDrawOffset.y, 0.0f); glScale.glScale(currentDrawScale.x, currentDrawScale.y, 1.0f); glTranslate = glScale * glTranslate; SetMatrix(MATRIX_MODELVIEW, glTranslate); // Logger::Info("2D matricies recalculated"); // Matrix4 modelViewSave = RenderManager::Instance()->GetMatrix(RenderManager::MATRIX_MODELVIEW); // Logger::Info("Model matrix"); // modelViewSave.Dump(); // Matrix4 projectionSave = RenderManager::Instance()->GetMatrix(RenderManager::MATRIX_PROJECTION); // Logger::Info("Proj matrix"); // projectionSave.Dump(); } } }
CObject::CObject(CDummyObject *object) { SetModelIndexNoCreate(object->model_index); if(object->m_pRwObject) { AttachToRwObject(object->m_pRwObject, 1); } else { if(!object->m_xyz) { object->AllocateMatrix(); object->placement.RotateZ(object->m_xyz->matrix); } SetMatrix(object->m_xyz->matrix); } DetachFromRwObject(object); Init(); m_iplIndex = object->m_iplIndex; m_areaCode = object->m_areaCode; bRenderDamaged = object->bRenderDamaged; RpClump *rwobj = m_pRwObject; if(rwobj) { if(rwobj->object.type != TYPE_CLUMP) { rwobj = (RpAtomic*)getFirstAtomicInClump(rwobj); } if(!isAtomicHaveNightColor((RpAtomic*)rwobj)) { bLightObject = true; } } }
void CBillboard::SetScale(float scale) { m_xScale = m_yScale = scale; m_width = scale * 2; m_height = scale * 2; SetMatrix(); }
void RenderGI() { giRT->Bind(); glClearColor(0.0f, 0.0f, 0.0f, 0.0f); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glEnable(GL_DEPTH_TEST); giShader.Bind(); glActiveTexture(GL_TEXTURE1); glBindTexture(GL_TEXTURE_2D, vplRT->Texture()); giShader.SetUniform("vplTexture", (int)1); glActiveTexture(GL_TEXTURE2); glBindTexture(GL_TEXTURE_2D, vplPosRT->Texture()); giShader.SetUniform("vplPosTexture", (int)2); glActiveTexture(GL_TEXTURE3); glBindTexture(GL_TEXTURE_2D, vplNormalRT->Texture()); giShader.SetUniform("vplNormalTexture", (int)3); SetMatrix(giShader); DrawObjects(giShader); giShader.Unbind(); }
//pos void CBillboard::SetPos(float xPos, float yPos, float zPos) { m_pos.x = xPos; m_pos.y = yPos; m_pos.z = zPos; SetMatrix(); }
void wxSVGCanvasCairo::DrawPath(cairo_t* cr, wxSVGCanvasPathCairo& canvasPath, const wxSVGMatrix& matrix, const wxCSSStyleDeclaration& style, wxSVGSVGElement& svgElem) { SetMatrix(cr, matrix); // Filling if (canvasPath.GetFill() && style.GetFill().Ok() && style.GetFill().GetPaintType() != wxSVG_PAINTTYPE_NONE) { cairo_path_t* path = canvasPath.GetPath(); cairo_append_path(cr, path); SetPaint(cr, style.GetFill(), style.GetOpacity()*style.GetFillOpacity(), canvasPath, svgElem, matrix); cairo_fill(cr); cairo_path_destroy(path); } // Stroking if (style.GetStroke().Ok() && style.GetStrokeWidth() > 0 && style.GetStroke().GetPaintType() != wxSVG_PAINTTYPE_NONE) { cairo_path_t* path = canvasPath.GetPath(); cairo_append_path(cr, path); SetPaint(cr, style.GetStroke(), style.GetOpacity()*style.GetStrokeOpacity(), canvasPath, svgElem, matrix); wxSVGCanvasPathCairo::ApplyStrokeStyle(cr, style); cairo_stroke(cr); cairo_path_destroy(path); } // marker if (style.HasMarkerStart()) { DrawMarker(style.GetMarkerStart().GetStringValue(), wxSVGMark::START, canvasPath, matrix, style, svgElem); } if (style.HasMarkerMid()) { DrawMarker(style.GetMarkerMid().GetStringValue(), wxSVGMark::MID, canvasPath, matrix, style, svgElem); } if (style.HasMarkerEnd()) { DrawMarker(style.GetMarkerEnd().GetStringValue(), wxSVGMark::END, canvasPath, matrix, style, svgElem); } }
void Render(HWND hWnd) { g_pDevice->Clear(0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(123, 65, 255), 1.0f, 0); g_pDevice->BeginScene(); SetMatrix(); if (::GetAsyncKeyState(0x31) & 0x8000f) g_pDevice->SetRenderState(D3DRS_FILLMODE, D3DFILL_WIREFRAME); if (::GetAsyncKeyState(0x32) & 0x8000f) g_pDevice->SetRenderState(D3DRS_FILLMODE, D3DFILL_SOLID); g_pDevice->SetRenderState(D3DRS_LIGHTING, FALSE); g_pDevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_CCW);//开启背面消隐 g_pDevice->SetStreamSource(0, g_pVertexBuffer, 0, sizeof(CUSTOMVERTEX)); g_pDevice->SetFVF(D3DFVF_CUSTOMVERTEX); g_pDevice->SetIndices(g_pIndexBuffer); g_pDevice->SetTexture(0, g_pTexture); g_pDevice->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, 0, 0, 24, 0, 12); RECT rect; GetClientRect(hWnd, &rect); int count = _stprintf_s(g_strFPS, 20, TEXT("FPS : %0.3f"), GetFPS()); g_pFont->DrawText(NULL, g_strFPS, count, &rect, DT_TOP | DT_RIGHT, D3DCOLOR_XRGB(255, 239, 136)); g_pDevice->EndScene(); g_pDevice->Present(NULL, NULL, NULL, NULL); }
void cNode3D::UpdateMatrix(bool abSetChildrenUpdated) { cMatrixf mtxTransform = GetLocalMatrix(); //Save the translation and set it to 0 so that only the rotation is altered. cVector3f vPos = mtxTransform.GetTranslation(); mtxTransform.SetTranslation(cVector3f(0,0,0)); //Log("Startpos: %s",vPos.ToString().c_str()); //Log("World pos: %s\n",GetWorldMatrix().GetTranslation().ToString().c_str()); //The animation rotation is applied before the local. mtxTransform = cMath::MatrixMul(mtxTransform,m_mtxRotation); //Skip scale for now. //mtxTransform = cMath::MatrixMul(cMath::MatrixScale(mvScale), mtxTransform); mtxTransform.SetTranslation(vPos + mvTranslation); SetMatrix(mtxTransform,abSetChildrenUpdated); //Log("World pos: %s\n",GetWorldMatrix().GetTranslation().ToString().c_str()); //Reset values m_mtxRotation = cMatrixf::Identity; mvScale = cVector3f(1,1,1); mvTranslation = cVector3f(0,0,0); }
void gfxContext::PixelSnappedRectangleAndSetPattern(const gfxRect& rect, gfxPattern *pattern) { gfxRect r(rect); // Bob attempts to pixel-snap the rectangle, and returns true if // the snapping succeeds. If it does, we need to set up an // identity matrix, because the rectangle given back is in device // coordinates. // // We then have to call a translate to dr.pos afterwards, to make // sure the image lines up in the right place with our pixel // snapped rectangle. // // If snapping wasn't successful, we just translate to where the // pattern would normally start (in app coordinates) and do the // same thing. gfxMatrix mat = CurrentMatrix(); if (UserToDevicePixelSnapped(r)) { IdentityMatrix(); } Translate(r.TopLeft()); r.MoveTo(gfxPoint(0, 0)); Rectangle(r); SetPattern(pattern); SetMatrix(mat); }
void Matrix4x4::Transpose() { SetMatrix(_11, _21, _31, _41, _12, _22, _32, _42, _13, _23, _33, _43, _14, _24, _34, _44); }
LUAMTA_FUNCTION(camera, SetMatrix) { auto self = my->ToCameraPtr(1); self->SetMatrix(my->ToMatrix34(2)); return 0; }
int cText::ShowTextBillboard(std::string Text, DWORD Color) { SetMatrix(mtR, &cCore::BillboardMt); cCore::pd3dDevice->SetTransform(D3DTS_WORLD, Matrix()); return Draw(&Text, &Color); }
void SVGTransform::SetMatrix(SVGMatrix& aMatrix, ErrorResult& rv) { if (mIsAnimValItem) { rv.Throw(NS_ERROR_DOM_NO_MODIFICATION_ALLOWED_ERR); return; } SetMatrix(aMatrix.GetMatrix()); }
void CBillboard::SetScale(float xScale, float yScale) { m_xScale = xScale; m_width = xScale * 2; m_yScale = yScale; m_height = yScale * 2; SetMatrix(); }
void CBillboard::SetScale(D3DXVECTOR2 scale) { m_xScale = scale.x; m_width = scale.x * 2; m_yScale = scale.y; m_height = scale.y * 2; SetMatrix(); }
/************************Rotation Matrix**************************** * Give the Rotation Axis and the Rotation Angle * Generate the Rotation Matrix * Author: C.Y. * Date 2006.11.30. *************************End***************************************/ inline bool RotationMatrix(const myvector &axis, double angle, matrix &romtx) { if(axis.size()!=3) { cout<<"Error 1 in RotationMatrix()"<<endl; return false; } myvector ouc(3, 0); if(!Norm2Vector(axis, ouc)) { cout<<"Error 2 in RotationMatrix()"<<endl; return false; } int i=0, j=0; matrix su, u_i, unit, tmp; SetMatrix(su, 3, 3); su[0][0]=0; su[0][1]=-ouc[2]; su[0][2]=ouc[1]; su[1][0]=ouc[2]; su[1][1]=0; su[1][2]=-ouc[0]; su[2][0]=-ouc[1]; su[2][1]=ouc[0]; su[2][2]=0; RealTimesMatrix(sin(angle), su, su); TransVectorTimesVector(ouc, ouc, u_i); SetMatrix(unit, 3, 3); SetMatrix(tmp, 3, 3); unit[0][0]=1; unit[1][1]=1; unit[2][2]=1; RealTimesMatrix(-1, u_i, tmp); MatrixAddMatrix(unit, tmp, tmp); RealTimesMatrix(cos(angle), tmp, tmp); MatrixAddMatrix(u_i, tmp, tmp); MatrixAddMatrix(su, tmp, tmp); SetMatrix(romtx, 4, 4); for(i=0; i<tmp.size(); ++i) for(j=0; j<tmp[i].size(); ++j) romtx[i][j]=tmp[i][j]; romtx[0][3]=0; romtx[1][3]=0; romtx[2][3]=0; romtx[3][0]=0; romtx[3][1]=0; romtx[3][2]=0; romtx[3][3]=1; return true; }
void AnimaMappedValues::CopyMatrices(const AnimaMappedValues& src) { _matricesMap.clear(); const boost::unordered_map<AnimaString, AnimaMatrix, AnimaStringHasher>* srcMatricesMap = &src._matricesMap; for (auto pair : *srcMatricesMap) { AnimaString propertyName = ExtractName(pair.first); SetMatrix(propertyName, pair.second); } }
LUAMTA_FUNCTION(camera, CreateModelMatrix) { auto self = my->ToCameraPtr(1); auto mat = self->GetMatrix(); gEnv->pRenderer->MakeMatrix(my->ToVec3(2), my->ToVec3(3), my->ToVec3(4), &mat); self->SetMatrix(mat); return 0; }
Mat44::Mat44( const f32 m11, const f32 m12, const f32 m13, const f32 m14, const f32 m21, const f32 m22, const f32 m23, const f32 m24, const f32 m31, const f32 m32, const f32 m33, const f32 m34, const f32 m41, const f32 m42, const f32 m43, const f32 m44) { SetMatrix( m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34, m41, m42, m43, m44); };
void SetTransform( PluginInstance *This, HPS hps, PRECTL rclWin ) { if ( !This->hmf ) return; HAB hab=WinQueryAnchorBlock( This->hWnd ); MATRIXLF mtlf; SetMatrix( This, hps, rclWin, &mtlf ); if ( GpiSetDefaultViewMatrix( hps, 9L, &mtlf, TRANSFORM_REPLACE ) ) { // pprintf( szPPR, "GpiSetDefaultViewMatrix done\n\r" ); // pprMatrix( szPPR, &mtlf ); } else { pprintf( szPPR, "GpiSetDefaultViewMatrix failed, Err=%x\n\r", WinGetLastError( hab ) ); } }
void Terrain::DrawShadowMap() { auto shader = ShaderStock::GetInstance()->GetTerrainShadowShader(); auto renderState = Device::GetInstance()->GetRenderState(); auto shaderPrev = renderState->GetCurrentShader(); Matrix world; GetWorldMatrix(&world); Matrix mv = world * renderState->GetViewMatrix(); shader->Use(); shader->UsePass(0); shader->SetMatrix("g_mvMatrix", mv); shader->SetMatrix("g_projection", renderState->GetProjectionMatrix()); shader->SetFloat("g_zscale", this->zScale); shader->SetTexture("g_heightMap", this->heightMap.Get()); shader->CommitChanges(); DrawGeometry(); shaderPrev->Use(); }
void iEntity3D::LoadFromSaveData(iSaveData *apSaveData) { kSaveData_LoadFromBegin(iEntity3D); //Log("-------- Loading %s --------------\n",msName.c_str()); SetMatrix(pData->m_mtxLocalTransform); //Not sure of this is needed: kSaveData_LoadFrom(mBoundingVolume); kSaveData_LoadFrom(msSourceFile); }
void CoreDelegateImpl::Draw() { static float x = 50; static float y = 600; auto p_renderer = Core::GetRenderer(); IRect rect = p_renderer->GetTargetRectangle(); p_renderer->SetMatrix(MatrixMode::Projection, Matrix4f::CreateOrtho(0, rect.Width(), 0, rect.Height())); std::wstring message = L"FPS: " + std::to_wstring(Core::GetApplication()->GetCurrentFPS()); auto en_font = Core::GetGlobalObject<Resources::ResourceManager>()->GetHandleToResource<Render::Font>("Arial_en"); auto arial_font = Core::GetGlobalObject<Resources::ResourceManager>()->GetHandleToResource<Render::Font>("Arial"); Core::GetGlobalObject<Render::FontManager>()->Render({ x, y }, 1.f, message, arial_font); Core::GetGlobalObject<Render::FontManager>()->Render({ x, y - 50 }, 1.f, message_num_0, en_font); Core::GetGlobalObject<Render::FontManager>()->Render({ x, y - 100 }, 1.f, L"Мама мыла раму!", arial_font); }
void RenderVPLNormal() { vplNormalRT->Bind(); glClearColor(0.0f, 0.0f, 0.0f, 0.0f); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glEnable(GL_DEPTH_TEST); vpl_normalShader.Bind(); SetMatrix(vpl_normalShader); DrawObjects(vpl_normalShader); vpl_normalShader.Unbind(); }
inline bool TransVectorTimesVector(const myvector &trans, const myvector &vctor, matrix &mtx) { if(trans.size()!=vctor.size()) { cout<<"Error in TransVectorTimesVector()"<<endl; return false; } int i=0, j=0; SetMatrix(mtx, trans.size(), vctor.size()); for(i=0; i<trans.size(); ++i) for(j=0; j<vctor.size(); ++j) mtx[i][j]=trans[i]*vctor[j]; return true; }
bool Transform::Init(Document::Node *node) { Vector4 pos(0.0f); Vector4 angles(0.0f); node->ResolveAsVectorN("pos", 3, pos.vals); node->ResolveAsVectorN("angles", 3, angles.vals); SetMatrix(pos, Quaternion(angles)); Vector4 target(0.0f); if(node->ResolveAsVectorN("target", 3, target.vals)) { LookAt(target); } return true; }