本文整理汇总了C++中Bundle类的典型用法代码示例。如果您正苦于以下问题:C++ Bundle类的具体用法?C++ Bundle怎么用?C++ Bundle使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Bundle类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SAFE_RELEASE
void TerrainSample::initialize()
{
// Load scene
_scene = Scene::load("res/common/terrain/sample.scene");
_terrain = dynamic_cast<Terrain*>(_scene->findNode("terrain")->getDrawable());
_sky = _scene->findNode("sky");
_sky->setTag("lighting", "none");
// Load shapes
Bundle* bundle;
bundle = Bundle::create("res/common/sphere.gpb");
_sphere = bundle->loadNode("sphere");
dynamic_cast<Model*>(_sphere->getDrawable())->setMaterial("res/common/terrain/shapes.material#sphere", 0);
SAFE_RELEASE(bundle);
bundle = Bundle::create("res/common/box.gpb");
_box = bundle->loadNode("box");
dynamic_cast<Model*>(_box->getDrawable())->setMaterial("res/common/terrain/shapes.material#box", 0);
SAFE_RELEASE(bundle);
// Load font
_font = Font::create("res/ui/arial.gpb");
// Setup form
_form = Form::create("res/common/terrain/terrain.form");
_form->getControl("plusButton")->addListener(this, Control::Listener::CLICK);
_form->getControl("minusButton")->addListener(this, Control::Listener::CLICK);
_form->getControl("wireframe")->addListener(this, Control::Listener::VALUE_CHANGED);
_form->getControl("patches")->addListener(this, Control::Listener::VALUE_CHANGED);
_form->getControl("physics")->addListener(this, Control::Listener::VALUE_CHANGED);
_form->getControl("lod")->addListener(this, Control::Listener::VALUE_CHANGED);
_form->getControl("culling")->addListener(this, Control::Listener::VALUE_CHANGED);
_form->getControl("snapToGround")->addListener(this, Control::Listener::VALUE_CHANGED);
_form->getControl("dropSphere")->addListener(this, Control::Listener::CLICK);
_form->getControl("dropBox")->addListener(this, Control::Listener::CLICK);
_form->getControl("clearAll")->addListener(this, Control::Listener::CLICK);
Control* main = _form->getControl("main");
_formSize.set(main->getWidth(), main->getHeight());
// Use script camera for navigation
enableScriptCamera(true);
setScriptCameraSpeed(20, 80);
_directionalLight = _scene->findNode("directionalLight")->getLight();
}
示例2: function_GridStyleSecondary
// Set drawing style of secondary surface
bool Commands::function_GridStyleSecondary(CommandNode* c, Bundle& obj, ReturnValue& rv)
{
if (obj.notifyNull(Bundle::GridPointer)) return false;
Grid::SurfaceStyle ss = Grid::surfaceStyle(c->argc(0));
if (ss == Grid::nSurfaceStyles) return false;
obj.g->setSecondaryStyle(ss);
rv.reset();
return true;
}
示例3: TEST
/**
* Send a bundle to check it with the wireshark.
* The bundle must be valid.
* It will appears under UDP.
*/
TEST(BundleTest, WiresharkTest) {
Bundle b = Bundle("node100", "node101", "This is a test payload");
std::string raw = b.toRaw();
sockaddr_in remote = { 0 };
remote.sin_family = AF_INET;
remote.sin_port = htons(0);
remote.sin_addr.s_addr = htonl(INADDR_ANY);
int sock = socket(AF_INET, SOCK_DGRAM, 0);
EXPECT_LE(0,
bind(sock, reinterpret_cast<sockaddr*>(&remote), sizeof(remote)));
sockaddr_in destination = { 0 };
destination.sin_family = AF_INET;
destination.sin_port = htons(4556);
inet_aton("127.0.0.1", &destination.sin_addr);
EXPECT_LT(
0,
sendto(sock, raw.c_str(), raw.size(), 0,
reinterpret_cast<sockaddr*>(&destination), sizeof(destination)));
}
示例4: setMultiTouch
void Audio3DTest::initialize()
{
setMultiTouch(true);
_font = Font::create("res/common/arial18.gpb");
// Load game scene from file
Bundle* bundle = Bundle::create("res/common/box.gpb");
_scene = bundle->loadScene();
SAFE_RELEASE(bundle);
// Get light node
Node* lightNode = _scene->findNode("directionalLight1");
Light* light = lightNode->getLight();
// Initialize box model
Node* boxNode = _scene->findNode("box");
Model* boxModel = boxNode->getModel();
Material* boxMaterial = boxModel->setMaterial("res/common/box.material");
boxMaterial->getParameter("u_lightColor")->setValue(light->getColor());
boxMaterial->getParameter("u_lightDirection")->setValue(lightNode->getForwardVectorView());
// Remove the cube from the scene but keep a reference to it.
_cubeNode = boxNode;
_cubeNode->addRef();
_scene->removeNode(_cubeNode);
loadGrid(_scene);
// Initialize cameraa
Vector3 cameraPosition(5, 5, 1);
if (Camera* camera = _scene->getActiveCamera())
{
camera->getNode()->getTranslation(&cameraPosition);
}
_fpCamera.initialize();
_fpCamera.setPosition(cameraPosition);
_scene->addNode(_fpCamera.getRootNode());
_scene->setActiveCamera(_fpCamera.getCamera());
_gamepad = getGamepad(0);
GP_ASSERT(_gamepad);
_gamepad->getForm()->setConsumeInputEvents(false);
}
示例5: function_AddFreePoint
ATEN_USING_NAMESPACE
// Add free grid point data at specified coordinates
bool Commands::function_AddFreePoint(CommandNode* c, Bundle& obj, ReturnValue& rv)
{
if (obj.notifyNull(Bundle::GridPointer)) return false;
obj.g->addFreePoint(c->argd(0), c->argd(1), c->argd(2), c->argd(3));
rv.reset();
return true;
}
示例6: displayScreen
void SpaceshipGame::initialize()
{
// TODO: Not working on iOS
// Display the gameplay splash screen for at least 1 second.
displayScreen(this, &SpaceshipGame::drawSplash, NULL, 1000L);
// Create our render state block that will be reused across all materials
_stateBlock = RenderState::StateBlock::create();
_stateBlock->setDepthTest(true);
_stateBlock->setCullFace(true);
_stateBlock->setBlend(true);
_stateBlock->setBlendSrc(RenderState::BLEND_SRC_ALPHA);
_stateBlock->setBlendDst(RenderState::BLEND_ONE_MINUS_SRC_ALPHA);
// Load our scene from file
Bundle* bundle = Bundle::create("res/spaceship.gpb");
_scene = bundle->loadScene();
SAFE_RELEASE(bundle);
// Update the aspect ratio for our scene's camera to match the current device resolution
_scene->getActiveCamera()->setAspectRatio((float)getWidth() / (float)getHeight());
// Initialize scene data
initializeSpaceship();
initializeEnvironment();
// Create a background audio track
_backgroundSound = AudioSource::create("res/background.ogg");
if (_backgroundSound)
_backgroundSound->setLooped(true);
// Create font
_font = Font::create("res/airstrip28.gpb");
// Store camera node
_cameraNode = _scene->findNode("camera1");
// Store initial ship and camera positions
_initialShipPos = _shipGroupNode->getTranslation();
_initialShipRot = _shipGroupNode->getRotation();
_initialCameraPos = _cameraNode->getTranslation();
}
示例7: function_GridAxes
// Set grid axes (nine doubles)
bool Commands::function_GridAxes(CommandNode* c, Bundle& obj, ReturnValue& rv)
{
if (obj.notifyNull(Bundle::GridPointer)) return false;
Matrix mat;
mat.setColumn(0, c->arg3d(0), 0.0);
mat.setColumn(1, c->arg3d(3), 0.0);
mat.setColumn(2, c->arg3d(6), 0.0);
obj.g->setAxes(mat);
rv.reset();
return true;
}
示例8: function_GetGrid
// Return nth grid of model
bool Commands::function_GetGrid(CommandNode* c, Bundle& obj, ReturnValue& rv)
{
if (obj.notifyNull(Bundle::ModelPointer)) return false;
Grid* g = NULL;
switch (c->argType(0))
{
case (VTypes::IntegerData):
g = obj.rs()->grid(c->argi(0)-1);
break;
case (VTypes::GridData):
g = (Grid*) c->argp(0, VTypes::GridData);
break;
default:
Messenger::print("Can't convert a variable of type '%s' to a Grid.", VTypes::dataType(c->argType(0)));
break;
}
if (g == NULL) return false;
rv.set(VTypes::GridData, g);
return true;
}
示例9: CCAssert
void FightPrepare::fight()
{
if (mState != Prepare_State_Loaded)
{
CCAssert(false,"数据还没准备好,请确认调用了prepareData函数载入数据,并且是在prepareSuccess回调接口中调用的这个函数");
return;
}
Bundle bundle;
bundle.putBool("testMode",mTestMode);
if (!mTestMode)
{
bundle.putString("JumpToWhenEnd","FightEndLayer");
}
// 直接换scene
ClientFightLayer* layer = (ClientFightLayer*)GameDirector::getDirector()->fight(mPreparedDir_vec,mCallback->getBg(mTaskId,mGridIndex),bundle);
GameDirector::getDirector()->hideWaiting();
layer->setBeforeFightPro(beforeFightPro);
}
示例10: getSignal
void OMEMO::publishOwnBundle(int account) {
Bundle b = getSignal(account)->collectBundle();
if (!b.isValid()) return;
QDomDocument doc;
QDomElement publish = doc.createElement("publish");
doc.appendChild(publish);
QDomElement item = doc.createElement("item");
publish.appendChild(item);
QDomElement bundle = doc.createElementNS(OMEMO_XMLNS, "bundle");
item.appendChild(bundle);
publish.setAttribute("node", bundleNodeName(getSignal(account)->getDeviceId()));
QDomElement signedPreKey = doc.createElement("signedPreKeyPublic");
signedPreKey.setAttribute("signedPreKeyId", b.signedPreKeyId);
setNodeText(signedPreKey, b.signedPreKeyPublic);
bundle.appendChild(signedPreKey);
QDomElement signedPreKeySignature = doc.createElement("signedPreKeySignature");
setNodeText(signedPreKeySignature, b.signedPreKeySignature);
bundle.appendChild(signedPreKeySignature);
QDomElement identityKey = doc.createElement("identityKey");
setNodeText(identityKey, b.identityKeyPublic);
bundle.appendChild(identityKey);
QDomElement preKeys = doc.createElement("prekeys");
bundle.appendChild(preKeys);
foreach (auto preKey, b.preKeys) {
QDomElement preKeyPublic = doc.createElement("preKeyPublic");
preKeyPublic.setAttribute("preKeyId", preKey.first);
setNodeText(preKeyPublic, preKey.second);
preKeys.appendChild(preKeyPublic);
}
pepPublish(account, doc.toString());
}
示例11: send
//-------------------------------------------------------------------------------------
Reason WebSocketPacketFilter::send(Channel * pChannel, PacketSender& sender, Packet * pPacket)
{
Bundle* pBundle = pPacket->pBundle();
TCPPacket* pRetTCPPacket = TCPPacket::ObjPool().createObject();
websocket::WebSocketProtocol::FrameType frameType = websocket::WebSocketProtocol::BINARY_FRAME;
if(pBundle && pBundle->packets().size() > 1)
{
bool isEnd = pBundle->packets().back() == pPacket;
bool isBegin = pBundle->packets().front() == pPacket;
if(!isEnd && !isBegin)
{
frameType = websocket::WebSocketProtocol::NEXT_FRAME;
}
else
{
if(!isEnd)
frameType = websocket::WebSocketProtocol::INCOMPLETE_BINARY_FRAME;
else
frameType = websocket::WebSocketProtocol::END_FRAME;
}
}
websocket::WebSocketProtocol::makeFrame(frameType, pPacket, pRetTCPPacket);
int space = pPacket->length() - pRetTCPPacket->space();
if(space > 0)
{
WARNING_MSG(fmt::format("WebSocketPacketFilter::send: no free space, buffer added:{}, total={}.\n",
space, pRetTCPPacket->size()));
pRetTCPPacket->data_resize(pRetTCPPacket->size() + space);
}
(*pRetTCPPacket).append(pPacket->data() + pPacket->rpos(), pPacket->length());
pRetTCPPacket->swap(*(static_cast<KBEngine::MemoryStream*>(pPacket)));
TCPPacket::ObjPool().reclaimObject(pRetTCPPacket);
return PacketFilter::send(pChannel, sender, pPacket);
}
示例12: us_bundle_stop
pointer us_bundle_stop(scheme* sc, pointer args)
{
if(args == sc->NIL)
{
std::cerr << "Empty argument list" << std::endl;
return sc->F;
}
if (sc->vptr->list_length(sc, args) != 1)
{
return sc->F;
}
pointer arg = pair_car(args);
Bundle bundle;
if (is_string(arg))
{
std::string name = sc->vptr->string_value(arg);
bundle = get_bundle(name);
}
else if (is_integer(arg))
{
bundle = GetBundleContext().GetBundle(ivalue(arg));
}
if (bundle)
{
try
{
bundle.Stop();
return sc->T;
}
catch (const std::exception& e)
{
std::cerr << e.what();
}
}
return sc->F;
}
示例13: import_from_bundle
bool Layer_list_model::import_from_bundle(Bundle& bundle) {
unsigned n = bundle.size();
for (unsigned i = 0; i < n && i < layers.size(); i++) {
unsigned layer_index = 0;
QString layer_name = bundle.layer_name(i);
QByteArray layer_state = bundle.layer_state(i);
while (layer_index < layers.size() && layer_name != layers[layer_index]->get_name()) {
layer_index++;
}
if (layer_index==layers.size()) continue;
swap_in_layers(i, layer_index);
#ifdef INVALIDATE_CACHE_AT_COLOR_CHANGE
layers[i]->invalidate_cache();/// \todo why do I need this for colors? it should work without invalidating with the display lists
#endif
layers[i]->restoreState(bundle.layer_state(i));
}
// deactivate
for (unsigned i=0; i < layers.size(); i++) {
bool found = false;
QString name_from_layers = layers[i]->get_name();
for (int j=0; j<bundle.size(); j++)
if (name_from_layers == bundle.layer_name(j)) found = true;
if (!found) layers[i]->set_active(false);
}
filter_apply(filter_text, show_only_active);
emit dataChanged(QModelIndex(), QModelIndex());
emit layers_reordered();
return true;
}
示例14: function_GridColourscale
// Set colour scale for grid
bool Commands::function_GridColourscale(CommandNode* c, Bundle& obj, ReturnValue& rv)
{
if (obj.notifyNull(Bundle::GridPointer)) return false;
int cs = c->argi(0);
if ((cs < 0) || (cs > 10))
{
Messenger::print("ColourScale %i is out of range (1-10, or 0 to use object's internal colour).",cs);
return false;
}
obj.g->setColourScale(cs-1);
rv.reset();
return true;
}
示例15: cost
template<class Obs, class Bundle> double cost(const Bundle& bundle)
{
const auto nb_obs = bundle.template at_obs<Obs>().size();
if (nb_obs==0) return 0;
// std::cout << " cost without save " << std::endl;
double total = 0;
// #pragma omp parallel for reduction(+:total) if(use_omp())
for(auto iobs = bundle.template at_obs<Obs>().first() ; iobs < nb_obs ; ++iobs)
{
//total += (make_function(bundle.obs(iobs))(bundle.map(iobs))).squaredNorm() / 2;
auto pair_residu = make_function(bundle.obs(iobs))(bundle.map(iobs));
if (pair_residu.second)
total += ( pair_residu ).first.squaredNorm();
}
if (std::isnan(total))
throw NAN_ERROR(" NAN : cost_and_save");
return total/2.0;
}