예제 #1
0
dgFloat32 dgCollisionUserMesh::RayCastSimd(const dgVector& localP0,
    const dgVector& localP1, dgContactPoint& contactOut,
    OnRayPrecastAction preFilter, const dgBody* const body,
    void* const userData) const
{
  return RayCast(localP0, localP1, contactOut, preFilter, body, userData);
}
예제 #2
0
void Level00::HandleInput(Input& input)
{
	// Player Mouse

	if (input.GetKeyDown(KEYCODE_1))
	{
		Application::SharedInstance().LoadScene<MainMenuScene>();
	}

	if (input.GetMouseButtonDown(MOUSEBUTTON_LEFT))
	{
		float x = (2.0f * input.mousePosition.x) / mRenderer->GetWindowWidth() - 1.0f;
		float y = 1.0f - (2.0f * input.mousePosition.y) / mRenderer->GetWindowHeight();

		mat4f toWorld = (mQuadShaderData.Projection * mQuadShaderData.View).inverse();
		vec3f worldPos = vec4f(x, y, 0.0f, 1.0f) * toWorld;
		vec3f worldDir = vec3f(0.0f, 0.0f, 1.0f);
		worldPos.z = -30.0f;

		Ray<vec3f> ray = { worldPos, worldDir };

		RayCastHit<vec3f> hit;
		if (RayCast(&hit, ray, mLightColliders, mCircleCount))
		{
			mCircleColorWeights[hit.index] = mCircleColorWeights[hit.index] > 0 ? 0.0f : 1.0f;
		}
	}
}
예제 #3
0
const void*	DyWorld::GetUserPointerFromRayCast( const MtVector3& from, const MtVector3& to, DyCollision& collision )
{
	const btRigidBody *pRigidBody = RayCast( from, to, collision );
	if( pRigidBody )
	{
		return (void*)pRigidBody->getUserPointer();
	}
	return BtNull;
}
예제 #4
0
			virtual sensor_value_t read() const override
			{
				auto world = m_body->GetWorld();

				RC_Callback cb;
				auto start = m_body->GetWorldPoint(m_pos);
				auto w_dir = m_body->GetWorldVector(m_dir);
				auto end = start + m_range * w_dir;
				world->RayCast(&cb, start, end);

				auto dist = cb.hit() ? (double)(cb.fraction * m_range) : std::numeric_limits< double >::max();
				return dist;
			}
예제 #5
0
파일: skeleton.c 프로젝트: carlic578/school
/************************************************
|| display()
|| Purpose: display function for opengl 
************************************************/
void display()
{
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
        glMatrixMode(GL_MODELVIEW);
        glLoadIdentity();
        glFlush();
        glColor3f(0,0,0);

        //printf("Casting rays\n");
        RayCast(); //start finding points
    //printf("Number of Objects: %d\n", numObjs);
    //printf("number of numLights: %d\n", numLights);
        glutSwapBuffers();
}
예제 #6
0
//------------------------------------------------------------------------------
bool
SceEllipsoid::RayCast(Ray const & ray, 
                      float & t, 
                      Vec3f & point, 
                      Vec3f & normal) const
{
    float tIntersection;

    if (RayCast(ray, tIntersection))
    {
        t = tIntersection;
        point = ray.calcPosition(tIntersection);
        normal = (mMatrixInvTInv * (point - mCenter)).normalized();
        return true;
    }

    return false;
}
예제 #7
0
void main(void)
{
   int j,k;
   long xp=6*CELL_WIDTH,
       yp=6*CELL_HEIGHT,dx,dy,
       angle = 500;
   char key;
   float rad;

   clrscr();
   SetMode();
   LoadMap("RayMap.Dat");
   Wall    = (unsigned char *)malloc(64*64);
   Wall1   = (unsigned char *)malloc(64*64);
   ClearScreen(SCREEN);
   MakeTables();
      // get mem for double buffer.
   VSCREEN = (char far*)farmalloc(64000);
   Fondo   = (char far*)farmalloc(64000);
   LoadImage(Fondo,"fondo.cel");
   LoadImage(Wall,"walltext.cel");
   LoadImage(Wall1,"wall1.cel");
   InstallKeyboardHandler();
   while (!keypress[ESC])
   {
      Dest = VSCREEN;
      Source = Fondo;
      ShowPage32();
      RayCast(xp,yp,angle);
      Dest = SCREEN;
      Source = VSCREEN;
      ShowPage32();
      dx=dy=0;
      if (keypress[RIGHT])
         if ((angle += WorldAngles[6]) > WorldAngles[360])
            angle = WorldAngles[0];
      if (keypress[LEFT])
         if ((angle -=WorldAngles[6]) < WorldAngles[0])
            angle = WorldAngles[360];

      if (keypress[UP])
      {
         rad = 6.28*angle/WorldAngles[360];
         dx=cos(rad)*30;
         dy=sin(rad)*30;
      }

      if (keypress[DOWN])
      {
         rad = 6.28*angle/WorldAngles[360];
         dx=-cos(rad)*30;
         dy=-sin(rad)*30;
      }
  // move player

  xp+=dx;
  yp+=dy;

   }
   RemoveKeyboardHandler();

   SetText();

   farfree(VSCREEN);
   farfree(Fondo);
   FreeTables();
//   if (Wall != NULL)
      free(Wall);
      free(Wall1);
//   farfree(Wall1);


}