Пример #1
0
int main()
{

	Complex value1(5, 2);
	Complex value2(3, -3);
	cout << "First num:" << value1 << "\n" << "Second num:" << value2 << endl;
	cout << "Plus: " << value1 + value2 << endl;
	cout << "Minus: " << value1 - value2 << endl;
	cout << "Multiplication: " << value1 * value2 << endl;
	value1 = value2;
	cout << "Assimilation: " << value1 << " = " << value2 << endl;

	cout << "\n\n";
	
	Matrixx matr1(2, 3);
	for (int i = 0; i < 6; i++)
	{
		Complex temp(rand() % 20, rand() % 10);
		matr1.data[i] = temp;
	}
	Matrixx matr2(3, 4);
	for (int i = 0; i < 12; i++)
	{
		Complex temp(rand() % 20, rand() % 10);
		matr2.data[i] = temp;
	}
	
	Matrixx matr3(2, 3);
	for (int i = 0; i < 6; i++)
	{
		Complex temp(rand() % 20, rand() % 10);
		matr3.data[i] = temp;
	}
	cout << "matr1: \n" << matr1 << "matr2: \n" << matr2 << "matr3: \n" << matr3 << endl;
	cout << "matr1+matr3: \n" << (matr1+matr3) << endl;
	cout << "matr1*matr2: \n" << matr1*matr2 << endl;
	//cout << ~matr1 << endl;
	cout << "matr1: \n" << matr1 << "matr2: \n" << matr2 << "matr3: \n" << matr3 << endl;
	cout << "matr1(1,1) = " << Matrindex(matr1, 1, 1) << endl;
	//Запись в файл при использовании потоков
	ofstream out("text.txt", ios::app);
	if (!out)
	{
		cout << "Create a file first \n";
		system("pause");
		return 0;
	}
	out << matr1 << endl;
	out.close();
	system("pause");
	return 0;
}
void CBC_OnedUPCAWriter::ShowChars(const CFX_WideStringC& contents,
                                   CFX_DIBitmap* pOutBitmap,
                                   CFX_RenderDevice* device,
                                   const CFX_Matrix* matrix,
                                   int32_t barWidth,
                                   int32_t multiple,
                                   int32_t& e) {
  if (!device && !pOutBitmap) {
    e = BCExceptionIllegalArgument;
    return;
  }

  int32_t leftPadding = 7 * multiple;
  int32_t leftPosition = 10 * multiple + leftPadding;
  CFX_ByteString str = FX_UTF8Encode(contents);
  int32_t iLen = str.GetLength();
  FXTEXT_CHARPOS* pCharPos = FX_Alloc(FXTEXT_CHARPOS, iLen);
  FXSYS_memset(pCharPos, 0, sizeof(FXTEXT_CHARPOS) * iLen);
  CFX_ByteString tempStr = str.Mid(1, 5);
  FX_FLOAT strWidth = (FX_FLOAT)35 * multiple;
  FX_FLOAT blank = 0.0;
  CFX_FxgeDevice geBitmap;
  if (pOutBitmap)
    geBitmap.Attach(pOutBitmap, false, nullptr, false);

  iLen = tempStr.GetLength();
  int32_t iFontSize = (int32_t)fabs(m_fFontSize);
  int32_t iTextHeight = iFontSize + 1;
  if (!pOutBitmap) {
    CFX_Matrix matr(m_outputHScale, 0.0, 0.0, 1.0, 0.0, 0.0);
    CFX_FloatRect rect(
        (FX_FLOAT)leftPosition, (FX_FLOAT)(m_Height - iTextHeight),
        (FX_FLOAT)(leftPosition + strWidth - 0.5), (FX_FLOAT)m_Height);
    matr.Concat(*matrix);
    matr.TransformRect(rect);
    FX_RECT re = rect.GetOutterRect();
    device->FillRect(&re, m_backgroundColor);
    CFX_Matrix matr1(m_outputHScale, 0.0, 0.0, 1.0, 0.0, 0.0);
    CFX_FloatRect rect1(
        (FX_FLOAT)(leftPosition + 40 * multiple),
        (FX_FLOAT)(m_Height - iTextHeight),
        (FX_FLOAT)((leftPosition + 40 * multiple) + strWidth - 0.5),
        (FX_FLOAT)m_Height);
    matr1.Concat(*matrix);
    matr1.TransformRect(rect1);
    re = rect1.GetOutterRect();
    device->FillRect(&re, m_backgroundColor);
    FX_FLOAT strWidth1 = (FX_FLOAT)multiple * 7;
    CFX_Matrix matr2(m_outputHScale, 0.0, 0.0, 1.0, 0.0, 0.0);
    CFX_FloatRect rect2(0.0, (FX_FLOAT)(m_Height - iTextHeight),
                        (FX_FLOAT)strWidth1 - 1, (FX_FLOAT)m_Height);
    matr2.Concat(*matrix);
    matr2.TransformRect(rect2);
    re = rect2.GetOutterRect();
    device->FillRect(&re, m_backgroundColor);
    CFX_Matrix matr3(m_outputHScale, 0.0, 0.0, 1.0, 0.0, 0.0);
    CFX_FloatRect rect3(
        (FX_FLOAT)(leftPosition + 85 * multiple),
        (FX_FLOAT)(m_Height - iTextHeight),
        (FX_FLOAT)((leftPosition + 85 * multiple) + strWidth1 - 0.5),
        (FX_FLOAT)m_Height);
    matr3.Concat(*matrix);
    matr3.TransformRect(rect3);
    re = rect3.GetOutterRect();
    device->FillRect(&re, m_backgroundColor);
  }
  if (!pOutBitmap)
    strWidth = strWidth * m_outputHScale;

  CalcTextInfo(tempStr, pCharPos + 1, m_pFont, strWidth, iFontSize, blank);
  CFX_Matrix affine_matrix(1.0, 0.0, 0.0, -1.0, 0.0, (FX_FLOAT)iFontSize);
  CFX_FxgeDevice ge;
  if (pOutBitmap) {
    ge.Create((int)strWidth, iTextHeight, FXDIB_Argb, nullptr);
    ge.GetBitmap()->Clear(m_backgroundColor);
    ge.DrawNormalText(iLen, pCharPos + 1, m_pFont,
                      CFX_GEModule::Get()->GetFontCache(), (FX_FLOAT)iFontSize,
                      &affine_matrix, m_fontColor, FXTEXT_CLEARTYPE);
    geBitmap.SetDIBits(ge.GetBitmap(), leftPosition, m_Height - iTextHeight);
  } else {
    CFX_Matrix affine_matrix1(1.0, 0.0, 0.0, -1.0,
                              (FX_FLOAT)leftPosition * m_outputHScale,
                              (FX_FLOAT)(m_Height - iTextHeight + iFontSize));
    if (matrix) {
      affine_matrix1.Concat(*matrix);
    }
    device->DrawNormalText(
        iLen, pCharPos + 1, m_pFont, CFX_GEModule::Get()->GetFontCache(),
        (FX_FLOAT)iFontSize, &affine_matrix1, m_fontColor, FXTEXT_CLEARTYPE);
  }
  tempStr = str.Mid(6, 5);
  iLen = tempStr.GetLength();
  CalcTextInfo(tempStr, pCharPos + 6, m_pFont, strWidth, iFontSize, blank);
  if (pOutBitmap) {
    FX_RECT rect2(0, 0, (int)strWidth, iTextHeight);
    ge.FillRect(&rect2, m_backgroundColor);
    ge.DrawNormalText(iLen, pCharPos + 6, m_pFont,
                      CFX_GEModule::Get()->GetFontCache(), (FX_FLOAT)iFontSize,
                      &affine_matrix, m_fontColor, FXTEXT_CLEARTYPE);
    geBitmap.SetDIBits(ge.GetBitmap(), leftPosition + 40 * multiple,
                       m_Height - iTextHeight);
  } else {
    CFX_Matrix affine_matrix1(
        1.0, 0.0, 0.0, -1.0,
        (FX_FLOAT)(leftPosition + 40 * multiple) * m_outputHScale,
        (FX_FLOAT)(m_Height - iTextHeight + iFontSize));
    if (matrix) {
      affine_matrix1.Concat(*matrix);
    }
    device->DrawNormalText(
        iLen, pCharPos + 6, m_pFont, CFX_GEModule::Get()->GetFontCache(),
        (FX_FLOAT)iFontSize, &affine_matrix1, m_fontColor, FXTEXT_CLEARTYPE);
  }
  tempStr = str.Mid(0, 1);
  iLen = tempStr.GetLength();
  strWidth = (FX_FLOAT)multiple * 7;
  if (!pOutBitmap)
    strWidth = strWidth * m_outputHScale;

  CalcTextInfo(tempStr, pCharPos, m_pFont, strWidth, iFontSize, blank);
  if (pOutBitmap) {
    delete ge.GetBitmap();
    ge.Create((int)strWidth, iTextHeight, FXDIB_Argb, nullptr);
    ge.GetBitmap()->Clear(m_backgroundColor);
    ge.DrawNormalText(iLen, pCharPos, m_pFont,
                      CFX_GEModule::Get()->GetFontCache(), (FX_FLOAT)iFontSize,
                      &affine_matrix, m_fontColor, FXTEXT_CLEARTYPE);
    geBitmap.SetDIBits(ge.GetBitmap(), 0, m_Height - iTextHeight);
  } else {
    CFX_Matrix affine_matrix1(1.0, 0.0, 0.0, -1.0, 0,
                              (FX_FLOAT)(m_Height - iTextHeight + iFontSize));
    if (matrix) {
      affine_matrix1.Concat(*matrix);
    }
    device->DrawNormalText(
        iLen, pCharPos, m_pFont, CFX_GEModule::Get()->GetFontCache(),
        (FX_FLOAT)iFontSize, &affine_matrix1, m_fontColor, FXTEXT_CLEARTYPE);
  }
  tempStr = str.Mid(11, 1);
  iLen = tempStr.GetLength();
  CalcTextInfo(tempStr, pCharPos + 11, m_pFont, strWidth, iFontSize, blank);
  if (pOutBitmap) {
    delete ge.GetBitmap();
    ge.Create((int)strWidth, iTextHeight, FXDIB_Argb, nullptr);
    ge.GetBitmap()->Clear(m_backgroundColor);
    ge.DrawNormalText(iLen, pCharPos + 11, m_pFont,
                      CFX_GEModule::Get()->GetFontCache(), (FX_FLOAT)iFontSize,
                      &affine_matrix, m_fontColor, FXTEXT_CLEARTYPE);
    geBitmap.SetDIBits(ge.GetBitmap(), leftPosition + 85 * multiple,
                       m_Height - iTextHeight);
  } else {
    CFX_Matrix affine_matrix1(
        1.0, 0.0, 0.0, -1.0,
        (FX_FLOAT)(leftPosition + 85 * multiple) * m_outputHScale,
        (FX_FLOAT)(m_Height - iTextHeight + iFontSize));
    if (matrix) {
      affine_matrix1.Concat(*matrix);
    }
    device->DrawNormalText(
        iLen, pCharPos + 11, m_pFont, CFX_GEModule::Get()->GetFontCache(),
        (FX_FLOAT)iFontSize, &affine_matrix1, m_fontColor, FXTEXT_CLEARTYPE);
  }
  FX_Free(pCharPos);
}
Пример #3
0
bool MainApp::init(){
	useOcclusionQueries = true;

	char fileName[] = "room0.hmdl";
	unsigned int i;

	OpenGLModel *rooms[5];

	for (i = 0; i < 5; i++){
		fileName[4] = '0' + i;

		rooms[i] = new OpenGLModel();
		rooms[i]->loadFromFile(fileName);
	}

	mat4 matr0(1,0,0,0, 0,1,0,0, 0,0,1,0, 0,0,0,1);
	matr0.translate(vec3(0, 256, 0));

	mat4 matr1(1,0,0,0, 0,1,0,0, 0,0,1,0, 0,0,0,1);
	matr1.translate(vec3(-384, 256, 3072));

	mat4 matr2(1,0,0,0, 0,1,0,0, 0,0,1,0, 0,0,0,1);
	matr2.translate(vec3(1536,256,2688));

	mat4 matr3(1,0,0,0, 0,1,0,0, 0,0,1,0, 0,0,0,1);
	matr3.translate(vec3(-1024,-768,2688));

	mat4 matr4(1,0,0,0, 0,1,0,0, 0,0,1,0, 0,0,0,1);
	matr4.translate(vec3(-2304,256,2688));

	for (i = 0; i < rooms[1]->getBatchCount(); i++){
		rooms[0]->getBatch(i)->transform(matr0, ATT_VERTEX);
		rooms[1]->getBatch(i)->transform(matr1, ATT_VERTEX);
		rooms[2]->getBatch(i)->transform(matr2, ATT_VERTEX);
		rooms[3]->getBatch(i)->transform(matr3, ATT_VERTEX);
		rooms[4]->getBatch(i)->transform(matr4, ATT_VERTEX);
	}


	for (i = 0; i < 5; i++)	sectors.add(new Sector(rooms[i]));

	sectors[0]->addPortal(Portal(sectors[1], vec3(-384, 384, 1024), vec3(-128, 384, 1024), vec3(-384, 0, 1024)));
	sectors[1]->addPortal(Portal(sectors[0], vec3(-384, 384, 1024), vec3(-128, 384, 1024), vec3(-384, 0, 1024)));

	sectors[1]->addPortal(Portal(sectors[2], vec3(512, 384, 2816), vec3(512, 384, 3072), vec3(512, 0, 2816)));
	sectors[2]->addPortal(Portal(sectors[1], vec3(512, 384, 2816), vec3(512, 384, 3072), vec3(512, 0, 2816)));

	sectors[2]->addPortal(Portal(sectors[3], vec3(512, -256, 2304), vec3(512, -256, 2560), vec3(512, -640, 2304)));
	sectors[3]->addPortal(Portal(sectors[2], vec3(512, -256, 2304), vec3(512, -256, 2560), vec3(512, -640, 2304)));

	sectors[1]->addPortal(Portal(sectors[4], vec3(-1280, 384, 1664), vec3(-1280, 384, 1920), vec3(-1280, 128, 1664)));
	sectors[4]->addPortal(Portal(sectors[1], vec3(-1280, 384, 1664), vec3(-1280, 384, 1920), vec3(-1280, 128, 1664)));

	sectors[1]->addPortal(Portal(sectors[4], vec3(-1280,  192, 3840), vec3(-1280,  192, 4096), vec3(-1280, -256, 3840)));
	sectors[4]->addPortal(Portal(sectors[1], vec3(-1280,  192, 3840), vec3(-1280,  192, 4096), vec3(-1280, -256, 3840)));


	sectors[0]->addLight(vec3( 0,     128, 0   ), 800,  100, 100, 100);

	sectors[1]->addLight(vec3(-256,   224, 1800), 650,  100, 80,  100);
	sectors[1]->addLight(vec3(-512,   128, 3100), 900,  100, 100, 300);

	sectors[2]->addLight(vec3( 1300,  128, 2700), 800,  100, 100, 200);

	sectors[3]->addLight(vec3(-100,  -700, 2432), 600,  50,  50,  50);
	sectors[3]->addLight(vec3(-1450, -700, 2900), 1200, 250, 80,  250);

	sectors[4]->addLight(vec3(-2200,  256, 2300), 800,  100, 100, 100);
	sectors[4]->addLight(vec3(-2000,  0,   4000), 800,  100, 100, 100);

	return true;
}