//---------------------------------------------------------------------------- // NPP_SetWindow: //---------------------------------------------------------------------------- NPError NP_LOADDS NPP_SetWindow(NPP instance, NPWindow* window) { pprintf( szPPR, "NPP_SetWindow\n\r" ); if ( instance == 0 ) return NPERR_INVALID_INSTANCE_ERROR; PluginInstance* This = (PluginInstance*) instance->pdata; // // *Developers*: Before setting fWindow to point to the // new window, you may wish to compare the new window // info to the previous window (if any) to note window // size changes, etc. // // if window handle changed if ( This->hWnd != (HWND)window->window ) { pprintf( szPPR, "HWND (hmf %x) changed, %x --> %x\n\r", This->hmf, (int)This->hWnd, (int)window->window ); // remember the new window This->fWindow = window; if ( This->hWnd ) { // Remove the subclass for the old client window WinSubclassWindow(This->hWnd, This->lpfnOldWndProc); } // remember the new window handle This->hWnd = (HWND)This->fWindow->window; // subclass the window This->lpfnOldWndProc = WinSubclassWindow(This->hWnd, SubClassFunc); AssociateInstance( This->hWnd, This ); /* paint a background for the drawing */ WinQueryWindowRect( This->hWnd, &This->rclWnd ); // WinFillRect( This->hps, &This->rclWnd, CLR_PALEGRAY ); // destroy old PS and create new PS if ( This->hps ) GpiDestroyPS( This->hps ); HDC hdc = WinQueryWindowDC( This->hWnd ); if ( !hdc ) hdc = WinOpenWindowDC( This->hWnd ); SIZEL siz={ 0, 0 }; HAB hab=WinQueryAnchorBlock( This->hWnd ); This->hps = GpiCreatePS( hab, hdc, &siz, PU_PELS | GPIT_NORMAL | GPIA_ASSOC ); pprintf( szPPR, "GpiCreatePS, hdc=%x, hps=%x\n\r", (int)hdc, (int)This->hps ); if ( !This->hps ) { pprintf( szPPR, "GpiCreatePS failed, Err=%x\n\r", WinGetLastError( hab ) ); } SetTransform( This, This->hps, &This->rclWnd ); } else { // check if window coordinates changed. //It may happens for full-screan RECTL rcl; WinQueryWindowRect( This->hWnd, &rcl ); if ( memcmp( &This->rclWnd, &rcl, sizeof( rcl ) ) ) { pprintf( szPPR, "Rect (hmf %x) changed, ( %d, %d ) - ( %d, %d ) --> ( %d, %d ) - ( %d, %d )\n\r", This->hmf, This->rclWnd.xLeft, This->rclWnd.yBottom, This->rclWnd.xRight, This->rclWnd.yTop, rcl.xLeft, rcl.yBottom, rcl.xRight, rcl.yTop ); memcpy( &This->rclWnd, &rcl, sizeof( rcl ) ); SetTransform( This, This->hps, &This->rclWnd ); } } return NPERR_NO_ERROR; }
//------------------------------------------------------------------------------------------ HRESULT CGraphicDevice::SetCameraInfo( const SCameraInfo& i_cameraInfo ) { HRESULT hr; // 新しいカメラ情報を保持 m_cameraInfo = i_cameraInfo; /// 新しいカメラ情報でビュー,射影行列を計算 /// D3DXMATRIX mView, mProj; // ビュー行列を計算 D3DXMatrixLookAtRH( &mView , &m_cameraInfo.vEyePos , &m_cameraInfo.vInterestPos , &m_cameraInfo.vUpDir ); // 射影行列を計算 D3DXMatrixPerspectiveFovRH( &mProj , m_cameraInfo.fFov , ((float)m_nWidth) / m_nHeight , m_cameraInfo.fNear , m_cameraInfo.fFar ); // 各行列を設定 V_RETURN( SetTransform(TransformType_View, mView) ); V_RETURN( SetTransform(TransformType_Projection, mProj) ); return S_OK; }
void FlyCamera::CalculateRotation(double dt, double xOffset, double yOffset) { if (xOffset != 0.0) { glm::mat4 rot = glm::rotate((float)(m_fRotationSpeed * dt * -xOffset), glm::vec3(0, 1, 0)); SetTransform(GetTransform() * rot); } if (yOffset != 0.0) { glm::mat4 rot = glm::rotate((float)(m_fRotationSpeed * dt * -yOffset), glm::vec3(1, 0, 0)); SetTransform(GetTransform() * rot); } //Clean up rotation glm::mat4 oldTrans = GetTransform(); glm::mat4 trans; glm::vec3 worldUp = glm::vec3(0, 1, 0); //Right trans[0] = glm::normalize(glm::vec4(glm::cross(worldUp, oldTrans[2].xyz()), 0)); //Up trans[1] = glm::normalize(glm::vec4(glm::cross(oldTrans[2].xyz(), trans[0].xyz()), 0)); //Forward trans[2] = glm::normalize(oldTrans[2]); //Position trans[3] = oldTrans[3]; SetTransform(trans); }
void SpatialNode::SetWorldTransform(const Vector3& newPosition, const Quaternion& newRotation) { SpatialNode* parentNode = SpatialParent(); if (parentNode) { Vector3 localPosition = parentNode->WorldTransform().Inverse() * newPosition; Quaternion localRotation = parentNode->WorldRotation().Inverse() * newRotation; SetTransform(localPosition, localRotation); } else SetTransform(newPosition, newRotation); }
void DrawTarget::PushDeviceSpaceClipRects(const IntRect* aRects, uint32_t aCount) { Matrix oldTransform = GetTransform(); SetTransform(Matrix()); RefPtr<PathBuilder> pathBuilder = CreatePathBuilder(); for (uint32_t i = 0; i < aCount; i++) { AppendRectToPath(pathBuilder, Rect(aRects[i])); } RefPtr<Path> path = pathBuilder->Finish(); PushClip(path); SetTransform(oldTransform); }
void CMeshShape::Init(Data::PParams Desc) { InitialTfm.ident(); //??? (was in mangalore, see XML CompositeLoader) SetTransform(InitialTfm); SetMaterialType(CMaterialTable::StringToMaterialType(Desc->Get<nString>(CStrID("Mtl"), "Metal"))); SetFileName(Desc->Get<nString>(CStrID("File"))); }
void UpdateAnimation(HWND hwnd) { if (!IsAnimating()) return; // Compute the elapsed time since the start of the animation in seconds. DWORD const tickCount = GetTickCount(); float elapsed = (tickCount - g_animationStartCount) * (1.0f / 1000); if (elapsed < g_animationDuration) { // We're still animating. Compuate the current x by interpolating between // the start x and end x. float r = elapsed / g_animationDuration; g_animationCurrentX = (g_animationStartX * (1 - r)) + (g_animationEndX * r); } else { // We're done with this animation. Let both the current and start x equal the end x. g_animationCurrentX = g_animationEndX; g_animationStartX = g_animationEndX; // If we're not at zero, we'll start a new animation ending at zero. The duration of // this animation depends on the distance. g_animationEndX = 0; g_animationStartCount = tickCount; g_animationDuration = fabs(g_animationStartX) / 10; } SetTransform(hwnd); }
void PointRenderer::GetExtent(CachedExtent &ioCache) { SetTransform(ioCache.mTransform); for(int i=0; i<mTransformed.size(); i++) ioCache.mExtent.Add(mTransformed[i]); }
//------------------------------------ //NAME : Direct3DRender() //DESC : 绘制3D场景 //------------------------------------ void Direct3DRender() { /* Direct3D的绘制过程就是:绘制→显示→绘制→显示。 但是,每当开始绘制图形之前,都需要通过IDirect3DDevice9接口的Clear方法将后台缓存中的内容进行清空,并设置表面的填充颜色等 HRESULT IDirect3DDevice9::Clear( DWORD Count, const D3DRECT *pRects, //指定对表面指定的矩形区域进行清除操作,数组中包含的矩形的数量由Count参数指定 DWORD Flags, //指定了需要清除的表面,该参数可以取值于D3DCLEAR_TARGET、D3DCLEAR_ZBUFFER和D3DCLEAR_STENCIL,分别表示对后台缓存、深度缓存和模板缓存进行清除 D3DCOLOR Color, //用于指定在清除缓存内容后设置的背景色,可以通过D3DCOLOR_XRGB宏将RGB值转换给该参数 float Z, //指定当清除缓存内容后设置深度缓存的值 DWORD Stencil ); */ g_pd3dDevice->Clear(0,NULL,D3DCLEAR_TARGET|D3DCLEAR_ZBUFFER,D3DCOLOR_XRGB(0,0,0),1.0f,0);//黑色背景 //开始绘制 g_pd3dDevice->BeginScene(); //在绘制立方体之前,分别取得绕x,y,z轴旋转变换的矩阵,然后将他们组合并让立方体同时绕这3个轴旋转 SetTransform(); /*图形绘制的实际过程*/ DrawPrimitive(); //结束绘制 g_pd3dDevice->EndScene(); //翻转 g_pd3dDevice->Present(NULL,NULL,NULL,NULL); }
void ODERigidObject::Create(dWorldID worldID,dSpaceID space,bool useBoundaryLayer) { Clear(); spaceID = space; bodyID = dBodyCreate(worldID); dMass mass; mass.mass = obj.mass; //NOTE: in ODE, COM must be zero vector! -- we take care of this by shifting geometry //CopyVector3(mass.c,obj.com); mass.c[0] = mass.c[1] = mass.c[2] = 0; mass.c[3] = 1.0; CopyMatrix(mass.I,obj.inertia); int res=dMassCheck(&mass); if(res != 1) { fprintf(stderr,"Uh... mass is not considered to be valid by ODE?\n"); std::cerr<<"Inertia: "<<obj.inertia<<std::endl; } dBodySetMass(bodyID,&mass); geometry = new ODEGeometry; geometry->Create(&obj.geometry,spaceID,-obj.com,useBoundaryLayer); dGeomSetBody(geometry->geom(),bodyID); dGeomSetData(geometry->geom(),(void*)-1); geometry->SetPadding(defaultPadding); geometry->surf().kRestitution = obj.kRestitution; geometry->surf().kFriction = obj.kFriction; geometry->surf().kStiffness = obj.kStiffness; geometry->surf().kDamping = obj.kDamping; SetTransform(obj.T); }
void SelectMetaFile( PluginInstance *This, HMF hmf ) { if ( This->hmf ) GpiDeleteMetaFile( This->hmf ); This->hmf=hmf; HAB hab=WinQueryAnchorBlock( This->hWnd ); HPS hps=This->hps; if ( !hps ) { pprintf( szPPR, "No hps ???\n\r" ); return; } //calculate bounds HDC hdc = WinQueryWindowDC( This->hWnd ); if ( !hdc ) hdc = WinOpenWindowDC( This->hWnd ); GpiResetBoundaryData( hps ); if ( GpiAssociate( hps, NULL ) ) { GpiSetDrawControl( hps, DCTL_BOUNDARY, DCTL_ON ); Draw( This, hps, FALSE, FALSE ); if ( GpiQueryBoundaryData( hps, &This->rclMeta ) && (This->rclMeta.xLeft<This->rclMeta.xRight) ) { if ( !GpiAssociate( hps, hdc ) ) pprintf( szPPR, "GpfAssociate( hps, hdc ) failed\n\r" ); GpiSetDrawControl( hps, DCTL_BOUNDARY, DCTL_OFF ); GpiResetPS( hps, GRES_ALL); SetTransform( This, hps, &This->rclWnd ); } else { pprintf( szPPR, "GpiQueryBoundaryData failed, Err=%x\n\r", WinGetLastError( hab ) ); } } else pprintf( szPPR, "GpfAssociate( hps, NULL ) failed\n\r" ); // invalidate window to ensure a redraw WinInvalidateRect( This->hWnd, 0, TRUE ); }
void SceneNode::SetTransform(CXMMATRIX transform) { XMFLOAT4X4 t; XMStoreFloat4x4(&t, transform); SetTransform(t); }
void mtsOSGBody::Body::UpdateTransform(){ if( GetPosition.IsValid() ){ // Get the position of the camera prmPositionCartesianGet prmRt; GetPosition( prmRt ); bool valid = false; prmRt.GetValid( valid ); // Set the transformation if( valid ) { SetTransform( prmRt.Position() ); } } // Update the transformation osaOSGBody::UpdateTransform(); { prmPositionCartesianSet prmRt; prmRt.SetGoal( GetTransform() ); bool valid = true; prmRt.SetValid( valid ); SetPosition( prmRt ); } }
void MineActor::TickLocal(const dtGame::Message& msg) { ProjectileActor::TickLocal(msg); dtCore::Transform currentTransform; GetTransform(currentTransform); currentTransform.SetRotation(currentTransform.GetRotation() + osg::Vec3(1.0, 0.0, 0.0)); SetTransform(currentTransform); }
void GL::PushTransform(const Matrix& aTransform) { MOZ_ASSERT(IsCurrent()); MatrixPushEXT(GL_MODELVIEW); mTransformIdStack.push(mTransformIdStack.top()); SetTransform(aTransform, GetUniqueId()); }
void RenderSprite::Draw(float _x, float _y, float _width, float _height, float _rotation, float _alpha, float _red, float _green, float _blue) { SetTransform(_x, _y, _width, _height, _rotation); SetColor(_red, _green, _blue, _alpha); Draw(); }
void FlyCamera::CalculateRotation(double dt, double xOffset, double yOffset) { if (xOffset != 0) { glm::mat4 rot = glm::rotate((float)(dt * -xOffset), glm::vec3(0, 1, 0)); SetTransform(GetTransform() * rot); } if (yOffset != 0) { glm::mat4 rot = glm::rotate((float)(dt * -yOffset), glm::vec3(1, 0, 0)); SetTransform(GetTransform() * rot); } glm::mat4 oldTrans = GetTransform(); glm::vec3 worldUp = glm::vec3(0, 1, 0); glm::mat4 trans; trans[0] = glm::normalize(glm::vec4(glm::cross(worldUp, oldTrans[2].xyz()), 0)); trans[1] = glm::normalize(glm::vec4(glm::cross(oldTrans[2].xyz(), trans[0].xyz()), 0)); trans[2] = glm::normalize(oldTrans[2]); trans[3] = oldTrans[3]; SetTransform(trans); }
void TransformMath::SetSizeToScreen(Node* node, Node* parent) { auto trans = TransformEnt("", ofVec2f(0, 0), 1, CALCTYPE_PER, ofVec2f(0, 0), ofVec2f(1, 0), // zero because we want to scale according to the x axis CALCTYPE_ABS_PER, 0); SetTransform(node, parent, trans, 0, 0); }
void ScalingAxis::AlignBinder() { float3 vPos = m_pBind->GetPosition(GVNode::S_ABSOLUTE); GVNode* pParent = m_pBind->GetParent(); const clstd::TRANSFORM& T = m_pBind->GetTransform(); // 如果存在父对象,则使用自身的全局变换解算出全局旋转 // 如果不存在父对象,它的全局变换就是自身的局部变换 if(pParent) { float3 s; quaternion r; m_pBind->GetTransform().GlobalMatrix.Decompose(&s, &r); SetTransform(m_bTracking ? &(T.scaling / m_vTrackedScaling) : NULL, &r, &vPos); } else { SetTransform(m_bTracking ? &(T.scaling / m_vTrackedScaling) : NULL, &T.rotation, &vPos); } }
vtkSmartPointer<vtkAlgorithm> createTransformPipeline( const CoordinateSystemSpecification & /*toSystem*/, vtkAlgorithmOutput * pipelineUpstream) const override { auto filter = vtkSmartPointer<vtkTransformPolyDataFilter>::New(); filter->SetInputConnection(pipelineUpstream); filter->SetTransform(m_transform); return filter; }
CqTransform::CqTransform( const CqTransformPtr& From, TqFloat time, const CqMatrix& matTrans, const Set& /* set */ ) : CqMotionSpec<SqTransformation>( *From ), m_IsMoving( From->m_IsMoving ), m_StaticMatrix( From->m_StaticMatrix ), m_Handedness( From->m_Handedness ) { SetTransform( time, matTrans ); }
void CBaseEntity::AttachBody(CBoundingVolume * pContactBV, CRigidBody * pContactRigidBody, CBoundingVolume * pFoceEnvelopeBV) { m_pContactBV = pContactBV; m_pRigidBody = pContactRigidBody; m_pFoceEnvelopeBV = pFoceEnvelopeBV; SetTransform(m_LocalTransform); }
void GLWidget::paintGL() { SetView(); SetCamera(0, 0, 10, 0, 0, 0); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glColor3f(1.0f, 0.0f, 0.0f); SetTransform(cameraAngleX, cameraAngleY, cameraDistance, 0, 0, 0); gluCylinder(pQuadric, 2, 1, 1, 20, 10); renderText(20, 10, "Hello, My first OpenGL app."); }
void PolyModelRenderer::BeginDrawModel(AActor *actor, FSpriteModelFrame *smf, const VSMatrix &objectToWorldMatrix, bool mirrored) { ModelActor = actor; const_cast<VSMatrix &>(objectToWorldMatrix).copy(ObjectToWorld.Matrix); SetTransform(); if (actor->RenderStyle == LegacyRenderStyles[STYLE_Normal] || !!(smf->flags & MDL_DONTCULLBACKFACES)) PolyTriangleDrawer::SetTwoSided(Thread->DrawQueue, true); PolyTriangleDrawer::SetCullCCW(Thread->DrawQueue, !mirrored); }
void CPathCamera::Reset(const zeus::CTransform&, CStateManager& mgr) { CPlayer& player = mgr.GetPlayer(); zeus::CVector3f playerPt = player.GetTranslation() + zeus::CVector3f(0.f, 0.f, g_tweakPlayer->GetPlayerBallHalfExtent()); float closestLength = x188_spline.FindClosestLengthOnSpline(0.f, playerPt); float negLength = std::max(0.f, closestLength - x1dc_lengthExtent); zeus::CVector3f negPoint = x188_spline.GetInterpolatedSplinePointByLength(negLength).origin; float posLength = std::min(x188_spline.GetLength(), closestLength + x1dc_lengthExtent); zeus::CVector3f posPoint = x188_spline.GetInterpolatedSplinePointByLength(posLength).origin; zeus::CTransform camXf = mgr.GetCameraManager()->GetBallCamera()->GetTransform(); if (player.GetMorphballTransitionState() != CPlayer::EPlayerMorphBallState::Morphed) camXf = mgr.GetCameraManager()->GetCurrentCameraTransform(mgr); bool neg = false; if (x1e8_initPos == EInitialSplinePosition::BallCamBasis) { zeus::CVector3f tmp = playerPt - negPoint; if (tmp.canBeNormalized()) { if (tmp.normalized().dot(camXf.basis[1]) > 0.f) neg = true; } } else { neg = x1e8_initPos == EInitialSplinePosition::Negative; } #if 0 zeus::CVector3f camToSpline = splinePt - camXf.origin; mgr.RayStaticIntersection(camXf.origin, camToSpline.normalized(), camToSpline.magnitude(), kLineOfSightFilter); zeus::CVector3f camToSpline2 = splinePt2 - camXf.origin; mgr.RayStaticIntersection(camXf.origin, camToSpline2.normalized(), camToSpline2.magnitude(), kLineOfSightFilter); #endif zeus::CVector3f viewPoint; if (neg) { x1d4_pos = negLength; viewPoint = negPoint; } else { x1d4_pos = posLength; viewPoint = posPoint; } if (x1e8_initPos == EInitialSplinePosition::ClampBasis) { if (x188_spline.ClampLength(playerPt, false, kLineOfSightFilter, mgr) <= negLength) { x1d4_pos = negLength; viewPoint = negPoint; } else { x1d4_pos = posLength; viewPoint = posPoint; } } SetTransform(zeus::lookAt(viewPoint, mgr.GetCameraManager()->GetBallCamera()->GetFixedLookPos())); }
void plAnimPath::MakeDrawList(hsTArray<uint16_t>& idx, hsTArray<hsPoint3>& pos) { hsMatrix44 resetL2W = GetLocalToWorld(); hsMatrix44 resetW2L = GetWorldToLocal(); hsMatrix44 ident; ident.Reset(); SetTransform(ident, ident); float numSegs = fRadius; // crude estimate of arclength if (numSegs>100) numSegs=100; float animLen = GetLength(); float timeInc = animLen/numSegs; float time=0; hsPoint3 p1, p2; SetCurTime(0, kCalcPosOnly); GetPosition(&p1); time += timeInc; bool quit=false; while(! quit && time < animLen+timeInc) { if (time > animLen) { time = animLen; quit=true; } SetCurTime(time, kCalcPosOnly); GetPosition(&p2); IMakeSegment(idx, pos, p1, p2); time += timeInc; p1 = p2; } SetTransform(resetL2W, resetW2L); }
void Arrow::draw() { auto device = ShaderDevise::device(); device->SetTransform(D3DTS_WORLD, &world); device->SetFVF(D3DFVF_CUSTOMVERTEX); device->SetRenderState(D3DRS_LIGHTING, false); device->SetStreamSource(0, vbuf, 0, sizeof(CUSTOMVERTEX)); device->DrawPrimitive(D3DPT_LINELIST, 0, 2); device->SetRenderState(D3DRS_LIGHTING, true); }
void PolyModelRenderer::BeginDrawHUDModel(AActor *actor, const VSMatrix &objectToWorldMatrix, bool mirrored) { ModelActor = actor; const_cast<VSMatrix &>(objectToWorldMatrix).copy(ObjectToWorld.Matrix); SetTransform(); PolyTriangleDrawer::SetWeaponScene(Thread->DrawQueue, true); if (actor->RenderStyle == LegacyRenderStyles[STYLE_Normal]) PolyTriangleDrawer::SetTwoSided(Thread->DrawQueue, true); PolyTriangleDrawer::SetCullCCW(Thread->DrawQueue, mirrored); }
void PolygonRender::GetExtent(CachedExtent &ioCache) { mBuildExtent = &ioCache.mExtent; *mBuildExtent = Extent2DF(); SetTransform(ioCache.mTransform); Iterate(itGetExtent,*ioCache.mTransform.mMatrix); mBuildExtent = 0; }
void TranslationAxis::SetSpace( ESpace eSpace ) { if(m_eSpace == eSpace) { return; } m_eSpace = eSpace; if(m_pBind) { const clstd::TRANSFORM& T = m_pBind->GetTransform(); SetTransform(NULL, m_eSpace == GVNode::S_RELATIVE ? &T.rotation : &quaternion(0.0f), &T.translation); } }