Example #1
0
VOID Render(float timeDelta)
{
	SetupMatrix() ;

	g_totalTime += timeDelta ;
	float x = cosf(g_totalTime) * 8.0f ;
	float y = sinf(g_totalTime) * 4.0f ;
	D3DXVECTOR3 pos(x, y, 20) ;
	
	g_Balls->Update(timeDelta, &pos) ;

	// Clear the back-buffer to a RED color
	g_pd3dDevice->Clear( 0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0,0,0), 1.0f, 0 );

	// Begin the scene
	if( SUCCEEDED( g_pd3dDevice->BeginScene() ) )
	{
		// Draw teapot 
		//g_pTeapotMesh->DrawSubset(0) ;
		g_Balls->Render() ;

		// End the scene
		g_pd3dDevice->EndScene();
	}

	// Present the back-buffer contents to the display
	g_pd3dDevice->Present( NULL, NULL, NULL, NULL );
}
void OsgHingeLimit::SetLimitPos(float fltHeight)
{
    float fltLimitPos = m_lpThisLimit->LimitPos();
	CStdFPoint vPos(0, 0, 0), vRot(0, 0, 0); 

	//Reset the position and rotation of the flap.
	if(m_osgFlapRotateMT.valid() && m_osgFlapTranslateMT.valid())
	{

		vPos.Set(0, 0, 0); vRot.Set(0, 0, -fltLimitPos); 
		m_osgFlapRotateMT->setMatrix(SetupMatrix(vPos, vRot));

		vPos.Set((fltHeight/2)*sin(-fltLimitPos), -(fltHeight/2)*cos(-fltLimitPos), 0); vRot.Set(0, 0, 0); 
		m_osgFlapTranslateMT->setMatrix(SetupMatrix(vPos, vRot));
	}
}
Example #3
0
VOID Render()
{
	SetupLight() ;
	SetupLight() ;
	SetupMatrix() ;

	g_pCamera->Update(0.1f, 1.0f) ;

	// Clear the back-buffer to a RED color
	g_pd3dDevice->Clear( 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(255,255,255), 1.0f, 0 );

	// Begin the scene
	if( SUCCEEDED( g_pd3dDevice->BeginScene() ) )
	{
		// Draw teapot
		g_pTeapotMesh->DrawSubset(0) ;

		RenderFog(0xff00ff00, D3DFOG_LINEAR, TRUE, 10.f) ;

		//RenderGround() ;

		// End the scene
		g_pd3dDevice->EndScene();
	}

	// Present the back-buffer contents to the display
	g_pd3dDevice->Present( NULL, NULL, NULL, NULL );
}
Example #4
0
VOID Render()
{
	SetupMatrix() ;

	OnFrameMove() ;

	g_pCamera->Update(0.1f, 1.0f) ;

	// Clear the back-buffer to a RED color
	g_pd3dDevice->Clear( 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(255,255,255), 1.0f, 0 );

	// Begin the scene
	if( SUCCEEDED( g_pd3dDevice->BeginScene() ) )
	{
		RenderTerrain() ;

		RenderTree() ;

		RenderTeapot() ;

		// End the scene
		g_pd3dDevice->EndScene();
	}

	// Present the back-buffer contents to the display
	g_pd3dDevice->Present( NULL, NULL, NULL, NULL );
}
Example #5
0
VOID Render(float timeDelta)
{
	if (!g_bActive)
		Sleep(50) ;

	SetupMatrix(timeDelta);

	// Clear the back-buffer to a BLUE color
	float color[4] = { 0.0f, 0.125f, 0.3f, 1.0f };
	g_pd3dDevice->ClearRenderTargetView(g_pRenderTargetView, color);

	// Set the input layout
	g_pd3dDevice->IASetInputLayout(g_pVertexLayout);

	// Set rasterazition state
	g_pd3dDevice->RSSetState(g_pRasterizerState);

	// Apply each pass in technique and draw triangle.
	D3D10_TECHNIQUE_DESC techDesc;
	g_pTechnique->GetDesc(&techDesc);
	for (unsigned int i = 0; i < techDesc.Passes; ++i)
	{
		g_pTechnique->GetPassByIndex(i)->Apply(0);
	}

	// Draw sphere
	g_pSphere->DrawSubset(0);

	// Present the sence from back buffer to front buffer
	g_pSwapChain->Present(0, 0);
}
Example #6
0
VOID Render(float timeDelta) 
{ 
	if(!PrepareShader()) 
		return ; 

	SetupMatrix(timeDelta) ; 

	// Clear the back-buffer to a RED color 
	g_pd3dDevice->Clear( 0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0,0,0), 1.0f, 0 ); 

	// Begin the scene 
	if( SUCCEEDED( g_pd3dDevice->BeginScene() ) ) 
	{ 
		// Rendering of scene objects can happen here 
		g_pd3dDevice->SetPixelShader(g_pPixelShader) ; 

		g_pTorusMesh->DrawSubset(0) ; 

		// End the scene 
		g_pd3dDevice->EndScene(); 
	} 

	// Present the back-buffer contents to the display 
	g_pd3dDevice->Present( NULL, NULL, NULL, NULL ); 
} 
bool VsJoint::Physics_CalculateLocalPosForWorldPos(float fltWorldX, float fltWorldY, float fltWorldZ, CStdFPoint &vLocalPos)
{
	VsMovableItem *lpParent = m_lpThisVsMI->VsParent();

	if(lpParent && m_lpVsChild)
	{
		fltWorldX *= m_lpThisAB->GetSimulator()->InverseDistanceUnits();
		fltWorldY *= m_lpThisAB->GetSimulator()->InverseDistanceUnits();
		fltWorldZ *= m_lpThisAB->GetSimulator()->InverseDistanceUnits();

		CStdFPoint vPos(fltWorldX, fltWorldY, fltWorldZ), vRot(0, 0, 0);
		osg::Matrix osgWorldPos = SetupMatrix(vPos, vRot);

		//Get the parent object.
		osg::Matrix osgInverse = osg::Matrix::inverse(m_lpVsChild->GetWorldMatrix());

		osg::Matrix osgCalc = osgWorldPos * osgInverse;

		osg::Vec3 vCoord = osgCalc.getTrans();
		vLocalPos.Set(vCoord[0] * m_lpThisAB->GetSimulator()->DistanceUnits(), 
				      vCoord[1] * m_lpThisAB->GetSimulator()->DistanceUnits(), 
				      vCoord[2] * m_lpThisAB->GetSimulator()->DistanceUnits());
		
		return true;
	}

	return false;
}
Example #8
0
void Camera::SetProjTransform( F32 n, F32 f, F32 fv)
{
  if (f <= n)
  {
    f = n + 1.0f;
  }
  isIso = FALSE;

  nearPlane = n;
	farPlane  = f;
	fov		    = fv;
  maxZ      = farPlane * zoom - nearPlane;

	Vid::SetTranBucketMaxZ( farPlane * zoom);
	Vid::SetTranBucketMinZ(0.0f);
  Vid::SetTranMaxBucketCount( TRANMAXBUCKETCOUNT);

  halfHeight = ((F32) rect.Height()) * 0.5f;
  halfWidth  = ((F32) rect.Width())  * 0.5f;
  aspectHW   = halfHeight / halfWidth;

  projMatrix.SetProjection( nearPlane, farPlane * zoom, fov / zoom, aspectHW);

  viewMatrix.Transform( tranMatrix, projMatrix);

  SetupMatrix();
  SetupView();
}
Example #9
0
void Camera::SetProjTransformIso( F32 n, F32 f, F32 fv, F32 w, F32 h)
{
  if (f <= n)
  {
    f = n + 1.0f;
  }
  isIso = TRUE;

  nearPlane = n;
	farPlane  = f;
	fov		    = fv;
  maxZ      = farPlane * zoom - nearPlane;

  fv *= 0.5f;
	F32 s = (F32) sin(fv);
	F32 qv = s * f / (f - n);
	  
  // set up the isometric projection matrix
	projMatrix.Zero();
  projMatrix.right.x = 2.0f / h;
	projMatrix.up.y    = 2.0f / w;
	projMatrix.front.z = 1.0f;
//	projMatrix.frontw = 1.0f;
	projMatrix.posit.z = -qv * n;
	projMatrix.positw = 1.0f;

  halfHeight = ((F32) rect.Height()) * 0.5f;
  halfWidth  = ((F32) rect.Width())  * 0.5f;
  aspectHW   = halfHeight / halfWidth;

  viewMatrix.Transform( tranMatrix, projMatrix);

  SetupMatrix();
  SetupView();
}
/**
\brief	Creates the default ball graphics.

\author	dcofer
\date	4/15/2011
**/
void VsJoint::CreateJointGraphics()
{
	//Create the cylinder for the hinge
	m_osgDefaultBall = CreateSphereGeometry(15, 15, m_lpThisJoint->Size());
	osg::ref_ptr<osg::Geode> osgBall = new osg::Geode;
	osgBall->addDrawable(m_osgDefaultBall.get());

	CStdFPoint vPos(0, 0, 0), vRot(VX_PI/2, 0, 0); 
	m_osgDefaultBallMT = new osg::MatrixTransform();
	m_osgDefaultBallMT->setMatrix(SetupMatrix(vPos, vRot));
	m_osgDefaultBallMT->addChild(osgBall.get());

	//create a material to use with the pos flap
	if(!m_osgDefaultBallMat.valid())
		m_osgDefaultBallMat = new osg::Material();		

	//create a stateset for this node
	m_osgDefaultBallSS = m_osgDefaultBallMT->getOrCreateStateSet();

	//set the diffuse property of this node to the color of this body	
	m_osgDefaultBallMat->setAmbient(osg::Material::FRONT_AND_BACK, osg::Vec4(0.1, 0.1, 0.1, 1));
	m_osgDefaultBallMat->setDiffuse(osg::Material::FRONT_AND_BACK, osg::Vec4(1, 0.25, 1, 1));
	m_osgDefaultBallMat->setSpecular(osg::Material::FRONT_AND_BACK, osg::Vec4(0.25, 0.25, 0.25, 1));
	m_osgDefaultBallMat->setShininess(osg::Material::FRONT_AND_BACK, 64);
	m_osgDefaultBallSS->setMode(GL_BLEND, osg::StateAttribute::OVERRIDE | osg::StateAttribute::ON); 

	//apply the material
	m_osgDefaultBallSS->setAttribute(m_osgDefaultBallMat.get(), osg::StateAttribute::ON);

	m_osgJointMT->addChild(m_osgDefaultBallMT.get());
}
void Render(float timeDelta)
{
	if (!g_bActive)
	{
		Sleep(50) ;
	}

	SetupMatrix() ;

	// Clear the back-buffer to a RED color
	g_pd3dDevice->Clear( 0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0,0,0), 1.0f, 0 );

	// Begin the scene
	if( SUCCEEDED( g_pd3dDevice->BeginScene() ) )
	{
		// Draw teapot 
		g_pTeapotMesh->DrawSubset(0) ;

		// End the scene
		g_pd3dDevice->EndScene();
	}

	// Present the back-buffer contents to the display
	g_pd3dDevice->Present( NULL, NULL, NULL, NULL );
}
void MazeGraphicsView::wheelEvent(QWheelEvent* event)
{
    if (event->delta() > 0)
        ZoomIn();
    else
        ZoomOut();

    SetupMatrix();
}
    //! Setup Hierarchy object
    virtual void SetupHierarchy(Hierarchy& H) const {
      TEUCHOS_TEST_FOR_EXCEPTION(!H.GetLevel(0)->IsAvailable("A"), Exceptions::RuntimeError, "No fine level operator");

      // Setup Matrix
      // TODO: I should certainly undo this somewhere...
      RCP<Level>  l  = H.GetLevel(0);
      RCP<Matrix> Op = l->Get<RCP<Matrix> >("A");

      Xpetra::UnderlyingLib lib = Op->getRowMap()->lib();
      H.setlib(lib);

      SetupMatrix(*Op);
      SetupExtra(H);

      // Setup Hierarchy
      H.SetMaxCoarseSize(maxCoarseSize_);
      H.SetDefaultVerbLevel(verbosity_);
      if (graphOutputLevel_ >= 0)
        H.EnableGraphDumping("dep_graph.dot", graphOutputLevel_);

      // TODO: coarsestLevelManager

      H.Clear();

      int  levelID     = 0;
      int  lastLevelID = numDesiredLevel_ - 1;
      bool isLastLevel = false;

      while (!isLastLevel) {
        bool r = H.Setup(levelID,
                         LvlMngr(levelID-1, lastLevelID),
                         LvlMngr(levelID,   lastLevelID),
                         LvlMngr(levelID+1, lastLevelID));

        isLastLevel = r || (levelID == lastLevelID);
        levelID++;
      }
      RCP<Teuchos::FancyOStream> fos = Teuchos::fancyOStream(Teuchos::rcpFromRef(std::cout));
      fos->setOutputToRootOnly(0);
      H.print(*fos,verbosity_);

      // When we reuse hierarchy, it is necessary that we don't
      // change the number of levels. We also cannot make requests
      // for coarser levels, because we don't construct all the
      // data on previous levels. For instance, let's say our first
      // run constructed three levels. If we try to do requests during
      // next setup for the fourth level, it would need Aggregates
      // which we didn't construct for level 3 because we reused P.
      // To fix this situation, we change the number of desired levels
      // here.
      numDesiredLevel_ = levelID;

      WriteData<Matrix>(H, matricesToPrint_,     "A");
      WriteData<Matrix>(H, prolongatorsToPrint_, "P");
      WriteData<Matrix>(H, restrictorsToPrint_,  "R");

    } //SetupHierarchy
void OsgHingeLimit::SetupLimitGraphics(float fltFlapWidth, float fltCylinderHeight)
{
    float fltLimitPos = m_lpThisLimit->LimitPos();
    CStdColor *vColor =  m_lpThisLimit->Color();

	//Create the min flap
	m_osgFlap = CreateBoxGeometry(fltFlapWidth, (fltCylinderHeight/2), 
									fltCylinderHeight, fltFlapWidth, 
									(fltCylinderHeight/2), fltCylinderHeight);
	osg::ref_ptr<osg::Geode> osgFlap = new osg::Geode;
	osgFlap->addDrawable(m_osgFlap.get());

	CStdFPoint vPos(0, 0, 0), vRot(0, 0, 0); 

	//Rotate flap first then translate.
	vPos.Set(0, 0, 0); vRot.Set(0, 0, -fltLimitPos); 
	m_osgFlapRotateMT = new osg::MatrixTransform();
	m_osgFlapRotateMT->setMatrix(SetupMatrix(vPos, vRot));
	m_osgFlapRotateMT->addChild(osgFlap.get());

	vPos.Set((fltCylinderHeight/2)*sin(-fltLimitPos), -(fltCylinderHeight/2)*cos(-fltLimitPos), 0); 
	vRot.Set(0, 0, 0); 
	m_osgFlapTranslateMT = new osg::MatrixTransform();
	m_osgFlapTranslateMT->setMatrix(SetupMatrix(vPos, vRot));
	m_osgFlapTranslateMT->addChild(m_osgFlapRotateMT.get());

	//create a material to use with the pos flap
	if(!m_osgFlapMat.valid())
		m_osgFlapMat = new osg::Material();		

	//create a stateset for this node
	m_osgFlapSS = m_osgFlapTranslateMT->getOrCreateStateSet();

	//set the diffuse property of this node to the color of this body	
	m_osgFlapMat->setAmbient(osg::Material::FRONT_AND_BACK, osg::Vec4(0.1, 0.1, 0.1, 1));
	m_osgFlapMat->setDiffuse(osg::Material::FRONT_AND_BACK, osg::Vec4(vColor->r(), vColor->g(), vColor->b(), vColor->a()));
	m_osgFlapMat->setSpecular(osg::Material::FRONT_AND_BACK, osg::Vec4(0.25, 0.25, 0.25, 1));
	m_osgFlapMat->setShininess(osg::Material::FRONT_AND_BACK, 64);
	m_osgFlapSS->setMode(GL_BLEND, osg::StateAttribute::OVERRIDE | osg::StateAttribute::ON); 

	//apply the material
	m_osgFlapSS->setAttribute(m_osgFlapMat.get(), osg::StateAttribute::ON);
}
Example #15
0
bool RGBColorSystem::Data::ValidateParameters( const FVector& x, const FVector& y, const FVector& Y )
{
   try
   {
      volatile Vector M_ = InverseMatrix( SetupMatrix( x, y, Y ) );
      return true;
   }
   catch ( ... )
   {
      return false;
   }
}
MazeGraphicsView::MazeGraphicsView(QWidget* parent)
    : QGraphicsView(parent)
    , zoom_value_(MIN_ZOOM)
{
    setRenderHint(QPainter::Antialiasing);
    setDragMode(QGraphicsView::ScrollHandDrag);

    setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);

    SetupMatrix();
}
Example #17
0
void Camera::SetWorldRecurseRender( const Matrix &world, FamilyState *stateArray)
{
  CalcWorldMatrix( world);

  NList<FamilyNode>::Iterator kids(&children);
  FamilyNode *node;
  while ((node = kids++) != NULL)
  {
    node->SetWorldRecurseRender( statePtr->WorldMatrix(), stateArray);
  }
  
  SetupMatrix();
}
VxVector3 VsJoint::NormalizeAxis(CStdFPoint vLocalRot)
{
	osg::Vec3 vPosN(1, 0, 0);
	CStdFPoint vMatrixPos(0, 0, 0);

	osg::Matrix osgMT = SetupMatrix(vMatrixPos, vLocalRot);

	osg::Vec3 vNorm = vPosN * osgMT;

	VxVector3 axis((double) vNorm[0], (double) vNorm[1], (double) vNorm[2]);

	return axis;
}
void VsJoint::Physics_UpdateMatrix()
{
	LocalMatrix(SetupMatrix(m_lpThisMI->Position(), m_lpThisMI->Rotation()));
	m_osgMT->setMatrix(m_osgLocalMatrix);
	m_osgDragger->SetupMatrix();

	//Now lets get the localmatrix from the child object and use that for our offsetmatrix
	VsBody *lpVsChild = dynamic_cast<VsBody *>(m_lpThisJoint->Child());
	if(lpVsChild)
		ChildOffsetMatrix(lpVsChild->LocalMatrix());

	//If we are here then we did not have a physics component, just and OSG one.
	Physics_UpdateAbsolutePosition();
}
VOID Render(float timeDelta)
{
    SetupMatrix() ;

    g_ModelViewCamera->OnFrameMove();

    // Save render target
    g_pd3dDevice->GetRenderTarget(0, &g_pOldRenderTarget) ;

    g_pd3dDevice->SetRenderTarget(0, g_pRenderSurface) ;
    g_pd3dDevice->Clear( 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0xff0000ff, 1.0f, 0 );

    // Begin the scene
    if( SUCCEEDED( g_pd3dDevice->BeginScene() ) )
    {
        // Without this line, the teapot won't show up, what's the inner stuff of SetTexture?
        g_pd3dDevice->SetTexture(0, NULL) ;

        // Disable lighting, since we didn't specify color for vertex
        g_pd3dDevice->SetRenderState( D3DRS_LIGHTING , FALSE );
        g_pd3dDevice->SetRenderState(D3DRS_FILLMODE, D3DFILL_WIREFRAME) ;

        D3DXMATRIX word ;
        D3DXMatrixTranslation(&word, 0.0f, 0.0f, 0.0f) ;

        static float totalTime = 0.0f ;
        totalTime += timeDelta * 2 ;

        D3DXMATRIX rot ;
        D3DXMatrixRotationY(&rot, totalTime) ;

        word *= rot ;
        g_pd3dDevice->SetTransform(D3DTS_WORLD, &word) ;

        g_pTeapotMesh->DrawSubset(0) ;

        // End the scene
        g_pd3dDevice->EndScene();
    }

    // Restore the back buffer
    g_pd3dDevice->SetRenderTarget(0, g_pOldRenderTarget) ;

    RenderCube(timeDelta) ;

    // Present the back-buffer contents to the display
    g_pd3dDevice->Present( NULL, NULL, NULL, NULL );
}
/**
\brief	Sets up the graphics for the joint.

\detail This base joint class sets up a default ball graphics object. A few of the joint
classes do not have any special graphics associated with them, so simply knowing where the joint
is located is enough, and a ball to define that position is sufficient. This base code creates
that graphics so that each derived class does not have to. If a joint does need special 
graphics then just override this function and define it yourself, but do not call this base method.

\author	dcofer
\date	4/15/2011
**/
void VsJoint::SetupGraphics()
{
	//Setup Vs pointers to child and parent.
	m_lpVsParent = dynamic_cast<VsRigidBody *>(m_lpThisJoint->Parent());
	if(!m_lpVsParent)
		THROW_ERROR(Vs_Err_lUnableToConvertToVsRigidBody, Vs_Err_strUnableToConvertToVsRigidBody);

	m_lpVsChild = dynamic_cast<VsRigidBody *>(m_lpThisJoint->Child());
	if(!m_lpVsChild)
		THROW_ERROR(Vs_Err_lUnableToConvertToVsRigidBody, Vs_Err_strUnableToConvertToVsRigidBody);

	//The parent osg object for the joint is actually the child rigid body object.
	m_osgParent = ParentOSG();
	osg::ref_ptr<osg::Group> osgChild = ChildOSG();

	if(m_osgParent.valid())
	{
		//Add the parts to the group node.
		CStdFPoint vPos(0, 0, 0), vRot(VX_PI/2, 0, 0); 
		vPos.Set(0, 0, 0); vRot.Set(0, VX_PI/2, 0); 
		
		m_osgJointMT = new osg::MatrixTransform();
		m_osgJointMT->setMatrix(SetupMatrix(vPos, vRot));

		m_osgNode = m_osgJointMT.get();

		//Create the sphere.
		CreateJointGraphics();

		BuildLocalMatrix();

		SetAlpha();
		SetCulling();
		SetVisible(m_lpThisMI->IsVisible());

		//Add it to the scene graph.
		m_osgParent->addChild(m_osgRoot.get());

		//Set the position with the world coordinates.
		Physics_UpdateAbsolutePosition();

		//We need to set the UserData on the OSG side so we can do picking.
		//We need to use a node visitor to set the user data for all drawable nodes in all geodes for the group.
		osg::ref_ptr<VsOsgUserDataVisitor> osgVisitor = new VsOsgUserDataVisitor(this);
		osgVisitor->traverse(*m_osgMT);
	}
}
void VsJoint::BuildLocalMatrix(CStdFPoint localPos, CStdFPoint localRot, std::string strName)
{
	if(!m_osgMT.valid())
	{
		m_osgMT = new osgManipulator::Selection;
		m_osgMT->setName(strName + "_MT");
	}

	if(!m_osgChildOffsetMT.valid())
	{
		m_osgChildOffsetMT = new osg::MatrixTransform;
		m_osgChildOffsetMT->setName(strName + "ChildOffsetMT");
		m_osgChildOffsetMT->addChild(m_osgMT.get());
	}

	if(!m_osgRoot.valid())
	{
		m_osgRoot = new osg::Group;
		m_osgRoot->setName(strName + "_Root");
		m_osgRoot->addChild(m_osgChildOffsetMT.get());
	}

	LocalMatrix(SetupMatrix(localPos, localRot));

	//set the matrix to the matrix transform node
	m_osgMT->setMatrix(m_osgLocalMatrix);	
	m_osgMT->setName(strName.c_str());

	//Now lets get the localmatrix from the child object and use that for our offsetmatrix
	VsBody *lpVsChild = dynamic_cast<VsBody *>(m_lpThisJoint->Child());
	if(lpVsChild)
		ChildOffsetMatrix(lpVsChild->LocalMatrix());

	//First create the node group. The reason for this is so that we can add other decorated groups on to this node.
	//This is used to add the selected overlays.
	if(!m_osgNodeGroup.valid())
	{
		m_osgNodeGroup = new osg::Group();
		m_osgNodeGroup->addChild(m_osgNode.get());		
		m_osgNodeGroup->setName(strName + "_NodeGroup");

		m_osgMT->addChild(m_osgNodeGroup.get());
	
		CreateSelectedGraphics(strName);
	}
}
Example #23
0
VOID Render()
{
	SetupMatrix() ;

	g_ModelViewCamera->OnFrameMove();

	g_pd3dDevice->GetRenderTarget(0, &g_pOldRenderTarget) ;

	g_pd3dDevice->SetRenderTarget(0, g_pRenderSurface) ;
	g_pd3dDevice->Clear( 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0xff0000ff, 1.0f, 0 );

	// Begin the scene
	if( SUCCEEDED( g_pd3dDevice->BeginScene() ) )
	{
		// Without this line, the teapot won't show up, what's the inner stuff of SetTexture?
		g_pd3dDevice->SetTexture(0, NULL) ;

		// Disable lighting, since we didn't specify color for vertex
		g_pd3dDevice->SetRenderState( D3DRS_LIGHTING , FALSE ); 
		g_pd3dDevice->SetRenderState(D3DRS_FILLMODE, D3DFILL_WIREFRAME) ;
		g_pTeapotMesh->DrawSubset(0) ;

		// End the scene
		g_pd3dDevice->EndScene();
	}

	g_pd3dDevice->SetRenderTarget(0, g_pOldRenderTarget) ;

	g_pd3dDevice->Clear( 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0xff00ff00, 1.0f, 0 );

	// Begin the scene
	if( SUCCEEDED( g_pd3dDevice->BeginScene() ) )
	{
		g_pd3dDevice->SetRenderState(D3DRS_FILLMODE, D3DFILL_SOLID) ;

		// Render texture
		RenderQuad() ;

		// End the scene
		g_pd3dDevice->EndScene();
	}

	// Present the back-buffer contents to the display
	g_pd3dDevice->Present( NULL, NULL, NULL, NULL );
}
Example #24
0
VOID Render()
{
	SetupMatrix() ;

	g_pd3dDevice->Clear( 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0xff000000, 1.0f, 0 );

	// Begin the scene
	if( SUCCEEDED( g_pd3dDevice->BeginScene() ) )
	{
		RenderQuad() ;

		// End the scene
		g_pd3dDevice->EndScene();
	}

	// Present the back-buffer contents to the display
	g_pd3dDevice->Present( NULL, NULL, NULL, NULL );
}
Example #25
0
VOID Render()
{
	// Set a red light
	SetupLight(D3DXCOLOR(1.0f, 0.0f, 0.0f, 1.0f)) ;

	SetupMatrix() ;

	// Clear the back-buffer to a RED color
	g_pd3dDevice->Clear( 0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(55,205,0), 1.0f, 0 );

	// Begin the scene
	if( SUCCEEDED( g_pd3dDevice->BeginScene() ) )
	{
		g_pTeapotMesh->DrawSubset(0) ;

		/*
		Here, we create a small new viewport and place it at the bottom right of the main window
		the new view port start at position(400, 400) with size(200, 200)
		*/
		D3DVIEWPORT9 viewport ;
		viewport.X = 400 ;
		viewport.Y = 400 ;
		viewport.Width = 200 ;
		viewport.Height = 200 ;
		viewport.MinZ = 0.0f ;
		viewport.MaxZ = 1.0f ;
		
		// Set the new view port
		g_pd3dDevice->SetViewport(&viewport) ;

		// Clear the view port to yellow
		// This will failed in Debug libaries
		g_pd3dDevice->Clear( 0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(255,255,0), 1.0f, 0 );

		// Draw the teapot again
		g_pTeapotMesh->DrawSubset(0) ;

		// End the scene
		g_pd3dDevice->EndScene();
	}

	// Present the back-buffer contents to the display
	g_pd3dDevice->Present( NULL, NULL, NULL, NULL );
}
VOID Render()
{
	// Clear the back-buffer to a blue color
	g_pd3dDevice->Clear( 0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(255,255,255), 1.0f, 0 );

	// Begin the scene
	if( SUCCEEDED( g_pd3dDevice->BeginScene() ) )
	{
		SetupMatrix() ;
		
		DrawCube();

		// End the scene
		g_pd3dDevice->EndScene();
	}

	// Present the backbuffer contents to the display
	g_pd3dDevice->Present( NULL, NULL, NULL, NULL );
}
Example #27
0
void Render(float timeDelta)
{
	if (!g_bActive)
	{
		Sleep(50) ;
	}

	SetupMatrix() ;

	// Clear the back-buffer to a RED color
	g_pd3dDevice->Clear( 0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0,0,0), 1.0f, 0 );

	// Begin the scene
	if( SUCCEEDED( g_pd3dDevice->BeginScene() ) )
	{
		// Render state
		g_pd3dDevice->SetRenderState( D3DRS_ALPHABLENDENABLE, TRUE );
		g_pd3dDevice->SetRenderState( D3DRS_SRCBLEND, D3DBLEND_ONE );
		g_pd3dDevice->SetRenderState( D3DRS_DESTBLEND, D3DBLEND_ONE );
		g_pd3dDevice->SetRenderState(D3DRS_POINTSPRITEENABLE, TRUE) ;
		g_pd3dDevice->SetRenderState(D3DRS_POINTSCALEENABLE, TRUE) ;
		g_pd3dDevice->SetRenderState( D3DRS_POINTSIZE, FtoDW(0.2f) );


		// Set texture
		g_pd3dDevice->SetTexture(0, g_pTexture) ;

		// Draw points
		g_pd3dDevice->SetStreamSource( 0, g_pVB, 0, sizeof(POINTVERTEX));
		g_pd3dDevice->SetFVF(D3DFVF_POINTVERTEX) ;
		g_pd3dDevice->DrawPrimitive( D3DPT_POINTLIST, 0, NUM_VERTEX) ;

		// Restore state
		g_pd3dDevice->SetRenderState( D3DRS_ALPHABLENDENABLE, FALSE );

		// End the scene
		g_pd3dDevice->EndScene();
	}

	// Present the back-buffer contents to the display
	g_pd3dDevice->Present( NULL, NULL, NULL, NULL );
}
Example #28
0
VOID Render()
{
	SetupMatrix() ;

	// Clear the back-buffer to a RED color
	g_pd3dDevice->Clear( 0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0,0,0), 1.0f, 0 );

	// Begin the scene
	if( SUCCEEDED( g_pd3dDevice->BeginScene() ) )
	{
		// Draw teapot 
		g_pMesh->DrawSubset(0) ;

		// End the scene
		g_pd3dDevice->EndScene();
	}

	// Present the back-buffer contents to the display
	g_pd3dDevice->Present( NULL, NULL, NULL, NULL );
}
Example #29
0
VOID Render(float timeDelta)
{
	SetupMatrix() ;

	UpdateTextureCoordinates(timeDelta) ;

	// Clear the back-buffer to a RED color
	g_pd3dDevice->Clear( 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0xff568800, 1.0f, 0 );

	// Begin the scene
	if( SUCCEEDED( g_pd3dDevice->BeginScene() ) )
	{
		RenderQuad() ;

		// End the scene
		g_pd3dDevice->EndScene();
	}

	// Present the back-buffer contents to the display
	g_pd3dDevice->Present( NULL, NULL, NULL, NULL );
}
void Render(float timeDelta)
{
	if (!g_bActive)
	{
		Sleep(50) ;
	}

	SetupMatrix() ;

	// Clear the back-buffer to a RED color
	g_pd3dDevice->Clear( 0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0,0,0), 1.0f, 0 );

	// Disable lighting, since we didn't specify color for vertex
	g_pd3dDevice->SetRenderState( D3DRS_LIGHTING , FALSE );   

	// Begin the scene
	if( SUCCEEDED( g_pd3dDevice->BeginScene() ) )
	{
		// Draw teapot 
		g_pd3dDevice->SetStreamSource( 0, g_pVB, 0, sizeof(CUSTOMVERTEX) );
		g_pd3dDevice->SetFVF( D3DFVF_CUSTOMVERTEX );

		// 12 triangles forms six faces and a cube
		g_pd3dDevice->DrawPrimitive( D3DPT_TRIANGLELIST, 0, 12 );


		// End the scene
		g_pd3dDevice->EndScene();
	}

	// Present the back-buffer contents to the display
	HRESULT hr = g_pd3dDevice->Present( NULL, NULL, NULL, NULL );
	if (FAILED(hr))
	{
		d3dpp.Windowed = TRUE; // use window mode, not full screen
		d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
		d3dpp.BackBufferFormat = D3DFMT_UNKNOWN;
		ResetDevice(d3dpp);
	}
}