Пример #1
0
sphere::sphere(sphere const& other) :
shape(other.name(), other.Color()),
center_(other.center()),
radius_(other.radius())
{
	// cout << "sphere copy c'tor" << endl;
}
//--------------------------------------------------------------------------------------
// Release D3D11 resources created in OnD3D11CreateDevice 
//--------------------------------------------------------------------------------------
void CALLBACK OnD3D11DestroyDevice( void* pUserContext )
{
    g_DialogResourceManager.OnD3D11DestroyDevice();
    g_D3DSettingsDlg.OnD3D11DestroyDevice();
    //CDXUTDirectionWidget::StaticOnD3D11DestroyDevice();
    DXUTGetGlobalResourceCache().OnDestroyDevice();
	test.destroy();
	tessplane.destroy();
	lightsphere.destroy();
	tesscube.destroy();
	fuse.destroy();
	deboard.destroy();
	board1.destroy();
	geo_alien.destroy();
	FirePart.destroy();
    SAFE_DELETE( g_pTxtHelper );
	SAFE_RELEASE(g_DepthState);
    //g_Mesh11.Destroy();
    //            
    //SAFE_RELEASE( g_pVertexLayout11 );
    //SAFE_RELEASE( g_pVertexBuffer );
    //SAFE_RELEASE( g_pIndexBuffer );
    //SAFE_RELEASE( g_pVertexShader );
    //SAFE_RELEASE( g_pPixelShader );
    //SAFE_RELEASE( g_pSamLinear );

 /*   SAFE_RELEASE( g_pcbVSPerObject );
    SAFE_RELEASE( g_pcbPSPerObject );
    SAFE_RELEASE( g_pcbPSPerFrame );*/
}
Пример #3
0
        //! Intersect with a sphere, returning true if there is an intersection.
        bool intersect(const sphere<Type>& s) const
        {
            const Type d1 = (s.getCenter() - m_center).sqrLength();
            const Type d2 = m_radius + s.getRadius();

            return (d1 < d2 * d2);
        }
Пример #4
0
	bool bounding_box::contains(const sphere & sphere) const
	{
		const math::box & box = bounding_box::get_box();
		const math::point & min = box.get_min();
		const math::point & max = box.get_max();
		float sq_dist = 0.f;

		int matches = 0;

		for (int i = 0; i < 3; i++)
		{
			float v = sphere.get_origin()[i];

			if (v < min[i])
			{
				sq_dist += std::pow(min[i] - v, 2);
			}
			else if (v > max[i])
			{
				sq_dist += std::pow(v - max[i], 2);
			}
			else if (v >= min[i] + sphere.get_radius()
				&& v <= max[i] - sphere.get_radius())
			{
				matches++;
			}
		}

		return matches == 3;
	}
Пример #5
0
sphere sphere::operator +(const sphere& other) const
{
	glm::vec4 center = (c + other.getCenter()) * 0.5f;

	float radius = glm::distance(c, center) + glm::max(r, other.getRadius());

	return sphere(center, radius);
}
Пример #6
0
 bool triangle<T,color_type>::intersects(const sphere<T,color_type>& s) const
 {
     // If any of the 3 corners is inside the sphere, the triangle intersects.
     if (s.inside( plane<T,color_type>::get_origin()) ||
         s.inside( plane<T,color_type>::get_origin() + plane<T,color_type>::get_u_vector()) ||
         s.inside( plane<T,color_type>::get_origin() + plane<T,color_type>::get_v_vector()))
     {
         return true;
     }
     return false;
 }
Пример #7
0
        //! Extend the boundaries of the sphere by the given sphere.
        void extendBy(const sphere<Type>& sphere)
        {
            if (intersect(sphere))
                return;

            const vec3<Type> dir = (m_center - sphere.getCenter()).normalized();
            const vec3<Type> p1 = m_center + m_radius * dir;
            const vec3<Type> p2 = sphere.getCenter() - sphere.getRadius() * dir;

            setPoles(p1, p2);
        }
Пример #8
0
inline sphere<T,N> shiftCtrlP(const sphere<T,N>& a,
                              const vec<T,N>& mpos,
                              const vec<T,N>& mshift,
                              const vec<T,N>& mindim,
                              const uint8_t * mask)
{
    if (mask) {
        if (pnw::get_bit(*mask, 0)) { a.c() += mshift; }
        if (pnw::get_bit(*mask, 1)) { a.r() -= dot(normalize(a.c() - mpos), mshift); }
    }
    return a;
}
Пример #9
0
	bool bbox::intersects(const sphere& s) const
	{
		const vec3& center(s.center());
		float radius(s.radius());

		return ((center.x >= mn.x && (mn.x - center.x) <= radius) &&
			(center.x <= mx.x && (center.x - mx.x) <= radius) &&
			(center.y >= mn.y && (mn.y - center.y) <= radius) &&
			(center.y <= mx.y && (center.y - mx.y) <= radius) &&
			(center.z >= mn.z && (mn.z - center.z) <= radius) &&
			(center.z <= mx.z && (center.z - mx.z) <= radius));
	}
Пример #10
0
/*! Inverse Operation of \c sphere<T,N>_getSub(). */
inline sphere<T,N> getRel(const box<T,N>& a,
                          const sphere<T,N>& b)
{
    auto ad = a.dim();
    sphere<T,N> ba((b.c() - a.l()) / ad,
                   b.r() / pnw::mean(ad(0), ad(1), ad(2)));
    if (ad(0) != ad(1) or
        ad(1) != ad(2) or
        ad(2) != ad(0)) {
        PTODO("ad's components not all equal => may result in an ellipse\n");
    }
    return ba;
}
Пример #11
0
/*! Inverse Operation of \c sphere<T,N>_getSub_box2f(). */
inline void
sphere<T,N>_getRel_box2f(const box2f& a,
                         const sphere<T,N>& b,
                         sphere<T,N>& ba)
{
    vec2f ad; box2f_rdDim(a, &ad);
    vec3f_set(&ba.c(),
              (b.c()(0) - a.l(0)) / ad(0),
              (b.c()(1) - a.l(1)) / ad(1),
              b.c()(2));		/* z is ignored */
    ba.r() = b.r() / mean(ad(0), ad(1));
    if (ad(0) != ad(1)) {
        PTODO("ad's components not all equal => may result in an ellipse\n");
    }
}
Пример #12
0
void mouse_event(int button, int state, int x, int y)
{
    glClear(GL_COLOR_BUFFER_BIT);
    light.draw();
    r.clearZbuffer();
    switch(button)
    {
    case GLUT_LEFT_BUTTON:
    {
        for(unsigned int i=0;i<o.face_size;i++)
        {
            o.vertices[i] =SCH*o.vertices[i];
        }
        o.draw(Color(0.3,0.2,0.3));
        break;
    }
    case GLUT_RIGHT_BUTTON:
    {
        for(unsigned int i=0;i<o.face_size;i++)
        {
            o.vertices[i] =SCL*o.vertices[i];
        }
        o.draw(Color(0.3,0.2,0.3));
        break;
    }
    }
    glFlush();
    glutSwapBuffers();

}
Пример #13
0
VkBool32 frustum::isVisible(const sphere& sphereWorld) const
{
	float distance;

	for (auto& currentSide : sidesWorld)
	{
		distance = currentSide.distance(sphereWorld.getCenter());

		if (distance + sphereWorld.getRadius() < 0.0f)
		{
			return VK_FALSE;
		}
	}

	return VK_TRUE;
}
Пример #14
0
/*! Sub-Sphere when \p ba is viewed relative to \p a and put
 * result in \p b.
 * The inverse operation of \c sphere<T,N>_getRel().
 */
inline void
sphere<T,N>_getSub(const box<T,N>& a,
                   const sphere<T,N>& ba,
                   sphere<T,N>& b)
{
    vec3f ad; box3f_rdDim(a, &ad);
    vec3f_set(&b.c(),
              a.l(0) + ad(0) * ba.c()(0),
              a.l(1) + ad(1) * ba.c()(1),
              a.l(2) + ad(2) * ba.c()(2));
    b.r() = ba.r() * pnw::mean(ad(0), ad(1), ad(2));
    if (ad(0) != ad(1) or
        ad(1) != ad(2) or
        ad(2) != ad(0)) {
        PTODO("ad's components not all equal => may result in an ellipse\n");
    }
}
Пример #15
0
void
plane::
extendBy ( const sphere& sphereIn )
{
	if ( !sphereIn.isEmpty() )
	{
		vec3 pos ( math::vec3::NoInit );
		ValueType radius;
		sphereIn.get ( pos, radius );
		vec3 dir = normal;
		dir.normalize ();
		vec3 pt = pos + dir * radius;
		extendBy ( pt );
		pt = pos - dir * radius;
		extendBy ( pt );
	}
}
Пример #16
0
	bool ray::intersects(const sphere& s, float* f) const
	{
		const vec3& rayorig(pos - s.center());
		float radius(s.radius());

		if(f) *f = 0.0f;
		if(rayorig.lengthSq() <= (radius * radius))
			return true;
		float a(dir.dot(dir));
		float b(2.0f * rayorig.dot(dir));
		float c(rayorig.dot(rayorig) - radius * radius);
		float d((b * b) - (4.0f * a * c));
		if(d < SSH_EPSILON) return false;
		if(f)
		{
			*f = (-b - sqrtf(d)) / (2.0f * a);
			if(*f < 0.0f) *f = (-b + sqrtf(d)) / (2.0f * a);
		}

		return true;
	}
Пример #17
0
hit_test intersect_sphere (ray r, sphere s)
{
  hit_test result = {0};
  v3 sc = s.center;
  double sr = s.radius;
  v3 a = v3_sub(r.origin, sc);
  double b = v3_dot(a, r.direction);
  double c = v3_dot(a, a) - (sr * sr);
  double d = (b * b) - c;
  double t = -b - sqrt(d);
  result.miss = MISS;
  if (d > 0 && t > 0) {
    v3 intersection = ray_position(r, t);  
    result.miss = HIT;
    result.t = t;
    result.hit_point = intersection;
    result.surf = s.surface_color(sc, intersection);
    result.shine = s.shine;
    result.surf_norm = v3_norm(v3_sub(intersection, sc));
  }
  return result;
}
Пример #18
0
void
sphere::
extendBy ( const sphere& sphere )
{
	if ( this == &sphere )
		return;					// no extend by self.

	if ( sphere.isEmpty () )
		return;					// do nothing with empty spheres

	if ( isEmpty () )
	{
		*this = sphere;
	}
	else
	{
      // this finds the vector seperating this and sphere and add to
      // the length the radius of the other sphere to get a point on
      // the far side of sphere... it then calls extendBy with the
      // calculated point

		vec3 diff ( sphere.center );
		diff -= center;

		ValueType diffLen = diff.length ();

		diff /= diffLen;

		diffLen += sphere.radius;

		diff *= diffLen;

		diff += center;

		extendBy ( diff );
	}
}
//--------------------------------------------------------------------------------------
// Handle key presses
//--------------------------------------------------------------------------------------
void CALLBACK OnKeyboard( UINT nChar, bool bKeyDown, bool bAltDown, void* pUserContext )
{
    if( bKeyDown )
    {
        switch( nChar )
        {
            case VK_F1:
                g_bShowHelp = !g_bShowHelp; break;
			case 0x49://i
				lightpos += D3DXVECTOR3(0,0,5);
				lightsphere.move(lightpos);
				break;
			case 0x4B://k
				lightpos += D3DXVECTOR3(0,0,-5);
				lightsphere.move(lightpos);
				break;
			case 0x4A://j
				lightpos += D3DXVECTOR3(-5,0,0);
				lightsphere.move(lightpos);
				break;
			case 0x4C://l
				lightpos += D3DXVECTOR3(5,0,0);
				lightsphere.move(lightpos);
				break;
			case 0x55: //U
				lightpos += D3DXVECTOR3(0,-5,0);
				lightsphere.move(lightpos);
				break;
			case 0x4F://O
				lightpos += D3DXVECTOR3(0,5,0);
				lightsphere.move(lightpos);
				break;
			case 0x56://v
				geo_alien.start_explode();
				break;
			case 0x20://spacebar
				board1.change_screen();
				deboard.change_screen();
				break;
        }
    }
}
Пример #20
0
	bounding_sphere::bounding_sphere(const sphere & sphere)
		: bounding_volume(sphere.get_origin(), sphere.get_radius(), type::sphere)
	{}
Пример #21
0
 hit::list plane::collide(const sphere& p) const {
   return p.collide(*this);
 }
Пример #22
0
 hit::list vertices::collide(const sphere& p) const {
   return p.collide(*this);
 }
//--------------------------------------------------------------------------------------
// Render the scene using the D3D11 device
//--------------------------------------------------------------------------------------
void CALLBACK OnD3D11FrameRender( ID3D11Device* pd3dDevice, ID3D11DeviceContext* pd3dImmediateContext, double fTime,
                                  float fElapsedTime, void* pUserContext )
{
    HRESULT hr;

    // If the settings dialog is being shown, then render it instead of rendering the app's scene
    if( g_D3DSettingsDlg.IsActive() )
    {
        g_D3DSettingsDlg.OnRender( fElapsedTime );
        return;
    }

		//Render light arrow
    D3DXMATRIX mView;
    D3DXMATRIX mProj;
	mProj = ( *g_Camera.GetProjMatrix() );
    mView = ( *g_Camera.GetViewMatrix() );
	D3DXCOLOR arrowColor = D3DXCOLOR( 1, 1, 0, 1 );
	//hr = g_LightControl.OnRender11( arrowColor, &mView, &mProj, g_Camera.GetEyePt() );
	FirePart.calculate_particle(pd3dDevice,pd3dImmediateContext,fElapsedTime,&g_Camera,&g_LightControl);
	MissilePart.calculate_particle(pd3dDevice,pd3dImmediateContext,fElapsedTime,&g_Camera,&g_LightControl);
	board1.RenderTexture(pd3dDevice,pd3dImmediateContext,fTime,fElapsedTime,pUserContext,&g_LightControl);	
    deboard.RenderTexture(pd3dDevice,pd3dImmediateContext,fTime,fElapsedTime,pUserContext,&g_LightControl);	

    // Clear the render target and depth stencil
    float ClearColor[4] = { 0.0f, 0.0f, 0.0f, 0.0f };
    //ID3D11RenderTargetView* pRTV = DXUTGetD3D11RenderTargetView();
	ID3D11RenderTargetView* pRTV = DXUTGetD3D11RenderTargetView();
    pd3dImmediateContext->ClearRenderTargetView( rtv_render_to_texture_ori, ClearColor );
    ID3D11DepthStencilView* pDSV = DXUTGetD3D11DepthStencilView();
    pd3dImmediateContext->ClearDepthStencilView( pDSV, D3D11_CLEAR_DEPTH, 1.0, 0 );
	pd3dImmediateContext->OMSetRenderTargets(1,&rtv_render_to_texture_ori,pDSV);
	
	
	
	
	pd3dImmediateContext->OMSetDepthStencilState(NULL, 0);
	sky.Render(pd3dDevice,pd3dImmediateContext,fTime,fElapsedTime,pUserContext,&g_Camera,lightpos);

	lightsphere.Render(pd3dDevice,pd3dImmediateContext,fTime,fElapsedTime,pUserContext,&g_Camera,lightpos);
	tessplane.Render(pd3dDevice,pd3dImmediateContext,fTime,fElapsedTime,pUserContext,&g_Camera,lightpos);
	tesscube.Render(pd3dDevice,pd3dImmediateContext,fTime,fElapsedTime,pUserContext,&g_Camera,lightpos);
	fuse.Render(pd3dDevice,pd3dImmediateContext,fTime,fElapsedTime,pUserContext,&g_Camera,&g_LightControl);
	board1.Render(pd3dDevice,pd3dImmediateContext,fTime,fElapsedTime,pUserContext,&g_Camera,lightpos);
	deboard.Render(pd3dDevice,pd3dImmediateContext,fTime,fElapsedTime,pUserContext,&g_Camera,lightpos);
	
	test.Render(pd3dDevice,pd3dImmediateContext,fTime,fElapsedTime,pUserContext,&g_Camera,lightpos);
	if(show_buildings)
	{
		buildings.Render(pd3dDevice,pd3dImmediateContext,fTime,fElapsedTime,pUserContext,&g_Camera,lightpos);
	}
	geo_alien.Render(pd3dDevice,pd3dImmediateContext,fTime,fElapsedTime,pUserContext,&g_Camera,lightpos);
	FirePart.Render(pd3dDevice,pd3dImmediateContext,fTime,fElapsedTime,pUserContext,&g_Camera);
	MissilePart.Render(pd3dDevice,pd3dImmediateContext,fTime,fElapsedTime,pUserContext,&g_Camera);
	//ID3D11RenderTargetView* pRTV = DXUTGetD3D11RenderTargetView();

	
	pd3dImmediateContext->OMSetDepthStencilState(NULL, 0);

	pd3dImmediateContext->OMSetBlendState(NULL,NULL,0xffffffff);
	//find bright spot 
	pd3dImmediateContext->ClearRenderTargetView( rtv_render_to_texture_1, ClearColor );
    pDSV = DXUTGetD3D11DepthStencilView();
    pd3dImmediateContext->ClearDepthStencilView( pDSV, D3D11_CLEAR_DEPTH, 1.0, 0 );
	pd3dImmediateContext->OMSetRenderTargets(1,&rtv_render_to_texture_1,pDSV);

	pd3dImmediateContext->VSSetShader( VSPPFirstPass, NULL, 0 );
    pd3dImmediateContext->PSSetShader( PSPPFirstPass, NULL, 0 );

	pd3dImmediateContext->HSSetShader( NULL, NULL, 0 );
	pd3dImmediateContext->DSSetShader( NULL, NULL, 0 );
    pd3dImmediateContext->GSSetShader( NULL, NULL, 0 );

	pd3dImmediateContext->PSSetSamplers(0, 1, &g_pSamLinear);
	pd3dImmediateContext->PSSetShaderResources(0,1,&sr_texture_original);
	//pd3dImmediateContext->RSSetState( g_pRasterizerStateSolid );
	pd3dImmediateContext->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
	pd3dImmediateContext->Draw(9,0);

	//blur hori
	pd3dImmediateContext->ClearRenderTargetView( rtv_render_to_texture_2, ClearColor );
    pDSV = DXUTGetD3D11DepthStencilView();
    pd3dImmediateContext->ClearDepthStencilView( pDSV, D3D11_CLEAR_DEPTH, 1.0, 0 );
	pd3dImmediateContext->OMSetRenderTargets(1,&rtv_render_to_texture_2,pDSV);


	Compute_blur(1.0f / width, 0);

	D3D11_MAPPED_SUBRESOURCE MappedResource;
    V( pd3dImmediateContext->Map( blur_cb_buffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &MappedResource ) );
    blur_cbuffer* pPerFrame = ( blur_cbuffer* )MappedResource.pData;
	std::copy(&blur_cb_data.offset[0], &blur_cb_data.offset[15], pPerFrame->offset);
	//std::copy(&blur_cb_data.offset[0], &blur_cb_data.offset[15], pPerFrame->offset);
	//std::copy(&blur_cb_data.weight[0], &blur_cb_data.weight[15], pPerFrame->weight);
    pd3dImmediateContext->Unmap( blur_cb_buffer, 0 );

	pd3dImmediateContext->VSSetShader( VSPPBlur, NULL, 0 );
    pd3dImmediateContext->PSSetShader( PSPPBlur, NULL, 0 );

	pd3dImmediateContext->HSSetShader( NULL, NULL, 0 );
	pd3dImmediateContext->DSSetShader( NULL, NULL, 0 );
    pd3dImmediateContext->GSSetShader( NULL, NULL, 0 );

	pd3dImmediateContext->PSSetConstantBuffers(0,1,&blur_cb_buffer);
	pd3dImmediateContext->PSSetSamplers(0, 1, &g_pSamLinear);
	pd3dImmediateContext->PSSetShaderResources(0,1,&sr_texture1);
	//pd3dImmediateContext->RSSetState( g_pRasterizerStateSolid );
	pd3dImmediateContext->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
	pd3dImmediateContext->Draw(9,0);

	

	//blur vert
	pd3dImmediateContext->ClearRenderTargetView( rtv_render_to_texture_1, ClearColor );
     pDSV = DXUTGetD3D11DepthStencilView();
    pd3dImmediateContext->ClearDepthStencilView( pDSV, D3D11_CLEAR_DEPTH, 1.0, 0 );
	pd3dImmediateContext->OMSetRenderTargets(1,&rtv_render_to_texture_1,pDSV);



	Compute_blur(0, 1.0f / height);

    V( pd3dImmediateContext->Map( blur_cb_buffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &MappedResource ) );
    pPerFrame = ( blur_cbuffer* )MappedResource.pData;
	std::copy(&blur_cb_data.offset[0], &blur_cb_data.offset[15], pPerFrame->offset);
	//std::copy(&blur_cb_data.offset[0], &blur_cb_data.offset[15], pPerFrame->offset);
	//std::copy(&blur_cb_data.weight[0], &blur_cb_data.weight[15], pPerFrame->weight);
    pd3dImmediateContext->Unmap( blur_cb_buffer, 0 );

	pd3dImmediateContext->VSSetShader( VSPPBlur, NULL, 0 );
    pd3dImmediateContext->PSSetShader( PSPPBlur, NULL, 0 );

	pd3dImmediateContext->HSSetShader( NULL, NULL, 0 );
	pd3dImmediateContext->DSSetShader( NULL, NULL, 0 );
    pd3dImmediateContext->GSSetShader( NULL, NULL, 0 );

	pd3dImmediateContext->PSSetConstantBuffers(0,1,&blur_cb_buffer);
	pd3dImmediateContext->PSSetSamplers(0, 1, &g_pSamLinear);
	pd3dImmediateContext->PSSetShaderResources(0,1,&sr_texture2);
	//pd3dImmediateContext->RSSetState( g_pRasterizerStateSolid );
	pd3dImmediateContext->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
	pd3dImmediateContext->Draw(9,0);


	//combine effect
	pd3dImmediateContext->ClearRenderTargetView( pRTV, ClearColor );
     pDSV = DXUTGetD3D11DepthStencilView();
    pd3dImmediateContext->ClearDepthStencilView( pDSV, D3D11_CLEAR_DEPTH, 1.0, 0 );
	pd3dImmediateContext->OMSetRenderTargets(1,&pRTV,pDSV);




 //   V( pd3dImmediateContext->Map( blur_cb_buffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &MappedResource ) );
 //   pPerFrame = ( blur_cbuffer* )MappedResource.pData;
	//std::copy(&blur_cb_data.offset[0], &blur_cb_data.offset[15], pPerFrame->offset);
 //   pd3dImmediateContext->Unmap( blur_cb_buffer, 0 );

	pd3dImmediateContext->VSSetShader( VSPPComb, NULL, 0 );
    pd3dImmediateContext->PSSetShader( PSPPComb, NULL, 0 );

	pd3dImmediateContext->HSSetShader( NULL, NULL, 0 );
	pd3dImmediateContext->DSSetShader( NULL, NULL, 0 );
    pd3dImmediateContext->GSSetShader( NULL, NULL, 0 );

	pd3dImmediateContext->PSSetConstantBuffers(0,1,&blur_cb_buffer);
	pd3dImmediateContext->PSSetSamplers(0, 1, &g_pSamLinear);
	pd3dImmediateContext->PSSetShaderResources(0,1,&sr_texture1);//bloom blurred
	pd3dImmediateContext->PSSetShaderResources(1,1,&sr_texture_original);//base tex
	//pd3dImmediateContext->RSSetState( g_pRasterizerStateSolid );
	pd3dImmediateContext->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
	pd3dImmediateContext->Draw(9,0);


    DXUT_BeginPerfEvent( DXUT_PERFEVENTCOLOR, L"HUD / Stats" );
    g_HUD.OnRender( fElapsedTime );
    g_SampleUI.OnRender( fElapsedTime );
    RenderText();
    DXUT_EndPerfEvent();
}
//--------------------------------------------------------------------------------------
// Create any D3D11 resources that aren't dependant on the back buffer
//--------------------------------------------------------------------------------------
HRESULT CALLBACK OnD3D11CreateDevice( ID3D11Device* pd3dDevice, const DXGI_SURFACE_DESC* pBackBufferSurfaceDesc,
                                      void* pUserContext )
{
    HRESULT hr;

    ID3D11DeviceContext* pd3dImmediateContext = DXUTGetD3D11DeviceContext();
    V_RETURN( g_DialogResourceManager.OnD3D11CreateDevice( pd3dDevice, pd3dImmediateContext ) );
    V_RETURN( g_D3DSettingsDlg.OnD3D11CreateDevice( pd3dDevice ) );
    g_pTxtHelper = new CDXUTTextHelper( pd3dDevice, pd3dImmediateContext, &g_DialogResourceManager, 15 );

   // D3DXVECTOR3 vCenter( 0.25767413f, -28.503521f, 111.00689f );
    FLOAT fObjectRadius = 378.15607f;
	lightpos = D3DXVECTOR3(300,300,-200);
	//test = new testing();
	hr = test.setup(pd3dDevice,pBackBufferSurfaceDesc,pUserContext);
	hr = tessplane.setup(pd3dDevice,pBackBufferSurfaceDesc,pUserContext);
	hr = tesscube.setup(pd3dDevice,pBackBufferSurfaceDesc,pUserContext,80,D3DXVECTOR3(300,50,-200));//D3DXVECTOR3(300,50,-200
	hr = lightsphere.setup(pd3dDevice,pBackBufferSurfaceDesc,pUserContext,10,lightpos);
	hr = fuse.setup(pd3dDevice,pBackBufferSurfaceDesc,pUserContext);
	hr = board1.setup(pd3dDevice,pBackBufferSurfaceDesc,pUserContext,D3DXVECTOR3(300,-300,-1000));
	hr = deboard.setup(pd3dDevice,pBackBufferSurfaceDesc,pUserContext,D3DXVECTOR3(-300,-300,-1000));
	hr = geo_alien.setup(pd3dDevice,pBackBufferSurfaceDesc,pUserContext);
	hr = FirePart.setup(pd3dDevice,pBackBufferSurfaceDesc,pUserContext,80,0); //0 = fire
	hr = sky.setup(pd3dDevice,pBackBufferSurfaceDesc,pUserContext,D3DXVECTOR3(0,0,0));
	hr = buildings.setup(pd3dDevice,pBackBufferSurfaceDesc,pUserContext);
	hr = MissilePart.setup(pd3dDevice,pBackBufferSurfaceDesc,pUserContext,20,1);
    g_LightControl.SetRadius( 2000 );



	
    // Setup the camera's view parameters
    D3DXVECTOR3 vecEye( 0.0f, 50.0f, -1000.0f );
    D3DXVECTOR3 vecAt ( 0.0f, 0.0f, -0.0f );

	g_Camera.SetRotateButtons(true,false,false);
    g_Camera.SetViewParams( &vecEye, &vecAt );
	g_Camera.SetEnablePositionMovement( true );
	g_Camera.SetScalers( 0.005f, 500.0f );

	D3D11_DEPTH_STENCIL_DESC descDS;
	ZeroMemory(&descDS, sizeof(descDS));
	descDS.DepthEnable = false;
	descDS.DepthWriteMask = D3D11_DEPTH_WRITE_MASK_ALL;	
	descDS.DepthFunc = D3D11_COMPARISON_LESS;	
	

	descDS.StencilEnable = FALSE;
	hr = pd3dDevice->CreateDepthStencilState( &descDS, &g_DepthState);

	//setup stuff for post process


	ID3DBlob* pVertexShaderBuffer = NULL;
    V_RETURN( CompileShaderFromFile( L"PP1.hlsl", "VS", "vs_4_0", &pVertexShaderBuffer ) );

    ID3DBlob* pPixelShaderBuffer = NULL;
    V_RETURN( CompileShaderFromFile( L"PP1.hlsl", "PS", "ps_4_0", &pPixelShaderBuffer ) );

	V_RETURN( pd3dDevice->CreateVertexShader( pVertexShaderBuffer->GetBufferPointer(),
                                              pVertexShaderBuffer->GetBufferSize(), NULL, &VSPPFirstPass ) );
    DXUT_SetDebugName( VSPPFirstPass, "VSPost1" );
    V_RETURN( pd3dDevice->CreatePixelShader( pPixelShaderBuffer->GetBufferPointer(),
                                             pPixelShaderBuffer->GetBufferSize(), NULL, &PSPPFirstPass ) );
    DXUT_SetDebugName( PSPPFirstPass, "PSPost1" );

	pVertexShaderBuffer = NULL;
    V_RETURN( CompileShaderFromFile( L"Gaussblur.hlsl", "VS", "vs_4_0", &pVertexShaderBuffer ) );

    pPixelShaderBuffer = NULL;
    V_RETURN( CompileShaderFromFile( L"Gaussblur.hlsl", "PS", "ps_4_0", &pPixelShaderBuffer ) );

	V_RETURN( pd3dDevice->CreateVertexShader( pVertexShaderBuffer->GetBufferPointer(),
                                              pVertexShaderBuffer->GetBufferSize(), NULL, &VSPPBlur ) );
    DXUT_SetDebugName( VSPPBlur, "VSBlur" );
    V_RETURN( pd3dDevice->CreatePixelShader( pPixelShaderBuffer->GetBufferPointer(),
                                             pPixelShaderBuffer->GetBufferSize(), NULL, &PSPPBlur ) );
    DXUT_SetDebugName( PSPPBlur, "PSBlur" );

	pVertexShaderBuffer = NULL;
    V_RETURN( CompileShaderFromFile( L"bloom_combine.hlsl", "VS", "vs_4_0", &pVertexShaderBuffer ) );

    pPixelShaderBuffer = NULL;
    V_RETURN( CompileShaderFromFile( L"bloom_combine.hlsl", "PS", "ps_4_0", &pPixelShaderBuffer ) );

	V_RETURN( pd3dDevice->CreateVertexShader( pVertexShaderBuffer->GetBufferPointer(),
                                              pVertexShaderBuffer->GetBufferSize(), NULL, &VSPPComb ) );
    DXUT_SetDebugName( VSPPComb, "VSComb" );
    V_RETURN( pd3dDevice->CreatePixelShader( pPixelShaderBuffer->GetBufferPointer(),
                                             pPixelShaderBuffer->GetBufferSize(), NULL, &PSPPComb ) );
    DXUT_SetDebugName( PSPPComb, "PSComb" );





	
	D3D11_BUFFER_DESC Desc;
    Desc.Usage = D3D11_USAGE_DYNAMIC;
    Desc.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
    Desc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
    Desc.MiscFlags = 0;

    Desc.ByteWidth = sizeof( blur_cbuffer );
    V_RETURN( pd3dDevice->CreateBuffer( &Desc, NULL, &blur_cb_buffer ) );
    DXUT_SetDebugName( blur_cb_buffer, "blur_cb" );


    //g_Camera.SetRadius( fObjectRadius * 3.0f, fObjectRadius * 0.5f, fObjectRadius * 10.0f );
    return S_OK;
}
//--------------------------------------------------------------------------------------
// Handles the GUI events
//--------------------------------------------------------------------------------------
void CALLBACK OnGUIEvent( UINT nEvent, int nControlID, CDXUTControl* pControl, void* pUserContext )
{
    switch( nControlID )
    {
        case IDC_TOGGLEFULLSCREEN:
            DXUTToggleFullScreen(); break;
        case IDC_TOGGLEREF:
            DXUTToggleREF(); break;
        case IDC_CHANGEDEVICE:
            g_D3DSettingsDlg.SetActive( !g_D3DSettingsDlg.IsActive() ); break;

		case IDC_DISPLACEMENTLVL:
        {
            displacement_level = g_SampleUI.GetSlider( IDC_DISPLACEMENTLVL )->GetValue()/ 100.0f;
			tessplane.setdislvl(displacement_level);
            WCHAR sz[100];
            swprintf_s( sz, L"Displacement Level: %2.1f", displacement_level );
            g_SampleUI.GetStatic( IDC_DISPLACEMENTLVL_STATIC )->SetText( sz );
        }
            break;

		case IDC_TESSLVL:
        {
            tess_lvl = g_SampleUI.GetSlider( IDC_TESSLVL )->GetValue();
			tessplane.setTesslvl(tess_lvl);
			tesscube.set_tesslvl(tess_lvl);
			fuse.set_tesslvl(tess_lvl);
            WCHAR sz[100];
            swprintf_s( sz, L"Tesselation Level: %2.1f", tess_lvl );
            g_SampleUI.GetStatic( IDC_TESSLVL_STATIC )->SetText( sz );
        }
            break;
		case IDC_TOGGLEBUILDING:
			show_buildings = g_SampleUI.GetCheckBox( IDC_TOGGLEBUILDING )->GetChecked();
			break;
		case IDC_TOGGLEWIRE:
			tessplane.toggleWire(g_SampleUI.GetCheckBox( IDC_TOGGLEWIRE )->GetChecked());
			tesscube.toggleWire(g_SampleUI.GetCheckBox( IDC_TOGGLEWIRE )->GetChecked());
			fuse.toggleWire(g_SampleUI.GetCheckBox( IDC_TOGGLEWIRE )->GetChecked());
            break;
		case IDC_TOGGLEDT:
			tessplane.toggleDT(g_SampleUI.GetCheckBox( IDC_TOGGLEDT )->GetChecked());
            break;
        case IDC_PARTITION_INTEGER:
			tessplane.settessmethod(0);
			tesscube.settessmethod(0);
			fuse.settessmethod(0);
            break;
        case IDC_PARTITION_FRAC_EVEN:
			tessplane.settessmethod(1);
			tesscube.settessmethod(1);
			fuse.settessmethod(1);
            break;
        case IDC_PARTITION_FRAC_ODD:
			tesscube.settessmethod(2);
			tessplane.settessmethod(2);
			fuse.settessmethod(2);
            break;
    }

}
Пример #26
0
sphere operator *(const glm::mat4& transform, const sphere& s)
{
	return sphere(transform * s.getCenter(), s.getRadius());
}
Пример #27
0
int main(int argc, char** argv)
{
    glutInit(&argc, argv);
    glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB);
    glutInitWindowSize (WINDOW_X,WINDOW_Y);
    glutInitWindowPosition (90,0);
    glutCreateWindow ("KAKA_GL");
    glClearColor (0.8, 0.72, 0.97, 1.0);
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    glOrtho(-WINDOW_X/2, WINDOW_X/2, -WINDOW_Y/2, WINDOW_Y/2, -WINDOW_X/2, WINDOW_X/2);
    glClear (GL_COLOR_BUFFER_BIT);
    glPointSize(1);

    o.loadOBJ("/home/ezer/Documents/Qt/CGproject/Models/crawler1.obj");
    rem.loadOBJ("/home/ezer/Documents/Qt/CGproject/Models/rem1.obj");
    boom.loadOBJ("/home/ezer/Documents/Qt/CGproject/Models/boom1.obj");
    hook.loadOBJ("/home/ezer/Documents/Qt/CGproject/Models/hook1.obj");

    /*rem.TF1 = x_y_zCoordinate(0,0,+113.8);
    rem.TF2 = x_y_zCoordinate(-0,0,-113.8);

    rem.RA1 = x_y_zCoordinate(0,-13.45,-133.8);
    rem.RA2 = x_y_zCoordinate(0,+13.45,-133.8);*/

    rem.TF1 = x_y_zCoordinate(0,0,0);

    rem.RA1 = x_y_zCoordinate(0,0,0);
    rem.RA2 = x_y_zCoordinate(0,1,0);

    RR = rotate_oaxis(rem.RA1,rem.RA2,30);
    NN = translate(kaka);
    MM = translate(x_y_zCoordinate(-kaka.x,-kaka.y,-kaka.z));

    //light
    light.create(20);
    for(unsigned int i=0;i<light.Total_Points;i++)
    {
        light.Vertices[i] = LL*light.Vertices[i];
    }
    //light.draw();

    /*for(unsigned int i=0;i<o.face_size;i++)
    {
        o.vertices[i] =SCS*SCE*YYY*o.vertices[i];
    }*/
    for(unsigned int i=0;i<o.face_size;i++)
    {
        o.vertices[i] =rames*LLL*o.vertices[i];
    }
    for(unsigned int i=0;i<rem.face_size;i++)
    {
        rem.vertices[i] =rames*LLL*rem.vertices[i];
    }
    for(unsigned int i=0;i<boom.face_size;i++)
    {
        boom.vertices[i] =rames*LLL*boom.vertices[i];
    }
    for(unsigned int i=0;i<=hook.face_size;i++)
    {
        hook.vertices[i] =rames*LLL*hook.vertices[i];
    }
    hook.vertices[hook.face_size].display();
    glEnd();
    glFlush ();
    glutSwapBuffers();
    glutSpecialFunc(special_keyboard);
    glutKeyboardFunc(keyboard_event);
    glutDisplayFunc(display);
    //glutMouseFunc(mouse_event);
    glutMainLoop();
    return 0;
}
Пример #28
0
float sphere::distance(const sphere& sphere) const
{
	return glm::abs(glm::distance(c, sphere.getCenter())) - r - sphere.getRadius();
}
Пример #29
0
void special_keyboard(int key,int ,int)
{
    glClear(GL_COLOR_BUFFER_BIT);
    r.clearZbuffer();
    DrawTriangle(x_y_zCoordinate(-450,0,3000),Color(1,1,0),x_y_zCoordinate(-600,-350,-1000),
                 Color(0,1,0),x_y_zCoordinate(600,-350,-1000),Color(0,1,1));
    DrawTriangle(x_y_zCoordinate(-450,0,3000),Color(1,1,0),x_y_zCoordinate(600,0,-1000),
                 Color(0,1,0),x_y_zCoordinate(600,-350,-1000),Color(0,1,1));
    light.draw();
    switch (key)
    {
    case GLUT_KEY_DOWN:
    {
        for(unsigned int i=0;i<o.face_size;i++)
        {
            o.vertices[i] =DOWN*o.vertices[i];
        }
        for(unsigned int i=0;i<rem.face_size;i++)
        {
            rem.vertices[i] =DOWN*rem.vertices[i];
        }
        for(unsigned int i=0;i<boom.face_size;i++)
        {
            boom.vertices[i] =DOWN*boom.vertices[i];
        }
        for(unsigned int i=0;i<hook.face_size;i++)
        {
            hook.vertices[i] =DOWN*hook.vertices[i];
        }
        o.draw(Color(0.3,0.2,0.3));
        rem.draw(Color(1.0,1.2,0.1));
        boom.draw(Color(0.8,0.9,1));
        hook.draw(Color(0.1,0,1));

        break;
    }
    case GLUT_KEY_UP:
    {
        for(unsigned int i=0;i<o.face_size;i++)
        {
            o.vertices[i] =UP*o.vertices[i];
        }
        for(unsigned int i=0;i<rem.face_size;i++)
        {
            rem.vertices[i] =UP*rem.vertices[i];
        }
        for(unsigned int i=0;i<boom.face_size;i++)
        {
            boom.vertices[i] =UP*boom.vertices[i];
        }
        for(unsigned int i=0;i<hook.face_size;i++)
        {
            hook.vertices[i] =UP*hook.vertices[i];
        }
        o.draw(Color(0.3,0.2,0.3));
        rem.draw(Color(1.0,1.2,0.1));
        boom.draw(Color(0.8,0.9,1));
        hook.draw(Color(0.1,0,1));
        break;
    }
    case GLUT_KEY_RIGHT:
    {
        for(unsigned int i=0;i<o.face_size;i++)
        {
            o.vertices[i] =T*o.vertices[i];
        }
        for(unsigned int i=0;i<rem.face_size;i++)
        {
            rem.vertices[i] =T*rem.vertices[i];
        }
        for(unsigned int i=0;i<boom.face_size;i++)
        {
            boom.vertices[i] =T*boom.vertices[i];
        }
        for(unsigned int i=0;i<hook.face_size;i++)
        {
            hook.vertices[i] =T*hook.vertices[i];
        }
        cout<<"rotation\n";
        RR.display();
        cout<<"NNpaxadi\n";
        NN.display();
        cout<<"agadi\n";
        MM.display();
        RR = RR*T;
        MM = MM*T;
        NN = NN*T;

        o.draw(Color(0.3,0.2,0.3));
        rem.draw(Color(1.0,1.2,0.1));
        boom.draw(Color(0.8,0.9,1));
        hook.draw(Color(0.1,0,1));
        break;
    }
    case GLUT_KEY_LEFT:
    {
        for(unsigned int i=0;i<o.face_size;i++)
        {
            o.vertices[i] =T2*o.vertices[i];

        }
        for(unsigned int i=0;i<rem.face_size;i++)
        {
            rem.vertices[i] =T2*rem.vertices[i];

        }
        for(unsigned int i=0;i<boom.face_size;i++)
        {
            boom.vertices[i] =T2*boom.vertices[i];
        }
        for(unsigned int i=0;i<hook.face_size;i++)
        {
            hook.vertices[i] =T2*hook.vertices[i];
        }
        o.draw(Color(0.3,0.2,0.3));
        rem.draw(Color(1.0,1.2,0.1));
        boom.draw(Color(0.8,0.9,1));
        hook.draw(Color(0.1,0,1));
        break;
    }
    case GLUT_KEY_F1:
    {

    }
    default:
        o.draw(Color(0.3,0.2,0.3));
        rem.draw(Color(1.0,1.2,0.1));
        boom.draw(Color(0.8,0.9,1));
        hook.draw(Color(0.1,0,1));
        break;
    }

    glFlush();
    glutSwapBuffers();
}
Пример #30
0
void keyboard_event(unsigned char key,int x,int y)
{

    glClear(GL_COLOR_BUFFER_BIT);
    r.clearZbuffer();

    x+=0;y+=0;
    DrawTriangle(x_y_zCoordinate(-450,0,3000),Color(1,1,0),x_y_zCoordinate(-600,-350,-1000),
                 Color(0,1,0),x_y_zCoordinate(600,-350,-1000),Color(0,1,1));
    DrawTriangle(x_y_zCoordinate(-450,0,3000),Color(1,1,0),x_y_zCoordinate(600,0,-1000),
                 Color(0,1,0),x_y_zCoordinate(600,-350,-1000),Color(0,1,1));
    light.draw();
    for(unsigned int i=0;i<hook.face_size;i++){
    if ((hook.vertices[i].x > ligh.x -10 && hook.vertices[i].x < ligh.x +10) && (hook.vertices[i].y > ligh.y -10
       && hook.vertices[i].y < ligh.y +10)&& (hook.vertices[i].z > ligh.z -10 && hook.vertices[i].z < ligh.z +10))
    {
        set = true;
    }}
    //c1.create();

    switch(key)
    {
    case 'o':
    {
        for(unsigned int i=0;i<hook.face_size;i++)
        {
            hook.vertices[i] =TTTT*hook.vertices[i];
        }
        o.draw(Color(0.3,0.2,0.3));
        rem.draw(Color(1.0,1.2,0.1));
        boom.draw(Color(0.8,0.9,1));
        hook.draw(Color(0.1,0,1));

        break;
    }
    case'i':
    {
        if(set==true){
            for(unsigned int i=0;i<light.Total_Points;i++)
            {
                light.Vertices[i]=LLLL*light.Vertices[i];
            }}

            for(unsigned int i=0;i<hook.face_size;i++)
            {
                hook.vertices[i] =LLLL*hook.vertices[i];
            }

        o.draw(Color(0.3,0.2,0.3));
        rem.draw(Color(1.0,1.2,0.1));
        boom.draw(Color(0.8,0.9,1));
        hook.draw(Color(0.1,0,1));
        break;
    }


    case 'q':
    {
        /* for(unsigned int i=0;i<sph.Total_Points;i++)
        {
            sph.Vertices[i] = IN*sph.Vertices[i];
        }
        //drawLine(-600,0,600,0);
        //drawLine(0,350,0,-350);
        sph.draw();*/
        for(unsigned int i=0;i<o.face_size;i++)
        {
            o.vertices[i] =IN*o.vertices[i];
        }
        o.draw(Color(0.3,0.2,0.3));
        rem.draw(Color(1.0,1.2,0.1));
        boom.draw(Color(0.8,0.9,1));
        hook.draw(Color(0.1,0,1));

        break;
    }
    case 'e':
    {
        /*for(unsigned int i=0;i<sph.Total_Points;i++)
        {
            sph.Vertices[i] = OUT*sph.Vertices[i];
        }
        //drawLine(-600,0,600,0);
        //drawLine(0,350,0,-350);
        sph.draw();*/
        for(unsigned int i=0;i<o.face_size;i++)
        {
            o.vertices[i] =OUT*o.vertices[i];
        }

        break;
    }
    case 'x':
    {
        /*for(int i=0;i<sph.Total_Points;i++)
        {
            sph.Vertices[i] = XR*sph.Vertices[i];
        }
        sph.draw();*/

        for(unsigned int i=0;i<o.face_size;i++)
        {
            o.vertices[i] =XR*o.vertices[i];
        }
        for(unsigned int i=0;i<rem.face_size;i++)
        {
            rem.vertices[i] =XR*rem.vertices[i];
        }
        for(unsigned int i=0;i<boom.face_size;i++)
        {
            boom.vertices[i] =XR*boom.vertices[i];
        }
        for(unsigned int i=0;i<hook.face_size;i++)
        {
            hook.vertices[i] =XR*hook.vertices[i];
        }
        o.draw(Color(0.3,0.2,0.3));
        rem.draw(Color(1.0,1.2,0.1));
        boom.draw(Color(0.8,0.9,1));
        hook.draw(Color(0.1,0,1));
        cout<<"\nx";
        break;
    }
    case 'y':
    {
        /* for(int i=0;i<sph.Total_Points;i++)
        {
            sph.Vertices[i] = YR*sph.Vertices[i];

        }
        sph.draw();*/

        for(unsigned int i=0;i<o.face_size;i++)
        {
            o.vertices[i] =YR*o.vertices[i];
        }
        for(unsigned int i=0;i<rem.face_size;i++)
        {
            rem.vertices[i] =YR*rem.vertices[i];
        }
        for(unsigned int i=0;i<boom.face_size;i++)
        {
            boom.vertices[i] =YR*boom.vertices[i];
        }
        for(unsigned int i=0;i<hook.face_size;i++)
        {
            hook.vertices[i] =YR*hook.vertices[i];
        }
        o.draw(Color(0.3,0.2,0.3));
        rem.draw(Color(1.0,1.2,0.1));
        boom.draw(Color(0.8,0.9,1));
        hook.draw(Color(0.1,0,1));
        cout<<"\ny";
        break;
    }
    case 'z':
    {
        /* for(int i=0;i<sph.Total_Points;i++)
        {
            sph.Vertices[i] = ZR*sph.Vertices[i];
        }

        sph.draw();*/

        for(unsigned int i=0;i<o.face_size;i++)
        {
            o.vertices[i] =ZR*o.vertices[i];
        }
        o.draw(Color(0.3,0.2,0.3));
        rem.draw(Color(1.0,1.2,0.1));
        boom.draw(Color(0.8,0.9,1));
        hook.draw(Color(0.1,0,1));
        cout<<"\nz";
        break;
    }
    case 'l':
    {
        //for(int i=0;i<sph.Total_Points;i++)
        //{
        //  sph.Vertices[i] = SCL*sph.Vertices[i];
        //}
        //sph.draw();
        for(unsigned int i=0;i<o.face_size;i++)
        {
            o.vertices[i] =SCL*o.vertices[i];
        }
        for(unsigned int i=0;i<rem.face_size;i++)
        {
            rem.vertices[i] =SCL*rem.vertices[i];
        }
        for(unsigned int i=0;i<boom.face_size;i++)
        {
            boom.vertices[i] =SCL*boom.vertices[i];
        }
        for(unsigned int i=0;i<hook.face_size;i++)
        {
            hook.vertices[i] =SCL*hook.vertices[i];
        }
        o.draw(Color(0.3,0.2,0.3));
        rem.draw(Color(1.0,1.2,0.1));
        boom.draw(Color(0.8,0.9,1));
        hook.draw(Color(0.1,0,1));
        o.draw(Color(0.3,0.2,0.3));
        rem.draw(Color(1.0,1.2,0.1));
        boom.draw(Color(0.8,0.9,1));
        hook.draw(Color(0.1,0,1));
        cout<<"\nl";
        break;
    }
    case 'h':
    {
        /*for(int i=0;i<sph.Total_Points;i++)
        {
            sph.Vertices[i] = SCH*sph.Vertices[i];
        }
        sph.draw();*/
        for(unsigned int i=0;i<o.face_size;i++)
        {
            o.vertices[i] =SCH*o.vertices[i];
        }
        for(unsigned int i=0;i<rem.face_size;i++)
        {
            rem.vertices[i] =SCH*rem.vertices[i];
        }
        for(unsigned int i=0;i<boom.face_size;i++)
        {
            boom.vertices[i] =SCH*boom.vertices[i];
        }
        for(unsigned int i=0;i<hook.face_size;i++)
        {
            hook.vertices[i] =SCH*hook.vertices[i];
        }
        //o.draw(Color(0.3,0.2,0.3));
        //rem.draw(Color(1.0,1.2,0.1));
        //boom.draw(Color(0.8,0.9,1));
        hook.draw(Color(0.1,0,1));
        cout<<"\nh";
        break;
    }
    case 'm':
    {
        /*for(unsigned int i=0;i<sph.Total_Points;i++)
        {
            sph.Vertices[i] = RR*sph.Vertices[i];
        }
        sph.draw();*/
        for(unsigned int i=0;i<rem.face_size;i++)
        {
            rem.vertices[i] =NN*RR*MM*rem.vertices[i];
        }
        for(unsigned int i=0;i<boom.face_size;i++)
        {
            boom.vertices[i] =NN*RR*MM*boom.vertices[i];
        }
        for(unsigned int i=0;i<=hook.face_size;i++)
        {
            hook.vertices[i] =NN*RR*MM*hook.vertices[i];
        }

        o.draw(Color(0.3,0.2,0.3));
        rem.draw(Color(1.0,1.2,0.1));
        boom.draw(Color(0.8,0.9,1));
        hook.draw(Color(0.1,0,1));
        break;
    }
    case 'c':
    {
        break;
    }

    case 'p':
    {
        x_y_zCoordinate cc111(-600,-310,10),cc222(-512,310,10),cc333(0,280,10);

        x_y_zCoordinate cc11(0,0,0),cc22(480,0,0),cc33(0,350,0);

        x_y_zCoordinate cc1(0,0,10),cc2(340,0,10),cc3(0,340,10);


        Color c1(1,0,0),c2(0,1,0),c3(0,0,1);
        DrawTriangle(cc1,c3,cc2,c3,cc3,c3);
        DrawTriangle(cc11,c1,cc22,c1,cc33,c1);
        DrawTriangle(cc111,c2,cc222,c2,cc333,c2);

        //DrawTriangle();
        break;
    }
    case 'b':
    {
        o.draw(Color(0.3,0.2,0.3));
        rem.draw(Color(1.0,1.2,0.1));
        boom.draw(Color(0.8,0.9,1));
        hook.draw(Color(0.1,0,1));
        setPixel(0,0,Color(1,0,0));
        break;
    }
    default:
        //drawLine(-600,0,600,0);
        //drawLine(0,350,0,-350);
         exit(-1);//terminate the program
        break; // do nothing
    }

    glFlush();
    glutSwapBuffers();
}