本文整理匯總了C++中AddComponent函數的典型用法代碼示例。如果您正苦於以下問題:C++ AddComponent函數的具體用法?C++ AddComponent怎麽用?C++ AddComponent使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了AddComponent函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。
示例1: WindowActivity
ServerSaveActivity::ServerSaveActivity(SaveInfo save, bool saveNow, ServerSaveActivity::SaveUploadedCallback * callback) :
WindowActivity(ui::Point(-1, -1), ui::Point(200, 50)),
thumbnailRenderer(nullptr),
save(save),
callback(callback),
saveUploadTask(NULL)
{
ui::Label * titleLabel = new ui::Label(ui::Point(0, 0), Size, "Saving to server...");
titleLabel->SetTextColour(style::Colour::InformationTitle);
titleLabel->Appearance.HorizontalAlign = ui::Appearance::AlignCentre;
titleLabel->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
AddComponent(titleLabel);
AddAuthorInfo();
saveUploadTask = new SaveUploadTask(this->save);
saveUploadTask->AddTaskListener(this);
saveUploadTask->Start();
}
示例2: while
void test::TestEntityComponentAttachment() {
auto entities = new stoked::EntityPool(2);
auto componentPoolA = new stoked::ComponentPool<ComponentA>(4);
auto componentPoolB = new stoked::ComponentPool<ComponentB>(4);
while (entities->Available()) {
auto e1 = entities->Create();
auto a = componentPoolA->Get();
auto b = componentPoolB->Get();
bool resA = e1->AddComponent(a);
bool resB = e1->AddComponent(b);
assert(resA);
assert(resB);
}
PASSED();
}
示例3: lock
int Storage::AddRepo (const RepoInfo& ri)
{
Util::DBLock lock (DB_);
try
{
lock.Init ();
}
catch (const std::runtime_error& e)
{
qWarning () << Q_FUNC_INFO
<< "could not acquire DB lock";
throw;
}
QueryAddRepo_.bindValue (":url", Slashize (ri.GetUrl ()).toEncoded ());
QueryAddRepo_.bindValue (":name", ri.GetName ());
QueryAddRepo_.bindValue (":description", ri.GetShortDescr ());
QueryAddRepo_.bindValue (":longdescr", ri.GetLongDescr ());
QueryAddRepo_.bindValue (":maint_name", ri.GetMaintainer ().Name_);
QueryAddRepo_.bindValue (":maint_email", ri.GetMaintainer ().Email_);
if (!QueryAddRepo_.exec ())
{
Util::DBLock::DumpError (QueryAddRepo_);
throw std::runtime_error ("Query execution failed.");
}
QueryAddRepo_.finish ();
int repoId = FindRepo (Slashize (ri.GetUrl ()));
if (repoId == -1)
{
qWarning () << Q_FUNC_INFO
<< "OH SHI~, just inserted repo cannot be found!";
throw std::runtime_error ("Just inserted repo cannot be found.");
}
Q_FOREACH (const QString& component, ri.GetComponents ())
AddComponent (repoId, component);
lock.Good ();
return repoId;
}
示例4: itLED
void CDirectionalLEDEquippedEntity::Init(TConfigurationNode& t_tree) {
try {
/* Init parent */
CComposableEntity::Init(t_tree);
/* Go through the led entries */
TConfigurationNodeIterator itLED("directional_led");
for(itLED = itLED.begin(&t_tree);
itLED != itLED.end();
++itLED) {
/* Initialise the LED using the XML */
CDirectionalLEDEntity* pcLED = new CDirectionalLEDEntity(this);
pcLED->Init(*itLED);
CVector3 cPositionOffset;
GetNodeAttribute(*itLED, "position", cPositionOffset);
CQuaternion cOrientationOffset;
GetNodeAttribute(*itLED, "orientation", cOrientationOffset);
/* Parse and look up the anchor */
std::string strAnchorId;
GetNodeAttribute(*itLED, "anchor", strAnchorId);
/*
* NOTE: here we get a reference to the embodied entity
* This line works under the assumption that:
* 1. the DirectionalLEDEquippedEntity has a parent;
* 2. the parent has a child whose id is "body"
* 3. the "body" is an embodied entity
* If any of the above is false, this line will bomb out.
*/
CEmbodiedEntity& cBody =
GetParent().GetComponent<CEmbodiedEntity>("body");
/* Add the LED to this container */
m_vecInstances.emplace_back(*pcLED,
cBody.GetAnchor(strAnchorId),
cPositionOffset,
cOrientationOffset);
AddComponent(*pcLED);
}
UpdateComponents();
}
catch(CARGoSException& ex) {
THROW_ARGOSEXCEPTION_NESTED("Failed to initialize directional LED equipped entity \"" <<
GetContext() + GetId() << "\".", ex);
}
}
示例5: VisTriggerTargetComponent_cl
void GameState::InitFunction()
{
// Add target component
VisTriggerTargetComponent_cl *pTargetComp = new VisTriggerTargetComponent_cl();
AddComponent(pTargetComp);
// Get trigger box entity
VisBaseEntity_cl *pTriggerBoxEntity = Vision::Game.SearchEntity("TriggerBox");
VASSERT(pTriggerBoxEntity);
// Find source component
VisTriggerSourceComponent_cl* pSourceComp = vstatic_cast<VisTriggerSourceComponent_cl*>(
pTriggerBoxEntity->Components().GetComponentOfTypeAndName(VisTriggerSourceComponent_cl::GetClassTypeId(), "OnObjectEnter"));
VASSERT(pSourceComp != NULL);
// Link source and target component
IVisTriggerBaseComponent_cl::OnLink(pSourceComp, pTargetComp);
m_eState = GAME_STATE_RUN;
}
示例6: m_timer
PlayerProjectile::PlayerProjectile(const float direction, const float speed)
: uth::GameObject(),
m_timer(0.f),
m_direction()
{
// Load a texture and create a sprite component.
auto tex = uthRS.LoadTexture("enemy.png");
AddComponent(new uth::Sprite(tex));
SetActive(true);
// Compute a rotation vector from the given angle. (This doesn't currently work for some reason)
const float sine = pmath::sin(direction);
m_direction.x = sine * 1.f;
m_direction.y = sine * m_direction.x + pmath::cos(direction) * 1.f;
m_direction.normalize();
m_direction.x *= speed;
m_direction.y *= speed;
}
示例7: SetName
void GameObject::LoadFloor()
{
SetName("Floor");
auto meshComponent = MeshComponentPtr(
new MeshComponent(
MeshManager::Get().GetMesh("floor.mm"),
PngManager::Get().GetPngTexture("MartEngine.png")
)
);
SetScale(10.f);
SetRotation(Quaternion(Vector3(0.0f, 0.0f, 0.0f), 0.0f));
SetTranslation(Vector3(0.0f, 5.0f, 0.0f));
AddComponent(meshComponent);
//AddComponent(std::make_shared<Plane>(Vector3(0,0,0),Vector3(0,1,0)));
}
示例8: AddComponent
bool PackAnimation::CreateFramePart(const ee::SprConstPtr& spr, Frame& frame)
{
const IPackNode* node = PackNodeFactory::Instance()->Create(spr);
PackAnimation::Part part;
CU_STR name;
s2::SprNameMap::Instance()->IDToStr(spr->GetName(), name);
if (Utility::IsNameValid(name.c_str())) {
name = name;
}
bool force_mat = false;
bool new_comp = AddComponent(node, name.c_str(), part.comp_idx, force_mat);
PackAnimation::LoadSprTrans(spr, part.t, force_mat);
frame.parts.push_back(part);
return new_comp;
}
示例9: UI_REGISTER
SelectionWindow::SelectionWindow(Rect dimensions):UIBase(){
UI_REGISTER(SelectionWindow);
box = dimensions;
optionCounter = 0;
mother = nullptr;
box.x = dimensions.x;
box.y = dimensions.y;
OnMousePress = [=](UIBase*w,int button,Point pos){
SetFocused(true);
};
selectedOption = -1;
arrow = Text(style.fontfile,style.fontSize,style.txtstyle,">", {style.fg[0],style.fg[1],style.fg[2]} );
Back = [=](UIBase *b){
};
title = new Label(Point(dimensions.w/2 -16,2),std::string(""),this);
title->style.fg[0] = 255;
title->style.txtstyle = TEXT_BLENDED;
AddComponent(title);
}
示例10: UIDiscreteSliderComponent
void UIDiscreteSlider::AddCells( unsigned int maxValue, unsigned int startValue, float cellSpacing )
{
MaxValue = maxValue;
StartValue = startValue;
DiscreteSliderComponent = new UIDiscreteSliderComponent( *this, StartValue );
OVR_ASSERT( DiscreteSliderComponent );
AddComponent( DiscreteSliderComponent );
float cellOffset = 0.0f;
const float pixelCellSpacing = cellSpacing * VRMenuObject::DEFAULT_TEXEL_SCALE;
VRMenuFontParms fontParms( HORIZONTAL_CENTER, VERTICAL_CENTER, false, false, false, 1.0f );
Vector3f defaultScale( 1.0f );
for ( unsigned int cellIndex = 0; cellIndex <= MaxValue; ++cellIndex )
{
const Posef pose( Quatf( Vector3f( 0.0f, 1.0f, 0.0f ), 0.0f ),
Vector3f( cellOffset, 0.f, 0.0f ) );
cellOffset += pixelCellSpacing;
VRMenuObjectParms cellParms( VRMENU_BUTTON, Array< VRMenuComponent* >(), VRMenuSurfaceParms(),
"", pose, defaultScale, fontParms, Menu->AllocId(),
VRMenuObjectFlags_t(), VRMenuObjectInitFlags_t( VRMENUOBJECT_INIT_FORCE_POSITION ) );
UICell * cellObject = new UICell( GuiSys );
cellObject->AddToDiscreteSlider( Menu, this, cellParms );
cellObject->SetImage( 0, SURFACE_TEXTURE_DIFFUSE, CellOffTexture );
UICellComponent * cellComp = new UICellComponent( *DiscreteSliderComponent, cellIndex );
VRMenuObject * object = cellObject->GetMenuObject();
OVR_ASSERT( object );
object->AddComponent( cellComp );
DiscreteSliderComponent->AddCell( cellObject );
}
DiscreteSliderComponent->HighlightCells( StartValue );
}
示例11: commandField
ConsoleView::ConsoleView():
ui::Window(ui::Point(0, 0), ui::Point(WINDOWW, 150)),
commandField(NULL)
{
class CommandHighlighter: public ui::TextboxAction
{
ConsoleView * v;
public:
CommandHighlighter(ConsoleView * v_) { v = v_; }
virtual void TextChangedCallback(ui::Textbox * sender)
{
sender->SetDisplayText(v->c->FormatCommand(sender->GetText()));
}
};
commandField = new ui::Textbox(ui::Point(7, Size.Y-16), ui::Point(Size.X, 16), "");
commandField->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
commandField->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
commandField->SetActionCallback(new CommandHighlighter(this));
AddComponent(commandField);
FocusComponent(commandField);
commandField->SetBorder(false);
}
示例12: CDirectionalLEDEntity
void CDirectionalLEDEquippedEntity::AddLED(const CVector3& c_position,
const CQuaternion& c_orientation,
SAnchor& s_anchor,
const CRadians& c_observable_angle,
const CColor& c_color) {
/* create the new directional LED entity */
CDirectionalLEDEntity* pcLED =
new CDirectionalLEDEntity(this,
"directional_led_" + std::to_string(m_vecInstances.size()),
c_position,
c_orientation,
c_observable_angle,
c_color);
/* add it to the instances vector */
m_vecInstances.emplace_back(*pcLED,
s_anchor,
c_position,
c_orientation);
/* inform the base class about the new entity */
AddComponent(*pcLED);
UpdateComponents();
}
示例13: GetNodeAttribute
/**
* Load the sphere configuration from its XML tag
*/
void CSphereEntity::Init(TConfigurationNode &t_tree)
{
try
{
// Init parent
CComposableEntity::Init(t_tree);
// Parse XML to get the radius (required)
GetNodeAttribute(t_tree, "radius", m_fRadius);
// Parse XML to get the movable attribute (optional: defaults to true)
bool bMovable;
GetNodeAttributeOrDefault(t_tree, "movable", bMovable, true);
// Get the mass from XML if the sphere is movable
if (bMovable)
{
// Parse XML to get the mass (optional, defaults to 1)
GetNodeAttributeOrDefault(t_tree, "mass", m_fMass, 1.0f);
}
else
{
m_fMass = 0.0f;
}
// Create embodied entity using parsed data
m_pcEmbodiedEntity = new CEmbodiedEntity(this);
m_pcEmbodiedEntity->Init(GetNode(t_tree, "body"));
m_pcEmbodiedEntity->SetMovable(bMovable);
AddComponent(*m_pcEmbodiedEntity);
UpdateComponents();
}
catch (CARGoSException &ex)
{
THROW_ARGOSEXCEPTION_NESTED("Failed to initialize the ball entity.", ex);
}
}
示例14: FAILED_CHECK
HRESULT CBaseUI::Initialize(void)
{
FAILED_CHECK(AddComponent());
m_fX = 150.f;
m_fY = 50.f;
m_fSizeX = 140.f;
m_fSizeY = 42.f;
//
CRenderMgr::GetInstance()->AddRenderGroup(TYPE_UI, this);
m_pFont->m_eType = FONT_TYPE_OUTLINE;
m_pFont->m_wstrText = L" ";//여기에 아이디 넣자고하면 수정.
m_pFont->m_fSize = 20.f;
m_pFont->m_nColor = 0xFF008AFF;
m_pFont->m_nFlag = FW1_CENTER | FW1_VCENTER | FW1_RESTORESTATE;
m_pFont->m_vPos = D3DXVECTOR2(m_fX, m_fY + 150);
m_pFont->m_fOutlineSize = 1.f;
m_pFont->m_nOutlineColor = 0xFF000000 /*0xFFFFFFFF*/;
return S_OK;
}
示例15: MeshRendererGameComponent
void CubesGame::Initialize()
{
Game::Initialize();
MediaManager::Instance().AddSearchPath("../../examples/resources");
MediaManager::Instance().AddSearchPath("../../examples/resources/textures");
MediaManager::Instance().AddSearchPath("../../examples/resources/models");
MediaManager::Instance().AddSearchPath("../../examples/resources/shaders");
MediaManager::Instance().AddSearchPath("../../examples/resources/spriteSheet");
MediaManager::Instance().AddSearchPath("../../examples/resources/script");
MediaManager::Instance().AddSearchPath("../../examples/resources/fonts");
// Line2DRendererComponent *m_pLine2DRenderer = NEW_AO Line2DRendererComponent(this);
// Line3DRendererComponent *m_pLine3DRenderer = NEW_AO Line3DRendererComponent(this);
MeshRendererGameComponent *m_pModelRenderer = NEW_AO MeshRendererGameComponent(this);
//DebugSystem *m_pDebugSystem = NEW_AO DebugSystem(this);
// AddComponent(m_pLine2DRenderer);
// AddComponent(m_pLine3DRenderer);
AddComponent(m_pModelRenderer);
//AddComponent(m_pDebugSystem);
}