示例#1
0
/*
============
idTraceModel::SetupBox
============
*/
void idTraceModel::SetupBox( const idBounds &boxBounds ) {
	int i;

	if ( type != TRM_BOX ) {
		InitBox();
	}
	// offset to center
	offset = ( boxBounds[0] + boxBounds[1] ) * 0.5f;
	// set box vertices
	for ( i = 0; i < 8; i++ ) {
		verts[i][0] = boxBounds[(i^(i>>1))&1][0];
		verts[i][1] = boxBounds[(i>>1)&1][1];
		verts[i][2] = boxBounds[(i>>2)&1][2];
	}
	// set polygon plane distances
	polys[0].dist = -boxBounds[0][2];
	polys[1].dist = boxBounds[1][2];
	polys[2].dist = -boxBounds[0][1];
	polys[3].dist = boxBounds[1][0];
	polys[4].dist = boxBounds[1][1];
	polys[5].dist = -boxBounds[0][0];
	// set polygon bounds
	for ( i = 0; i < 6; i++ ) {
		polys[i].bounds = boxBounds;
	}
	polys[0].bounds[1][2] = boxBounds[0][2];
	polys[1].bounds[0][2] = boxBounds[1][2];
	polys[2].bounds[1][1] = boxBounds[0][1];
	polys[3].bounds[0][0] = boxBounds[1][0];
	polys[4].bounds[0][1] = boxBounds[1][1];
	polys[5].bounds[1][0] = boxBounds[0][0];

	bounds = boxBounds;
}
示例#2
0
PhysicalObject::PhysicalObject(const Scenable& obj) :
    mass(0.0f),
    velocity()
{
    const Box_t* box = &((Entity&)obj).GetMesh()->GetBox();
    vector<const Box_t*> vec_box(1,box);
    InitBox(vec_box);
    group.push_back(obj._GetId());
    obj.SetStageRef(*this);
}
int GameInitial(){
    InitializeCriticalSection(&cs);
    Screen.bar(0,0,SCREEN_WIDTH,SCREEN_HEIGHT,BLACK);
    InitBox();
    ShowBox();
    ShowScore();
    SDL_EnableKeyRepeat(400,KEYBREAK);
    ChangeTimes = 1;
    return 0;
}
示例#4
0
PhysicalObject::PhysicalObject(const vector<const Scenable*>& vec_group) : StageObject(vec_group),
    velocity(),
    mass(0.0f)
{
    vector<const Box_t*> box_vec;
    for (auto obj : vec_group) {
        box_vec.push_back(&((Entity*)obj)->GetMesh()->GetBox());
    }
    InitBox(box_vec);
}
示例#5
0
/* Simply creates a new box and sets the parent and child pointers correctly.
   The child's spot in the parent's children array determines its position.
   So, 0 is upper right, 1 is upper left, 2 is bottom left, and 3 is bottom
   right. That's how I know how to set the location of the child box's center
   just by knowing the child number. */
box *
CreateChild (long my_id, box *pb, long new_child_num)
{
   real child_length, child_offset;
   box *ret_box;

   child_length = pb->length / (real) NUM_DIMENSIONS;
   child_offset = pb->length / (real) NUM_OFFSPRING;
   if (new_child_num == 0) {
      pb->children[0] = InitBox(my_id, (pb->x_center + child_offset),
				(pb->y_center + child_offset), child_length,
				pb);
      pb->shadow[0] = pb->children[0];
   }
   if (new_child_num == 1) {
      pb->children[1] = InitBox(my_id, (pb->x_center - child_offset),
				(pb->y_center + child_offset), child_length,
				pb);
      pb->shadow[1] = pb->children[1];
   }
   if (new_child_num == 2) {
      pb->children[2] = InitBox(my_id, (pb->x_center - child_offset),
				(pb->y_center - child_offset), child_length,
				pb);
      pb->shadow[2] = pb->children[2];
   }
   if (new_child_num == 3) {
      pb->children[3] = InitBox(my_id, (pb->x_center + child_offset),
				(pb->y_center - child_offset), child_length,
				pb);
      pb->shadow[3] = pb->children[3];
   }
   pb->children[new_child_num]->child_num = new_child_num;
   ret_box = pb->children[new_child_num];
   pb->num_children += 1;
   return ret_box;
}
示例#6
0
box *
InitGrid (long my_id)
{
   real x_length, y_length;
   real grid_length, grid_x_center, grid_y_center;
   int exp;
   box *ret_box;

   frexp(Local[my_id].Local_X_Max, &exp);
   if (Local[my_id].Local_X_Max > 0)
      Local[my_id].Local_X_Max = ldexp(1.0, exp);
   else {
      if (Local[my_id].Local_X_Max < 0)
	 Local[my_id].Local_X_Max = -ldexp(1.0, exp - 1);
   }
   frexp(Local[my_id].Local_X_Min, &exp);
   if (Local[my_id].Local_X_Min < 0)
      Local[my_id].Local_X_Min = -ldexp(1.0, exp);
   else {
      if (Local[my_id].Local_X_Min > 0)
	 Local[my_id].Local_X_Min = ldexp(1.0, exp - 1);
   }
   frexp(Local[my_id].Local_Y_Max, &exp);
   if (Local[my_id].Local_Y_Max > 0)
      Local[my_id].Local_Y_Max = ldexp(1.0, exp);
   else {
      if (Local[my_id].Local_Y_Max < 0)
	 Local[my_id].Local_Y_Max = -ldexp(1.0, exp - 1);
   }
   frexp(Local[my_id].Local_Y_Min, &exp);
   if (Local[my_id].Local_Y_Min < 0)
      Local[my_id].Local_Y_Min = -ldexp(1.0, exp);
   else {
      if (Local[my_id].Local_Y_Min > 0)
	 Local[my_id].Local_Y_Min = ldexp(1.0, exp - 1);
   }

   x_length = Local[my_id].Local_X_Max - Local[my_id].Local_X_Min;
   y_length = Local[my_id].Local_Y_Max - Local[my_id].Local_Y_Min;
   if (x_length > y_length)
      grid_length = x_length;
   else
      grid_length = y_length;
   grid_x_center = (grid_length / (real) 2.0) + Local[my_id].Local_X_Min;
   grid_y_center = (grid_length / (real) 2.0) + Local[my_id].Local_Y_Min;

   ret_box = InitBox(my_id, grid_x_center, grid_y_center, grid_length, NULL);
   return ret_box;
}
示例#7
0
box *
CreateLeaf (long my_id, box *pb, long new_child_num, particle **p_array, long length)
{
   real child_length, child_offset;
   box *ret_box = NULL;
   long i;

   child_length = pb->length / (real) NUM_DIMENSIONS;
   child_offset = pb->length / (real) NUM_OFFSPRING;
   if (new_child_num == 0) {
      ret_box = InitBox(my_id, (pb->x_center + child_offset),
			(pb->y_center + child_offset), child_length,
			pb);
   }
   if (new_child_num == 1) {
      ret_box = InitBox(my_id, (pb->x_center - child_offset),
			(pb->y_center + child_offset), child_length,
			pb);
   }
   if (new_child_num == 2) {
      ret_box = InitBox(my_id, (pb->x_center - child_offset),
			(pb->y_center - child_offset), child_length,
			pb);
   }
   if (new_child_num == 3) {
      ret_box = InitBox(my_id, (pb->x_center + child_offset),
			(pb->y_center - child_offset), child_length,
			pb);
   }
   ret_box->child_num = new_child_num;
   for (i = 0; i < length; i++) {
      ret_box->particles[i] = p_array[i];
   }
   ret_box->num_particles = length;
   return ret_box;
}
示例#8
0
void StageObject::InitBox(const vector<const SpaceObject*>& vec_group)
{
    vector<const Box_t*> vec_box;

    //LOGE("[STAGEOBJECT][InitBox] SpaceObj vec size %d",vec_group.size());

    for (auto obj : vec_group) {
        vec_box.push_back(&(obj->GetBox()));
      //  LOGE("[STAGEOBJECT][InitBox] position %s", obj->GetBox().position.Print().c_str());
      //  LOGE("[STAGEOBJECT][InitBox] halfvec %s", obj->GetBox().halfVec.Print().c_str());
    }

    InitBox(vec_box);

}
示例#9
0
BOOL DlgGasAccum::OnInitDialog() 
{
	DlgJun::OnInitDialog();
	// TODO: Add extra initialization here
	CString strTitle;
	strTitle.LoadString(IDS_STRGASACCUM);
	SetWindowText(strTitle);
	m_DlgEle.Create(IDD_DLGONEElE,this);
	InitBox(m_DlgEle);
	m_tab.AddPage("空气罐模型",&m_page1,IDD_GASACCUMMODEL);
	m_tab.AddPage("管道流向",&m_page2,IDD_PAGEPIPEDIR);
	m_tab.AddPage(IDS_STRPAGEOPTION,&m_page3,IDD_GASACCUMOPTION);
	m_tab.AddPage(IDS_STRSTATUS,&m_pageStatus,IDD_PAGESTATUS);
	m_tab.Show();
	Init();
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}
示例#10
0
文件: main.c 项目: theStack/bluecube
/*=========================================================================
// Name: NewGame()
// Desc: Starts a new game
//=======================================================================*/
void NewGame()
{
    InitBox(); /* Clear Box */
    BoxDrawInit(); /* Init boxdraw values */
    DestroyParticles(); /* Destroy any particles that might be left */
    
    lines = 0; /* Reset lines counter */
    score = 0; /* Reset score */
    level = 0; /* Reset level */
    nextPiece = rand()%7; /* Create random nextPiece */
    NewCluster();

    bPause = 0; /* No pause */
    bCrazy = 0; /* No crazymode :) */
    bGameOver = 0;

    gamestate = STATE_PLAY; /* Set playstate */
}
示例#11
0
BOOL DlgDeadEnd::OnInitDialog() 
{
	DlgJun::OnInitDialog();
	
	// TODO: Add extra initialization here
	CString strTitle;
	strTitle.LoadString(IDS_STRDEADEND);
	SetWindowText(strTitle);
	m_DlgEnd.Create(IDD_DLGONEEND,this);
	InitBox(m_DlgEnd);
	m_tab.AddPage(IDS_STRPAGEOPTION,&m_page1,IDD_DEADENDOPTION);
	m_tab.AddPage(IDS_STRSTATUS,&m_pageStatus,IDD_PAGESTATUS);
	m_tab.Show();
	
	Init();
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}
示例#12
0
BOOL DlgAreaChange::OnInitDialog() 
{
	DlgJun::OnInitDialog();
	
	// TODO: Add extra initialization here
	CString strTitle;
	strTitle.LoadString(IDS_STRAREACHANGE);
	SetWindowText(strTitle);
	m_DlgEle.Create(IDD_DLGTWOEND,this);
	InitBox(m_DlgEle);
	m_tab.AddPage(_T("Ò쾶¹ÜÄ£ÐÍ"),&m_page1,IDD_AREACHANGEMODEL);
	m_tab.AddPage(IDS_STRPAGEOPTION,&m_page2,IDD_DLGAREACHANGEOPTION);
	m_tab.AddPage(IDS_STRSTATUS,&m_pageStatus,IDD_PAGESTATUS);
	m_tab.Show();

	Init();
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}
示例#13
0
BOOL DlgAssigPress::OnInitDialog() 
{
	DlgJun::OnInitDialog();
	
	// TODO: Add extra initialization here
	CString strTitle;
	strTitle.LoadString(IDS_STRASSIGNPRESS);
	SetWindowText(strTitle);
	m_DlgEle.Create(IDD_DLGONEElE,this);
	InitBox(m_DlgEle);
	m_tab.AddPage("压力模型",&m_page1,IDD_PAGEPRESS1);
	m_tab.AddPage("损失系数",&m_page2,IDD_PAGEBRANCH1);
	m_tab.AddPage(IDS_STRPAGETRANS,&m_page3,IDD_PAGETRANS3);
	m_tab.AddPage(IDS_STRPAGEOPTION,&m_page4,IDD_ASSIGNPRESSOPTION);
	m_tab.AddPage(IDS_STRSTATUS,&m_pageStatus,IDD_PAGESTATUS);
	m_tab.Show();

	Init();
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}
示例#14
0
StageObject::StageObject(const vector<const StageObject*>& vec_group):
    name(vec_group.front()->_GetName()),
    visible(true),
    selected(false)
{
	vector<const SpaceObject*> vec_space;

	for (auto obj : vec_group) {
	       // LOGE("[STAGEOBJECT][StageObject] position %s", obj->GetBox().position.Print().c_str());
	       // LOGE("[STAGEOBJECT][StageObject] halfvec %s", obj->GetBox().halfVec.Print().c_str());
	        vec_space.push_back(dynamic_cast<const SpaceObject*>(obj));
	    }

	for (auto obj : vec_space) {
		     //   LOGE("[STAGEOBJECT][StageObject] vec_space position %s", obj->GetBox().position.Print().c_str());
		     //   LOGE("[STAGEOBJECT][StageObject] vec_space halfvec %s", obj->GetBox().halfVec.Print().c_str());
	}

   // InitBox(Translate<StageObject,SpaceObject>(vec_group));
	 InitBox(vec_space);
    InitGroup(Translate<StageObject,GusObject>(vec_group));
}
示例#15
0
LLRegion::LLRegion( const LLBBox& llbbox )
{
    InitBox(llbbox.GetMinLat(), llbbox.GetMinLon(), llbbox.GetMaxLat(), llbbox.GetMaxLon());
}
示例#16
0
LLRegion::LLRegion( float minlat, float minlon, float maxlat, float maxlon)
{
    InitBox(minlat, minlon, maxlat, maxlon);
}