当前位置: 首页>>代码示例>>C++>>正文


C++ D3DXMatrixScaling函数代码示例

本文整理汇总了C++中D3DXMatrixScaling函数的典型用法代码示例。如果您正苦于以下问题:C++ D3DXMatrixScaling函数的具体用法?C++ D3DXMatrixScaling怎么用?C++ D3DXMatrixScaling使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了D3DXMatrixScaling函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: D3DXMatrixScaling

	void Node::SetScale(float x, float y, float z)
	{
		D3DXMatrixScaling( &this->matScale, x, y, z);        // Pitch
	}
开发者ID:Siduron,项目名称:Siduron-Engine,代码行数:4,代码来源:Node.cpp

示例2: starTwinkle

void star::starDraw(void)//this draws a Star to the Background will eventually include arguments to set stars X Y coords, size and color of star
{

	
	D3DXMATRIX matTranslateStar;    // a matrix to store the translation information
	D3DXMATRIX matSpikeRotation;	//matrix used to rotate drawn spikes
	D3DXMATRIX matScaleStar;			//matrix used to scale stars down
	D3DXMATRIX matTwinkle;

	starTwinkle();
	
	D3DXMatrixTranslation(&matTranslateStar, xStar, yStar, -5.0f);//set star transformation here
	D3DXMatrixScaling(&matScaleStar,scale,scale,scale);
	D3DXMatrixRotationZ(&matTwinkle,D3DXToRadian(twinkle));

	starBase();
	// set the world transform

	
    dev->d3ddev->SetTransform(D3DTS_WORLD, &(matScaleStar*matTwinkle*matTranslateStar));    // set the world transform
	
	// select the vertex buffer to display
    dev->d3ddev->SetStreamSource(0, dev->v_buffer, 0, sizeof(CUSTOMVERTEX));
    dev->d3ddev->SetIndices(dev->i_buffer);
	// draw
    dev->d3ddev->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, 0, 0, 18, 0, 32);
	dev->cleanBuffers();


	starAngle();
	for(float i=0;i<=3;i+=1)//draws 4 spikes at equal areas
	{
	// set the world transform
	D3DXMatrixRotationZ(&matSpikeRotation, D3DXToRadian(90*i));
    dev->d3ddev->SetTransform(D3DTS_WORLD, &(matSpikeRotation*matScaleStar*matTwinkle*matTranslateStar));    // set the world transform
	 
	// select the vertex buffer to display
    dev->d3ddev->SetStreamSource(0, dev->v_buffer, 0, sizeof(CUSTOMVERTEX));
    dev->d3ddev->SetIndices(dev->i_buffer);
	// draw
    dev->d3ddev->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, 0, 0, 5, 0, 4);
	}
	dev->cleanBuffers();

	starHV();
	for(float i=0;i<=3;i+=1)//draws 4 spikes at equal areas
	{
	// set the world transform
	D3DXMatrixRotationZ(&matSpikeRotation, D3DXToRadian(90*i));
    dev->d3ddev->SetTransform(D3DTS_WORLD, &(matSpikeRotation*matScaleStar*matTwinkle*matTranslateStar));    // set the world transform
	
	// select the vertex buffer to display
    dev->d3ddev->SetStreamSource(0, dev->v_buffer, 0, sizeof(CUSTOMVERTEX));
    dev->d3ddev->SetIndices(dev->i_buffer);
	// draw
    dev->d3ddev->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, 0, 0, 5, 0, 4);
	}
	dev->cleanBuffers();


	return;
}
开发者ID:ascriven,项目名称:Galaxian3D,代码行数:62,代码来源:Star.cpp

示例3: getFloatProperty

void MegaExtrudeOperator::process(int tick)
{
    if (mesh != 0)
        delete mesh;

    float distance = getFloatProperty(0);
    unsigned char count = getByteProperty(1);
    D3DXVECTOR3 scaleVector = getVectorProperty(2);
    D3DXVECTOR3 rotationVector = getVectorProperty(3);
    D3DXMATRIX scaleMatrix;
    D3DXMatrixScaling(&scaleMatrix,
                      scaleVector.x,
                      scaleVector.y,
                      scaleVector.z);
    D3DXMATRIX rotationXMatrix;
    D3DXMatrixRotationX(&rotationXMatrix, rotationVector.x);
    D3DXMATRIX rotationYMatrix;
    D3DXMatrixRotationY(&rotationYMatrix, rotationVector.y);
    D3DXMATRIX rotationZMatrix;
    D3DXMatrixRotationZ(&rotationZMatrix, rotationVector.z);
    D3DXMATRIX translationMatrix;
    D3DXMatrixTranslation(&translationMatrix,
                          0.0f,
                          distance / (float)count,
                          0.0f);
    D3DXMATRIX extrudeMatrix = scaleMatrix * rotationXMatrix * rotationYMatrix * rotationZMatrix * translationMatrix;

    Mesh *srcMesh = getInput(0)->mesh;

    int numberOfVertices = srcMesh->getNumVertices();
    int numberOfQuads = srcMesh->getNumQuads();

    // Calculate the new number of quads and vertices.
    // The number of triangles will be unchanged.
    for (int i = 0; i < srcMesh->getNumFaces(); i++)
    {
        int n;
        int *face = srcMesh->face(i, n);

        if (srcMesh->faceSelected(i))
        {
            numberOfQuads += n * count;
            numberOfVertices += n * count;
        }
    }

    mesh = new Mesh(numberOfVertices, srcMesh->getNumTriangles(), numberOfQuads, 1);

    int triangleIndex = 0;
    int quadIndex = 0;

    // Copy the src mesh vertices.
    for (int i = 0; i < srcMesh->getNumVertices(); i++)
    {
        mesh->pos(i) = srcMesh->pos(i);
    }

    int vertexIndex = srcMesh->getNumVertices();
    // Extrude each selected face and add triangles and quads.

    Vec3* lastPositions = new Vec3[4];
    int* lastIndices = new int[4];
    int* currentIndices = new int[4];

    for (int i = 0; i < srcMesh->getNumFaces(); i++)
    {
        int n;
        int *face = srcMesh->face(i, n);

        for (int f = 0; f < n; f++)
        {
            lastPositions[f] = srcMesh->pos(face[f]);
            lastIndices[f] = face[f];
        }

        if (srcMesh->faceSelected(i))
        {
            // Get our base vectors.
            Vec3 pos1 = srcMesh->pos(face[1]);
            Vec3 pos0 = srcMesh->pos(face[0]);
            Vec3 faceBase1 = normalize(pos1 - pos0);
            Vec3 faceBase2 = normalize(srcMesh->getFaceNormal(i));
            Vec3 faceBase3 = normalize(cross(faceBase2, faceBase1));

            D3DXMATRIX fromFaceBaseMatrix = D3DXMATRIX(faceBase1.x, faceBase1.y, faceBase1.z, 0.0f,
                                            faceBase2.x, faceBase2.y, faceBase2.z, 0.0f,
                                            faceBase3.x, faceBase3.y, faceBase3.z, 0.0f,
                                            0.0f,               0.0f,        0.0f, 1.0f);
            D3DXMATRIX toFaceBaseMatrix = D3DXMATRIX(faceBase1.x, faceBase2.x, faceBase3.x, 0.0f,
                                          faceBase1.y, faceBase2.y, faceBase3.y, 0.0f,
                                          faceBase1.z, faceBase2.z, faceBase3.z, 0.0f,
                                          0.0f,               0.0f,        0.0f, 1.0f);

            D3DXMATRIX toFaceBaseAndOrigoMatrix = toFaceBaseMatrix;
            D3DXMATRIX fromFaceBaseAndToFaceMatrix = extrudeMatrix * fromFaceBaseMatrix;

            for (int c = 0; c < count; c++)
            {
                for (int f = 0; f < n; f++)
                {
//.........这里部分代码省略.........
开发者ID:olofn,项目名称:db_public,代码行数:101,代码来源:megaextrudeoperator.cpp

示例4: D3DXMatrixScaling

void CRenderManager::Render(CTexture const * _pTexture,
							CRect const * _rImgRect,
							D3DXVECTOR2 const & _vPosition,
							D3DXVECTOR2 const & _vScale,
							D3DCOLOR const _ImgColor,
							D3DXVECTOR2 const & _vCenter,
							float const _fLocalRotAmount,
							float const _fGlobalRotAmount,
							D3DXVECTOR2 const & _vRotationVector) const
{
	RECT _rRect;

	if(_rImgRect)
	{
		_rRect.top		= _rImgRect->m_nY;
		_rRect.bottom	= _rImgRect->m_nY + _rImgRect->m_nHeight;
		_rRect.left		= _rImgRect->m_nX;
		_rRect.right	= _rImgRect->m_nX + _rImgRect->m_nWidth;
	}

	/* NOTE */
	// Expensive call, transforming even when values are 0.

	/* NOTE */
	// Don't need to call identity on any of the matrices. Once the DirectX function gets call (Scale, Rotate, Translate),
	// the matrix becomes identity with the applied values from the function.
	D3DXMATRIX mTransform;

	// Order (SRT -> Scale, Rotate, Translate)
	// Scale
	D3DXMATRIX mScale;
 	D3DXMatrixScaling(&mScale, _vScale.x, _vScale.y, 0.0f);

	// Local Rotation
	D3DXMATRIX mLocalRotation;
	D3DXMATRIX mRotationTranslate;
	D3DXMatrixTranslation(&mRotationTranslate, -_vCenter.x, -_vCenter.y, 0.0f);
 	D3DXMatrixRotationAxis(&mLocalRotation, &D3DXVECTOR3(0.0f, 0.0f, 1.0f), _fLocalRotAmount);
	mLocalRotation = mRotationTranslate * mLocalRotation;

	// Translate
	D3DXMATRIX mTranslation;
	D3DXMatrixTranslation(&mTranslation, (_vPosition.x + _vCenter.x), (_vPosition.y + _vCenter.y), 0.0f);

	// Global Rotation
	D3DXMATRIX mGlobalRotation;
	D3DXMatrixTranslation(&mRotationTranslate, _vRotationVector.x, _vRotationVector.y, 0.0f);
	D3DXMatrixRotationAxis(&mGlobalRotation, &D3DXVECTOR3(0.0f, 0.0f, 1.0f), _fGlobalRotAmount);
	mGlobalRotation = mRotationTranslate * mGlobalRotation;

	// Multiply all the matrices together
	mTransform = mScale * mLocalRotation * mGlobalRotation * mTranslation;

	// Set the transform to move the position, draw, then reset back to origin
	m_pSpriteManager->SetTransform(&mTransform);
	m_pSpriteManager->Draw(_pTexture->GetTexture(), _rImgRect ? (&_rRect) : NULL, 0, 0, _ImgColor);

	// Now reset the picture back to top left of window
	D3DXMatrixIdentity(&mTransform);
	m_pSpriteManager->SetTransform(&mTransform);
}
开发者ID:107-Studios,项目名称:GasNGo,代码行数:61,代码来源:RenderManager.cpp

示例5: D3DXMatrixPerspectiveFovLH

void DXApp::RenderFrame()
{
    _p_device->Clear(0, NULL, D3DCLEAR_TARGET, 0x00000000, 1.0f, 0);
    _p_device->BeginScene();

    _p_device->SetRenderState(D3DRS_AMBIENT,RGB(255,255,255));
    _p_device->SetRenderState(D3DRS_LIGHTING,false);
    _p_device->SetRenderState(D3DRS_ZENABLE, D3DZB_TRUE);
    _p_device->SetRenderState(D3DRS_ZWRITEENABLE, TRUE);
    _p_device->SetRenderState(D3DRS_ZFUNC, D3DCMP_LESSEQUAL);
    D3DXMatrixPerspectiveFovLH(&matProjection,0.30f,(float)width/height,200.0f,2000.0f);
    //D3DXMatrixRotationX(&trans1, CameraAngleX);
    D3DXMatrixRotationYawPitchRoll(&trans1, 0.0f, CameraAngleX, CameraAngleY);
    D3DXMatrixIdentity(&matView);
    D3DXMatrixLookAtLH( &matView, (D3DXVECTOR3*)&Cam.location,
                        (D3DXVECTOR3*)&(Cam.location + Cam.ViewDir),
                        &D3DXVECTOR3( 0.0f, 1.0f, 0.0f ) );
    //D3DXMatrixMultiply(&matView, &trans1, &matView);
    D3DXMATRIX matLocal;
    D3DXMatrixIdentity(&matLocal);
    _p_device->GetRenderTarget(0, & _back_buffer);

    ///////////////////////////////////////////////////
    //Render Shadow Buffer
    IDirect3DSurface9* _shadow_buffer;
    ShadowBuffer->GetSurfaceLevel(0, &_shadow_buffer);
    _p_device->SetRenderTarget(0, _shadow_buffer);
    _p_device->Clear(0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0xFFFFFFFF, 1.0f, 0);

    D3DXMATRIX matSBView;
    D3DXMATRIX matSBProjection;
    D3DXMATRIX matSBFull;

    D3DXMatrixLookAtLH( &matSBView, (D3DXVECTOR3*)&DrawLight.location, &D3DXVECTOR3( 0.0f, 0.0f, 0.0f ), &D3DXVECTOR3( 0.0f, 1.0f, 0.0f ) );
    D3DXMatrixPerspectiveFovLH( &matSBProjection, D3DXToRadian(30.0f), 1,200.0f,2000.0f);
    D3DXMatrixMultiply( &matSBFull, &matSBView, &matSBProjection );

    _p_SB_vertex_constant_able->SetMatrix(_p_device, hSBMatProjection, &matSBFull);

    _p_device->SetFVF(particle_fvf);
    _p_device->SetPixelShader(_p_SB_shader);
    _p_device->SetVertexShader(_p_SB_vshader);

    //now render the scene
    for(int i=0; i < _max_particle_count; i++)
    {
        if(_particle_list[i].Particle != NULL)
        {
            NxMat34 Pose = _particle_list[i].Particle->getGlobalPose();

            float MatTransform[16];
            Pose.getColumnMajor44((NxF32*)&MatTransform);
            D3DXMATRIX Transfom(MatTransform);
            D3DXMatrixScaling(&matLocal, CubeMeshDrawScale, CubeMeshDrawScale, CubeMeshDrawScale);
            D3DXMatrixMultiply(&Transfom, &matLocal, &Transfom);
            _p_SB_vertex_constant_able->SetMatrix(_p_device, hSBMatWorld, &Transfom);
            _particle_Mesh->DrawSubset(0);
        }
    }

    _shadow_buffer->Release();








    /////////////////////////////////////////////////
    //Render Scene
    //_p_device->SetTexture(0, _point_texture);
    IDirect3DSurface9* screen_surface;
    _screen_buffer->GetSurfaceLevel(0, &screen_surface);
    _p_device->SetRenderTarget(0, screen_surface);
    _p_device->Clear(0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0xFF000000, 1.0f, 0);
    _p_device->SetRenderTarget(0, _back_buffer);
    _p_device->SetTexture(0, ShadowBuffer);

    IDirect3DSurface9* blur_surface;
    if(bMotionBlur)
    {
        _blur_buffer->GetSurfaceLevel(0, &blur_surface);
        _p_device->SetRenderTarget(1, blur_surface);
        _p_device->Clear(0, NULL, D3DCLEAR_TARGET, 0x00000000, 1.0f, 0);
    }
    _p_device->SetRenderTarget(0, screen_surface);
    //Setup the Transform Matricies for the VertexShader;
    _p_vertex_constant_able->SetMatrix(_p_device, hMatProjection, &matProjection);
    _p_vertex_constant_able->SetMatrix(_p_device, hMatView, &matView);
    _p_vertex_constant_able->SetFloatArray(_p_device, hLightPosition, (float*)&DrawLight.location, 3);

    float fTexOffs = 0.5f + (0.5f / (float)ShadowMapSize);
    D3DXMATRIX matTexAdj( 0.5f,     0.0f,     0.0f, 0.0f,
                          0.0f,     -0.5f,    0.0f, 0.0f,
                          0.0f,     0.0f,     1.0f, 0.0f,
                          fTexOffs, fTexOffs, 0.0f, 1.0f );

    D3DXMATRIX matTexture;// = matView;

//.........这里部分代码省略.........
开发者ID:Arelius,项目名称:TestMotionBlur,代码行数:101,代码来源:DXApp.cpp

示例6: D3DCOLOR_ARGB

void CWndChangeSex::OnDraw( C2DRender* p2DRender ) 
{ 
	if( g_pPlayer == NULL  )
		return;

	LPDIRECT3DDEVICE9 pd3dDevice = p2DRender->m_pd3dDevice;

	pd3dDevice->SetRenderState( D3DRS_ZWRITEENABLE, TRUE );
	pd3dDevice->SetRenderState( D3DRS_ZENABLE, TRUE );
	pd3dDevice->SetRenderState( D3DRS_CULLMODE, D3DCULL_CCW );
	pd3dDevice->SetRenderState( D3DRS_ALPHABLENDENABLE, FALSE );
	pd3dDevice->SetRenderState( D3DRS_FILLMODE, D3DFILL_SOLID );
	pd3dDevice->SetTextureStageState( 0, D3DTSS_COLOROP,   D3DTOP_SELECTARG1 );

	pd3dDevice->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE );
	pd3dDevice->SetTextureStageState( 0, D3DTSS_COLOROP,   D3DTOP_SELECTARG1 );
	pd3dDevice->SetSamplerState ( 0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR );
	pd3dDevice->SetSamplerState ( 0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR );

	pd3dDevice->SetTextureStageState( 0, D3DTSS_COLOROP,   D3DTOP_SELECTARG1 );

	pd3dDevice->SetRenderState( D3DRS_AMBIENT,  D3DCOLOR_ARGB( 255, 255,255,255) );
	
	CRect rect = GetClientRect();

	// 뷰포트 세팅 
	D3DVIEWPORT9 viewport;

	// 월드 
	D3DXMATRIXA16 matWorld;
	D3DXMATRIXA16 matScale;
	D3DXMATRIXA16 matRot;
	D3DXMATRIXA16 matTrans;

	// 카메라 
	D3DXMATRIX  matView;
	D3DXVECTOR3 vecLookAt( 0.0f, 0.0f, 3.0f );
	D3DXVECTOR3 vecPos(  0.0f, 0.7f, -3.5f );
	
	D3DXMatrixLookAtLH( &matView, &vecPos, &vecLookAt, &D3DXVECTOR3(0.0f,1.0f,0.0f) );
	
	pd3dDevice->SetTransform( D3DTS_VIEW, &matView );
	
	// 왼쪽 원본 모델 랜더링
	{
		LPWNDCTRL lpFace = GetWndCtrl( WIDC_STATIC1 );

		viewport.X      = p2DRender->m_ptOrigin.x + lpFace->rect.left;//2;
		viewport.X     -= 6;
		viewport.Y      = p2DRender->m_ptOrigin.y + lpFace->rect.top;//5;
		viewport.Width  = lpFace->rect.Width();//p2DRender->m_clipRect.Width();
		viewport.Height = lpFace->rect.Height();// - 10;//p2DRender->m_clipRect.Height();

		viewport.MinZ   = 0.0f;
		viewport.MaxZ   = 1.0f;
		pd3dDevice->SetViewport(&viewport);
		pd3dDevice->Clear(0, NULL, D3DCLEAR_ZBUFFER, 0xffa08080, 1.0f, 0 ) ;

		D3DXMATRIX matProj;
		D3DXMatrixIdentity( &matProj );
		FLOAT fAspect = ((FLOAT)viewport.Width) / (FLOAT)viewport.Height;
/*		
		D3DXMatrixPerspectiveFovLH( &matProj, D3DX_PI/4.0f, fAspect, CWorld::m_fNearPlane - 0.01f, CWorld::m_fFarPlane );
		pd3dDevice->SetTransform( D3DTS_PROJECTION, &matProj );
*/		
		FLOAT fov = D3DX_PI/4.0f;//796.0f;
		FLOAT h = cos(fov/2) / sin(fov/2);
		FLOAT w = h * fAspect;
		D3DXMatrixOrthoLH( &matProj, w, h, CWorld::m_fNearPlane - 0.01f, CWorld::m_fFarPlane );
		pd3dDevice->SetTransform( D3DTS_PROJECTION, &matProj );
		
	    D3DXMatrixIdentity(&matScale);
		D3DXMatrixIdentity(&matTrans);
		D3DXMatrixIdentity(&matWorld);
		
		D3DXMatrixScaling(&matScale, 4.5f, 4.5f, 4.5f);
		
		if( g_pPlayer->GetSex() == SEX_MALE )
			D3DXMatrixTranslation(&matTrans,0.0f,-5.6f,0.0f);
		else
			D3DXMatrixTranslation(&matTrans,0.0f,-5.8f,0.0f);

		D3DXMatrixMultiply(&matWorld,&matWorld,&matScale);
		D3DXMatrixMultiply(&matWorld, &matWorld, &matTrans );
		pd3dDevice->SetTransform( D3DTS_WORLD, &matWorld );

		// 랜더링 
		pd3dDevice->SetRenderState( D3DRS_FOGENABLE, FALSE );
		pd3dDevice->SetRenderState( D3DRS_LIGHTING, FALSE );//m_bViewLight );
		
		::SetLight( FALSE );
		::SetFog( FALSE );
		SetDiffuse( 1.0f, 1.0f, 1.0f );
		SetAmbient( 1.0f, 1.0f, 1.0f );
/*
		m_pModel->GetObject3D(PARTS_HAIR)->m_fAmbient[0] = 0.5f;
		m_pModel->GetObject3D(PARTS_HAIR)->m_fAmbient[1] = 0.5f;
		m_pModel->GetObject3D(PARTS_HAIR)->m_fAmbient[2] = 0.5f;
*/		
		D3DXVECTOR4 vConst( 1.0f, 1.0f, 1.0f, 1.0f );
//.........这里部分代码省略.........
开发者ID:KerwinMa,项目名称:AerothFlyffSource,代码行数:101,代码来源:WndChangeFace.cpp

示例7: The


//.........这里部分代码省略.........
- IND_Entity2d::setPosition()
- IND_Entity2d::setAngleXYZ()
- IND_Entity2d::setScale()
- IND_Entity2d::setBackCull()
- IND_Entity2d::setMirrorX()
- IND_Entity2d::setMirrorY()
- IND_Entity2d::setFilter()
- IND_Entity2d::setHotSpot()
- IND_Entity2d::setRegion()
- IND_Entity2d::toggleWrap()
*/
void DirectXRender::setTransform2d(int pX,
                                   int pY,
                                   float pAngleX,
                                   float pAngleY,
                                   float pAngleZ,
                                   float pScaleX,
                                   float pScaleY,
                                   int pAxisCalX,
                                   int pAxisCalY,
                                   bool pMirrorX,
                                   bool pMirrorY,
                                   int pWidth,
                                   int pHeight,
                                   IND_Matrix *pMatrix) {
	// ----- World matrix initialization -----

	D3DXMATRIX mMatWorld, mMatZ, mMatX, mMatY, mMatTraslation, mMatScale;
	//Initializes every object transform with pixel to point scale transform
	_info._device->SetTransform(D3DTS_WORLD, D3DXMatrixIdentity(&mMatWorld));

	// ----- Transformation matrix creation -----

	// Mirroring (180º rotations)
	if (pMirrorX || pMirrorY) {
		//A mirror is a rotation in desired axis (the actual mirror) and a repositioning because rotation
		//also moves 'out of place' the entity translation-wise
		if (pMirrorX) {
			D3DXMatrixTranslation(&mMatTraslation, 
								  static_cast<float>(- pWidth+pAxisCalX),//pWidth is the neeeded amount for normal mirroring, pAxisCalX is a correction for hotspot
								  static_cast<float>(-pAxisCalY), //Corrects the next translation when hotspot is on in Y
								  0);
			D3DXMatrixMultiply(&mMatWorld, &mMatWorld, &mMatTraslation);
			D3DXMatrixRotationY(&mMatY, D3DXToRadian(180));
			D3DXMatrixMultiply(&mMatWorld, &mMatWorld, &mMatY);
		}

		//A mirror is a rotation in desired axis (the actual mirror) and a repositioning because rotation
		//also moves 'out of place' the entity translation-wise
		if (pMirrorY) {
			D3DXMatrixTranslation(&mMatTraslation, 
								  static_cast<float>(-pAxisCalX),  //Corrects the next translation when hotspot is on in X
								  static_cast<float>( - pHeight+pAxisCalY), //pHeight is the neeeded amount for normal mirroring, pAxisCalY is a correction for hotspot
								  0);
			D3DXMatrixMultiply(&mMatWorld, &mMatWorld, &mMatTraslation);
			D3DXMatrixRotationX(&mMatX, D3DXToRadian(180));
			D3DXMatrixMultiply(&mMatWorld, &mMatWorld, &mMatX);
		}
	}

	// Hotspot
	if (pAxisCalX != 0 || pAxisCalY != 0) {
		D3DXMatrixTranslation(&mMatTraslation, static_cast<float>( pAxisCalX), static_cast<float>( pAxisCalY), 0);
		D3DXMatrixMultiply(&mMatWorld, &mMatWorld, &mMatTraslation);
	}

	// Scaling
	if (pScaleX != 1.0f || pScaleY != 1.0f) {
		D3DXMatrixScaling(&mMatScale, pScaleX, pScaleY, 1.0f);
		D3DXMatrixMultiply(&mMatWorld, &mMatWorld, &mMatScale);
	}

	// Rotations
	if (pAngleX != 0.0f) {
		D3DXMatrixRotationX(&mMatX, D3DXToRadian(pAngleX));
		D3DXMatrixMultiply(&mMatWorld, &mMatWorld, &mMatX);
	}
	if (pAngleY != 0.0f) {
		D3DXMatrixRotationY(&mMatY, D3DXToRadian(pAngleY));
		D3DXMatrixMultiply(&mMatWorld, &mMatWorld, &mMatY);
	}
	if (pAngleZ != 0.0f) {
		D3DXMatrixRotationZ(&mMatZ, D3DXToRadian(pAngleZ));
		D3DXMatrixMultiply(&mMatWorld, &mMatWorld, &mMatZ);
	}

	// Translations
	if (pX != 0 || pY != 0) {
		D3DXMatrixTranslation(&mMatTraslation, static_cast<float>(pX), static_cast<float>(pY), 0);
		D3DXMatrixMultiply(&mMatWorld, &mMatWorld, &mMatTraslation);
	}

	// ----- Return World Matrix (in IndieLib format) -----
	if (pMatrix) {
		pMatrix->readFromArray(&mMatWorld.m[0][0]);
	}

	// ----- Applies the transformation -----
	_info._device->SetTransform(D3DTS_WORLD, &mMatWorld);
}
开发者ID:dreamsxin,项目名称:indielib-crossplatform,代码行数:101,代码来源:RenderTransform2dDirectX.cpp

示例8: D3DXMatrixScaling

/**
* Changes GUI squash and updates matrix.
***/
void ViewAdjustment::ChangeGUISquash(float newSquash)
{
	squash = newSquash;

	D3DXMatrixScaling(&matSquash, squash, squash, 1);
}
开发者ID:DrBeef,项目名称:Perception,代码行数:9,代码来源:ViewAdjustment.cpp

示例9: D3DXVECTOR3

void cPart::Setup(float fWidth, float fHeight, float fDepth, Cube_Part type){
	ST_PT_VERTEX v;
	D3DXMATRIXA16 matScale, matRotate, matTrans, matFinal;
	m_epart = type;

	float left = -0.5f;
	float top = 0.5f;
	float right = 0.5f;
	float bottom = -0.5f;
	float frontdepth = 0.5f;
	float backdepth = -0.5f;

	//front
	std::vector<ST_PT_VERTEX> plane;
	v.p = D3DXVECTOR3(left, top, 0);
	plane.push_back(v);
	v.p = D3DXVECTOR3(right, top, 0);
	plane.push_back(v);
	v.p = D3DXVECTOR3(left, bottom, 0);
	plane.push_back(v);
	v.p = D3DXVECTOR3(left, bottom, 0);
	plane.push_back(v);
	v.p = D3DXVECTOR3(right, top, 0);
	plane.push_back(v);
	v.p = D3DXVECTOR3(right, bottom, 0);
	plane.push_back(v);

	for (UINT j = 0; j < plane.size(); j++){
		v = plane[j];
		D3DXMatrixRotationY(&matRotate, D3DXToRadian(180.0f));
		//D3DXMatrixTranslation(&matTrans, m_vec3Origin.x, m_vec3Origin.y, m_vec3Origin.z);
		//matFinal = matRotate * matTrans;
		D3DXVec3TransformCoord(&v.p, &v.p, &matRotate);
		v.p.z = v.p.z + frontdepth;
		m_vecVertex.push_back(v);
	}

	// right
	for (UINT j = 0; j < plane.size(); j++){
		v = plane[j];
		D3DXMatrixRotationY(&matRotate, D3DXToRadian(270.0f));
		//D3DXMatrixTranslation(&matTrans, m_vec3Origin.x, m_vec3Origin.y, m_vec3Origin.z);
		//matFinal = matRotate * matTrans;
		D3DXVec3TransformCoord(&v.p, &v.p, &matRotate);
		v.p.x = v.p.x + right;
		m_vecVertex.push_back(v);
	}

	//back
	for (UINT j = 0; j < plane.size(); j++){
		v = plane[j];
		//D3DXMatrixRotationY(&matRotate, D3DXToRadian(0.0f));
		//D3DXMatrixTranslation(&matTrans, m_vec3Origin.x, m_vec3Origin.y, m_vec3Origin.z);
		//matFinal = matRotate * matTrans;
		//D3DXVec3TransformCoord(&v.p, &v.p, &matRotate);
		v.p.z = v.p.z + backdepth;
		m_vecVertex.push_back(v);
	}
	//left
	for (UINT j = 0; j < plane.size(); j++){
		v = plane[j];
		D3DXMatrixRotationY(&matRotate, D3DXToRadian(90.0f));
		//D3DXMatrixTranslation(&matTrans, m_vec3Origin.x, m_vec3Origin.y, m_vec3Origin.z);
		//matFinal = matRotate * matTrans;
		D3DXVec3TransformCoord(&v.p, &v.p, &matRotate);
		v.p.x = v.p.x + left;
		m_vecVertex.push_back(v);
	}

	//top
	for (UINT j = 0; j < plane.size(); j++){
		v = plane[j];
		D3DXMatrixRotationX(&matRotate, D3DXToRadian(90.0f));
		//D3DXMatrixTranslation(&matTrans, m_vec3Origin.x, m_vec3Origin.y, m_vec3Origin.z);
		//matFinal = matRotate * matTrans;
		D3DXVec3TransformCoord(&v.p, &v.p, &matRotate);
		v.p.y = v.p.y + top;
		m_vecVertex.push_back(v);
	}

	// bottom
	// lefttop righttop leftbottom leftbottom righttop rightbottom
	for (UINT j = 0; j < plane.size(); j++){
		v = plane[j];
		D3DXMatrixRotationX(&matRotate, D3DXToRadian(270.0f));
		//D3DXMatrixTranslation(&matTrans, m_vec3Origin.x, m_vec3Origin.y, m_vec3Origin.z);
		//matFinal = matRotate * matTrans;
		D3DXVec3TransformCoord(&v.p, &v.p, &matRotate);
		v.p.y = v.p.y + bottom;
		m_vecVertex.push_back(v);
	}

	D3DXMatrixScaling(&matScale, fWidth, fHeight, fDepth);
	for (UINT i = 0; i < m_vecVertex.size(); i++){
		D3DXVec3TransformCoord(&m_vecVertex[i].p, &m_vecVertex[i].p, &matScale);
	}

	if (type == PT_head){
		// right
		m_vecVertex[0].t = D3DXVECTOR2(128.0f / 1024.0f, 128.0f / 512.0f);
//.........这里部分代码省略.........
开发者ID:arkiny,项目名称:Direct3D,代码行数:101,代码来源:cPart.cpp

示例10: Update

VOID Update()
{
	DWORD currentTime = GetTickCount();
	static DWORD preTime;
	g_ElapsedTime = currentTime - preTime;
	preTime = currentTime;

	if ( GetAsyncKeyState( VK_LEFT ) )
	{
		g_Box[0].CenterPos.x -= g_ElapsedTime*0.002f;
	}
	if ( GetAsyncKeyState( VK_RIGHT ) )
	{
		g_Box[0].CenterPos.x += g_ElapsedTime*0.002f;
	}
	if ( GetAsyncKeyState( VK_UP ) )
	{
		g_Box[0].CenterPos.y += g_ElapsedTime*0.002f;
	}
	if ( GetAsyncKeyState( VK_DOWN ) )
	{
		g_Box[0].CenterPos.y -= g_ElapsedTime*0.002f;
	}
	if ( GetAsyncKeyState( VK_LBUTTON ) )
	{
		if (g_ElapsedTime > 20)
		{
			g_Method = !g_Method;
		}
		
	}
	if ( GetAsyncKeyState( VK_HOME ) )
	{
		g_Box[1].BoxRotateZ -= 0.2f;
	}
	if ( GetAsyncKeyState( VK_END ) )
	{
		g_Box[1].BoxRotateZ += 0.2f;
	}

	D3DXVECTOR3 *vertices;

	g_pMesh->LockVertexBuffer( D3DLOCK_READONLY, (void**) &vertices );
	D3DXComputeBoundingBox( vertices, g_pMesh->GetNumVertices(), g_pMesh->GetNumBytesPerVertex(), &g_MinPoint, &g_MaxPoint );
	g_pMesh->UnlockVertexBuffer();

	D3DXMATRIX matScale, matTrans, matRotateZ, matWorld;
	D3DXMatrixTranslation( &matTrans, g_Box[0].CenterPos.x, g_Box[0].CenterPos.y, g_Box[0].CenterPos.z );
	D3DXMatrixScaling( &matScale, g_Box[0].BoxScaling, g_Box[0].BoxScaling, g_Box[0].BoxScaling );
	D3DXMatrixRotationZ( &matRotateZ, g_Box[0].BoxRotateZ );

	matWorld = matRotateZ* matScale * matTrans;
	D3DXVec3TransformCoord( &g_Box[0].MinPoint, &g_MinPoint, &matWorld );
	D3DXVec3TransformCoord( &g_Box[0].MaxPoint, &g_MaxPoint, &matWorld );
	
	if (!g_Method)
	{
		g_CheckFlag = CheckAABBIntersection( &g_Box[0].MinPoint, &g_Box[0].MaxPoint, &g_Box[1].MinPoint, &g_Box[1].MaxPoint );
	}
	else
	{
		g_CheckFlag = CheckOBBIntersection( &g_Box[0], &g_Box[1] );
	}
	
}
开发者ID:trizdreaming,项目名称:AABB_OBB_collision,代码行数:65,代码来源:AABB_OBB_collision.cpp

示例11: D3DXMatrixTranslation

/**
* Gets the view-projection transform matrices left and right.
* Unprojects, shifts view position left/right (using same matricies as (Left/Right)ViewRollAndShift)
* and reprojects using left/right projection.
* (matrix = projectionInverse * transform * projection)
***/
void ViewAdjustment::ComputeViewTransforms()
{
	// separation settings are overall (HMD and desktop), since they are based on physical IPD
	D3DXMatrixTranslation(&transformLeft, SeparationInWorldUnits() * LEFT_CONSTANT, 0, 0);
	D3DXMatrixTranslation(&transformRight, SeparationInWorldUnits() * RIGHT_CONSTANT, 0, 0);

	// projection transform, no roll
	matViewProjTransformLeftNoRoll = matProjectionInv * transformLeft * projectLeft;
	matViewProjTransformRightNoRoll = matProjectionInv * transformRight * projectRight;

	// head roll
	if (rollEnabled) {
		D3DXMatrixMultiply(&transformLeft, &rollMatrix, &transformLeft);
		D3DXMatrixMultiply(&transformRight, &rollMatrix, &transformRight);

		// projection 
		matViewProjLeft = matProjectionInv * rollMatrix * projectLeft;
		matViewProjRight = matProjectionInv * rollMatrix * projectRight;
	}
	else
	{
		// projection 
		matViewProjLeft = matProjectionInv * projectLeft;
		matViewProjRight = matProjectionInv * projectRight;
	}

	// projection transform
	matViewProjTransformLeft = matProjectionInv * transformLeft * projectLeft;
	matViewProjTransformRight = matProjectionInv * transformRight * projectRight;

	// now, create HUD/GUI helper matrices

	// if not HMD, set HUD/GUI to fullscreen
	if ((stereoType != 26) && // != StereoView::StereoTypes::OCULUS_RIFT
		(stereoType != 27) && // != StereoView::StereoTypes::OCULUS_RIFT_CROPPED
		(stereoType != 25))   // != StereoView::StereoTypes::DIY_RIFT))
	{
		squash = 1.0f;
		gui3DDepth = 0.0f;
		hudDistance = 0.0f;
		hud3DDepth = 0.0f;
	}

	// squash
	D3DXMatrixScaling(&matSquash, squash, squash, 1);

	// hudDistance
	D3DXMatrixTranslation(&matHudDistance, 0, 0, hudDistance);

	// hud3DDepth
	D3DXMatrixTranslation(&matLeftHud3DDepth, hud3DDepth, 0, 0);
	D3DXMatrixTranslation(&matRightHud3DDepth, -hud3DDepth, 0, 0);
	float additionalSeparation = (1.5f-hudDistance)*hmdInfo.lensXCenterOffset;
	D3DXMatrixTranslation(&matLeftHud3DDepthShifted, hud3DDepth+additionalSeparation, 0, 0);
	D3DXMatrixTranslation(&matRightHud3DDepthShifted, -hud3DDepth-additionalSeparation, 0, 0);
	D3DXMatrixTranslation(&matLeftGui3DDepth, gui3DDepth+SeparationIPDAdjustment(), 0, 0);
	D3DXMatrixTranslation(&matRightGui3DDepth, -(gui3DDepth+SeparationIPDAdjustment()), 0, 0);

	// gui/hud matrices
	matHudLeft = matProjectionInv * matLeftHud3DDepth * transformLeft * matHudDistance *  projectLeft;
	matHudRight = matProjectionInv * matRightHud3DDepth * transformRight * matHudDistance * projectRight;
	matGuiLeft =  matProjectionInv * matLeftGui3DDepth * matSquash * projectLeft;
	matGuiRight = matProjectionInv * matRightGui3DDepth * matSquash * projectRight;
}
开发者ID:DrBeef,项目名称:Perception,代码行数:70,代码来源:ViewAdjustment.cpp

示例12: InitGeometry

HRESULT InitGeometry( )
{
	if (FAILED(D3DXCreateBox(g_pD3DDevice, 1.f, 1.f, 1.f, &g_pMesh, NULL)))
	{
		return E_FAIL;
	}

	D3DXVECTOR3 *vertices;
	
	
	g_pMesh->LockVertexBuffer( D3DLOCK_READONLY, (void**) &vertices );
	D3DXComputeBoundingBox( vertices, g_pMesh->GetNumVertices(), g_pMesh->GetNumBytesPerVertex(), &g_MinPoint, &g_MaxPoint );
	g_pMesh->UnlockVertexBuffer();

	
	D3DXMATRIX matScale, matTrans, matRotateZ, matWorld;

	g_Box[0].BoxScaling = 1.5f;
	g_Box[0].CenterPos = D3DXVECTOR3( 0.f, 0.f, 0.f );
	g_Box[0].BoxRotateZ = 0.f;
	g_Box[0].AxisDir[0] = D3DXVECTOR3( 1, 0, 0 );
	g_Box[0].AxisDir[1] = D3DXVECTOR3( 0, 1, 0 );
	g_Box[0].AxisDir[2] = D3DXVECTOR3( 0, 0, 1 );

	for ( int i = 0; i < 3; ++i )
	{
		g_Box[0].AxisLen[i] = 0.5f;

		D3DXVec3TransformNormal( &(g_Box[0].AxisDir[i]), &(g_Box[0].AxisDir[i]), &matRotateZ );
		D3DXVec3Normalize( &( g_Box[0].AxisDir[i] ), &( g_Box[0].AxisDir[i] ) );
		g_Box[0].AxisLen[i] = g_Box[0].AxisLen[i] * g_Box[0].BoxScaling;
	}
	D3DXMatrixTranslation( &matTrans, g_Box[0].CenterPos.x, g_Box[0].CenterPos.y, g_Box[0].CenterPos.z );
	D3DXMatrixScaling( &matScale, g_Box[0].BoxScaling, g_Box[0].BoxScaling, g_Box[0].BoxScaling );
	D3DXMatrixRotationZ( &matRotateZ, g_Box[0].BoxRotateZ );

	matWorld = matRotateZ* matScale * matTrans;
	D3DXVec3TransformCoord( &g_Box[0].MinPoint, &g_MinPoint, &matWorld );
	D3DXVec3TransformCoord( &g_Box[0].MaxPoint, &g_MaxPoint, &matWorld );

	
	g_Box[1].BoxScaling = 2.f;
	g_Box[1].CenterPos = D3DXVECTOR3( 3.f, 3.f, 0.f );
	g_Box[1].BoxRotateZ = 0.f;
	g_Box[1].AxisDir[0] = D3DXVECTOR3( 1, 0, 0 );
	g_Box[1].AxisDir[1] = D3DXVECTOR3( 0, 1, 0 );
	g_Box[1].AxisDir[2] = D3DXVECTOR3( 0, 0, 1 );

	for ( int i = 0; i < 3; ++i )
	{
		g_Box[1].AxisLen[i] = 0.5f;

		D3DXVec3TransformNormal( &( g_Box[0].AxisDir[i] ), &( g_Box[1].AxisDir[i] ), &matRotateZ );
		D3DXVec3Normalize( &( g_Box[1].AxisDir[i] ), &( g_Box[1].AxisDir[i] ) );
		g_Box[1].AxisLen[i] = g_Box[1].AxisLen[i] * g_Box[1].BoxScaling;
	}

	D3DXMatrixTranslation( &matTrans, g_Box[1].CenterPos.x, g_Box[1].CenterPos.y, g_Box[1].CenterPos.z );
	D3DXMatrixScaling( &matScale, g_Box[1].BoxScaling, g_Box[1].BoxScaling, g_Box[1].BoxScaling );
	D3DXMatrixRotationZ( &matRotateZ, g_Box[1].BoxRotateZ );

	matWorld = matRotateZ* matScale * matTrans;
	D3DXVec3TransformCoord( &g_Box[1].MinPoint, &g_MinPoint, &matWorld );
	D3DXVec3TransformCoord( &g_Box[1].MaxPoint, &g_MaxPoint, &matWorld );


	return S_OK;
}
开发者ID:trizdreaming,项目名称:AABB_OBB_collision,代码行数:68,代码来源:AABB_OBB_collision.cpp

示例13: Render

//*************************************************************************************************************
void Render(float alpha, float elapsedtime)
{
	static float time = 0;

	D3DXMATRIX	inv;
	D3DXVECTOR3	axis(0, 1, 0);
	D3DXVECTOR4	texelsize(1.0f / (float)screenwidth, 1.0f / (float)screenheight, 0, 1);
	
	LPDIRECT3DSURFACE9 oldtarget = NULL;

	time += elapsedtime;

	D3DXMatrixRotationAxis(&inv, &axis, time);
	D3DXMatrixScaling(&world, 0.3f, 0.3f, 0.3f);
	//D3DXMatrixScaling(&world, 0.6f, 0.6f, 0.6f);
	D3DXMatrixMultiply(&world, &world, &inv);
	D3DXMatrixInverse(&inv, NULL, &world);

	device->SetTexture(0, texture);
	device->SetTexture(1, intensity);

	effect->SetMatrix("matWorld", &world);
	effect->SetMatrix("matWorldInv", &inv);
	effect->SetMatrix("matView", &view);
	effect->SetMatrix("matProj", &proj);

	if( useedgedetect )
	{
		device->GetRenderTarget(0, &oldtarget);
		device->SetRenderTarget(0, colorsurface);
		device->SetRenderTarget(1, normalsurface);
	}

	device->Clear(0, NULL, D3DCLEAR_TARGET|D3DCLEAR_ZBUFFER|D3DCLEAR_STENCIL, 0xff6694ed, 1.0f, 0);

	if( SUCCEEDED(device->BeginScene()) )
	{
		// draw scene + normals/depth
		effect->SetTechnique("celshading");

		effect->Begin(NULL, 0);
		effect->BeginPass(0);
		{
			mesh->DrawSubset(0);
		}
		effect->EndPass();
		effect->End();

		if( useedgedetect )
		{
			// edge detection
			device->SetVertexDeclaration(vertexdecl);
			device->SetRenderTarget(0, edgesurface);
			device->SetRenderTarget(1, NULL);
			device->SetTexture(0, normaltarget);
			device->Clear(0, NULL, D3DCLEAR_TARGET|D3DCLEAR_ZBUFFER, 0xff6694ed, 1.0f, 0);

			effect->SetTechnique("edgedetect");
			effect->SetVector("texelSize", &texelsize);

			effect->Begin(NULL, 0);
			effect->BeginPass(0);
			{
				device->DrawPrimitiveUP(D3DPT_TRIANGLELIST, 2, vertices, sizeof(D3DXVECTOR4) + sizeof(D3DXVECTOR2));
			}
			effect->EndPass();
			effect->End();

			// put together
			device->SetRenderTarget(0, oldtarget);
			device->SetTexture(0, colortarget);
			device->SetTexture(2, edgetarget);
			device->Clear(0, NULL, D3DCLEAR_TARGET|D3DCLEAR_ZBUFFER, 0xff6694ed, 1.0f, 0);

			oldtarget->Release();
			effect->SetTechnique("final");

			effect->Begin(NULL, 0);
			effect->BeginPass(0);
			{
				device->DrawPrimitiveUP(D3DPT_TRIANGLELIST, 2, vertices, sizeof(D3DXVECTOR4) + sizeof(D3DXVECTOR2));
			}
			effect->EndPass();
			effect->End();
		}
		else
		{
			D3DXMATRIX offproj;

			// use the stencil buffer
			device->SetRenderState(D3DRS_COLORWRITEENABLE, 0);
			device->SetRenderState(D3DRS_ZWRITEENABLE, FALSE);
			device->SetRenderState(D3DRS_STENCILENABLE, TRUE);
			device->SetRenderState(D3DRS_ZENABLE, FALSE);

			device->SetRenderState(D3DRS_STENCILFUNC, D3DCMP_ALWAYS);
			device->SetRenderState(D3DRS_STENCILREF, 1);
			device->SetRenderState(D3DRS_STENCILPASS, D3DSTENCILOP_REPLACE);

//.........这里部分代码省略.........
开发者ID:galek,项目名称:Asylum_Tutorials,代码行数:101,代码来源:main.cpp

示例14: getByteProperty

void CloneMeshOperator::process(int tick)
{
    if (mesh != 0)
        delete mesh;

    unsigned char clones = getByteProperty(0);
    D3DXVECTOR3 scaleVector = getVectorProperty(1);
    D3DXVECTOR3 rotationVector = getVectorProperty(2);
    D3DXVECTOR3 translationVector = getVectorProperty(3);
    D3DXMATRIX scaleMatrix;
    D3DXMatrixScaling(&scaleMatrix,
                      scaleVector.x,
                      scaleVector.y,
                      scaleVector.z);
    D3DXMATRIX rotationXMatrix;
    D3DXMatrixRotationX(&rotationXMatrix, rotationVector.x);
    D3DXMATRIX rotationYMatrix;
    D3DXMatrixRotationY(&rotationYMatrix, rotationVector.y);
    D3DXMATRIX rotationZMatrix;
    D3DXMatrixRotationZ(&rotationZMatrix, rotationVector.z);
    D3DXMATRIX translationMatrix;
    D3DXMatrixTranslation(&translationMatrix,
                          translationVector.x,
                          translationVector.y,
                          translationVector.z);
    D3DXMATRIX cloneMatrix = scaleMatrix * rotationXMatrix * rotationYMatrix * rotationZMatrix * translationMatrix;

    Mesh* srcMesh = getInput(0)->mesh;

    mesh = new Mesh(srcMesh->getNumVertices() * clones,
                    srcMesh->getNumTriangles() * clones,
                    srcMesh->getNumQuads() * clones);

    D3DXMATRIX matrix;
    D3DXMatrixIdentity(&matrix);

    int c = 0;
    int verticeOffset = 0;
    int triangleIndex = 0;
    int quadIndex = 0;
    do
    {
        c++;
        for (int v = 0; v < srcMesh->getNumVertices(); v++)
        {
            Vec3 pos = srcMesh->pos(v);
            Vec3 transformedPos;
            D3DXVec3TransformCoord(&transformedPos, &pos, &matrix);
            mesh->pos(verticeOffset + v) = transformedPos;
            mesh->uv(verticeOffset + v) = srcMesh->uv(v);
        }

        for (int f = 0; f < srcMesh->getNumFaces(); f++)
        {
            int n;
            int* face = srcMesh->face(f, n);

            if (n == 3)
            {
                mesh->setTriangle(triangleIndex,
                                  verticeOffset + face[0],
                                  verticeOffset + face[1],
                                  verticeOffset + face[2]);
                triangleIndex++;
            }
            else
            {
                mesh->setQuad(quadIndex,
                              verticeOffset + face[0],
                              verticeOffset + face[1],
                              verticeOffset + face[2],
                              verticeOffset + face[3]);
                quadIndex++;
            }
        }

        verticeOffset += srcMesh->getNumVertices();
        matrix *= cloneMatrix;
    }
    while (c < clones);
}
开发者ID:olofn,项目名称:db_public,代码行数:81,代码来源:clonemeshoperator.cpp

示例15: clock

void Dio::init(ResourceManager* resMan)
{
	for (int i=0;i<256;i++)
	{
		text[i]=0;
	}
	c=0;
	size_of_container=0;
	//timer initializer
	FPS=20;
	now = clock();
	delay = 1000/FPS;
	//speaker position and color
	speaker[0].rec.bottom=0;
	speaker[0].rec.left=0;
	speaker[0].rec.right=100;
	speaker[0].rec.top=400;
	speaker[0].textColor=D3DCOLOR_ARGB(255,255,255,255);
	//text position and color
	speaker[1].rec.bottom=0;
	speaker[1].rec.left=440;
	speaker[1].rec.right=400;
	speaker[1].rec.top=450;
	speaker[1].textColor=D3DCOLOR_ARGB(255,255,255,255);

	D3DXMATRIX matrixlove;
	D3DXMATRIX matrixlove1;
	D3DXMATRIX matrixlove2;
	D3DXMatrixIdentity(&matrixlove);
	D3DXMatrixIdentity(&matrixlove1);
	D3DXMatrixIdentity(&matrixlove2);
	D3DXMatrixScaling(&matrixlove,0.5f,0.5f,0.5f);
	D3DXMatrixTranslation(&matrixlove1,20,150,0);
	D3DXMatrixMultiply(&matrixlove2,&matrixlove1,&matrixlove);
	/*
	for (int i=0;i<=maxpics;i++)
	{
		pics[i].tex=stuff[i+9].objTex;
		pics[i].texinfo=stuff[i+9].texInfo;
		pics[i].matrix= matrixlove2;
	}
	*/

	for (int i=0;i<=maxpics;i++)
	{
		pics[i].matrix= matrixlove2;
	}

	pics[0].tex = resMan->getTexture(L"snake.png")->objTex;
	pics[0].texinfo = resMan->getTexture(L"snake.png")->texInfo;

	pics[1].tex = resMan->getTexture(L"joy.png")->objTex;
	pics[1].texinfo = resMan->getTexture(L"joy.png")->texInfo;

	pics[2].tex = resMan->getTexture(L"solidchu.png")->objTex;
	pics[2].texinfo = resMan->getTexture(L"solidchu.png")->texInfo;

	pics[3].tex = resMan->getTexture(L"evilchu.png")->objTex;
	pics[3].texinfo = resMan->getTexture(L"evilchu.png")->texInfo;

	texholder.tex=0;
	readname=true;
	readtext=true;
	saidtext=true;
	infile.open("Dialogue.txt");
}
开发者ID:Ishoa,项目名称:EeveeHound2.0,代码行数:66,代码来源:Dio.cpp


注:本文中的D3DXMatrixScaling函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。