Пример #1
0
//回転あり
void TexImage::render(int x, int y, double rad)
{
	glColor3f(1.0f, 1.0f, 1.0f);
	glPixelStorei(GL_UNPACK_ALIGNMENT, 4);
	glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, img->size().width, img->size().height, 0, GL_BGRA, GL_UNSIGNED_BYTE, img->data);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);

	glEnable(GL_TEXTURE_2D);
	glNormal3d(0.0, 0.0, 1.0);
	glBegin(GL_QUADS);

	vec2d center = vec2d(x + img->size().width / 2.0, y + img->size().height / 2.0);
	vec2d v;
	glTexCoord2d(0.0, 1.0);
	v = center + vec2d(-img->size().width / 2.0, -img->size().height / 2.0).rotate(rad);
	glVertex3d(v.x, v.y, 0.0);

	glTexCoord2d(1.0, 1.0);
	v = center + vec2d(img->size().width / 2.0, -img->size().height / 2.0).rotate(rad);
	glVertex3d(v.x, v.y, 0.0);

	glTexCoord2d(1.0, 0.0);
	v = center + vec2d(img->size().width / 2.0, img->size().height / 2.0).rotate(rad);
	glVertex3d(v.x, v.y, 0.0);

	glTexCoord2d(0.0, 0.0);
	v = center + vec2d(-img->size().width / 2.0, img->size().height / 2.0).rotate(rad);
	glVertex3d(v.x, v.y, 0.0);

	glEnd();
	glDisable(GL_TEXTURE_2D);
	glEnd();
}
Пример #2
0
bool TerrainNode::isOccluded(const box3d &box)
{
    if (!horizonCulling || localCameraPos.z > root->zmax) {
        return false;
    }
    vec2f corners[4];
    vec2d o = localCameraPos.xy();
    corners[0] = localCameraDir * (vec2d(box.xmin, box.ymin) - o).cast<float>();
    corners[1] = localCameraDir * (vec2d(box.xmin, box.ymax) - o).cast<float>();
    corners[2] = localCameraDir * (vec2d(box.xmax, box.ymin) - o).cast<float>();
    corners[3] = localCameraDir * (vec2d(box.xmax, box.ymax) - o).cast<float>();
    if (corners[0].y <= 0.0f || corners[1].y <= 0.0f || corners[2].y <= 0.0f || corners[3].y <= 0.0f) {
        return false;
    }
    float dz = float(box.zmax - localCameraPos.z);
    corners[0] = vec2f(corners[0].x, dz) / corners[0].y;
    corners[1] = vec2f(corners[1].x, dz) / corners[1].y;
    corners[2] = vec2f(corners[2].x, dz) / corners[2].y;
    corners[3] = vec2f(corners[3].x, dz) / corners[3].y;
    float xmin = min(min(corners[0].x, corners[1].x), min(corners[2].x, corners[3].x)) * 0.33f + 0.5f;
    float xmax = max(max(corners[0].x, corners[1].x), max(corners[2].x, corners[3].x)) * 0.33f + 0.5f;
    float zmax = max(max(corners[0].y, corners[1].y), max(corners[2].y, corners[3].y));
    int imin = max(int(floor(xmin * HORIZON_SIZE)), 0);
    int imax = min(int(ceil(xmax * HORIZON_SIZE)), HORIZON_SIZE - 1);
    for (int i = imin; i <= imax; ++i) {
        if (zmax > horizon[i]) {
            return false;
        }
    }
    return imax >= imin;
}
 DevNestedWidgetCoordinates(Display *display)
    : UIScreen(display)
 {
    display->background_color(color::black);
    CoordinateWidget *widget1 = new CoordinateWidget(this, 400, 300, 300, 300, color::white);
    CoordinateWidget *widget2 = new CoordinateWidget(widget1, 300, 200, 300, 300, color::orange);
    CoordinateWidget *widget3 = new CoordinateWidget(widget2, 300, 200, 300, 300, color::chartreuse);
    widget2->place.rotation = 0.2;
    widget2->place.scale = vec2d(1.5, 1.5);
    widget3->place.rotation = 0.2;
    widget3->place.scale = vec2d(0.75, 0.75);
 }
Пример #4
0
 void on_message(UIWidget *sender, std::string message) override
 {
    if (sender == reset_camera_button)
    {
       camera->place.position = vec2d(0, 0);
       camera->place.scale = vec2d(1, 1);
    }
    else if (sender == button1) camera->place.position.y -= 10;
    else if (sender == button2) camera->place.position.y += 10;
    else if (sender == button3) camera->place.position.x -= 10;
    else if (sender == button4) camera->place.position.x += 10;
    else if (sender == zoom_in_button) camera->place.scale *= 1.1;
    else if (sender == zoom_out_button) camera->place.scale *= 0.9;
 }
Пример #5
0
void GameDelegate::onTouchReleased(int x, int y, int prevX, int prevY)
{
    vec2d pos = vec2d(static_cast<double>(x), static_cast<double>(y));
    pos.x /= m_screen.x;
    pos.y /= m_screen.y;
    pos *= 2.0f;
    pos -= 1.0f;
    vec2d prevPos = vec2d(static_cast<double>(x), static_cast<double>(y));
    prevPos.x /= m_screen.x;
    prevPos.y /= m_screen.y;
    prevPos *= 2.0f;
    prevPos -= 1.0f;
    TouchManager::GetInstance()->onTouchEnded(pos, prevPos);
}
Пример #6
0
bool TerrainNode::addOccluder(const box3d &occluder)
{
    if (!horizonCulling || localCameraPos.z > root->zmax) {
        return false;
    }
    vec2f corners[4];
    vec2d o = localCameraPos.xy();
    corners[0] = localCameraDir * (vec2d(occluder.xmin, occluder.ymin) - o).cast<float>();
    corners[1] = localCameraDir * (vec2d(occluder.xmin, occluder.ymax) - o).cast<float>();
    corners[2] = localCameraDir * (vec2d(occluder.xmax, occluder.ymin) - o).cast<float>();
    corners[3] = localCameraDir * (vec2d(occluder.xmax, occluder.ymax) - o).cast<float>();
    if (corners[0].y <= 0.0f || corners[1].y <= 0.0f || corners[2].y <= 0.0f || corners[3].y <= 0.0f) {
        // skips bounding boxes that are not fully behind the "near plane"
        // of the reference frame used for horizon occlusion culling
        return false;
    }
    float dzmin = float(occluder.zmin - localCameraPos.z);
    float dzmax = float(occluder.zmax - localCameraPos.z);
    vec3f bounds[4];
    bounds[0] = vec3f(corners[0].x, dzmin, dzmax) / corners[0].y;
    bounds[1] = vec3f(corners[1].x, dzmin, dzmax) / corners[1].y;
    bounds[2] = vec3f(corners[2].x, dzmin, dzmax) / corners[2].y;
    bounds[3] = vec3f(corners[3].x, dzmin, dzmax) / corners[3].y;
    float xmin = min(min(bounds[0].x, bounds[1].x), min(bounds[2].x, bounds[3].x)) * 0.33f + 0.5f;
    float xmax = max(max(bounds[0].x, bounds[1].x), max(bounds[2].x, bounds[3].x)) * 0.33f + 0.5f;
    float zmin = min(min(bounds[0].y, bounds[1].y), min(bounds[2].y, bounds[3].y));
    float zmax = max(max(bounds[0].z, bounds[1].z), max(bounds[2].z, bounds[3].z));

    int imin = max(int(floor(xmin * HORIZON_SIZE)), 0);
    int imax = min(int(ceil(xmax * HORIZON_SIZE)), HORIZON_SIZE - 1);

    // first checks if the bounding box projection is below the current horizon line
    bool occluded = imax >= imin;
    for (int i = imin; i <= imax; ++i) {
        if (zmax > horizon[i]) {
            occluded = false;
            break;
        }
    }
    if (!occluded) {
        // if it is not, updates the horizon line with the projection of this bounding box
        imin = max(int(ceil(xmin * HORIZON_SIZE)), 0);
        imax = min(int(floor(xmax * HORIZON_SIZE)), HORIZON_SIZE - 1);
        for (int i = imin; i <= imax; ++i) {
            horizon[i] = max(horizon[i], zmin);
        }
    }
    return occluded;
}
BOOST_FIXTURE_TEST_CASE(can_set_the_alpha_threshold, Fixture)
{
   ALLEGRO_BITMAP *bmp = al_create_bitmap(1, 1);
   UISurfaceAreaBitmapAlpha surface_area = UISurfaceAreaBitmapAlpha(0, 0, bmp);
   surface_area.placement.align = vec2d(0, 0);
   al_set_target_bitmap(bmp);

   float alpha = 0.5;

   surface_area.set_alpha_threshold(alpha);
   al_put_pixel(0, 0, al_map_rgba_f(1.0, 1.0, 1.0, alpha - 0.01));
   BOOST_CHECK_EQUAL(false, surface_area.collides(0.5, 0.5));
   al_put_pixel(0, 0, al_map_rgba_f(1.0, 1.0, 1.0, alpha + 0.01));
   BOOST_CHECK_EQUAL(true, surface_area.collides(0.5, 0.5));

   alpha = 0.1;

   surface_area.set_alpha_threshold(alpha);
   al_put_pixel(0, 0, al_map_rgba_f(1.0, 1.0, 1.0, alpha - 0.01));
   BOOST_CHECK_EQUAL(false, surface_area.collides(0.5, 0.5));
   al_put_pixel(0, 0, al_map_rgba_f(1.0, 1.0, 1.0, alpha + 0.01));
   BOOST_CHECK_EQUAL(true, surface_area.collides(0.5, 0.5));

   alpha = 0.9;

   surface_area.set_alpha_threshold(alpha);
   al_put_pixel(0, 0, al_map_rgba_f(1.0, 1.0, 1.0, alpha - 0.01));
   BOOST_CHECK_EQUAL(false, surface_area.collides(0.5, 0.5));
   al_put_pixel(0, 0, al_map_rgba_f(1.0, 1.0, 1.0, alpha + 0.01));
   BOOST_CHECK_EQUAL(true, surface_area.collides(0.5, 0.5));
}
BOOST_FIXTURE_TEST_CASE(does_not_collide_on_a_pixel_with_alpha_less_than_threshold, Fixture)
{
   UISurfaceAreaBitmapAlpha surface_area = UISurfaceAreaBitmapAlpha(0, 0, Fixture::bitmap);
   surface_area.placement.align = vec2d(0, 0);

   BOOST_CHECK_EQUAL(false, surface_area.collides(2, 2));
}
BOOST_FIXTURE_TEST_CASE(does_not_collide_at_coordinates_outside_its_bounding_box, Fixture)
{
   UISurfaceAreaBitmapAlpha surface_area = UISurfaceAreaBitmapAlpha(0, 0, Fixture::bitmap);
   surface_area.placement.align = vec2d(0, 0);

   BOOST_CHECK_EQUAL(false, surface_area.collides(-1, -1));
}
Пример #10
0
/**
* @brief Displays the players health bar.
*/
void healthBar()
{
	Vec2d scale;
	scale.y= 1;
	scale.x = (float)(playerData.health)/playerData.maxhealth;
	drawSprite(health_bar,0,vec2d(10,50),scale,0,gt_graphics_get_active_renderer());
}
Пример #11
0
bool SubSurface::Subtag( const vec3d & center )
{
    UpdatePolygonPnts(); // Update polygon vector

    for ( int p = 0; p < ( int )m_PolyPntsVec.size(); p++ )
    {
        bool inPoly = PointInPolygon( vec2d( center.x(), center.y() ), m_PolyPntsVec[p] );

        if ( inPoly && m_TestType() == vsp::INSIDE )
        {
            return true;
        }
        else if ( inPoly && m_TestType() == vsp::OUTSIDE )
        {
            return false;
        }
    }

    if ( m_TestType() == vsp::OUTSIDE )
    {
        return true;
    }

    return false;
}
BOOST_FIXTURE_TEST_CASE(will_collide_on_a_pixel_with_alpha_greater_than_threshold, Fixture)
{
   UISurfaceAreaBitmapAlpha surface_area = UISurfaceAreaBitmapAlpha(0, 0, Fixture::bitmap);
   surface_area.placement.align = vec2d(0, 0);

   BOOST_CHECK_EQUAL(true, surface_area.collides(150, 150));
}
Пример #13
0
void init_lvl1Graphics()
{
	camera = vec2d(0,0);
	floor = loadSprite("images/ground.png",1600,600,1);
    backTrees = loadSprite("images/back_treeline.png",1600,600,1);
    frontTrees = loadSprite("images/front_treeline.png",1600,600,1);
}
Пример #14
0
/**
 * LAB WORKSHEET 5, ASSIGNMENT 1
 *
 * compute the intersection between a box and a box
 */
vec2d CPhysicsIntersections::getProjection(iPhysicsObject const &boxObject, Vector const &axis)
{
	Vector boxHalfSize = static_cast<cObjectFactoryBox *>(&boxObject.object->objectFactory.getClass())->half_size;
	
	Vector vertexList[8] = {
		Vector(-boxHalfSize[0], -boxHalfSize[1], -boxHalfSize[2]),
		Vector(-boxHalfSize[0], -boxHalfSize[1], boxHalfSize[2]),
		Vector(-boxHalfSize[0], boxHalfSize[1], -boxHalfSize[2]),
		Vector(-boxHalfSize[0], boxHalfSize[1], boxHalfSize[2]),
		Vector(boxHalfSize[0], -boxHalfSize[1], -boxHalfSize[2]),
		Vector(boxHalfSize[0], -boxHalfSize[1], boxHalfSize[2]),
		Vector(boxHalfSize[0], boxHalfSize[1], -boxHalfSize[2]),
		Vector(boxHalfSize[0], boxHalfSize[1], boxHalfSize[2])
	};
	
	float min = axis.dotProd(boxObject.object->model_matrix * vertexList[0]);
	float max = min;
	for (int i = 1; i < 8; ++i) {
		// Vertices are in model space. We need to transform them to world space.
		Vector vertexPos = boxObject.object->model_matrix * vertexList[i];
		float projLength = axis.dotProd(vertexPos);
		if (projLength > max) max = projLength;
		else if (projLength < min) min = projLength;
	}

	return vec2d(min, max);
}
Пример #15
0
vector< ISegChain* > ISegChain::FindCoPlanarChains( Surf* sPtr, Surf* adjSurf )
{
	vector< ISegChain* > new_chains;

	vector< IPnt* > ipnt_vec;
	for ( int i = 0 ; i < (int)m_TessVec.size() ; i++ )
	{
		IPnt* ip = m_TessVec[i];
		vec3d p = ip->m_Pnt;

		//==== See if Point Is On Surface ====//
		double tol = 1.0e-04;
		vec2d uw = sPtr->ClosestUW( p, sPtr->GetMaxU()/2.0, sPtr->GetMaxW()/2.0 );

		vec3d sp = sPtr->CompPnt( uw[0], uw[1] );

		if ( dist( p, sp ) < tol )
		{
			Puw* puwa = new Puw( sPtr, vec2d( uw[0], uw[1] ) );
			cfdMeshMgrPtr->AddDelPuw( puwa );

			Puw* puwb = new Puw( sPtr, vec2d( uw[0], uw[1] ) );
			cfdMeshMgrPtr->AddDelPuw( puwb );

			IPnt* ip  = new IPnt( puwa, puwb );
			m_CreatedIPnts.push_back( ip );
	
			ipnt_vec.push_back( ip );
		}
	}

	if ( ipnt_vec.size() > 1 )
	{
		ISegChain* nc = new ISegChain();
		nc->m_SurfA = sPtr;
		nc->m_SurfB = sPtr;
		nc->m_BorderFlag = true;
		new_chains.push_back( nc );

		for ( int i = 0 ; i < (int)ipnt_vec.size() ; i++ )
		{
			nc->m_TessVec.push_back( ipnt_vec[i] );
		}
	}

	return new_chains;
}
Пример #16
0
Ship::Ship(const string& name, const string& collision, Sprite* body)
: PhysicNode(collision)
, m_name(name)
, m_ship(SpritePtr(body))
{
    setCamera(Painter::GetInstance()->getSceneCamera());
	setMoveDirection(vec2d(0.0f, 1.0f));
}
Пример #17
0
LabelGeom::LabelGeom() 
{
	drawMode = DRAW_HIGHLIGHT;
	textSize = 1.5f;
	viewScale = 1.0;
	cursor = vec2d(0,0);

}
Пример #18
0
void Fish::init(vec2d pos_, vec2d velo_)
{
	pos = pos_; velo = velo_; dire = vec2d(1.0, 1.0);
	behavior = new Behavior();
	static int staticID = 0;
	id = staticID++;
	partidx = -99;
}
Пример #19
0
void init_lvl2Graphics()
{
	camera = vec2d(0,0);
	levelTwoFloor = loadSprite("images/level2_ground.png",1600,600,1);
    levelTwoBackTrees = loadSprite("images/level2_back_treeline.png",1600,600,1);
    levelTwoFrontTrees = loadSprite("images/level2_front_treeline.png",1600,600,1);
    moonBack = loadSprite("images/moon.png",800,600,1);
}
Пример #20
0
void GameDelegate::onTouchPressed(int x, int y)
{
    vec2d pos = vec2d(static_cast<double>(x), static_cast<double>(y));
    pos.x /= m_screen.x;
    pos.y /= m_screen.y;
    pos *= 2.0f;
    pos -= 1.0f;
    TouchManager::GetInstance()->onTouchBegan(pos);
}
Пример #21
0
f32 extract_y_rotation(const core::vector3df &rot)
{
	core::vector3df vec(0,0,1);
	core::quaternion quat(rot * core::DEGTORAD);
	vec = quat * vec;
	
	core::vector2df vec2d(vec.X,vec.Z);
	vec2d.normalize();
	return vec2d.getAngle() + 90.0; // Irrlicht has 0 to the right (1,0) rather than up (0,1).
}
Пример #22
0
vec2d Behavior::randomwalk(Fish* self, World* p_world)
{
	//前方に半径rの円を仮定し、その円上にあるランダムな点に
	//向かう力を計算する(振動をさけ、滑らかな動きを実現するため)
	vec2d center = self->get_pos() + self->get_dire() * 0.5;
	double r = 0.2;
	double rd = 0.4;
	rw_rad += (double)(rand()) / RAND_MAX * rd - rd / 2.0;
	return (center + vec2d(0, r).rotate(rw_rad) - self->get_pos())*KR;
}
Пример #23
0
void SSControlSurf::UpdatePolygonPnts()
{
    if ( m_PolyPntsReadyFlag )
    {
        return;
    }

    if ( m_SurfType() == UPPER_SURF || m_SurfType() == LOWER_SURF )
    {
        SubSurface::UpdatePolygonPnts();
        vec3d pnt = m_LVec[0].GetP0();
        m_PolyPntsVec[0].push_back( vec2d( pnt.x(), pnt.y() ) );
        return;
    }

    m_PolyPntsVec.resize( 2 );

    int last_ind = 0;
    int start_ind = 0;
    for ( int i = 0; i < ( int )m_PolyPntsVec.size(); i++ )
    {
        m_PolyPntsVec[i].clear();

        if ( i == 0 ) { last_ind = 3; }
        if ( i == 1 ) { last_ind = 6; }

        vec3d pnt;
        for ( int ls = start_ind; ls < last_ind; ls++ )
        {
            pnt = m_LVec[ls].GetP0();
            m_PolyPntsVec[i].push_back( vec2d( pnt.x(), pnt.y() ) );
        }
        pnt = m_LVec[last_ind - 1].GetP1();
        m_PolyPntsVec[i].push_back( vec2d( pnt.x(), pnt.y() ) );
        pnt = m_LVec[start_ind].GetP0();
        m_PolyPntsVec[i].push_back( vec2d( pnt.x(), pnt.y() ) );

        start_ind = last_ind;
    }

    m_PolyPntsReadyFlag = true;
}
Пример #24
0
int TextureManager::LoadDirectory(const string_t &dirName, const string_t &texPrefix)
{
	int count = 0;

	SafePtr<FS::FileSystem> dir = g_fs->GetFileSystem(dirName);

	std::set<string_t> files;
	dir->EnumAllFiles(files, TEXT("*.tga"));

	for( std::set<string_t>::iterator it = files.begin(); it != files.end(); ++it )
	{
		TexDescIterator td;
		string_t f = dirName + TEXT("/") + *it;
		try
		{
			LoadTexture(td, f);
		}
		catch( const std::exception &e )
		{
			TRACE("WARNING: could not load texture '%s' - %s", f.c_str(), e.what());
			continue;
		}

		string_t texName = texPrefix + *it;
		texName.erase(texName.length() - 4); // cut out the file extension

		LogicalTexture tex;
		tex.dev_texture = td->id;
		tex.uvLeft   = 0;
		tex.uvTop    = 0;
		tex.uvRight  = 1;
		tex.uvBottom = 1;
		tex.uvPivot  = vec2d(0.5f, 0.5f);
		tex.xframes  = 1;
		tex.yframes  = 1;
		tex.uvFrameWidth  = 1;
		tex.uvFrameHeight = 1;
		tex.pxFrameWidth  = (float) td->width;
		tex.pxFrameHeight = (float) td->height;

		FRECT frame = {0,0,1,1};
		tex.uvFrames.push_back(frame);
		//---------------------
		if( _mapName_to_Index.end() != _mapName_to_Index.find(texName) )
			continue; // skip if there is a texture with the same name
		_mapName_to_Index[texName] = _logicalTextures.size();
		_logicalTextures.push_back(tex);
		td->refCount++;
		count++;
	}
	return count;
}
Пример #25
0
//==================================//
// This method updates the polygon points that define the polygon(s) used for the
// point in polygon test used to determine which triangles are inside or outside
// of the subsurface region
//==================================//
void SubSurface::UpdatePolygonPnts()
{
    if ( m_PolyPntsReadyFlag )
    {
        return;
    }

    m_PolyPntsVec.resize( 1 );

    m_PolyPntsVec[0].clear();

    int last_ind = m_LVec.size() - 1;
    vec3d pnt;
    for ( int ls = 0; ls < last_ind + 1; ls++ )
    {
        pnt = m_LVec[ls].GetP0();
        m_PolyPntsVec[0].push_back( vec2d( pnt.x(), pnt.y() ) );
    }
    pnt = m_LVec[last_ind].GetP1();
    m_PolyPntsVec[0].push_back( vec2d( pnt.x(), pnt.y() ) );

    m_PolyPntsReadyFlag = true;
}
Пример #26
0
std::vector<polygon> polygon::from(const ClipperLib::Paths& paths, base_int maxDenom)
{
	std::vector<polygon> ret;
	for(auto iter = paths.begin(); iter != paths.end(); iter++)
	{
		ret.push_back(polygon());
		auto& polyRef = ret.back();
		for(auto point = iter->begin(); point != iter->end(); point++)
		{
			polyRef.vertexes.push_back(vec2d(int_frac(point->X, maxDenom), int_frac(point->Y, maxDenom)));
		}
	}
	return ret;
}
Пример #27
0
int pause_menu()
{
  static int i = 0;
  SDL_Renderer *render;
  render = gt_graphics_get_active_renderer();
  SDL_RenderClear(gt_graphics_get_active_renderer());
  ResetBuffer();
  mainScreen = loadSprite("images/pause_screen.png",800,600,1);
  selection = loadSprite("images/selection.png",149,53,1);
  if(i == 0)
	{
		drawSprite(mainScreen,0,vec2d(0,0),vec2d(1,1),0,gt_graphics_get_active_renderer());
		drawSprite(selection,0,vec2d(311,294),vec2d(1,1),0,gt_graphics_get_active_renderer());
  }else if(i ==1)
  {
	  drawSprite(mainScreen,0,vec2d(0,0),vec2d(1,1),0,gt_graphics_get_active_renderer());
	  drawSprite(selection,0,vec2d(311,377),vec2d(1,1),0,gt_graphics_get_active_renderer());
	  
  }
  NextFrame();
  SDL_PumpEvents();
  keys = SDL_GetKeyboardState(NULL);
  if(keys[SDL_SCANCODE_ESCAPE])
    {
        done = 1;
    }
  if(keys[SDL_SCANCODE_DOWN])
    {
	  i = 1;
	}
  if(keys[SDL_SCANCODE_UP])
  {
	  i = 0;
  }
  if(keys[SDL_SCANCODE_RETURN])
  {
	  if(i == 0)
	  {
		  gameState = 1;
	  }
	  else
	  {
		  done = 1;
	  }
  }	  
   return 1;
}
Пример #28
0
void ISegChain::ApplyTess( )
{
	//==== Clear Old Tess ====//
	m_TessVec.clear();

	vector< vec3d > tuwa = m_ACurve.GetUWTessPnts();
	vector< vec3d > tuwb = m_BCurve.GetUWTessPnts();
	assert( tuwa.size() == tuwb.size() );

	//==== Add Other IPnts ====//
	for ( int i = 0 ; i < (int)tuwa.size() ; i++ )
	{
		Puw* puwa = new Puw( m_SurfA, vec2d( tuwa[i][0], tuwa[i][1] ) );
		cfdMeshMgrPtr->AddDelPuw( puwa );
		Puw* puwb = new Puw( m_SurfB, vec2d( tuwb[i][0], tuwb[i][1] ) );
		cfdMeshMgrPtr->AddDelPuw( puwb );

		IPnt* ip  = new IPnt( puwa, puwb );

		m_CreatedIPnts.push_back( ip );
		//m_CreatedPuws.push_back( puwa );
		//m_CreatedPuws.push_back( puwb );

		//vec3d pA = m_SurfA->CompPnt( tuwa[i][0], tuwa[i][1] );
		//vec3d pB = m_SurfB->CompPnt( tuwb[i][0], tuwb[i][1] );

		//double d = dist( pA, pB );
		//	printf( "%d Big D = %f \n",i, d );

		ip->CompPnt();
		m_TessVec.push_back( ip );
	}

//double d = dist( m_TessVec.front()->m_Pnt,  m_TessVec.back()->m_Pnt );
//printf("Tess Chain Size = %d %f\n", m_TessVec.size(), d );
}
Пример #29
0
vec2d Behavior::separation(Fish* self, World* p_world, std::list<Fish*>& neighbors)
{
	if (neighbors.size() == 0)
		return vec2d();

	//近傍の各対象に対し、距離に反比例する力を計算
	vec2d force;
	for (std::list<Fish*>::iterator it = neighbors.begin();
	it != neighbors.end(); ++it)
	{
		vec2d tovec = self->get_pos() - (*it)->get_pos();
		force += tovec.norm() / tovec.length();
	}
	return force*KS;
}
Пример #30
0
vec2d Behavior::alignment(Fish* self, World* p_world, std::list<Fish*>& neighbors)
{
	if (neighbors.size() == 0) return vec2d();

	//近傍の全対象の向きの平均を計算し、それに合わせるような力を計算
	vec2d ave;
	for (std::list<Fish*>::iterator it = neighbors.begin();
	it != neighbors.end(); ++it)
	{
		ave += (*it)->get_dire();
	}
	ave /= neighbors.size();
	return (ave - self->get_dire())*KA;

}