void CStageLine::RightBoxStageCreator() { auto Stage1 = [=]{ CreateLine(LineDirection::Right, Point(200, 560), 400); m_pStage[0]->setPosition(Point(443, 560)); }; auto Stage2 = [=]{ CreateLine(LineDirection::Down, Point(443, 573), 400); m_pStage[1]->setPosition(Point(443, 340)); }; auto Stage3 = [=]{ }; auto Stage4 = [=]{ }; auto Stage5 = [=]{ }; auto Stage6 = [=]{ }; auto Stage7 = [=]{ }; auto Stage8 = [=]{ }; auto Stage9 = [=] { }; auto Stage10 = [=] { }; auto CallStage = [=](int _num){ switch (_num) { case 0:Stage1(); break; case 1:Stage2(); break; case 2:Stage3(); break; case 3:Stage4(); break; case 4:Stage5(); break; case 5:Stage6(); break; case 6:Stage7(); break; case 7:Stage8(); break; case 8:Stage9(); break; case 9:Stage10(); break; default: break; } }; for (int i = 0; i <= m_nStagenum; i++) { CallStage(m_nStageCount); m_nStageCount++; } }
void Game::RefreshRendering(){ SwitchCircles.clear(); TrapBoxes.clear(); WiringLines.clear(); SwitchCircles.resize(track->Traps.size()); TrapBoxes.resize(track->Traps.size()); WiringLines.resize(track->Traps.size()); for (unsigned i=0; i<track->Traps.size(); i++) { Trap& trap=track->Traps[i]; SwitchCircles[i].resize(trap.SwitchPositions.size()); TrapBoxes[i].resize(trap.trapData.size()); WiringLines[i].resize(trap.Wiring.size()); bool MainSwitch=trap.MainSwitch; for (unsigned j=0; j<trap.SwitchPositions.size(); j++) { Vector2d SwitchPosition=ScalePosition(Vector2d(trap.SwitchPositions[j].x+0.5, trap.SwitchPositions[j].y+0.5) , Scaling, paddingdim, padding); if (MainSwitch==0) SwitchCircles[i][j]=CreateCircle(0.3*Scaling,sf::Color::Yellow,SwitchPosition); else SwitchCircles[i][j]=CreateCircle(0.3*Scaling,sf::Color::Green,SwitchPosition); } for (unsigned j=0; j<trap.trapData.size(); j++) { Vector2u TrapPosUnsigned=trap.trapData[j].Square; Tile* CurrentTile=track->getTile(TrapPosUnsigned.x,TrapPosUnsigned.y); bool isSquare=CurrentTile->isSquare; unsigned Orientation=CurrentTile->Orientation; bool Half=trap.trapData[j].Half; Vector2d TrapPosition=ScalePosition(Vector2d(TrapPosUnsigned.x+0.5, TrapPosUnsigned.y+0.5) , Scaling, paddingdim, padding); if (trap.MainSwitch==1 && isSquare) TrapBoxes[i][j]=CreateLineBox(TrapPosition, Scaling, sf::Color::Yellow); if (trap.MainSwitch==0 && isSquare) TrapBoxes[i][j]=CreateLineBox(TrapPosition, Scaling, sf::Color::Red); if (trap.MainSwitch==1 && !isSquare) TrapBoxes[i][j]=CreateLineTriangle(TrapPosition,Orientation,Half, Scaling, sf::Color::Yellow); if (trap.MainSwitch==0 && !isSquare) TrapBoxes[i][j]=CreateLineTriangle(TrapPosition,Orientation,Half, Scaling, sf::Color::Red); } for (unsigned j=0; j<trap.Wiring.size(); j++) { Vector2d StartPos=trap.Wiring[j].first; Vector2d EndPos=trap.Wiring[j].second; StartPos=ScalePosition(StartPos, Scaling, paddingdim, padding); EndPos=ScalePosition(EndPos, Scaling, paddingdim, padding); if(trap.MainSwitch==0) WiringLines[i][j]=CreateLine(StartPos,EndPos,sf::Color::Red); else WiringLines[i][j]=CreateLine(StartPos,EndPos,sf::Color::Yellow); } } }
MoveHood::MoveHood() : HoodObject(4.0f) { DAVA::float32 b = baseSize / 5; DAVA::float32 c = baseSize / 3; axisX = CreateLine(DAVA::Vector3(b, 0, 0), DAVA::Vector3(baseSize, 0, 0)); axisX->axis = ST_AXIS_X; axisY = CreateLine(DAVA::Vector3(0, b, 0), DAVA::Vector3(0, baseSize, 0)); axisY->axis = ST_AXIS_Y; axisZ = CreateLine(DAVA::Vector3(0, 0, b), DAVA::Vector3(0, 0, baseSize)); axisZ->axis = ST_AXIS_Z; axisXY1 = CreateLine(DAVA::Vector3(c, 0, 0), DAVA::Vector3(c, c, 0)); axisXY1->axis = ST_AXIS_XY; axisXY2 = CreateLine(DAVA::Vector3(0, c, 0), DAVA::Vector3(c, c, 0)); axisXY2->axis = ST_AXIS_XY; axisXZ1 = CreateLine(DAVA::Vector3(c, 0, 0), DAVA::Vector3(c, 0, c)); axisXZ1->axis = ST_AXIS_XZ; axisXZ2 = CreateLine(DAVA::Vector3(0, 0, c), DAVA::Vector3(c, 0, c)); axisXZ2->axis = ST_AXIS_XZ; axisYZ1 = CreateLine(DAVA::Vector3(0, c, 0), DAVA::Vector3(0, c, c)); axisYZ1->axis = ST_AXIS_YZ; axisYZ2 = CreateLine(DAVA::Vector3(0, 0, c), DAVA::Vector3(0, c, c)); axisYZ2->axis = ST_AXIS_YZ; }
const std::vector< boost::geometry::model::d2::point_xy<T> > GetLineRectIntersections( const boost::geometry::model::linestring< boost::geometry::model::d2::point_xy<T> > line, const boost::geometry::model::box< boost::geometry::model::d2::point_xy<T> > rect) { typedef boost::geometry::model::d2::point_xy<T> Point; typedef boost::geometry::model::linestring<Point> Line; typedef boost::geometry::model::box<Point> Rect; const Point p0 = Point(rect.min_corner().x(), rect.min_corner().y()); const Point p1 = Point(rect.max_corner().x(), rect.min_corner().y()); const Point p2 = Point(rect.min_corner().x(), rect.max_corner().y()); const Point p3 = Point(rect.max_corner().x(), rect.max_corner().y()); const std::vector<Line> lines = { CreateLine(std::vector<Point>( {p0,p1} )), CreateLine(std::vector<Point>( {p0,p2} )), CreateLine(std::vector<Point>( {p1,p3} )), CreateLine(std::vector<Point>( {p2,p3} )) }; std::vector<Point> points; std::for_each(lines.begin(),lines.end(), [&points,line](const Line& side) { const std::vector<Point> v = GetLineLineIntersections(line,side); std::copy(v.begin(),v.end(),std::back_inserter(points)); } ); //Remove doublures //Put 'typename' before 'std::vector<Point>::iteratortype' to prevent getting the error below: //error: need 'typename' before 'std::vector<boost::geometry::model::d2::point_xy<T> >::iterator' // because 'std::vector<boost::geometry::model::d2::point_xy<T> >' is a dependent scope typename std::vector<Point>::iterator new_end = std::unique( points.begin(),points.end(), [](const Point& lhs, const Point& rhs) { return lhs.x() == rhs.x() && lhs.y() == rhs.y(); } ); points.erase(new_end,points.end()); assert(points.size() <= 2); return points; }
void QtPvdbNewArrow::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget) { typedef boost::geometry::model::d2::point_xy<double> Point; typedef boost::geometry::model::linestring<Point> Line; typedef boost::geometry::model::box<Point> Rect; const Line line = CreateLine( std::vector<Point>( { Point(m_from->pos().x(),m_from->pos().y()), Point(this->line().p2().x(),this->line().p2().y()) } ) ); const QRectF qr1 = m_from->boundingRect().translated(m_from->pos()); const Rect r1( Point(qr1.topLeft().x() ,qr1.topLeft().y() ), Point(qr1.bottomRight().x(),qr1.bottomRight().y()) ); std::vector<Point> p1 = GetLineRectIntersections(line,r1); if (p1.empty()) { //Yes,it happens, when the line does not leave the rectangle //this happens when the two node rectanges overlap p1.push_back(Point(m_from->pos().x(),m_from->pos().y())); } assert(!p1.empty()); assert(p1.size() == 1); const QPointF p2 = this->line().p2(); this->setLine(QLineF(QPointF(p1[0].x(),p1[0].y()),p2)); QtArrowItem::paint(painter,option,widget); }
void Draw_Dxf::addLine(const DL_LineData& data) { RGBA color = RGBA(150,150,150); Shape* p = CreateLine(_painter,RGBA(255,255,255),(FLOAT)data.x1,(FLOAT)data.y1,(FLOAT)data.x2,(FLOAT)data.y2); p->regen(); TCHAR* layerName; if(_isBlockOpen) _block->insert(p); else { switch(_entityType) { case NONE : for(UINT i=0; i<_layers->size(); i++) { layerName = _layers->at(i)->getName(); if(0 == _tcscmp(layerName,String2TCHAR(attributes.getLayer()))) { _layers->at(i)->insert(p); _layers->at(i)->getLineColor(color); break; } } break; } } INT32 clValue = attributes.getColor(); if(clValue != 256) color = CL2RGBA(clValue); p->setLineColor(color); }
void CCloud::Create(const std::string& fileName, const Color& diffuse, const Color& ambient, float level) { m_diffuse = diffuse; m_ambient = ambient; m_level = level; m_time = 0.0f; m_lastTest = 0.0f; m_fileName = fileName; if (! m_fileName.empty()) m_engine->LoadTexture(m_fileName); if (m_terrain == nullptr) m_terrain = CRobotMain::GetInstancePointer()->GetTerrain(); m_wind = m_terrain->GetWind(); m_brickCount = m_terrain->GetBrickCount()*m_terrain->GetMosaicCount()*CLOUD_SIZE_EXPAND; m_brickSize = m_terrain->GetBrickSize(); m_brickCount /= m_subdiv*CLOUD_SIZE_EXPAND; m_brickSize *= m_subdiv*CLOUD_SIZE_EXPAND; if (m_level == 0.0f) return; m_lines.clear(); for (int y = 0; y < m_brickCount; y++) CreateLine(0, y, m_brickCount); }
void BufferedPrimitiveRenderer::CreatePrimitiveData() { CreateLine(); CreateWireCube(); CreateWireCircles(); CreateWireSpheres(); CreateWirePyramid(); CreateWireGrids(); }
Line CutSquareInHalf(Square s1, Square s2) { Point middle1, middle2; Line l; middle1=CreatePoint((s1.BottomLeft.x+s1.TopRight.x)/2, (s1.BottomLeft.y+s1.TopRight.y)/2); middle2=CreatePoint((s2.BottomLeft.x+s2.TopRight.x)/2, (s2.BottomLeft.y+s2.TopRight.y)/2); l=CreateLine(middle1, middle2); return l; }
RotateHood::RotateHood() : HoodObject(4.0f) { DAVA::float32 b = baseSize / 4; DAVA::float32 r = 2 * baseSize / 3; DAVA::float32 step = DAVA::PI_05 / ROTATE_HOOD_CIRCLE_PARTS_COUNT; DAVA::float32 x, y, lx = r, ly = 0; axisX = CreateLine(DAVA::Vector3(b, 0, 0), DAVA::Vector3(baseSize, 0, 0)); axisX->axis = ST_AXIS_X; axisY = CreateLine(DAVA::Vector3(0, b, 0), DAVA::Vector3(0, baseSize, 0)); axisY->axis = ST_AXIS_Y; axisZ = CreateLine(DAVA::Vector3(0, 0, b), DAVA::Vector3(0, 0, baseSize)); axisZ->axis = ST_AXIS_Z; for(int i = 0; i < ROTATE_HOOD_CIRCLE_PARTS_COUNT; ++i) { DAVA::float32 angle = step * (i + 1); x = r * cosf(angle); y = r * sinf(angle); axisXc[i] = CreateLine(DAVA::Vector3(0, lx, ly), DAVA::Vector3(0, x, y)); axisXc[i]->axis = ST_AXIS_X; axisYc[i] = CreateLine(DAVA::Vector3(lx, 0, ly), DAVA::Vector3(x, 0, y)); axisYc[i]->axis = ST_AXIS_Y; axisZc[i] = CreateLine(DAVA::Vector3(lx, ly, 0), DAVA::Vector3(x, y, 0)); axisZc[i]->axis = ST_AXIS_Z; lx = x; ly = y; } }
int CVecLine::InitVecLine( CMeshInfo* srcmeshinfo ) { int ret; DestroyLine(); ret = CreateLine( srcmeshinfo ); if( ret ){ DbgOut( "charpos2.cpp : CVecLine : InitVecLine : CreateLine error !!!\n" ); return 1; } return 0; }
void TfrmView::randomize() { Layer* pLayer = LayerFactory::create(_T("Randomize")); for(int i=0 ; i<100 ; i++) { Shape* pShape; SHAPE_TYPE type = rand()%3; switch(type) { case SHAPE_RECTANGLE: pShape = CreateRectangle(_pView->painter() ,RGBA(rand()%256,rand()%256,rand()%256) ,RGBA(rand()%256,rand()%256,rand()%256) ,rand()%400 - 200 ,rand()%400 - 200 ,rand()%400 - 200 ,rand()%400 - 200 ); break; case SHAPE_CIRCLE: pShape = CreateCircle(_pView->painter() ,RGBA(rand()%256,rand()%256,rand()%256) ,RGBA(rand()%256,rand()%256,rand()%256) ,rand()%400 - 200 ,rand()%400 - 200 ,rand()%100 ); break; case SHAPE_LINE: pShape = CreateLine(_pView->painter() ,RGBA(rand()%256,rand()%256,rand()%256) ,rand()%400 - 200 ,rand()%400 - 200 ,rand()%400 - 200 ,rand()%400 - 200 ); break; } pLayer->insert(pShape); } _pView->layers()->insert(pLayer); _pView->layers()->regen(); this->FormPaint(this); }
CXFA_Node* CXFA_FFWidgetHandler::CreateWidgetFormItem( XFA_WIDGETTYPE eType, CXFA_Node* pParent, CXFA_Node* pBefore) const { switch (eType) { case XFA_WIDGETTYPE_Barcode: return NULL; case XFA_WIDGETTYPE_PushButton: return CreatePushButton(pParent, pBefore); case XFA_WIDGETTYPE_CheckButton: return CreateCheckButton(pParent, pBefore); case XFA_WIDGETTYPE_ExcludeGroup: return CreateExclGroup(pParent, pBefore); case XFA_WIDGETTYPE_RadioButton: return CreateRadioButton(pParent, pBefore); case XFA_WIDGETTYPE_Arc: return CreateArc(pParent, pBefore); case XFA_WIDGETTYPE_Rectangle: return CreateRectangle(pParent, pBefore); case XFA_WIDGETTYPE_Image: return CreateImage(pParent, pBefore); case XFA_WIDGETTYPE_Line: return CreateLine(pParent, pBefore); case XFA_WIDGETTYPE_Text: return CreateText(pParent, pBefore); case XFA_WIDGETTYPE_DatetimeEdit: return CreateDatetimeEdit(pParent, pBefore); case XFA_WIDGETTYPE_DecimalField: return CreateDecimalField(pParent, pBefore); case XFA_WIDGETTYPE_NumericField: return CreateNumericField(pParent, pBefore); case XFA_WIDGETTYPE_Signature: return CreateSignature(pParent, pBefore); case XFA_WIDGETTYPE_TextEdit: return CreateTextEdit(pParent, pBefore); case XFA_WIDGETTYPE_DropdownList: return CreateDropdownList(pParent, pBefore); case XFA_WIDGETTYPE_ListBox: return CreateListBox(pParent, pBefore); case XFA_WIDGETTYPE_ImageField: return CreateImageField(pParent, pBefore); case XFA_WIDGETTYPE_PasswordEdit: return CreatePasswordEdit(pParent, pBefore); case XFA_WIDGETTYPE_Subform: return CreateSubform(pParent, pBefore); default: break; } return NULL; }
void AppendToLine(char *lines[], int line, const char *text) { /* Are we trying to append to an empty line? */ if (lines[line] == NULL) CreateLine(lines, line, text); else { /* Calculate the new required size... */ int size = strlen(lines[line]) + strlen(text) + 1; if ((lines[line] = realloc(lines[line], size)) == NULL) return; /* ... and append the new text. */ strcat(lines[line], text); } }
MoveHood::MoveHood() : HoodObject(4.0f) { DAVA::float32 b = baseSize / 5; DAVA::float32 c = baseSize / 3; axisX = CreateLine(DAVA::Vector3(b, 0, 0), DAVA::Vector3(baseSize, 0, 0)); axisX->axis = ST_AXIS_X; axisY = CreateLine(DAVA::Vector3(0, b, 0), DAVA::Vector3(0, baseSize, 0)); axisY->axis = ST_AXIS_Y; axisZ = CreateLine(DAVA::Vector3(0, 0, b), DAVA::Vector3(0, 0, baseSize)); axisZ->axis = ST_AXIS_Z; axisXY1 = CreateLine(DAVA::Vector3(c, 0, 0), DAVA::Vector3(c, c, 0)); axisXY1->axis = ST_AXIS_XY; axisXY2 = CreateLine(DAVA::Vector3(0, c, 0), DAVA::Vector3(c, c, 0)); axisXY2->axis = ST_AXIS_XY; axisXZ1 = CreateLine(DAVA::Vector3(c, 0, 0), DAVA::Vector3(c, 0, c)); axisXZ1->axis = ST_AXIS_XZ; axisXZ2 = CreateLine(DAVA::Vector3(0, 0, c), DAVA::Vector3(c, 0, c)); axisXZ2->axis = ST_AXIS_XZ; axisYZ1 = CreateLine(DAVA::Vector3(0, c, 0), DAVA::Vector3(0, c, c)); axisYZ1->axis = ST_AXIS_YZ; axisYZ2 = CreateLine(DAVA::Vector3(0, 0, c), DAVA::Vector3(0, c, c)); axisYZ2->axis = ST_AXIS_YZ; DAVA::RenderStateData hoodStateData; DAVA::RenderManager::Instance()->GetRenderStateData(DAVA::RenderState::RENDERSTATE_3D_BLEND, hoodStateData); hoodStateData.state = DAVA::RenderStateData::STATE_BLEND | DAVA::RenderStateData::STATE_COLORMASK_ALL | DAVA::RenderStateData::STATE_DEPTH_WRITE; hoodStateData.sourceFactor = DAVA::BLEND_SRC_ALPHA; hoodStateData.destFactor = DAVA::BLEND_ONE_MINUS_SRC_ALPHA; hoodDrawState = DAVA::RenderManager::Instance()->CreateRenderState(hoodStateData); }
/** * * Sets up the radial menu. * * @author Jade Abbott * @param _pRenderer Required for the surface manager, device manager, etc. * @param _pHud The Heads Up Display, which will be told to display certain information when the Radial Menu is open. * @param _uiMaximumDiameter Maximum diameter the radial menu can be (but is capped at 512); Must be even. * @param _uiMaxLines Maximum nuimber of lines used to define the shape of the inner circle. * @param _fLineWidth The width of the dividing lines drawn. * @param _fInnerCircleScalar Scalar value to set how much of the Radial Menu is taken by the centre button. * @param _fDrawPositionX The centre X coordinate where the Radial Menu will be drawn on screen. * @param _fDrawPositionY The centre Y coordinate where the Radial Menu will be drawn on screen. * @return True if initialisation was successful. * */ bool CRadialMenu::Initialise(CD3DRenderer* _pRenderer, CHud* _pHud, unsigned int _uiMaximumDiameter, unsigned int _uiMaxLines, float _fLineWidth, float _fInnerCircleScalar, float _fDrawPositionX, float _fDrawPositionY) { assert(_pRenderer); assert(!m_pRenderer); m_pRenderer = _pRenderer; m_pHud = _pHud; // Get default data; This is only to breakproof it. m_dwOriginalStencilState = _pRenderer->GetDeviceManager().GetRenderStateValue(D3DRS_STENCILENABLE); // Initialise resolution-based data. bool bSuccess = OnResolutionChange(_uiMaximumDiameter, _fDrawPositionX, _fDrawPositionY); // Set the radius of the inner circle. SetInnerCircleRadius(_fInnerCircleScalar * (m_uiDiameter * 0.5f)); // Create vertex buffer so ID3DXLine can draw into the stencil. bSuccess = SetMaxLines(_uiMaxLines) ? bSuccess : false; // Create line for stencil masking. bSuccess = CreateLine(_fLineWidth) ? bSuccess : false; assert(bSuccess); // Create dynamic vertex buffer, which is a screen-space textured quad. bSuccess = CreateVertexBufferQuad() ? bSuccess : false; assert(bSuccess); // Create dynamic vertex buffer for masking. bSuccess = CreateVertexBufferMask(_uiMaxLines) ? bSuccess : false; assert(bSuccess); return bSuccess; }
void ParseCommands(const std::vector<std::vector<std::string>>& commands, std::vector<std::shared_ptr<CShape>>& figures, std::vector<std::shared_ptr<sf::Shape>>& drawableFigures) { for (const auto& command : commands) { try { std::cout << "> Parsing:" << std::endl; std::copy(command.begin(), command.end(), std::ostream_iterator<std::string>(std::cout, " ")); std::cout << std::endl; if (command[0] == "rectangle") { CreateRectangle(command, figures, drawableFigures); } else if (command[0] == "circle") { CreateCircle(command, figures, drawableFigures); } else if (command[0] == "line") { CreateLine(command, figures, drawableFigures); } else if (command[0] == "triangle") { CreateTriangle(command, figures, drawableFigures); } else if (command[0] == "point") { CreatePoint(command, figures, drawableFigures); } else { throw std::exception("\tError: Invalid command"); } } catch (const std::exception& error) { std::cout << error.what() << std::endl; } } }
void CTrack_Player2::Allocate_Grid_Lines() { // Suppress 8192 calls to CPane::UpdatePosition ge::IPane* pPane = GetPane(); ge::IScrollPane* pSP = NULL; if (pPane) { pSP = dynamic_cast<ge::IScrollPane*>(pPane); } if (pSP) { pSP->SuppressUpdatePositions(true); } for(tint32 iLine =0; iLine < giNumber_Of_Grid_Lines; iLine++){ mppLine[iLine] = CreateLine(ge::IControl::giNoID, ge::SPos(0,0), ge::SPos(0,0) , ge::SRGB(0, 0, 0)); mppLine[iLine]->SetVisible(false); } // Allow UpdatePosition again if (pSP) { pSP->SuppressUpdatePositions(false); } }
int WINAPI mEndScene(LPDIRECT3DDEVICE9 Device) { SetDevice(Device); /*HANDLE ThreadLuaHandler;*/ if(!create_run) { CreateLine(); create_run = true; } ThreadDrawOn(); /* ThreadLuaHandler = CreateThread(NULL, NULL, (LPTHREAD_START_ROUTINE)ThreadLoadingLua, NULL, NULL, NULL); WaitForSingleObject(ThreadLuaHandler, INFINITE); */ /*ThreadLoadingLua();*/ return oEndScene(Device); }
void ControlsFactory::CustomizeMenuPopupCell(UIListCell *c, const WideString &text) { Font *font = GetFontLight(); c->SetStateFont(UIControl::STATE_NORMAL, font); c->SetStateFont(UIControl::STATE_SELECTED, font); c->SetStateText(UIControl::STATE_NORMAL, text); c->SetStateText(UIControl::STATE_SELECTED, text); c->SetStateDrawType(UIControl::STATE_NORMAL, UIControlBackground::DRAW_FILL); c->SetStateDrawType(UIControl::STATE_SELECTED, UIControlBackground::DRAW_FILL); c->GetStateBackground(UIControl::STATE_NORMAL)->color = Color(0.1f, 0.1f, 0.1f, 0.6f); c->GetStateBackground(UIControl::STATE_SELECTED)->color = Color(0.6f, 0.6f, 0.6f, 0.6f); Rect rect = c->GetRect(); rect.y = rect.dy - 1; rect.dy = 1; UIControl *line = CreateLine(rect); c->AddControl(line); SafeRelease(line); }
BOOL ObjectComLineConstruction(C4Object *cObj) { C4Object *linekit,*tstruct,*cline; DWORD ocf; ObjectActionStand(cObj); // Check physical if (!cObj->GetPhysical()->CanConstruct) { sprintf(OSTR,LoadResStr("IDS_OBJ_NOLINECONSTRUCT"),cObj->GetName()); GameMsgObject(OSTR,cObj); return FALSE; } // - - - - - - - - - - - - - - - - - - Line pickup - - - - - - - - - - - - - - - - - // Check for linekit if (!(linekit=cObj->Contents.Find(C4ID_Linekit))) { // Check for collection limit if (cObj->Def->CollectionLimit && (cObj->Contents.ObjectCount()>=cObj->Def->CollectionLimit) ) return FALSE; // Check line pickup ocf=OCF_LineConstruct; tstruct=Game.Objects.AtObject(cObj->x,cObj->y,ocf,cObj); if (!tstruct || !(ocf & OCF_LineConstruct)) return FALSE; if (!(cline=Game.FindObject(C4ID_None,0,0,0,0,OCF_All,"Connect",tstruct))) return FALSE; // Check line connected to linekit at other end if ( (cline->Action.Target && (cline->Action.Target->Def->id==C4ID_Linekit)) || (cline->Action.Target2 && (cline->Action.Target2->Def->id==C4ID_Linekit)) ) { StartSoundEffect("Error",false,100,cObj); sprintf(OSTR,LoadResStr("IDS_OBJ_NODOUBLEKIT"),cline->GetName()); GameMsgObject(OSTR,cObj); return FALSE; } // Create new linekit if (!(linekit=Game.CreateObject(C4ID_Linekit,cObj,cline->Owner))) return FALSE; // Enter linekit into clonk bool fRejectCollect; if (!linekit->Enter(cObj, TRUE, true, &fRejectCollect)) { // Enter failed: abort operation linekit->AssignRemoval(); return FALSE; } // Attach line to collected linekit StartSoundEffect("Connect",false,100,cObj); if (cline->Action.Target==tstruct) cline->Action.Target=linekit; if (cline->Action.Target2==tstruct) cline->Action.Target2=linekit; // Message sprintf(OSTR,LoadResStr("IDS_OBJ_DISCONNECT"),cline->GetName(),tstruct->GetName()); GameMsgObject(OSTR,tstruct); return TRUE; } // - - - - - - - - - - - - - - - Active construction - - - - - - - - - - - - - - - - - // Active line construction if (cline=Game.FindObject(C4ID_None,0,0,0,0,OCF_All,"Connect",linekit)) { // Check for structure connection ocf=OCF_LineConstruct; tstruct=Game.Objects.AtObject(cObj->x,cObj->y,ocf,cObj); // No structure if (!tstruct || !(ocf & OCF_LineConstruct)) { // No connect StartSoundEffect("Error",false,100,cObj); sprintf(OSTR,LoadResStr("IDS_OBJ_NOCONNECT")); GameMsgObject(OSTR,cObj); return FALSE; } // Check short circuit -> removal if ((cline->Action.Target==tstruct) || (cline->Action.Target2==tstruct)) { StartSoundEffect("Connect",false,100,cObj); sprintf(OSTR,LoadResStr("IDS_OBJ_LINEREMOVAL"),cline->GetName()); GameMsgObject(OSTR,tstruct); cline->AssignRemoval(); return TRUE; } // Check for correct connection type BOOL connect_okay=FALSE; switch (cline->Def->Line) { case C4D_Line_Power: if (tstruct->Def->LineConnect & C4D_Power_Input) connect_okay=TRUE; if (tstruct->Def->LineConnect & C4D_Power_Output) connect_okay=TRUE; break; case C4D_Line_Source: if (tstruct->Def->LineConnect & C4D_Liquid_Output) connect_okay=TRUE; break; case C4D_Line_Drain: if (tstruct->Def->LineConnect & C4D_Liquid_Input) connect_okay=TRUE; break; default: return FALSE; // Undefined line type } if (!connect_okay) { StartSoundEffect("Error",false,100,cObj); sprintf(OSTR,LoadResStr("IDS_OBJ_NOCONNECTTYPE"),cline->GetName(),tstruct->GetName()); GameMsgObject(OSTR,tstruct); return FALSE; } // Connect line to structure StartSoundEffect("Connect",false,100,cObj); if (cline->Action.Target==linekit) cline->Action.Target=tstruct; if (cline->Action.Target2==linekit) cline->Action.Target2=tstruct; linekit->Exit(); linekit->AssignRemoval(); sprintf(OSTR,LoadResStr("IDS_OBJ_CONNECT"),cline->GetName(),tstruct->GetName()); GameMsgObject(OSTR,tstruct); return TRUE; } // - - - - - - - - - - - - - - - - New line - - - - - - - - - - - - - - - - - - - - - // Check for new structure connection ocf=OCF_LineConstruct; tstruct=Game.Objects.AtObject(cObj->x,cObj->y,ocf,cObj); if (!tstruct || !(ocf & OCF_LineConstruct)) { StartSoundEffect("Error",false,100,cObj); sprintf(OSTR,LoadResStr("IDS_OBJ_NONEWLINE")); GameMsgObject(OSTR,cObj); return FALSE; } // Determine new line type C4ID linetype=C4ID_None; // Check source pipe if (linetype==C4ID_None) if (tstruct->Def->LineConnect & C4D_Liquid_Pump) if (!Game.FindObject(C4ID_SourcePipe,0,0,0,0,OCF_All,"Connect",tstruct)) linetype = C4ID_SourcePipe; // Check drain pipe if (linetype==C4ID_None) if (tstruct->Def->LineConnect & C4D_Liquid_Output) if (!Game.FindObject(C4ID_DrainPipe,0,0,0,0,OCF_All,"Connect",tstruct)) linetype = C4ID_DrainPipe; // Check power if (linetype==C4ID_None) if (tstruct->Def->LineConnect & C4D_Power_Output) linetype = C4ID_PowerLine; // No good if (linetype==C4ID_None) { StartSoundEffect("Error",false,100,cObj); sprintf(OSTR,LoadResStr("IDS_OBJ_NONEWLINE")); GameMsgObject(OSTR,cObj); return FALSE; } // Create new line C4Object *newline=CreateLine(linetype,cObj->Owner, tstruct,linekit); if (!newline) return FALSE; StartSoundEffect("Connect",false,100,cObj); sprintf(OSTR,LoadResStr("IDS_OBJ_NEWLINE"),newline->GetName()); GameMsgObject(OSTR,tstruct); return TRUE; }
UIControl * ControlsFactory::CreateLine(const Rect & rect) { return CreateLine(rect, Color(0.8f, 0.8f, 0.8f, 1.0f)); }
WOGScene* OGSceneConfig::Parser() { WOGScene* scene = new WOGScene; scene->minx = rootElement.attribute("minx").toDouble(); scene->miny = rootElement.attribute("miny").toDouble(); scene->maxx = rootElement.attribute("maxx").toDouble(); scene->maxy = rootElement.attribute("maxy").toDouble(); scene->backgroundcolor = StringToColor(rootElement.attribute("backgroundcolor")); QDomNode node = rootElement.firstChild(); while (!node.isNull()) { QDomElement domElement = node.toElement(); if (domElement.tagName() == "SceneLayer") { scene->sceneLayer << CreateSceneLayer(domElement); } else if (domElement.tagName() == "label") { scene->label << CreateLabel(domElement); } else if (domElement.tagName() == "buttongroup") { scene->buttongroup << CreateButtonGroup(domElement); } else if (domElement.tagName() == "button") { scene->button << CreateButton(domElement); } else if (domElement.tagName() == "radialforcefield") { scene->radialforcefield << CreateRadialForceField(domElement); } else if (domElement.tagName() == "linearforcefield") { scene->linearforcefield << CreateLinearForceField(domElement); } else if (domElement.tagName() == "particles") { scene->particle << CreateParticle(domElement); } else if (domElement.tagName() == "circle") { scene->circle << CreateCircle(domElement); } else if (domElement.tagName() == "line") { scene->line << CreateLine(domElement); } else if (domElement.tagName() == "rectangle") { scene->rectangle << CreateRectanle(domElement); } node = node.nextSibling(); } return scene; }
void CTrack_Player2::Init() { mpScrollPane = ge::IScrollPane::Create(); mpScrollPane->Init(ge::IControl::giNoID, giTimerID_Player2_ScrollPane); mpPane = dynamic_cast<ge::IPane*>(mpScrollPane); mpPane->SetSize(gTrack_Scroll_Editor); mpPane->SetBackgroundColour(ge::SRGB(239,239,239)); msLineColor[giColor_1] = ge::SRGB(83,124,214); msLineColor[giColor_2] = ge::SRGB(125,153,217); msLineColor[giColor_4] = ge::SRGB(125,153,217); msLineColor[giColor_8] = ge::SRGB(188,214,254); msLineColor[giColor_16] = ge::SRGB(188,214,254); msLineColor[giColor_32] = ge::SRGB(188,214,254); Allocate_Grid_Lines(); Update_Zoom(); Draw_Grid(); tint32 iTrack_PosY = 0; tint32 iTrack_SizeY = gTrack_Info_Small.iCY - 1; tint i; //-------------------------------------------- for( i=0; i<giNumber_Of_Tracks; i++) { // Create Tracks mppTrack[i] = new CTrack(this, GetGUI()); mppTrack[i]->SetInfo(i, iTrack_SizeY, this ); mppTrack[i]->Init(); mpPane->AddControl(mppTrack[i]->GetPane(), ge::SPos(0, iTrack_PosY)); mppTrack[i]->GetPane()->SetVisible(false); iTrack_PosY += iTrack_SizeY + 1; } // Snap_To_Grid(); // Lasse, dynamic_cast is slow on Windows! // tfloat64 fPixelPrSample = mpKSPlugIn->GetSamplesPrPixel(); tfloat64 fSamplesPrPixel = mpKSPlugIn->GetSamplesPrPixel(); //muiPane_Duration_In_Samples = gTrack_Scroll_Editor.iCX * fSamplesPrPixel; mpEmpty_Rect = CreateRect(ge::IControl::giNoID, ge::SRect(ge::SPos(0, iTrack_PosY), ge::SSize(gTrack_Scroll_Editor.iCX, gTrack_Scroll_Editor.iCY-iTrack_PosY)), ge::SRGB(204, 204, 204)); mpBack_Track_Shaddow_Bmp = CreateBitmap(ge::IControl::giNoID, IDB_Back_Track_Shaddow, ge::SPos(0, iTrack_PosY)); mpBack_Track_Shaddow_Bmp->SetSize(ge::SSize(gTrack_Scroll_Editor.iCX,8)); // Mouse-trap for activation of track mpMouseTrap = ge::IMouseTrap::Create(); // Only link into chain, but don't remove message (the third param = false) mpMouseTrap->EnableOneTrap(ge::MouseMove, true, false); mpPane->AddControl(mpMouseTrap, ge::SPos(0, 0)); mpMouseTrap->PlaceOnTopOf(GetPane()); mpMouseTrap->AddListener(this); // Play Head mpPlay_Line = CreateLine(ge::IControl::giNoID, ge::SPos(0, 0), ge::SPos(0, 0), ge::SRGB(0, 0, 0)); miLast_Play_Line_Pos_X = -1; }
void CRegion_GUI::Init() { // Create the main pane mpPane = ge::IPane::Create(); ge::SSize Size(miSize_X, miSize_Y ? giTrack_Size_Big-1: giTrack_Size_Small-1); mpPane->SetSize(Size); mpPane->SetAutomaticResize(true, ge::IControl::ResizeAbsoluteY ); // Small background mpRegion_Back_Small =CreateBitmapVU(ge::IControl::giNoID, IDB_Back_Region_Small, ge::SPos(0, 0), 11); mpRegion_Back_Small->SetSize(ge::SSize(miSize_X,giTrack_Size_Small-1)); mpRegion_Back_Small->SetAutomaticResize(true, ge::IControl::ResizeAbsoluteX); mpRegion_Back_Small->SetFrame(miColor); // Big background mpRegion_Back_Big =CreateBitmapVU(ge::IControl::giNoID, IDB_Back_Region_Big, ge::SPos(0, 0), 11); mpRegion_Back_Big->SetSize(ge::SSize(miSize_X,giTrack_Size_Big-1)); mpRegion_Back_Big->SetAutomaticResize(true, ge::IControl::ResizeAbsoluteX); mpRegion_Back_Big->SetFrame(miColor); mpLine_Start = CreateLine(ge::IControl::giNoID, ge::SPos(0,0), ge::SPos(0,giTrack_Size_Small-1) , ge::SRGB(128, 128, 128)); mpLine_End = CreateLine(ge::IControl::giNoID, ge::SPos(miSize_X-1,0), ge::SPos(miSize_X-1,giTrack_Size_Small-1) , ge::SRGB(128, 128, 128)); //-------------------------------------------- // Text label mpText = CreateDisplay( ge::IControl::giNoID, ge::SPos(2, 0), ge::SSize(118, 10), CreateFont(Generic128, IDB_Minix_Tight, ge::SRGB(32, 32, 32)), false); mpText->SetHorzAlignment(ge::IText::HorzAlignLeft); mpText->SetText(mPsz); //-------------------------------------------- // Custom control mpControl = ge::ICustomControl::Create(); mpControl->Init(ge::IControl::giNoID, dynamic_cast<ge::ICustomControlCallback*>(this)); mpControl->SetSize(Size); mpPane->AddControl(dynamic_cast<ge::IControl*>(mpControl), ge::SPos(0, 0)); mpDrawPrimitives = ge::IDrawPrimitives::Create(); mpDrawPrimitives->Init(GetWindow()); //-------------------------------------------- // Volume mpRegion_Volume_Handle = new CTrack_Fade_Handle(this, GetGUI()); mpRegion_Volume_Handle->SetInfo(this, giRegion_Volume_Handle); mpRegion_Volume_Handle->Init(); mpPane->AddControl(mpRegion_Volume_Handle->GetPane(), ge::SPos(miSize_X-7, 30)); // Volume Line mpLine_Region_Volume = CreateLine(ge::IControl::giNoID, ge::SPos(miSize_X,0), ge::SPos(miSize_X,0) , ge::SRGB(0, 0, 0)); //-------------------------------------------- // Fade in mpFade_In_Handle = new CTrack_Fade_Handle(this, GetGUI()); mpFade_In_Handle->SetInfo(this, giFade_In_Handle); mpFade_In_Handle->Init(); mpPane->AddControl(mpFade_In_Handle->GetPane(), ge::SPos(0, 0)); // Line mpLine_Fade_In = CreateLine(ge::IControl::giNoID, ge::SPos(0,0), ge::SPos(0,0) , ge::SRGB(0, 0, 0)); //-------------------------------------------- // Fade out mpFade_Out_Handle = new CTrack_Fade_Handle(this, GetGUI()); mpFade_Out_Handle->SetInfo(this, giFade_Out_Handle); mpFade_Out_Handle->Init(); mpPane->AddControl(mpFade_Out_Handle->GetPane(), ge::SPos(miSize_X-7, 0)); // Line mpLine_Fade_Out = CreateLine(ge::IControl::giNoID, ge::SPos(miSize_X,0), ge::SPos(miSize_X,0) , ge::SRGB(0, 0, 0)); Update_Graphic(); }
Primitive::Ptr Renderer::CreatePane( const sf::Vector2f& position, const sf::Vector2f& size, float border_width, const sf::Color& color, const sf::Color& border_color, int border_color_shift ) { if( border_width <= 0.f ) { return CreateRect( position, position + size, color ); } Primitive::Ptr primitive( new Primitive ); sf::Color dark_border( border_color ); sf::Color light_border( border_color ); Context::Get().GetEngine().ShiftBorderColors( light_border, dark_border, border_color_shift ); float left = position.x; float top = position.y; float right = left + size.x; float bottom = top + size.y; Primitive::Ptr rect( CreateQuad( sf::Vector2f( left + border_width, top + border_width ), sf::Vector2f( left + border_width, bottom - border_width ), sf::Vector2f( right - border_width, bottom - border_width ), sf::Vector2f( right - border_width, top + border_width ), color ) ); Primitive::Ptr line_top( CreateLine( sf::Vector2f( left, top + border_width / 2.f ), sf::Vector2f( right - border_width, top + border_width / 2.f ), light_border, border_width ) ); Primitive::Ptr line_right( CreateLine( sf::Vector2f( right - border_width / 2.f, top ), sf::Vector2f( right - border_width / 2.f, bottom - border_width ), dark_border, border_width ) ); Primitive::Ptr line_bottom( CreateLine( sf::Vector2f( right, bottom - border_width / 2.f ), sf::Vector2f( left + border_width, bottom - border_width / 2.f ), dark_border, border_width ) ); Primitive::Ptr line_left( CreateLine( sf::Vector2f( left + border_width / 2.f, bottom ), sf::Vector2f( left + border_width / 2.f, top + border_width ), light_border, border_width ) ); primitive->Add( *rect.get() ); primitive->Add( *line_top.get() ); primitive->Add( *line_right.get() ); primitive->Add( *line_bottom.get() ); primitive->Add( *line_left.get() ); std::vector<Primitive::Ptr>::iterator iter( std::find( m_primitives.begin(), m_primitives.end(), rect ) ); assert( iter != m_primitives.end() ); iter = m_primitives.erase( iter ); // rect iter = m_primitives.erase( iter ); // line_top iter = m_primitives.erase( iter ); // line_right iter = m_primitives.erase( iter ); // line_bottom m_primitives.erase( iter ); // line_left AddPrimitive( primitive ); return primitive; }
//---------------------------------------------------------------------------- bool InverseKinematics::OnInitialize () { if ( !Application::OnInitialize() ) return false; // set up camera ms_spkCamera->SetFrustum(1.0f,1000.0f,-0.55f,0.55f,0.4125f,-0.4125f); Vector3f kCamLoc(0.0f,-2.0f,0.5f); Matrix3f kCamOrient(-1.0f,0.0f,0.0f,0.0f,0.0f,1.0f,0.0f,1.0f,0.0f); ms_spkCamera->SetFrame(kCamLoc,kCamOrient); // ** layout of scene graph ** // scene // line // iknode // plane // target // goal // root // origin // effector // end // create objects m_spkScene = new Node(2); Node* pkIKNode = new Node(3); m_spkRoot = new Node(2); m_spkEffector = new Node(1); m_spkTarget = new Node; m_spkLine = CreateLine(); TriMesh* pkPlane = CreatePlane(); TriMesh* pkGoal = CreateCube(); TriMesh* pkOrigin = CreateCube(); TriMesh* pkEnd = CreateCube(); // transform objects pkIKNode->Rotate().FromAxisAngle(Vector3f::UNIT_Y,0.1f); pkIKNode->Translate() = Vector3f(0.1f,0.1f,0.1f); m_spkTarget->Translate() = 2.0f*Vector3f::UNIT_Y; m_spkEffector->Translate() = Vector3f::UNIT_X; // set parent-child links m_spkScene->AttachChild(m_spkLine); m_spkScene->AttachChild(pkIKNode); pkIKNode->AttachChild(pkPlane); pkIKNode->AttachChild(m_spkTarget); pkIKNode->AttachChild(m_spkRoot); m_spkTarget->AttachChild(pkGoal); m_spkRoot->AttachChild(pkOrigin); m_spkRoot->AttachChild(m_spkEffector); m_spkEffector->AttachChild(pkEnd); // create joints IKJoint** apkJoint = new IKJoint*[2]; apkJoint[0] = new IKJoint(m_spkRoot); apkJoint[0]->AllowRotation(2) = true; apkJoint[1] = new IKJoint(m_spkEffector); apkJoint[1]->AllowTranslation(2) = true; // create goal IKGoal** apkGoal = new IKGoal*[1]; apkGoal[0] = new IKGoal(m_spkTarget,m_spkEffector,1.0f); // create IK controller m_pkIKCtrl = new IKController(2,apkJoint,1,apkGoal,1); m_pkIKCtrl->Active() = false; m_spkRoot->AttachControl(m_pkIKCtrl); // set desired render state m_spkWireframeState = new WireframeState; m_spkScene->SetRenderState(m_spkWireframeState); m_spkZBufferState = new ZBufferState; m_spkZBufferState->Enabled() = true; m_spkZBufferState->Writeable() = true; m_spkZBufferState->Compare() = ZBufferState::CF_LEQUAL; m_spkScene->SetRenderState(m_spkZBufferState); // initial update of objects ms_spkCamera->Update(); m_spkScene->UpdateGS(0.0f); m_spkScene->UpdateRS(); UpdateLine(); m_bTurretActive = true; SetTurretAxes(); m_fTrnSpeed = 0.1f; m_fRotSpeed = 0.01f; return true; }
void CStageLine::DownBoxStageCreator() { auto Stage1 = [=]{ CreateLine(LineDirection::Left, Point(340 + 160, 650 - 20), 400); m_pStage[0]->setPosition(Point(117 + 160, 663 - 30)); }; auto Stage2 = [=]{ CreateLine(LineDirection::Down, Point(117 + 160, 663 - 20), 500); m_pStage[1]->setPosition(Point(117 + 13 + 160, 415)); }; auto Stage3 = [=]{ CreateLine(LineDirection::Right, Point(117 + 13 + 160, 415), 400); m_pStage[2]->setPosition(Point(340 + 160, 415 )); }; auto Stage4 = [=]{ CreateLine(LineDirection::Right, Point(340 + 160, 415), 400); m_pStage[3]->setPosition(Point(563 + 160, 415 )); }; auto Stage5 = [=]{ CreateLine(LineDirection::Right, Point(563 + 160, 415), 400); m_pStage[4]->setPosition(Point(774 + 160, 415 )); }; auto Stage6 = [=]{ CreateLine(LineDirection::Right, Point(786 + 195, 415), 200); m_pStage[5]->setPosition(Point(897.5 + 195, 415 )); }; auto Stage7 = [=]{ CreateLine(LineDirection::Down, Point(897.5 + 195, 415 + 13), 400); m_pStage[6]->setPosition(Point(885.5 + 195, 231)); }; auto Stage8 = [=]{ CreateLine(LineDirection::Left, Point(885.5 + 195, 231), 200); m_pStage[7]->setPosition(Point(774 + 155, 231)); }; auto Stage9 = [=] { CreateLine(LineDirection::Left, Point(774 + 195, 231), 400); m_pStage[8]->setPosition(Point(551 + 195, 231 )); }; auto Stage10 = [=] { CreateLine(LineDirection::Left, Point(551 + 195, 231), 400); m_pStage[9]->setPosition(Point(328 + 195, 231)); }; auto CallStage = [=](int _num){ switch (_num) { case 0:Stage1(); break; case 1:Stage2(); break; case 2:Stage3(); break; case 3:Stage4(); break; case 4:Stage5(); break; case 5:Stage6(); break; case 6:Stage7(); break; case 7:Stage8(); break; case 8:Stage9(); break; case 9:Stage10(); break; default: break; } }; for (int i = 0; i <= m_nStagenum; i++) { CallStage(m_nStageCount); m_nStageCount++; } }
void CStageLine::LeftBoxStageCreator() { auto Stage1 = [=]{ CreateLine(LineDirection::Left, Point(815, 60), 400); CreateLine(LineDirection::Up, Point(592, 49), 300); m_pStage[0]->setPosition(Point(592, 210)); }; auto Stage2 = [=]{ CreateLine(LineDirection::Up, Point(592, 240), 300); m_pStage[1]->setPosition(Point(592, 420)); }; auto Stage3 = [=]{ }; auto Stage4 = [=]{ }; auto Stage5 = [=]{ }; auto Stage6 = [=]{ }; auto Stage7 = [=]{ }; auto Stage8 = [=]{ }; auto Stage9 = [=] { }; auto Stage10 = [=] { }; auto CallStage = [=](int _num){ switch (_num) { case 0:Stage1(); break; case 1:Stage2(); break; case 2:Stage3(); break; case 3:Stage4(); break; case 4:Stage5(); break; case 5:Stage6(); break; case 6:Stage7(); break; case 7:Stage8(); break; case 8:Stage9(); break; case 9:Stage10(); break; default: break; } }; for (int i = 0; i <= m_nStagenum; i++) { CallStage(m_nStageCount); m_nStageCount++; } }