Пример #1
0
void CP3DRenderer::DrawPrimitiveUp (RenderPrimitiveType_t primType, UINT primCount, const void* pVertexData, UINT VertexStride)
{
	Prof(RENDERER_CP3DRenderer__DrawPrimitiveUp);
	STAT(STAT_DRAW_CALLS, 1);
	STAT(STAT_DRAW_VERTS, primCount);
	g_pD3DDevice->DrawPrimitiveUP ((D3DPRIMITIVETYPE)primType, primCount, pVertexData, VertexStride);
}
Пример #2
0
void CP3DRenderer::Present(HWND hWnd)
{
	Prof(RENDERER_CP3DRenderer__Present);

	// Present the backbuffer contents to the display
	if (g_pD3DDevice->Present( NULL, NULL, hWnd, NULL ) == D3DERR_DEVICELOST)
		OnLostDevice();
}
Пример #3
0
void
Main::render()
{
  Prof(render);
  if(rRenderSystem()->beginScene()) {
    rGUIManager()->render(rRenderSystem());
    rRenderSystem()->endScene();
  }
}
Пример #4
0
void
Main::dispatchTime(float timeStep)
{
  Prof(dispatch_time);
  mMode->update(timeStep);
//   mCurrentMission->updateSimulation();
  rGUIManager()->update(timeStep);

//   SoundManager::getSingletonPtr()->update(timeStep);
//   screenManager.getCurrentState()->update(timeStep);
//   ConfigManager::getCurrent()->getLicense()->update(timeStep);
//   ConfigManager::getPlayer()->mPlayTime += timeStep;
}
Пример #5
0
void CP3DRenderer::EndScene()
{
	P3DXMatrix matvp = g_matViewProj;
	P3DXMatrix matw;
	P3DXMatrix matwvp = matw * matvp;
	matw.SetIdentityMatrix();
	SetWorldTransform(matw);
	vb.Use();
	//effect.SetValue("gWVP", &matwvp, sizeof(P3DXMatrix));
	//effect.Begin("SolidTech");
	vb.Render(P3DPT_TRIANGLELIST, 0, 1);
	//effect.End();
	
	
	Prof(RENDERER_CP3DRenderer__EndScene);

/*
	// FIXME: TODO: debug !!!
	// testovat ci je vyhodne odoslat command buffer na spracovanie
	LPDIRECT3DQUERY9 pEventQuery = NULL;
	if (SUCCEEDED (g_pD3DDevice->CreateQuery(D3DQUERYTYPE_EVENT, &pEventQuery)))
	{
		pEventQuery->Issue(D3DISSUE_END);	// add an end marker to the command buffer queue.
		pEventQuery->GetData (NULL, 0, D3DGETDATA_FLUSH);	// empty the command buffer
		pEventQuery->Release ();
	}
	// FIXME: TODO: debug !!!
*/

	#ifdef _DEBUG
	g_stats.EndNewFrame();
	g_stats.DrawStats(); // STATS
	#endif

	g_pResMgr->RenderStats();

	// End the scene
	g_pD3DDevice->EndScene();
	// KEX: Proc?
}
Пример #6
0
void
BuildLayer::update(float)
{
  if(NULL == mStation || NULL == mCamera) return;
  Prof(collision);
  
  Vector pickPos = rGUIManager()->getRelativeCursorPosition(rGUIManager()->getCursorX(), rGUIManager()->getCursorY());
  Ray pickRay = mCamera->getCameraToViewportRay(pickPos[0], pickPos[1]);
   
  // Only test meshes and ports that have spherical intersections
  vector<ModuleHit> moduleHits;
  vector<PortHit> portHits;
  float oDistanceSphere = FLT_MAX;
  
  {
    const set<Module*>& modules = mStation->getModules();

    for(set<Module*>::const_iterator iModule = modules.begin(); iModule != modules.end(); ++iModule) {
      Module* currentModule = *iModule;
      Matrix moduleTransform(currentModule->getPosition(), currentModule->getOrientation());
      Mesh* moduleMesh = currentModule->getPrototype()->getMesh();
      if(moduleMesh->intersectRayBox(pickRay, moduleTransform, oDistanceSphere)) {
        moduleHits.push_back(ModuleHit(currentModule, oDistanceSphere));
      }
      
      if(STATE_SELECTED == mState && mSelectedModule == currentModule) continue;
      
      if(STATE_ADD == mState || STATE_SELECTED == mState) {
        const PortList& ports = currentModule->getPrototype()->getPorts();
        for(unsigned int iPort = 0; iPort < ports.size(); ++iPort) {
          if(!currentModule->isPortConnected(iPort)) {
            Matrix portTransform(ports[iPort]->getPosition(), ports[iPort]->getOrientation());
            Matrix combinedTransform = portTransform * moduleTransform;
            if(mPortMesh->intersectRayBox(pickRay, combinedTransform, oDistanceSphere)) {
              portHits.push_back(PortHit(currentModule, iPort, oDistanceSphere));
            }
          }
        }
      }
    }
  }
  
  {
    sort(moduleHits.begin(), moduleHits.end(), depthSort<ModuleHit>);
    sort(portHits.begin(), portHits.end(), depthSort<PortHit>);
  }
  
  {
    float minDistance = FLT_MAX;
    mMouseOver = MOUSEOVER_BACKGROUND;
    float oDistanceTri = FLT_MAX;  

    vector<ModuleHit>::iterator iModuleHit = moduleHits.begin();
    vector<PortHit>::iterator iPortHit = portHits.begin();

    while(iModuleHit != moduleHits.end() || iPortHit != portHits.end()) {
      if(iModuleHit == moduleHits.end() || (iPortHit != portHits.end() && (*iPortHit).distance < (*iModuleHit).distance)) {
        PortHit& portHit = *iPortHit;
        if(mPortMesh->intersectRayTri(pickRay, portHit.portModule->getFullPortTransform(portHit.portIndex), oDistanceTri)
           && oDistanceTri < minDistance) {
          mMouseOver = MOUSEOVER_PORT;
          mMouseOverModule = portHit.portModule;
          mMouseOverPortIndex = portHit.portIndex;
          minDistance = oDistanceTri;
        }
        iPortHit++;
      }
      else {
        ModuleHit& moduleHit = *iModuleHit;
        Mesh* moduleMesh = moduleHit.module->getPrototype()->getMesh();
        if(moduleMesh->intersectRayTri(pickRay, moduleHit.module->getTransform(), oDistanceTri) && oDistanceTri < minDistance) {
          mMouseOver = MOUSEOVER_MODULE;
          mMouseOverModule = moduleHit.module;
          minDistance = oDistanceTri;
        }
        iModuleHit++;
      }      

      // abort when the current hit is closer than all remaining bounding spheres
      if(iModuleHit != moduleHits.end() && iPortHit != portHits.end()) {
        if((*iModuleHit).distance > minDistance && (*iPortHit).distance > minDistance) break;
      }
      else if(iModuleHit != moduleHits.end()) {
        if((*iModuleHit).distance > minDistance) break;
      }
      else if(iPortHit != portHits.end()){
        if((*iPortHit).distance > minDistance) break;
      }
    }
  }
}
Пример #7
0
HRESULT CP3DIndexBuffer::UnLock ()
{
    Prof(RENDERER_CP3DVertexBuffer__UnLock);
    return m_pIB->Unlock();
}
Пример #8
0
HRESULT CP3DIndexBuffer::Lock (void** data, unsigned int SizeToLock)
{
    Prof(RENDERER_CP3DVertexBuffer__Lock);
    return m_pIB->Lock (0, SizeToLock, data, 0);
}