TPolyLine3D* BasicHorizontalRectangularDetectorElement::GeneratePolyLine3D()
{
	TPolyLine3D* pPolyLine = new TPolyLine3D(5);
//	printf("---------MinX: %f, Maxx:%f, Miny: %f, MaxY:%f, Z: %f\n", GetMinX(), GetMaxX(), GetMinY(), GetMaxY(), GetZOffset());
	pPolyLine->SetPoint(0, GetMinX(), GetMinY(), GetZOffset());
	pPolyLine->SetPoint(1, GetMaxX(), GetMinY(), GetZOffset());
	pPolyLine->SetPoint(2, GetMaxX(), GetMaxY(), GetZOffset());
	pPolyLine->SetPoint(3, GetMinX(), GetMaxY(), GetZOffset());
	pPolyLine->SetPoint(4, GetMinX(), GetMinY(), GetZOffset());
	return pPolyLine;
}
Exemple #2
0
void Camera::SetY(double y) {
	if ( !HasBounds() ) {
		this->y = y;
	} else {
		if ( y < GetMinY() )
			this->y = GetMinY();
		else if ( y > GetMaxY() )
			this->y = GetMaxY();
		else
			this->y = y;
	}
}
void FunctionSimple::SetMaxY(float f)
{
  // Offset is avg of min and max.
  m_offsetY = (f + GetMinY()) / 2.0f;
  // Multiplier is max - offset, or offset - min
  m_multiplierY = fabs(f - m_offsetY);
}
bool FGAFRect::IntersectsRect(const FGAFRect& rect) const
{
    return !(     GetMaxX() < rect.GetMinX() ||
             rect.GetMaxX() <      GetMinX() ||
                  GetMaxY() < rect.GetMinY() ||
             rect.GetMaxY() <      GetMinY());
}
Exemple #5
0
double XYDataset::GetMinValue(bool verticalAxis)
{
	if (verticalAxis) {
		return GetMinY();
	}
	else {
		return GetMinX();
	}
}
bool FGAFRect::ContainsPoint(const FVector2D& point) const
{
    bool bRet = false;

    if (point.X >= GetMinX() && point.X <= GetMaxX()
        && point.Y >= GetMinY() && point.Y <= GetMaxY())
    {
        bRet = true;
    }

    return bRet;
}
void FGAFRect::Merge(const FGAFRect& rect)
{
    float top1 = GetMaxY();
    float left1 = GetMinX();
    float right1 = GetMaxX();
    float bottom1 = GetMinY();
    
    float top2 = rect.GetMaxY();
    float left2 = rect.GetMinX();
    float right2 = rect.GetMaxX();
    float bottom2 = rect.GetMinY();
    Origin.X = FMath::Min(left1, left2);
    Origin.Y = FMath::Min(bottom1, bottom2);
    Size.Width = FMath::Max(right1, right2) - Origin.X;
    Size.Height = FMath::Max(top1, top2) - Origin.Y;
}
Exemple #8
0
    bool BattleRideFighter::PreGetObject()
    { 
        //获取战斗对象
        PreGetObject1() ;
        if(!_target)
            return false;
        if(count > 3)
            return false;
        if(!count || (getPosX() == _battleTargetX && getPosY() == _battleTargetY ))// || getPosX() >= (FIELD_WIDTH - 100) )
        {
            switch(count)
            {
                case 0:  //第一次出发
                    {
                        _battleTargetX = (getPosX() > (FIELD_WIDTH)/2) ? 100:(FIELD_WIDTH-100);
                        break;
                    }
                case 1:  //回头
                    {
                        _battleTargetX = GetMinX();
                        _battleTargetY = GetMinY();
                        break;
                    }
                case 2:  //停
                    {
                        SetBattleTargetPos(getPosX(),getPosY());
                        break;
                    }
                default:
                    return false ;
            }
            count++;
            //COUT << "战将编号:" << static_cast<UInt32>(GetBSNumber()) << "目的地:" << static_cast<UInt32>(_battleTargetX) << " , " << static_cast<UInt32>(_battleTargetY) << std::endl;
        }


        if(!_battleTargetY)
        {
            _battleTargetY = _target->getPosY();
        }
        BuildLocalStream(e_run);
        return true;
    } 
Exemple #9
0
Tank::Tank() :
_Body(Sprite::Create(LR"(Resources/Images/tank_body.png)")),
_Head(Sprite::Create(LR"(Resources/Images/tank_head.png)")),
_Gauge_Back(Sprite::Create(LR"(Resources/Images/gauge_back.png)")),
_Gauge_Front(Sprite::Create(LR"(Resources/Images/gauge_front.png)")),
_Bullet(Bullet::Create())
{
	_Body->SetAnchorPoint(Point::ANCHOR_MIDDLE_BOTTOM);
	auto bodyBox = _Body->GetBoundingBox();

	_Head->SetPosition(bodyBox.GetMidX(), bodyBox.GetMinY());
	_Head->SetAnchorPoint(Point(0.2f, 0.5f));

	_Gauge_Back->SetPosition(-150.f, -50.f);
	_Gauge_Back->SetAnchorPoint(Point::ANCHOR_MIDDLE_BOTTOM);

	_Gauge_Front->SetPosition(_Gauge_Back->GetPosition());
	_Gauge_Front->SetAnchorPoint(Point::ANCHOR_MIDDLE_BOTTOM);

	_Bullet->SetPosition(CalcBulletPos());

	for (float elapseTime = 0.f; elapseTime < TRACKPOINT_LIFE; elapseTime += TRACKPOINT_CREATE_CYCLE)
	{
		auto trackPoint = TrackPoint::Create();
		trackPoint->SetPosition(_Bullet->GetPosition());
		trackPoint->SetElapseTime(elapseTime);
		trackPoint->SetVisible(false);
		this->AddChild(trackPoint);

		_Track.push_back(trackPoint);
	}

	this->AddChild(_Bullet);
	this->AddChild(_Gauge_Back);
	this->AddChild(_Gauge_Front);
	this->AddChild(_Head);
	this->AddChild(_Body);
}
int CIppsSignalDC::GetY0(int zero) { return zero - GetMinY();}
int CIppsSignalDC::GetZeroIm() {
   return GetSpaceHeight()*2 + GetMaxY()*2 - GetMinY(); }
void CUmbralActor::RebuildActorRenderables()
{
	uint32 modelFolder = m_baseModelId % 10000;
	uint32 modelClass = m_baseModelId / 10000;
	const char* charaFolder = "";
	const char* charaPrefix = "";
	switch(modelClass)
	{
	case 1:
		charaFolder = "mon";
		charaPrefix = "m";
		break;
	case 2:
		charaFolder = "bgobj";
		charaPrefix = "b";
		break;
	case 4:
		charaFolder = "wep";
		charaPrefix = "w";
		break;
	default:
		assert(0);
		break;
	}

	uint32 subModelId = m_topModelId >> 10;
	uint32 variation = m_topModelId & 0x3FF;

	auto gamePath = CFileManager::GetGamePath();
	auto modelPath = string_format("%s/client/chara/%s/%s%0.3d/equ/e%0.3d/top_mdl/0001",
		gamePath.string().c_str(), charaFolder, charaPrefix, modelFolder, subModelId);

	Framework::CStdStream inputStream(modelPath.c_str(), "rb");

	auto modelResource = CSectionLoader::ReadSection(ResourceNodePtr(), inputStream);

	auto modelChunk = modelResource->SelectNode<CModelChunk>();
	assert(modelChunk);
	if(!modelChunk) return;

	auto boundingBox = modelChunk->SelectNode<CCompChunk>();

	CVector3 boxMin(boundingBox->GetMinX(), boundingBox->GetMinY(), boundingBox->GetMinZ());
	CVector3 boxMax(boundingBox->GetMaxX(), boundingBox->GetMaxY(), boundingBox->GetMaxZ());

	CVector3 modelSize = (boxMax - boxMin) / 2;
	CVector3 modelPos = (boxMax + boxMin) / 2;

	auto model = std::make_shared<CUmbralModel>(modelChunk);
	model->SetPosition(modelPos);
	model->SetScale(modelSize);
	AppendChild(model);

	auto modelBoundingSphere = model->GetBoundingSphere();
	modelBoundingSphere.radius *= std::max(std::max(modelSize.x, modelSize.y), modelSize.z);
	modelBoundingSphere.position += modelPos;
	m_boundingSphere = modelBoundingSphere;

	uint32 textureId = 0;
	if(modelClass == 4)
	{
		uint32 varWepId = 1000000000 + (modelFolder * 1000000) + (subModelId * 1000) + variation;
		auto var = CWeaponVars::GetInstance().GetVarForId(varWepId);
		textureId = var.textureId;

		for(const auto& meshNode : model->GetChildren())
		{
			if(auto mesh = std::dynamic_pointer_cast<CUmbralMesh>(meshNode))
			{
				auto meshName = mesh->GetName();
				int materialId = 0;
				if(meshName.find("_a") != std::string::npos)
				{
					materialId = 0;
				}
				if(meshName.find("_b") != std::string::npos)
				{
					materialId = 1;
				}
				if(meshName.find("_c") != std::string::npos)
				{
					materialId = 2;
				}
				if(meshName.find("_d") != std::string::npos)
				{
					assert(0);
				}
				const auto& varWepMaterial = var.materials[materialId];
				auto material = mesh->GetMaterial();
				ReplaceMaterialParam(material, "ps_diffuseColor", varWepMaterial.diffuseColor);
				ReplaceMaterialParam(material, "ps_multiDiffuseColor", varWepMaterial.multiDiffuseColor);
				ReplaceMaterialParam(material, "ps_specularColor", varWepMaterial.specularColor);
				ReplaceMaterialParam(material, "ps_multiSpecularColor", varWepMaterial.multiSpecularColor);
				ReplaceMaterialParam(material, "ps_reflectivity", varWepMaterial.specularColor);
				ReplaceMaterialParam(material, "ps_multiReflectivity", varWepMaterial.multiSpecularColor);
				ReplaceMaterialParam(material, "ps_shininess", varWepMaterial.shininess);
				ReplaceMaterialParam(material, "ps_multiShininess", varWepMaterial.multiShininess);
				mesh->SetActivePolyGroups(var.polyGroupState);
			}
		}
	}

	{
		auto texturePath = string_format("%s/client/chara/%s/%s%0.3d/equ/e%0.3d/top_tex2/%0.4d",
			gamePath.string().c_str(), charaFolder, charaPrefix, modelFolder, subModelId, textureId);

		Framework::CStdStream inputStream(texturePath.c_str(), "rb");
		auto textureResource = CSectionLoader::ReadSection(ResourceNodePtr(), inputStream);
		model->SetLocalTexture(textureResource);
	}

	m_renderableDirty = false;
}
Exemple #13
0
bool FData::SetValue(int Pos, double _Value, FDataMode _DataMode, int _UndoFlags)
{
    const int Id = GetId(0); // Procura o Id do arquivo de edição

    if(Id < 0) return false; // O arquivo de edição não está aberto

    FFile &file = Files[Id];

    // Quando ocorrer uma edição o refazer deve ser rezetado, exceto quado a edição for
    // chamada pelo Undo() ou pelo próprio Redo().
    if(CanClearRedo) RedoClear();

    Pos -= file.Offset; // Offset do arquivo. Desloca o arquivo em relação aos outros.

    // OffSet que deverá ser subtraído ao final do arquivo, a depender do modo.
    // Ex. Na visualização de 16Bits de um arquivo de tamanho 7FFF (8000 - 1 = Size - 1) o endereço 7FFF não
    // pode ser selecionado, pois ultrapassaria o tamanho do arquivo.
    const int _OffSetByte = GetPosByte(1, _DataMode);

    // Verifica se a posição informada está dentro do range do arquivo
    if( (Pos < 0) || (Pos > (GetSizeFile(Id) - _OffSetByte)) ) return false;

    // Verifica se valor a ser escrito no buffer está em conformidade com o modo informado
    if( (_Value > GetMaxY(_DataMode)) || (_Value < GetMinY(_DataMode)) ) return false;

    if(_UndoFlags & ADD_UNDO_POINT) AddUndoPoint();
    if(_UndoFlags & ADD_UNDO) AddUndoValue(Pos, _DataMode);


    /*union
    {
       word8s Tmp8bs[4];
       word16s Tmp16bs[2];
       word32s Tmp32bs;
       float TmpFloat;
     };*/

    union
    {
       word8 Tmp8b[4];
       word8s Tmp8bs[4];
       word16 Tmp16b[2];
       word16s Tmp16bs[2];
       word32 Tmp32b;
       word32s Tmp32bs;
       float TmpFloat;
     };

     Tmp32bs = 0; //Zera todas as variáveis da união.


       switch(_DataMode.Mode)
       {
             case BITS8:
                     if(_DataMode.Signal) Tmp8bs[0] = _Value;
                     else Tmp8b[0] = _Value;
                     file.Buffer[Pos] = Tmp8bs[0];
                     break;
             case BITS16:
                     if(_DataMode.Signal) Tmp16bs[0] = _Value;
                     else Tmp16b[0] = _Value;
                     if(_DataMode.Swap) // No PC por padrão os bytes ja são invertidos.
                     {
                       file.Buffer[Pos] = Tmp8bs[0];
                       file.Buffer[Pos + 1] = Tmp8bs[1];
                     }
                     else
                     {
                       file.Buffer[Pos] = Tmp8bs[1];
                       file.Buffer[Pos + 1] = Tmp8bs[0];
                     }
                     break;
             case BITS32:
                     if(_DataMode.Signal) Tmp32bs = _Value;
                     else Tmp32b = _Value;
                     if(_DataMode.Swap) // No PC por padrão os bytes ja são invertidos.
                     {
                       file.Buffer[Pos] = Tmp8bs[0];
                       file.Buffer[Pos + 1] = Tmp8bs[1];
                       file.Buffer[Pos + 2] = Tmp8bs[2];
                       file.Buffer[Pos + 3] = Tmp8bs[3];
                     }
                     else
                     {
                       file.Buffer[Pos] = Tmp8bs[3];
                       file.Buffer[Pos + 1] = Tmp8bs[2];
                       file.Buffer[Pos + 2] = Tmp8bs[1];
                       file.Buffer[Pos + 3] = Tmp8bs[0];
                     }
                     break;
             case BITSF:
                     TmpFloat = _Value;
                     if(_DataMode.Swap) // No PC por padrão os bytes ja são invertidos.
                     {
                       file.Buffer[Pos] = Tmp8bs[0];
                       file.Buffer[Pos + 1] = Tmp8bs[1];
                       file.Buffer[Pos + 2] = Tmp8bs[2];
                       file.Buffer[Pos + 3] = Tmp8bs[3];
                     }
                     else
                     {
                       file.Buffer[Pos] = Tmp8bs[3];
                       file.Buffer[Pos + 1] = Tmp8bs[2];
                       file.Buffer[Pos + 2] = Tmp8bs[1];
                       file.Buffer[Pos + 3] = Tmp8bs[0];
                     }

       }

    return true;

}
	//-----------------------------------------------------------------------
	//체인 테이블 생성 및 PreProcessing
	//-----------------------------------------------------------------------
	Dvoid RenderModule::CreateChainTable(vector<Line>& vecLine, vector<ActiveLine>& activeTable)
	{
		assert(!vecLine.empty());
		
		auto maxIter = max_element(begin(vecLine), end(vecLine), [](const Line& lhs, const Line& rhs)	{	return lhs.beginVertex.y < rhs.beginVertex.y; 	});
		auto minIter = min_element(begin(vecLine), end(vecLine), [](const Line& lhs, const Line& rhs)	{	return lhs.beginVertex.y < rhs.beginVertex.y;	});

		Dint maxY = (Dint)maxIter->beginVertex.y;
		Dint minY = (Dint)minIter->beginVertex.y;

		vector<Line> currentLine;
		currentLine.reserve(3);

		for (Dint y = minY; y < maxY; ++y)
		{				
			currentLine.clear();
			for (auto lineIter = vecLine.begin(); lineIter != vecLine.end();)
			{
				ITER_CONVERT(pLine, &(*lineIter));
				if (y == pLine->beginVertex.y || y == pLine->endVertex.y) //해당 y축에 정점이 걸치는지 검사			 	
				{
					currentLine.emplace_back( *pLine );
					lineIter = vecLine.erase(lineIter);
				}
				else
				{
					++lineIter;
				}
			} // 현재 라인에 포함가능한 엣지들 모두 포함
						
			if( currentLine.empty() )
			{
				continue;
			}		
			
			for( auto chainIter = currentLine.begin(); chainIter != currentLine.end(); )
			{
				auto checkOneCountIter = STD_FIND_IF(currentLine, [&] (const Line& line){	return CheckContinueLine(chainIter->lineKey, line.lineKey);		});
				if( checkOneCountIter == currentLine.end() )	//특정 정점이 연결되어 있지 않다 ( 1번만 카운트 됨 14_ScanLineFill.pdf 참조 )
				{					
					if( chainIter->isOneCount == false )
					{
						chainIter->isOneCount = true;
						++(chainIter->GetMinY());		 //y축 값 1올리기								
						vecLine.emplace_back(*chainIter);//다시 검색하기 위해서 리스트에 넣어두자						
						chainIter = currentLine.erase(chainIter);
					}
					else
					{
						++chainIter;
					}
				}
				else
				{
					++chainIter;
				}				
			}
						
			if( !currentLine.empty() )
			{
				STD_ERASE(currentLine, STD_REMOVE_IF(currentLine, [] (const Line& l){ return l.beginVertex.y == l.endVertex.y; }));
				activeTable.emplace_back(y, currentLine);
			}
		}	
	}