Ejemplo n.º 1
0
mm::Piece::Piece(std::string const& s)
    : mRotation(0)
    , mMaxRotations(0)
    , mPosX(InvalidPosition.first)
    , mPosY(InvalidPosition.second)
    , isSpecial(false)
    , originalStr(s)
{
    mStr[0] = CharToInt(s[3]);
    mStr[1] = CharToInt(s[0]);
    mStr[2] = CharToInt(s[1]);
    mStr[3] = CharToInt(s[2]);

    mL[0] = 100*BL() + 10*TL() + TR();
    mL[1] = 100*TL() + 10*TR() + BR();
    mL[2] = 100*TR() + 10*BR() + BL();
    mL[3] = 100*BR() + 10*BL() + TL();

    if      (mStr[0] == mStr[1] && mStr[1] == mStr[2] && mStr[0] == mStr[3]) { mMaxRotations = 1; }
    else if (mStr[0] == mStr[2] && mStr[1] == mStr[3])                       { mMaxRotations = 2; }
    else                                                                     { mMaxRotations = 4; }

    if (s == "GGGG" || s == "BBBB" || s == "YYYY" || s == "YRBG")
    {
        isSpecial = true;
    }
}
// заполнить содержимое региона для локации входа (вторая)
bool DynamicReg::CreateContentL1() {

	// обнулить количество экземпляров
	ZeroMemory(vectInstanceAmount, sizeof(UINT)* TerrainVectorModels.size());

	// перезаписать содержимое
	for (int i(0); i < Const::regionCellSize; i++) {
		for (int j(0); j < Const::regionCellSize; j++) {
			content[i][j] = CellFiller();
			content[i][j].biomType = B_DREAMFOREST;
			float xAdress = regionAdress.x * (float)Const::regionCellSize + i;
			float yAdress = regionAdress.y * (float)Const::regionCellSize + j;
			float treeFunction = Mediator::superFunct->TreeFunction(xAdress, yAdress);
			float random = Mediator::superFunct->FullRandom0(xAdress, yAdress); // полная случайность

			// генерация содержимого
			if (treeFunction > 0.0f) {
				if (random > 0.3f) { BR(GenerateItem(regionAdress, NumXY<UINT>(i, j), CI_TT1)); }
				else if (random > -0.3f) { BR(GenerateItem(regionAdress, NumXY<UINT>(i, j), CI_TT2)); }
				else { BR(GenerateItem(regionAdress, NumXY<UINT>(i, j), CI_TT3)); }
			}

		} // для каждой ячейки
	}

	// обновить описатели
	for (UINT i(0); i < TerrainVectorModels.size(); i++) {
		if (vectInstanceAmount[i]) BR(TerrainVectorModels[i]->AddDescription(regionAdress, vectInstanceAmount[i]));
	}

	return true;

}
// заполнить содержимое региона для тестовой локации
bool DynamicReg::CreateTestedLocationContent() {

	// обнулить количество экземпляров
	ZeroMemory(vectInstanceAmount, sizeof(UINT)* TerrainVectorModels.size());

	// перезаписать содержимое
	for (int i(0); i < Const::regionCellSize; i++) {
		for (int j(0); j < Const::regionCellSize; j++) {
			content[i][j] = CellFiller();
			content[i][j].biomType = B_TESTED;
			float xAdress = regionAdress.x * (float)Const::regionCellSize + i;
			float yAdress = regionAdress.y * (float)Const::regionCellSize + j;

			// режим отладки одиночного объекта
			BR(GenerateItem(regionAdress, NumXY<UINT>(i, j), 0)); // тестируемый объект


		} // для каждой ячейки
	}

	// обновить описатели
	for (UINT i(0); i < TerrainVectorModels.size(); i++) {
		if (vectInstanceAmount[i]) BR(TerrainVectorModels[i]->AddDescription(regionAdress, vectInstanceAmount[i]));
	}

	return true;

}
Ejemplo n.º 4
0
// нанести уров в точку
bool ArtInt::TakeDamage(myXMFLOAT3 position, float damage) {

	BR(boars->GetDamage(position, damage));
	BR(devils->GetDamage(position, damage));

	return true;

}
Ejemplo n.º 5
0
void BR(int k)
{
    if (k==num) count++;
    else
    {
        a[sao[k]]=49;
        if (Check_if_free(sao[k+1]-1)) BR(k+1);
        a[sao[k]]=48;
        if (Check_if_free(sao[k+1]-1)) BR(k+1);
    }
}
Ejemplo n.º 6
0
// рисование ИИ
bool ArtInt::Draw(bool toShadowMap) {

	// установка параметров
	Mediator::pDevContext->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST);

	// рисование персов
	BR(boars->Draw(toShadowMap)); // пауки
	BR(devils->Draw(toShadowMap)); // коровы

	return true;

}
Ejemplo n.º 7
0
// рисование меню
bool Menu::Draw() {

	// рисование заднего фона
	BR(backgrounds[menuState]->Draw());

	// рисование кнопок
	for (auto iter = buttons.begin(); iter != buttons.end(); iter++) {
		if ((*iter)->visible && !(*iter)->transarent) BR((*iter)->Draw());
	}

	return true;

}
Ejemplo n.º 8
0
// рисование
bool Map::Draw() {

	UINT vertexStride = sizeof(VertMap);
	UINT vertexOffset = 0;

	// установить параметры
	Mediator::pDevContext->IASetIndexBuffer(pIndexBuffer, DXGI_FORMAT_R32_UINT, 0);
	Mediator::pDevContext->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
	Mediator::pDevContext->IASetInputLayout(Mediator::pInputLayoutPosCol);
	Mediator::pDevContext->VSSetShader(Mediator::pVSPosCol, NULL, 0);
	Mediator::pDevContext->PSSetShader(Mediator::pPSPosCol, NULL, 0);

	// ???
	int x = 0;
	int y = 0;
	int z = 0;
	x = (int)Mediator::winDimentions->x / 2 - (int)Mediator::hero->GetPosition().x;
	y = (int)Mediator::winDimentions->y / 2 - (int)Mediator::hero->GetPosition().z;

	XMMATRIX world = XMMatrixTranslation((float)x, (float)y, (float)z);
	Mediator::shader->SetObjectBuffer(world);

	// рисование
	BR(patchField[0][0]->Draw()); // ???

	return true;

}
Ejemplo n.º 9
0
void GEMENI_charsent() {
	unsigned long r = s->log[s->lc];
	if (UCA0IFG & UCTXIFG) {
		s->nch++;
		switch (s->nch) {
			case 1:
				UCA0TXBUF = SL(r) << 5 |TL(r)<<4|KL(r)<<3|PL(r)<<2|WL(r)<<1|HL(r);
			break;
			case 2:
				UCA0TXBUF = RL(r)<<6 | AL(r)<<5 | OL(r)<<4 | STAR(r)<<3;
			break;
			case 3:
				UCA0TXBUF = ER(r)<<3 | UR(r)<<2 | FR(r)<<1 | RR(r);
			break;
			case 4:
				UCA0TXBUF = PR(r)<<6 | BR(r)<<5 | LR(r)<<4 | GR(r)<<3 | TR(r)<<2 | SR(r)<<1 | DRS(r);
			break;
			case 5:
				UCA0TXBUF = POUND(r)<<1 | ZRS(r);
			break;
			default:
				s->lc++;
				if (s->lc != s->nc-1) {

  					s->nch = 0;
  					UCA0TXBUF = 1 << 7; // first packet, no fn or '#'
				} else {
					s->flags &= ~CSEND;
				}

		}
	}
}
Ejemplo n.º 10
0
void fillWall(struct TILE *map, int sy, int sx, int ft, int wt){
	int y, x;
	for(y = 1; y < sy - 1; y++){
		for(x = 1; x < sx - 1; x++){
			if(map[CM(y,sx,x)].tT == TILE_BLANK){
				if(map[TL(y,sx,x)].tT == ft ||
				map[TM(y,sx,x)].tT == ft ||
				map[TR(y,sx,x)].tT == ft ||
				map[CL(y,sx,x)].tT == ft ||
				map[CR(y,sx,x)].tT == ft ||
				map[BL(y,sx,x)].tT == ft ||
				map[BM(y,sx,x)].tT == ft ||
				map[BR(y,sx,x)].tT == ft){
					map[CM(y,sx,x)].tT = wt;
				}
			}
		}
	}
	for(y = 0; y < sy; y++){
		for(x = 0; x < sx; x++){
			if(y == 0){
				if(map[S(y,sx,x)].tT == ft) map[C(y,sx,x)].tT = wt;
			}
			if(x == 0){
				if(map[E(y,sx,x)].tT == ft) map[C(y,sx,x)].tT = wt;
			}
			if(y == sy - 1){
				if(map[N(y,sx,x)].tT == ft) map[C(y,sx,x)].tT = wt;
			}
			if(x == sx - 1){
				if(map[W(y,sx,x)].tT == ft) map[C(y,sx,x)].tT = wt;
			}
		}
	}
}
Ejemplo n.º 11
0
// сброс спрайта
bool Sprite::Reset() {

	// сброс матрицы перемещения
	BR(UpdateMatrixTranslation(*Mediator::winDimentions));

	return true;

}
Ejemplo n.º 12
0
    Function* Create(const STREAMOUT_COMPILE_STATE& state)
    {
        static std::size_t soNum = 0;

        std::stringstream fnName("SOShader", std::ios_base::in | std::ios_base::out | std::ios_base::ate);
        fnName << soNum++;

        // SO function signature
        // typedef void(__cdecl *PFN_SO_FUNC)(SWR_STREAMOUT_CONTEXT*)

        std::vector<Type*> args{
            PointerType::get(Gen_SWR_STREAMOUT_CONTEXT(JM()), 0), // SWR_STREAMOUT_CONTEXT*
        };

        FunctionType* fTy = FunctionType::get(IRB()->getVoidTy(), args, false);
        Function* soFunc = Function::Create(fTy, GlobalValue::ExternalLinkage, fnName.str(), JM()->mpCurrentModule);

        // create return basic block
        BasicBlock* entry = BasicBlock::Create(JM()->mContext, "entry", soFunc);
        BasicBlock* returnBB = BasicBlock::Create(JM()->mContext, "return", soFunc);

        IRB()->SetInsertPoint(entry);

        // arguments
        auto argitr = soFunc->getArgumentList().begin();
        Value* pSoCtx = &*argitr++;
        pSoCtx->setName("pSoCtx");

        const STREAMOUT_STREAM& streamState = state.stream;
        buildStream(state, streamState, pSoCtx, returnBB, soFunc);

        BR(returnBB);

        IRB()->SetInsertPoint(returnBB);
        RET_VOID();

        JitManager::DumpToFile(soFunc, "SoFunc");

        ::FunctionPassManager passes(JM()->mpCurrentModule);

        passes.add(createBreakCriticalEdgesPass());
        passes.add(createCFGSimplificationPass());
        passes.add(createEarlyCSEPass());
        passes.add(createPromoteMemoryToRegisterPass());
        passes.add(createCFGSimplificationPass());
        passes.add(createEarlyCSEPass());
        passes.add(createInstructionCombiningPass());
        passes.add(createInstructionSimplifierPass());
        passes.add(createConstantPropagationPass());
        passes.add(createSCCPPass());
        passes.add(createAggressiveDCEPass());

        passes.run(*soFunc);

        JitManager::DumpToFile(soFunc, "SoFunc_optimized");

        return soFunc;
    }
Ejemplo n.º 13
0
vector compgene(cmatrix& A,cmatrix& B)
{
    int i;
	int N=A.Rows;
	int IFAIL=0;
	int MATV=0;
	int*  ITER=new int[N];
	vector ALFR(N);
	vector ALFI(N);
	vector BETA(N);
	double EPS1=0.;
	matrix AR(N,N);
	matrix AI(N,N);
	matrix BR(N,N);
	matrix BI(N,N);
	for (i=0;i<N;i++) for (int j=0;j<N;j++) {
		AR(i,j)=real(A(i,j));
		AI(i,j)=imag(A(i,j));
		BR(i,j)=real(B(i,j));
		BI(i,j)=imag(B(i,j));
	}
	matrix VR(N,N);
	matrix VI(N,N);

	/* f02gjf_(&N,AR.TheMatrix,&N,AI.TheMatrix,&N,BR.TheMatrix,&N,
			BI.TheMatrix,&N,&EPS1,ALFR.TheVector,ALFI.TheVector,
			BETA.TheVector,&MATV,VR.TheMatrix,&N, 
           VI.TheMatrix,&N,ITER,&IFAIL); */
	cerr<<"compgene to be implemented"<<endl;
        exit(1);

	if (IFAIL != 0) cerr <<"error in compgene "<<endl;
	if (!ALFR.TheVector) exit(1);
	for (i=0;i<N;i++) ALFR(i)=ALFR(i)/BETA(i);
// sort !
	char ORDER='A';
	int M1=1;
	int M2=N;
	/* m01caf_(ALFR.TheVector,&M1,&M2,&ORDER,&IFAIL);*/
	 cerr<<"sort to be implemented"<<endl;
        exit(1);

	if (IFAIL != 0) cerr <<"error in m01caf_ "<<endl;
	return ALFR;
}
Ejemplo n.º 14
0
// обновление ИИ
bool ArtInt::Update(float dT, NumXY<float> showPoint) {

	// рождение персов
	static float persTime = persSpawnTime;
	persTime -= dT;
	if (persTime < 0.0f) {
		persTime += persSpawnTime;
		TrySpawn(showPoint, 0);
		TrySpawn(showPoint, 1);
	}

	// обновление векторов персов
	BR(boars->Update(dT, showPoint)); // пауки
	BR(devils->Update(dT, showPoint)); // коровы

	return true;

}
Ejemplo n.º 15
0
// сброс
bool Menu::Reset() {

	// сброс родителя
	Sprite* parent = this;
	BR(parent->Reset());

	// сброс кнопок
	for (auto iter = buttons.begin(); iter != buttons.end(); iter++) {
		BR((*iter)->Reset());
	}

	// сброс задних фонов
	for (auto iter = backgrounds.begin(); iter != backgrounds.end(); iter++) {
		BR((*iter)->Reset());
	}

	return true;

}
Ejemplo n.º 16
0
// обновление камеры
bool Camera::Update(float dT, myXMFLOAT3 heroPosition) {

	camFocus = heroPosition;

	// обновление радиуса камеры
	if (Mediator::mouseChange->wheelShift) {
		radius -= Const::scrollSpeed * Mediator::mouseChange->wheelShift * (radius + 5);
		radius = MathHelper::Clutch(radius, minRadius, Const::maxRadius);
	}
	// обновление азимута
	if (Mediator::mouseChange->cursorShift.x && Mediator::mouseChange->holdButtons[1]) {
		azimuth += Mediator::mouseChange->cursorShift.x * rotationSpeed;
		if (azimuth < -XM_2PI) azimuth += XM_2PI;
		if (azimuth > XM_2PI) azimuth -= XM_2PI;
	}
	// обновление тангажа
	if (!Const::releaseCamera && Mediator::mouseChange->cursorShift.y && Mediator::mouseChange->holdButtons[1]) {
		pitch += Mediator::mouseChange->cursorShift.y * rotationSpeed;
		pitch = MathHelper::Clutch(pitch, Const::pitchLimit.x, Const::pitchLimit.y);
	}

	// вычисление координат камеры
	camPosition.x = radius * sin(azimuth) * cos(pitch);
	camPosition.z = radius * cos(azimuth) * cos(pitch);
	camPosition.y = radius * sin(pitch);
	camPosition += camFocus;

	// передача данных в шейдер
	XMVECTOR focus_JP = { camFocus.x - camPosition.x, camFocus.y - camPosition.y, camFocus.z - camPosition.z };
	XMMATRIX V_JP = XMMatrixLookAtLH(XMVectorSet(0.0f, 0.0f, 0.0f, 1.0f), focus_JP, camUp);
	BR(Mediator::shader->SetCamBuffer(V_JP * projMatrix, XMFLOAT4(camPosition.x, camPosition.y, camPosition.z, 1.0f), XMFLOAT4(camFocus.x, camFocus.y, camFocus.z, 1.0f)));

	// вычисление абсолютных матриц камеры
	XMVECTOR vCamPos = XMVectorSet(camPosition.x, camPosition.y, camPosition.z, 1.0f);
	XMVECTOR vCamFocus = XMVectorSet(camFocus.x, camFocus.y, camFocus.z, 1.0f);
	viewMatrix = XMMatrixLookAtLH(vCamPos, vCamFocus, camUp);

	// построение фрустума
	BR(RebuildFrustum());

	return true;

}
Ejemplo n.º 17
0
t_bool			ft_parsen(t_buff *buff, char *dst, int len)
{
	int				i;

	i = -1;
	while (++i < len && !BEOF(buff))
		dst[i] = BR(buff);
	if (i == len)
		return (true);
	return (false);
}
Ejemplo n.º 18
0
static num polarized(const num &na, 
		     const num &gaa,
		     const num &lapa, 
		     const num &taua) // Becke tau here, no factor 1/2
{
  const parameter gam = 0.80;
  num D = taua - 0.25*gaa/na;
  num Q = 1.0/6.0*(lapa + 2*gam*D);
  num x = BR(2.0/3.0*pow(M_PI,2.0/3.0)*pow(na,5.0/3.0)/Q);
  num b = cbrt(pow3(x)*exp(-x)/(8*M_PI*na));
  return -(1-(1+0.5*x)*exp(-x))/b; //FIXME: use expm1
}
Ejemplo n.º 19
0
// сброс кнопки
bool Button::Reset() {

	// сброс родителя
	Sprite* parent = this;
	BR(parent->Reset());

	// сброс параметров
	absPosition.x = GetSpriteRelPosition().x + Mediator::winDimentions->x / 2;
	absPosition.y = GetSpriteRelPosition().y + Mediator::winDimentions->y / 2;

	return true;

}
Ejemplo n.º 20
0
inline void
LocalTrrkKernel
( UpperOrLower uplo, 
  T alpha, const DistMatrix<T,MC,  STAR>& A,
           const DistMatrix<T,STAR,MR  >& B,
  T beta,        DistMatrix<T,MC,  MR  >& C )
{
#ifndef RELEASE
    PushCallStack("LocalTrrkKernel");
    CheckInput( A, B, C );
#endif
    const Grid& g = C.Grid();

    DistMatrix<T,MC,STAR> AT(g), 
                          AB(g);
    DistMatrix<T,STAR,MR> BL(g), BR(g);
    DistMatrix<T,MC,MR> CTL(g), CTR(g),
                        CBL(g), CBR(g);
    DistMatrix<T,MC,MR> DTL(g), DBR(g);

    const int half = C.Height()/2;
    ScaleTrapezoid( beta, LEFT, uplo, 0, C );
    LockedPartitionDown
    ( A, AT,
         AB, half );
    LockedPartitionRight( B, BL, BR, half );
    PartitionDownDiagonal
    ( C, CTL, CTR,
         CBL, CBR, half );

    DTL.AlignWith( CTL );
    DBR.AlignWith( CBR );
    DTL.ResizeTo( CTL.Height(), CTL.Width() );
    DBR.ResizeTo( CBR.Height(), CBR.Width() );
    //------------------------------------------------------------------------//
    if( uplo == LOWER )
        internal::LocalGemm( NORMAL, NORMAL, alpha, AB, BL, T(1), CBL );
    else
        internal::LocalGemm( NORMAL, NORMAL, alpha, AT, BR, T(1), CTR );

    internal::LocalGemm( NORMAL, NORMAL, alpha, AT, BL, T(0), DTL );
    AxpyTriangle( uplo, T(1), DTL, CTL );

    internal::LocalGemm( NORMAL, NORMAL, alpha, AB, BR, T(0), DBR );
    AxpyTriangle( uplo, T(1), DBR, CBR );
    //------------------------------------------------------------------------//
#ifndef RELEASE
    PopCallStack();
#endif
}
Ejemplo n.º 21
0
// сброс камеры
bool Camera::Reset() {

	// пересоздать матрицу проеции
	float ratio = (float)Mediator::winDimentions->x / Mediator::winDimentions->y;
	projMatrix = XMMatrixPerspectiveFovLH(XM_PIDIV4, ratio, NearFarZ.x, NearFarZ.y);

	// пересоздать матрицу ортографической проекции
	orthoMatrix = XMMatrixOrthographicOffCenterLH(0.0f, (float)Mediator::winDimentions->x, (float)Mediator::winDimentions->y, 0.0f, NearFarOZ.x, NearFarOZ.y);

	// запись в буфер шейдера
	BR(Mediator::shader->SetResetBuffer(orthoMatrix));

	// перестроить фрустум
	BR(RebuildFrustum());

	// передача в шейдер
	XMVECTOR focus_JP = { camFocus.x - camPosition.x, camFocus.y - camPosition.y, camFocus.z - camPosition.z };
	XMMATRIX V_JP = XMMatrixLookAtLH(XMVectorSet(0.0f, 0.0f, 0.0f, 1.0f), focus_JP, camUp);
	BR(Mediator::shader->SetCamBuffer(V_JP * projMatrix, XMFLOAT4(camPosition.x, camPosition.y, camPosition.z, 1.0f), XMFLOAT4(camFocus.x, camFocus.y, camFocus.z, 1.0f)));

	return true;

}
Ejemplo n.º 22
0
// попытаться родить перса
bool ArtInt::TrySpawn(NumXY<float> showPoint, UINT persType) {

	// ограничение количества
	if (boars->GetAmount() + devils->GetAmount() > 10) return false;

	// инициализация переменных
	float angle = MathHelper::RandF(-XM_PI, XM_PI);
	float radius = Const::showRadius;
	NumXY<float> spawnPoint;
	NumXY<int> regAdr;

	do {

		// определить точку появления
		spawnPoint = showPoint + MathHelper::GetDisplacementFromDirection(angle, radius);
		regAdr = MathHelper::GetDynamicRegionAdress(spawnPoint);
		if (regAdr.x == -1) break;
		if (Mediator::regionField[regAdr.x][regAdr.y]) break;
		radius -= 1.0f;

	} while (true);

	// проверка на столкновение с окружающей средой
	NumXY<int> contAdr = MathHelper::GetContentAdress(spawnPoint);
	if (Mediator::regionField[regAdr.x][regAdr.y]->getContent()[contAdr.x][contAdr.y].blocked) return false;

	// провека на столкновение с другим персом
	BoundingBox potBox(NumXY<float>(spawnPoint.x, spawnPoint.y), PERS_RADIUS);
	if (CheckObject(potBox, false)) return false;

	// родить перса
	if (persType) { BR(boars->Spawn(spawnPoint)); }
	else { BR(devils->Spawn(spawnPoint)); }

	return true;

}
Ejemplo n.º 23
0
// заполнить содержимое региона для базовой локации (первая)
bool DynamicReg::CreateContentL0() {

	// обнулить количество экземпляров
	ZeroMemory(vectInstanceAmount, sizeof(UINT)* TerrainVectorModels.size());

	// перезаписать содержимое
	for (int i(0); i < Const::regionCellSize; i++) {
		for (int j(0); j < Const::regionCellSize; j++) {
			content[i][j] = CellFiller();
			float xAdress = regionAdress.x * (float)Const::regionCellSize + i;
			float yAdress = regionAdress.y * (float)Const::regionCellSize + j;
			float treeFunction = Mediator::superFunct->TreeFunction(xAdress, yAdress);
			float random = Mediator::superFunct->FullRandom0(xAdress, yAdress); // полная случайность

			// генерация содержимого
			if (regionHeightMap[i + 1][j + 1] >= FOREST_MEADOW_BORDER) {
				BR(SolveMeadowContent(i, j, random, treeFunction)); // для лугового биома
			}
			else if (regionHeightMap[i + 1][j + 1] <= FOREST_SWAMP_BORDER) {
				BR(SolveSwampContent(i, j, random, treeFunction)); // для болотного биома
			}
			else {
				BR(SolveForestContent(i, j, random, treeFunction)); // для лесного биома
			}

		} // для каждой ячейки
	}

	// обновить описатели
	for (UINT i(0); i < TerrainVectorModels.size(); i++) {
		if (vectInstanceAmount[i]) BR(TerrainVectorModels[i]->AddDescription(regionAdress, vectInstanceAmount[i]));
	}

	return true;

}
Ejemplo n.º 24
0
void BR_taylor(const T &y0, taylor<T,1,Ndeg> &t)
{
  taylor<T,1,Ndeg> f,d;
  t = 0;
  t[0] = BR(y0);
  t[1] = 1;
  f = BR_y(t);
  t[1] = 1/f[1];
  // Linear method, for quadratic see i.e. Brent & Kung ~197x
  for (int i=2;i<=Ndeg;i++) 
    {
      f = BR_y(t);
      t[i] = -f[i]*t[1];
    }
}
Ejemplo n.º 25
0
	void DebugRenderer::drawBox(const glm::vec4& destRect, const Color& color, float angle){
		
		int i = _verts.size();
		_verts.resize(_verts.size() + 4);
		
		glm::vec2 halfDims(destRect.z / 2.0f, destRect.w / 2.0f);


		//Get points centered at origin
		glm::vec2 TL(-halfDims.x, halfDims.y);
		glm::vec2 BL(-halfDims.x, -halfDims.y);
		glm::vec2 BR(halfDims.x, -halfDims.y);
		glm::vec2 TR(halfDims.x, halfDims.y);


		glm::vec2 positionOffset(destRect.x, destRect.y);

		//Rotate the points
		_verts[i].position = rotatePoint(TL, angle) + halfDims + positionOffset;
		_verts[i + 1].position = rotatePoint(BL, angle) + halfDims + positionOffset;
		_verts[i + 2].position = rotatePoint(BR, angle) + halfDims + positionOffset;
		_verts[i + 3].position = rotatePoint(TR, angle) + halfDims + positionOffset;

		for (int j = i; j < i + 4; j++){
			_verts[j].color = color;
		}

		
		_indices.reserve(_indices.size() + 8);

		//Line 1
		_indices.push_back(i);
		_indices.push_back(i + 1);

		//Line 2
		_indices.push_back(i + 1);
		_indices.push_back(i + 2);
	
		//Line 3
		_indices.push_back(i + 2);
		_indices.push_back(i + 3);

		//Line 4
		_indices.push_back(i + 3);
		_indices.push_back(i);

	}
Ejemplo n.º 26
0
bool CSurface3DPanel::Fit(CSurface3D *p3D, CSurface3DFrame *pFrame,
                         long nX, double XMin, double XMax, long nY, double YMin, double YMax)
  {
  m_pFrame=pFrame;

  CSurface3DPoint BL(0.0, 0.0, (p3D->m_fnZ(XMin, YMin)));
  CSurface3DPoint BR(1.0, 0.0, (p3D->m_fnZ(XMax, YMin)));
  CSurface3DPoint TL(0.0, 1.0, (p3D->m_fnZ(XMin, YMax)));
  CSurface3DPoint TR(1.0, 1.0, (p3D->m_fnZ(XMax, YMax)));
  CSurface3DPoint CC(0.5, 0.5, (p3D->m_fnZ(0.5*(XMin+XMax), 0.5*(YMin+YMax))));
  m_bLOK=m_tL.Fit(BL, TL, CC);
  m_bROK=m_tR.Fit(BR, TR, CC);
  m_bTOK=m_tT.Fit(TL, TR, CC);
  m_bBOK=m_tB.Fit(BL, BR, CC);
  m_bFitOK=m_bLOK && m_bROK && m_bTOK && m_bBOK;
  return m_bFitOK;
  };
Ejemplo n.º 27
0
Archivo: system.c Proyecto: happz/ducky
void do_WELCOME()
{
  ASM_INT(u32_t, var_TEST_MODE);
  ASM_INT(u32_t, var_SHOW_PROMPT);
  ASM_INT(u32_t, var_ECHO);

  if (var_TEST_MODE == FORTH_TRUE)
    return;

  putcs(__ducky_welcome);

  printf("DuckyFORTH ver. %d.%d\r\n", FORTH_VERSION >> 8, FORTH_VERSION & 0xFF);
  printf("Build " XSTR(__BUILD_STAMP__) "\r\n");
  printf("%d cells remaining\r\n", CONFIG_RAM_SIZE - (u32_t)var_DP);
  printf("Type \"BYE\" to exit.\r\n");
  BR();

  var_SHOW_PROMPT = FORTH_TRUE;
  var_ECHO = FORTH_TRUE;
}
Ejemplo n.º 28
0
CSurface3DPanel::CSurface3DPanel(CSurface3D *p3D, CSurface3DFrame *pFrame,
                                long nX, double XMin, double XMax, long nY, double YMin, double YMax)
  {
  m_pFrame=pFrame;
  m_pMRUNext=NULL;
  m_pMRUPrev=NULL;

  CSurface3DPoint BL(0.0, 0.0, (p3D->m_fnZ(XMin, YMin)));
  CSurface3DPoint BR(1.0, 0.0, (p3D->m_fnZ(XMax, YMin)));
  CSurface3DPoint TL(0.0, 1.0, (p3D->m_fnZ(XMin, YMax)));
  CSurface3DPoint TR(1.0, 1.0, (p3D->m_fnZ(XMax, YMax)));
  CSurface3DPoint CC(0.5, 0.5, (p3D->m_fnZ(0.5*(XMin+XMax), 0.5*(YMin+YMax))));
  m_bLOK=m_tL.Fit(BL, TL, CC);
  m_bROK=m_tR.Fit(BR, TR, CC);
  m_bTOK=m_tT.Fit(TL, TR, CC);
  m_bBOK=m_tB.Fit(BL, BR, CC);
  m_bFitOK=true;
  if (!m_bLOK || !m_bROK || !m_bTOK || !m_bBOK)
    throw "BAD 3DFit";
  };
Ejemplo n.º 29
0
main()
{
  //  freopen("127inp.txt","r",stdin);
  //  freopen("127out.txt","w",stdout);
    int time=0;
    scanf("%d",&n);
    while (n!=0)
    {
        count=0;
        scanf("%s",&a);
        Pre();
        if (num==1)
        {
            if (Check_if_free(n-1)) count++;
        }
        else BR(1);
        printf("Case %d: %d\n",++time,count);
        scanf("%d",&n);
    }
}
Ejemplo n.º 30
0
// создать рецепты
bool IngameMenu::CreateRecipes() {

	Recipe rec[] =  {
		Recipe(II_ROPE, 1, II_STICK, 10, II_NOTHING, 0, II_CLUB, 1),
		Recipe(II_FERN, 5, II_NOTHING, 0, II_NOTHING, 0, II_ROPE, 1),
		Recipe(II_FANG, 2, II_ROPE, 1, II_STICK, 5, II_PICK, 1),
		Recipe(II_ROCK, 1, II_ROPE, 1, II_STICK, 5, II_AXE, 1),
	};

	// выравнивание рецептов по возрастанию
	for (UINT receptNumber(0); receptNumber < ARRAYSIZE(rec); receptNumber++) {

		// для каждого рецепта
		for (UINT j(0); j < ARRAYSIZE(rec[receptNumber].ingredient) - 1; j++) {
			INVENTORY_ITEM maxItem = rec[receptNumber].ingredient[j].invItem;
			UINT maxIndex = j;
			for (UINT i(j + 1); i < ARRAYSIZE(rec[receptNumber].ingredient); i++) {
				if (rec[receptNumber].ingredient[i].invItem > maxItem) {
					maxItem = rec[receptNumber].ingredient[i].invItem;
					maxIndex = i;
				}
			}
			if (maxIndex != j) MathHelper::Swap(&rec[receptNumber].ingredient[maxIndex], &rec[receptNumber].ingredient[j]);
		} // для каждого рецепта
	}

	recipesAmount = ARRAYSIZE(rec);
	recipes = new Recipe[recipesAmount];
	memcpy(recipes, rec, sizeof(rec));

	// проверка на возрастаемость рецептов
	for (UINT j(0); j < recipesAmount; j ++)
		for (UINT i(0); i < MAX_ITEM_CRAFT_AMOUNT - 2; i++) {
			BR(recipes[j].ingredient[i].invItem >= recipes[j].ingredient[i + 1].invItem);
		}

	return true;

}