void Mesh_D3D11::Draw(void)
{
#if 0
  // Set vertex buffer
  unsigned int iOffset = 0;
  GetApp()->GetContext()->IASetVertexBuffers(0, 1, &m_pVertexBuffer, &m_iVertexSize, &iOffset);

  // Set index buffer
  GetApp()->GetContext()->IASetIndexBuffer(m_pIndexBuffer, DXGI_FORMAT_R16_UINT, 0);

  // Set primitive topology
  GetApp()->GetContext()->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST);

  // Set the input layout
  GetApp()->GetContext()->IASetInputLayout(m_pVertexLayout);

  // Draw
  GetApp()->GetContext()->DrawIndexed(m_iNumTris * 3, 0, 0);
#endif

  noMat4 tm(worldTM_.rotate_ * worldTM_.scale_, worldTM_.trans_);
  tm.TransposeSelf();	

  GetApp()->drawModel(m_rd, ToMat4(tm), ViewMat(), ProjMat());

  g_iTrisPerFrame += m_iNumTris;
}
	void CloudLayer::Render(BaseCamera* c)
	{
		GetRenderer()->reset();
		GetRenderer()->setShader(mSkyX->mCloudShader);
		
		GetRenderer()->setVertexFormat(mSkyX->mCloudVF);
		GetRenderer()->setVertexBuffer(0, mSkyX->getMeshManager()->mVB);
		GetRenderer()->setIndexBuffer(mSkyX->getMeshManager()->mIB);

		GetRenderer()->setDepthState(mSkyX->getMeshManager()->mDepthWrite);
		GetRenderer()->setTexture("CloudTex", mSkyX->mDiffuseTex);
		GetRenderer()->setTexture("CloudNormal", mSkyX->mNormalTex);
		GetRenderer()->setTexture("CloudTileTex", mSkyX->mTileTex);

		GetRenderer()->setSamplerState("uClouds", mSkyX->linearWarp);		
		GetRenderer()->setSamplerState("uCloudsNormal", mSkyX->linearWarp);
		GetRenderer()->setSamplerState("uCloudsTile", mSkyX->linearWarp);		
		
		GetRenderer()->setBlendState(GetApp()->GetBlendMode(5));

		mat4 view =ViewMat();
		view.rows[3].x = view.rows[3].y = view.rows[3].z = 0.f;
		mat4 wvp =  view * ProjMat();
		GetRenderer()->setShaderConstant4x4f("uWorldViewProj", transpose(wvp));
		GetRenderer()->apply();
		GetRenderer()->drawElements(PRIM_TRIANGLES, 0, mSkyX->getMeshManager()->mNumIndices, 0, 0);	
	}
void WowActor::LoadModel()
{
	mesh_ = new M2Mesh;
	M2Loader* loader = new M2Object(gRenderer, this); 
	mesh_->m2_ = loader;
	loader->SetViewMatrix(ViewMat());
	mesh_->owner_ = this;
	
	m_spNode = mesh_;
		
	wxString fn(m_filename.c_str());

	bool isChar = (fn.Lower().Find(wxT("char")) || fn.Lower().Find(wxT("alternate\\char")));
		
	loader->Load(fn.wx_str(), true);	
	if (!isChar)
		loader->modelType = MT_NORMAL;


	/*LOG_INFO << " Bone Start";

	for (size_t i=0; i< loader->header.nBones; i++) {		
		if (loader->bones[i].parent != -1)
		{		
					
			LOG_INFO << " Parent Bone Id : " << loader->bones[i].parent <<  "  Bone Id" << i ;
			
		}
	}
	LOG_INFO << " Bone End";*/


	meshEdit_ = new M2Edit;
	meshEdit_->Init(gRenderer, mesh_, this);
	
	CreateRenderModel(loader);
	
	if (!GetStateMachine())
	{
		AnimationSystem* animSys = (AnimationSystem*)mesh_->m2_->animManager;		
		AnimationSystem::InitStand(mesh_->m2_, true);
	}
	
	mesh_->CreateBuffers();	
}
Exemple #4
0
FMatrix FCanvas::CalcBaseTransform3D(uint32 ViewSizeX, uint32 ViewSizeY, float fFOV, float NearPlane)
{
	FMatrix ViewMat(CalcViewMatrix(ViewSizeX,ViewSizeY,fFOV));
	FMatrix ProjMat(CalcProjectionMatrix(ViewSizeX,ViewSizeY,fFOV,NearPlane));
	return ViewMat * ProjMat;
}
Exemple #5
0
static int CaptureImage(CameraV4L2 *pCap, cv::Mat &RGB, cv::Mat &IR, bool sRGB = true )
{
	int height = RGB.rows;
	int width = RGB.cols;
	cv::Point2i start = cv::Point2i(0,0);
	int bufLen; 
//	std::string videoName("/tmp/Viewfinder.avi");
	std::string videoName("/tmp/Viewfinder.avi/");
//	std::string videoName("http://localhost/feed1.ffm/");
	int fourcc = CV_FOURCC('M','J','P','G');
	int fps = 100;
	int viewWidth = width/2; int viewHeight = height/2;
	viewWidth += (viewWidth % 16);  viewHeight += (16-viewHeight % 16);
	cv::Size frameSize(viewWidth,viewHeight);
	cv::Mat ViewMat(viewHeight,viewWidth,RGB.type());
	bool isColor = true;
	cv::VideoWriter outputVideo;
	outputVideo.open(videoName, fourcc, fps, frameSize,isColor);

	bool status = outputVideo.isOpened();
	cv::Mat xRGB(RGB.size(),RGB.type());
	cv::Mat xIR(IR.size(),IR.type());
 	pCap->Start();
	int key = -1;
	while (key == -1)	// anykey to exit
	{
		do
		{
			bufLen = pCap->WaitForFrame();
			start = ExtractBayerY16toRGB(xRGB, xIR, pCap->Buffer(), bufLen, start);
		} while (start.y < height);
		start = cv::Point2i(0,0);	// restart capture for next loop
		
		if (sRGB)
		{
			pCap->ConvertTosRGB(xRGB,RGB);
			pCap->ConvertTosRGB(xIR,IR);
		}
		std::vector<cv::Mat> plane;
		cv::split(RGB,plane);
		cv::imshow("frameB",plane[0]);
		cv::imshow("frameG",plane[1]);
		cv::imshow("frameR",plane[2]);
		cv::imshow("frameRGB",RGB);	// viewfinder displays
		cv::imshow("frameIR",IR);
		
		cv::resize(RGB,ViewMat,ViewMat.size(),0,0, CV_INTER_NN);
		outputVideo << ViewMat;
		key = cv::waitKey(20);	// catch key
		if(key == -1) continue;
		int current;
		switch (key)
		{
		case 1113938:
			// increase exposure by 1/2 stop
			current = pCap->GetExposure();
			if (current >= 0)
			{
				current = (int)((float)current * SQRT2);
				current = (current < 3 ) ? ++current : current;
				pCap->SetExposure(current);
			}
			key = -1;
			break;
		case 1113940:
			// decrease exposure by half stop
			current = pCap->GetExposure();
			if(current >= 0)
			{
				current = (int)((float)current * SQRT2INV);
				pCap->SetExposure(current);
			}
			key = -1;
			break;
		default:
			break;
		}
	}	// while(key)
	
	outputVideo.release();
	pCap->Stop();
    return 0;
}
void M2EffectRender::RenderRibbons()
{

	//renderer->changeToMainFramebuffer();
	//loader->reset();

	ID3D11RenderTargetView* pRTV;
	ID3D11DepthStencilView* pDSV;

	D3D11Context()->OMGetRenderTargets(1, &pRTV, &pDSV);

	ID3D11DeviceContext* pd3dContext = GetApp()->GetContext();

	float ClearColor[4] =
	{
		0.0f, 0.0f, 0.0f, 1.0f
	};
	//pd3dContext->ClearRenderTargetView( pRTV, ClearColor);
	//pd3dContext->ClearDepthStencilView( pDSV, D3D11_CLEAR_DEPTH, 1.0, 0);

	D3DXVECTOR3 vEyePt;
	D3DXMATRIX mWorldViewProjection;	
	D3DXMATRIX mWorld;
	D3DXMATRIX mView;
	D3DXMATRIX mProj;	
	GetCamera()->getFrom(vEyePt);
	const unsigned int size16 = sizeof(float) * 16;


	memcpy(&mView, &ViewMat(), size16);	 
	memcpy(&mProj, &ProjMat(), size16);
	memcpy(&mWorld, &WorldMat(), size16);	

	RibbonData_.gpmWorld->SetMatrix( (float*)mWorld);	
	mWorldViewProjection = mWorld * mView * mProj;


	RibbonData_.gpmWorldViewProjection->SetMatrix( ( float* )&mWorldViewProjection );


	

	D3D11Context()->IASetInputLayout( RibbonData_.gpVertexLayout );
	for (size_t i=0; i < Owner_->header.nRibbonEmitters; ++i)
	{
		if (RibbonData_.gNumActiveParticles.at(i) == 0)
			continue;
			
		UINT Strides[1];
		UINT Offsets[1];
		ID3D11Buffer* pVB[1];
		pVB[0] = RibbonData_.ParticleBuffers.at(i);
		Strides[0] = sizeof( RibbonVertex );
		Offsets[0] = 0;
		pd3dContext->IASetVertexBuffers( 0, 1, pVB, Strides, Offsets );
		pd3dContext->IASetIndexBuffer( NULL, DXGI_FORMAT_R16_UINT, 0 );
		pd3dContext->IASetPrimitiveTopology( D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP );

		HRESULT hr = RibbonData_.gptxDiffuse->SetResource( RibbonData_.ParticleTextureSRVMaps.find(Owner_->ribbons[i].texture)->second );

		//Render
		D3DX11_TECHNIQUE_DESC techDesc;
		RibbonData_.gpRenderParticles->GetDesc( &techDesc );

		for( UINT p = 0; p < techDesc.Passes; ++p )
		{
			RibbonData_.gpRenderParticles->GetPassByIndex( p )->Apply( 0, pd3dContext );
			pd3dContext->Draw( RibbonData_.gNumActiveParticles.at(i) * 4, 0 );
		}		
	}
}