这篇教程C++ v2f函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中v2f函数的典型用法代码示例。如果您正苦于以下问题:C++ v2f函数的具体用法?C++ v2f怎么用?C++ v2f使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了v2f函数的28个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: assert//.........这里部分代码省略......... NULL);*/ img2->copyTo(atlas_img, pos_in_atlas + v2s32(j*dim.Width,0), core::rect<s32>(v2s32(0,0), dim), NULL); } // Copy the borders a few times to disallow texture bleeding for(u32 side=0; side<2; side++) // top and bottom for(s32 y0=0; y0<padding; y0++) for(s32 x0=0; x0<(s32)xwise_tiling*(s32)dim.Width; x0++) { s32 dst_y; s32 src_y; if(side==0) { dst_y = y0 + pos_in_atlas.Y + dim.Height; src_y = pos_in_atlas.Y + dim.Height - 1; } else { dst_y = -y0 + pos_in_atlas.Y-1; src_y = pos_in_atlas.Y; } s32 x = x0 + pos_in_atlas.X; video::SColor c = atlas_img->getPixel(x, src_y); atlas_img->setPixel(x,dst_y,c); } img2->drop(); /* Add texture to caches */ bool reuse_old_id = false; u32 id = m_atlaspointer_cache.size(); // Check old id without fetching a texture core::map<std::string, u32>::Node *n; n = m_name_to_id.find(name); // If it exists, we will replace the old definition if(n){ id = n->getValue(); reuse_old_id = true; /*infostream<<"TextureSource::buildMainAtlas(): " <<"Replacing old AtlasPointer"<<std::endl;*/ } // Create AtlasPointer AtlasPointer ap(id); ap.atlas = NULL; // Set on the second pass ap.pos = v2f((float)pos_in_atlas.X/(float)atlas_dim.Width, (float)pos_in_atlas.Y/(float)atlas_dim.Height); ap.size = v2f((float)dim.Width/(float)atlas_dim.Width, (float)dim.Width/(float)atlas_dim.Height); ap.tiled = xwise_tiling; // Create SourceAtlasPointer and add to containers SourceAtlasPointer nap(name, ap, atlas_img, pos_in_atlas, dim); if(reuse_old_id) m_atlaspointer_cache[id] = nap; else m_atlaspointer_cache.push_back(nap); m_name_to_id[name] = id; // Increment position pos_in_atlas.Y += dim.Height + padding * 2; } /* Make texture */ video::ITexture *t = driver->addTexture("__main_atlas__", atlas_img); assert(t); /* Second pass: set texture pointer in generated AtlasPointers */ for(core::map<std::string, bool>::Iterator i = sourcelist.getIterator(); i.atEnd() == false; i++) { std::string name = i.getNode()->getKey(); if(m_name_to_id.find(name) == NULL) continue; u32 id = m_name_to_id[name]; //infostream<<"id of name "<<name<<" is "<<id<<std::endl; m_atlaspointer_cache[id].a.atlas = t; } /* Write image to file so that it can be inspected */ /*std::string atlaspath = porting::path_user + DIR_DELIM + "generated_texture_atlas.png"; infostream<<"Removing and writing texture atlas for inspection to " <<atlaspath<<std::endl; fs::RecursiveDelete(atlaspath); driver->writeImageToFile(atlas_img, atlaspath.c_str());*/}
开发者ID:fusionlightcat,项目名称:minetest,代码行数:101,
示例2: v2fnormalizestatic inline Vec2 v2fnormalize(const Vec2 &p){ Vec2 r(p.x, p.y); r.normalize(); return v2f(r.x, r.y);}
开发者ID:TheWindShan,项目名称:Test,代码行数:6,
示例3: lockvoid ParticleManager::handleParticleEvent(ClientEvent *event, IGameDef *gamedef, scene::ISceneManager* smgr, LocalPlayer *player){ if (event->type == CE_DELETE_PARTICLESPAWNER) { JMutexAutoLock lock(m_spawner_list_lock); if (m_particle_spawners.find(event->delete_particlespawner.id) != m_particle_spawners.end()) { delete m_particle_spawners.find(event->delete_particlespawner.id)->second; m_particle_spawners.erase(event->delete_particlespawner.id); } // no allocated memory in delete event return; } if (event->type == CE_ADD_PARTICLESPAWNER) { { JMutexAutoLock lock(m_spawner_list_lock); if (m_particle_spawners.find(event->add_particlespawner.id) != m_particle_spawners.end()) { delete m_particle_spawners.find(event->add_particlespawner.id)->second; m_particle_spawners.erase(event->add_particlespawner.id); } } video::ITexture *texture = gamedef->tsrc()->getTexture(*(event->add_particlespawner.texture)); ParticleSpawner* toadd = new ParticleSpawner(gamedef, smgr, player, event->add_particlespawner.amount, event->add_particlespawner.spawntime, *event->add_particlespawner.minpos, *event->add_particlespawner.maxpos, *event->add_particlespawner.minvel, *event->add_particlespawner.maxvel, *event->add_particlespawner.minacc, *event->add_particlespawner.maxacc, event->add_particlespawner.minexptime, event->add_particlespawner.maxexptime, event->add_particlespawner.minsize, event->add_particlespawner.maxsize, event->add_particlespawner.collisiondetection, event->add_particlespawner.vertical, texture, event->add_particlespawner.id, this); /* delete allocated content of event */ delete event->add_particlespawner.minpos; delete event->add_particlespawner.maxpos; delete event->add_particlespawner.minvel; delete event->add_particlespawner.maxvel; delete event->add_particlespawner.minacc; delete event->add_particlespawner.texture; delete event->add_particlespawner.maxacc; { JMutexAutoLock lock(m_spawner_list_lock); m_particle_spawners.insert( std::pair<u32, ParticleSpawner*>( event->add_particlespawner.id, toadd)); } return; } if (event->type == CE_SPAWN_PARTICLE) { video::ITexture *texture = gamedef->tsrc()->getTexture(*(event->spawn_particle.texture)); Particle* toadd = new Particle(gamedef, smgr, player, m_env, *event->spawn_particle.pos, *event->spawn_particle.vel, *event->spawn_particle.acc, event->spawn_particle.expirationtime, event->spawn_particle.size, event->spawn_particle.collisiondetection, event->spawn_particle.vertical, texture, v2f(0.0, 0.0), v2f(1.0, 1.0)); addParticle(toadd); delete event->spawn_particle.pos; delete event->spawn_particle.vel; delete event->spawn_particle.acc; return; }}
开发者ID:proller,项目名称:minetest,代码行数:93,
示例4: v2fmultstatic inline Vec2 v2fmult(const Vec2 &v, float s){ return v2f(v.x * s, v.y * s);}
开发者ID:TheWindShan,项目名称:Test,代码行数:4,
示例5: v2fnegstatic inline Vec2 v2fneg(const Vec2 &p0){ return v2f(-p0.x, - p0.y);}
开发者ID:TheWindShan,项目名称:Test,代码行数:4,
示例6: v2fforanglestatic inline ccVertex2F v2fforangle(float _a_){ return v2f(cosf(_a_), sinf(_a_));}
开发者ID:hgl888,项目名称:DialogGl,代码行数:4,
示例7: v2faddstatic inline Vec2 v2fadd(const Vec2 &v0, const Vec2 &v1){ return v2f(v0.x+v1.x, v0.y+v1.y);}
开发者ID:TheWindShan,项目名称:Test,代码行数:4,
示例8: v2fnormalizestatic inline Vec2 v2fnormalize(const Vec2 &p){ Vec2 r = Vec2(p.x, p.y).getNormalized(); return v2f(r.x, r.y);}
开发者ID:CatalystApps,项目名称:Cocos2dxv3_GAFSampleGame,代码行数:5,
示例9: init_argsbool ClientLauncher::run(GameParams &game_params, const Settings &cmd_args){ init_args(game_params, cmd_args); // List video modes if requested if (list_video_modes) return print_video_modes(); if (!init_engine(game_params.log_level)) { errorstream << "Could not initialize game engine." << std::endl; return false; } // Create time getter g_timegetter = new IrrlichtTimeGetter(device); // Speed tests (done after irrlicht is loaded to get timer) if (cmd_args.getFlag("speedtests")) { dstream << "Running speed tests" << std::endl; speed_tests(); return true; } video::IVideoDriver *video_driver = device->getVideoDriver(); if (video_driver == NULL) { errorstream << "Could not initialize video driver." << std::endl; return false; } porting::setXorgClassHint(video_driver->getExposedVideoData(), PROJECT_NAME_C); /* This changes the minimum allowed number of vertices in a VBO. Default is 500. */ //driver->setMinHardwareBufferVertexCount(50); video_driver->setMinHardwareBufferVertexCount(100); // Create game callback for menus g_gamecallback = new MainGameCallback(device); device->setResizable(true); if (random_input) input = new RandomInputHandler(); else input = new RealInputHandler(device, receiver); smgr = device->getSceneManager(); smgr->getParameters()->setAttribute(scene::ALLOW_ZWRITE_ON_TRANSPARENT, true); guienv = device->getGUIEnvironment(); skin = guienv->getSkin(); skin->setColor(gui::EGDC_BUTTON_TEXT, video::SColor(255, 255, 255, 255)); skin->setColor(gui::EGDC_3D_LIGHT, video::SColor(0, 0, 0, 0)); skin->setColor(gui::EGDC_3D_HIGH_LIGHT, video::SColor(255, 30, 30, 30)); skin->setColor(gui::EGDC_3D_SHADOW, video::SColor(255, 0, 0, 0)); skin->setColor(gui::EGDC_HIGH_LIGHT, video::SColor(255, 56, 121, 65)); skin->setColor(gui::EGDC_HIGH_LIGHT_TEXT, video::SColor(255, 255, 255, 255)); g_fontengine = new FontEngine(g_settings, guienv); FATAL_ERROR_IF(g_fontengine == NULL, "Font engine creation failed.");#if (IRRLICHT_VERSION_MAJOR >= 1 && IRRLICHT_VERSION_MINOR >= 8) || IRRLICHT_VERSION_MAJOR >= 2 // Irrlicht 1.8 input colours skin->setColor(gui::EGDC_EDITABLE, video::SColor(255, 128, 128, 128)); skin->setColor(gui::EGDC_FOCUSED_EDITABLE, video::SColor(255, 97, 173, 109));#endif // Create the menu clouds if (!g_menucloudsmgr) g_menucloudsmgr = smgr->createNewSceneManager(); if (!g_menuclouds) g_menuclouds = new Clouds(g_menucloudsmgr->getRootSceneNode(), g_menucloudsmgr, -1, rand(), 100); g_menuclouds->update(v2f(0, 0), video::SColor(255, 200, 200, 255)); scene::ICameraSceneNode* camera; camera = g_menucloudsmgr->addCameraSceneNode(0, v3f(0, 0, 0), v3f(0, 60, 100)); camera->setFarValue(10000); /* GUI stuff */ ChatBackend chat_backend; // If an error occurs, this is set to something by menu(). // It is then displayed before the menu shows on the next call to menu() std::string error_message; bool reconnect_requested = false; bool first_loop = true; /* Menu-game loop */ bool retval = true; bool *kill = porting::signal_handler_killstatus();//.........这里部分代码省略.........
开发者ID:stormchaser3000,项目名称:freeminer,代码行数:101,
示例10: switchvoid ParticleManager::handleParticleEvent(ClientEvent *event, Client *client, LocalPlayer *player){ switch (event->type) { case CE_DELETE_PARTICLESPAWNER: { MutexAutoLock lock(m_spawner_list_lock); if (m_particle_spawners.find(event->delete_particlespawner.id) != m_particle_spawners.end()) { delete m_particle_spawners.find(event->delete_particlespawner.id)->second; m_particle_spawners.erase(event->delete_particlespawner.id); } // no allocated memory in delete event break; } case CE_ADD_PARTICLESPAWNER: { { MutexAutoLock lock(m_spawner_list_lock); if (m_particle_spawners.find(event->add_particlespawner.id) != m_particle_spawners.end()) { delete m_particle_spawners.find(event->add_particlespawner.id)->second; m_particle_spawners.erase(event->add_particlespawner.id); } } video::ITexture *texture = client->tsrc()->getTextureForMesh(*(event->add_particlespawner.texture)); ParticleSpawner *toadd = new ParticleSpawner(client, player, event->add_particlespawner.amount, event->add_particlespawner.spawntime, *event->add_particlespawner.minpos, *event->add_particlespawner.maxpos, *event->add_particlespawner.minvel, *event->add_particlespawner.maxvel, *event->add_particlespawner.minacc, *event->add_particlespawner.maxacc, event->add_particlespawner.minexptime, event->add_particlespawner.maxexptime, event->add_particlespawner.minsize, event->add_particlespawner.maxsize, event->add_particlespawner.collisiondetection, event->add_particlespawner.collision_removal, event->add_particlespawner.object_collision, event->add_particlespawner.attached_id, event->add_particlespawner.vertical, texture, event->add_particlespawner.id, event->add_particlespawner.animation, event->add_particlespawner.glow, this); /* delete allocated content of event */ delete event->add_particlespawner.minpos; delete event->add_particlespawner.maxpos; delete event->add_particlespawner.minvel; delete event->add_particlespawner.maxvel; delete event->add_particlespawner.minacc; delete event->add_particlespawner.texture; delete event->add_particlespawner.maxacc; { MutexAutoLock lock(m_spawner_list_lock); m_particle_spawners.insert( std::pair<u32, ParticleSpawner*>( event->add_particlespawner.id, toadd)); } break; } case CE_SPAWN_PARTICLE: { video::ITexture *texture = client->tsrc()->getTextureForMesh(*(event->spawn_particle.texture)); Particle *toadd = new Particle(client, player, m_env, *event->spawn_particle.pos, *event->spawn_particle.vel, *event->spawn_particle.acc, event->spawn_particle.expirationtime, event->spawn_particle.size, event->spawn_particle.collisiondetection, event->spawn_particle.collision_removal, event->spawn_particle.object_collision, event->spawn_particle.vertical, texture, v2f(0.0, 0.0), v2f(1.0, 1.0), event->spawn_particle.animation, event->spawn_particle.glow); addParticle(toadd); delete event->spawn_particle.pos; delete event->spawn_particle.vel; delete event->spawn_particle.acc; delete event->spawn_particle.texture; break; } default: break; }//.........这里部分代码省略.........
开发者ID:Gael-de-Sailly,项目名称:minetest,代码行数:101,
示例11: checkobject// hud_add(self, form)int ObjectRef::l_hud_add(lua_State *L){ NO_MAP_LOCK_REQUIRED; ObjectRef *ref = checkobject(L, 1); Player *player = getplayer(ref); if (player == NULL) return 0; HudElement *elem = new HudElement; elem->type = (HudElementType)getenumfield(L, 2, "hud_elem_type", es_HudElementType, HUD_ELEM_TEXT); lua_getfield(L, 2, "position"); elem->pos = lua_istable(L, -1) ? read_v2f(L, -1) : v2f(); lua_pop(L, 1); lua_getfield(L, 2, "scale"); elem->scale = lua_istable(L, -1) ? read_v2f(L, -1) : v2f(); lua_pop(L, 1); lua_getfield(L, 2, "size"); elem->size = lua_istable(L, -1) ? read_v2s32(L, -1) : v2s32(); lua_pop(L, 1); elem->name = getstringfield_default(L, 2, "name", ""); elem->text = getstringfield_default(L, 2, "text", ""); elem->number = getintfield_default(L, 2, "number", 0); elem->item = getintfield_default(L, 2, "item", 0); elem->dir = getintfield_default(L, 2, "direction", 0); // Deprecated, only for compatibility's sake if (elem->dir == 0) elem->dir = getintfield_default(L, 2, "dir", 0); lua_getfield(L, 2, "alignment"); elem->align = lua_istable(L, -1) ? read_v2f(L, -1) : v2f(); lua_pop(L, 1); lua_getfield(L, 2, "offset"); elem->offset = lua_istable(L, -1) ? read_v2f(L, -1) : v2f(); lua_pop(L, 1); lua_getfield(L, 2, "world_pos"); elem->world_pos = lua_istable(L, -1) ? read_v3f(L, -1) : v3f(); lua_pop(L, 1); /* check for known deprecated element usage */ if ((elem->type == HUD_ELEM_STATBAR) && (elem->size == v2s32())) { log_deprecated(L,"Deprecated usage of statbar without size!"); } u32 id = getServer(L)->hudAdd(player, elem); if (id == U32_MAX) { delete elem; return 0; } lua_pushnumber(L, id); return 1;}
开发者ID:hondalyfe88,项目名称:MultiCraft,代码行数:62,
示例12: draw_odraw_o() { bgntmesh(); v2f(o_data[0]); v2f(o_data[1]); v2f(o_data[2]); v2f(o_data[3]); v2f(o_data[4]); v2f(o_data[5]); v2f(o_data[6]); v2f(o_data[7]); v2f(o_data[8]); v2f(o_data[9]); v2f(o_data[10]); v2f(o_data[11]); v2f(o_data[12]); v2f(o_data[13]); v2f(o_data[14]); v2f(o_data[15]); v2f(o_data[16]); v2f(o_data[17]); v2f(o_data[18]); v2f(o_data[19]); v2f(o_data[20]); v2f(o_data[21]); v2f(o_data[22]); v2f(o_data[23]); v2f(o_data[24]); v2f(o_data[25]); v2f(o_data[26]); v2f(o_data[27]); v2f(o_data[28]); v2f(o_data[29]); v2f(o_data[30]); v2f(o_data[31]); v2f(o_data[32]); endtmesh(); bgnline(); v2f(o_data[0]); v2f(o_data[2]); v2f(o_data[4]); v2f(o_data[6]); v2f(o_data[8]); v2f(o_data[10]); v2f(o_data[12]); v2f(o_data[14]); v2f(o_data[16]); v2f(o_data[18]); v2f(o_data[20]); v2f(o_data[22]); v2f(o_data[24]); v2f(o_data[26]); v2f(o_data[28]); v2f(o_data[30]); v2f(o_data[32]); v2f(o_data[31]); v2f(o_data[29]); v2f(o_data[27]); v2f(o_data[25]); v2f(o_data[23]); v2f(o_data[21]); v2f(o_data[19]); v2f(o_data[17]); v2f(o_data[15]); v2f(o_data[13]); v2f(o_data[11]); v2f(o_data[9]); v2f(o_data[7]); v2f(o_data[5]); v2f(o_data[3]); v2f(o_data[1]); endline();}
开发者ID:bartgrantham,项目名称:alice,代码行数:75,
示例13: v3fv3f:: v3f ( float x1, float y1, float z1 ) : x ( x1 ), y ( y1 ), z ( z1 ){}ostream& operator<< ( ostream& s, const v3f& v ){ return s << "(" << v.x << "," << v.y << "," << v.z << ")";}// ======================================chromaticities ChromaticitiesForACES = { v2f(0.73470f, 0.26530f), v2f(0.00000f, 1.00000f), v2f(0.00010f,-0.07700f), v2f(0.32168f, 0.33767f) }; //acesacesHeaderInfo:: acesHeaderInfo(): // initialize required attributes to required, or default, valuesacesImageContainerFlag ( 1 ), pixelAspectRatio ( 1.0f ),screenWindowWidth ( 1.0f ),// initialize optional attributes to "ignored" valuesaltitude ( 0.0f ),aperture ( 0.0f ),
开发者ID:alexfry,项目名称:aces_container,代码行数:30,
示例14: v2fperpstatic inline ccVertex2F v2fperp(const ccVertex2F &p0){ return v2f(-p0.y, p0.x);}
开发者ID:hgl888,项目名称:DialogGl,代码行数:4,
示例15: bufvoid TestSerialization::testBufReader(){ u8 u8_data; u16 u16_data; u32 u32_data; u64 u64_data; s8 s8_data; s16 s16_data; s32 s32_data; s64 s64_data; f32 f32_data, f32_data2, f32_data3, f32_data4; video::SColor scolor_data; v2s16 v2s16_data; v3s16 v3s16_data; v2s32 v2s32_data; v3s32 v3s32_data; v2f v2f_data; v3f v3f_data; std::string string_data; std::wstring widestring_data; std::string longstring_data; u8 raw_data[10] = {0}; BufReader buf(test_serialized_data, sizeof(test_serialized_data)); // Try reading data like normal UASSERT(buf.getU8() == 0x11); UASSERT(buf.getU16() == 0x2233); UASSERT(buf.getU32() == 0x44556677); UASSERT(buf.getU64() == 0x8899AABBCCDDEEFF); UASSERT(buf.getS8() == -128); UASSERT(buf.getS16() == 30000); UASSERT(buf.getS32() == -6); UASSERT(buf.getS64() == -43); UASSERT(buf.getF1000() == 53.534f); UASSERT(buf.getF1000() == -300000.32f); UASSERT(buf.getF1000() == F1000_MIN); UASSERT(buf.getF1000() == F1000_MAX); UASSERT(buf.getString() == "foobar!"); UASSERT(buf.getV2S16() == v2s16(500, 500)); UASSERT(buf.getV3S16() == v3s16(4207, 604, -30)); UASSERT(buf.getV2S32() == v2s32(1920, 1080)); UASSERT(buf.getV3S32() == v3s32(-400, 6400054, 290549855)); UASSERT(buf.getV2F1000() == v2f(500.656f, 350.345f)); UASSERT(buf.getWideString() == L"/x02~woof~/x5455"); UASSERT(buf.getV3F1000() == v3f(500, 10024.2f, -192.54f)); UASSERT(buf.getARGB8() == video::SColor(255, 128, 50, 128)); UASSERT(buf.getLongString() == "some longer string here"); // Verify the offset and data is unchanged after a failed read size_t orig_pos = buf.pos; u32_data = 0; UASSERT(buf.getU32NoEx(&u32_data) == false); UASSERT(buf.pos == orig_pos); UASSERT(u32_data == 0); // Now try the same for a failed string read UASSERT(buf.getStringNoEx(&string_data) == false); UASSERT(buf.pos == orig_pos); UASSERT(string_data == ""); // Now try the same for a failed string read UASSERT(buf.getWideStringNoEx(&widestring_data) == false); UASSERT(buf.pos == orig_pos); UASSERT(widestring_data == L""); UASSERT(buf.getU16() == 0xF00D); UASSERT(buf.remaining() == 0); // Check to make sure these each blow exceptions as they're supposed to EXCEPTION_CHECK(SerializationError, buf.getU8()); EXCEPTION_CHECK(SerializationError, buf.getU16()); EXCEPTION_CHECK(SerializationError, buf.getU32()); EXCEPTION_CHECK(SerializationError, buf.getU64()); EXCEPTION_CHECK(SerializationError, buf.getS8()); EXCEPTION_CHECK(SerializationError, buf.getS16()); EXCEPTION_CHECK(SerializationError, buf.getS32()); EXCEPTION_CHECK(SerializationError, buf.getS64()); EXCEPTION_CHECK(SerializationError, buf.getF1000()); EXCEPTION_CHECK(SerializationError, buf.getARGB8()); EXCEPTION_CHECK(SerializationError, buf.getV2S16()); EXCEPTION_CHECK(SerializationError, buf.getV3S16()); EXCEPTION_CHECK(SerializationError, buf.getV2S32()); EXCEPTION_CHECK(SerializationError, buf.getV3S32()); EXCEPTION_CHECK(SerializationError, buf.getV2F1000()); EXCEPTION_CHECK(SerializationError, buf.getV3F1000()); EXCEPTION_CHECK(SerializationError, buf.getString()); EXCEPTION_CHECK(SerializationError, buf.getWideString()); EXCEPTION_CHECK(SerializationError, buf.getLongString()); EXCEPTION_CHECK(SerializationError, buf.getRawData(raw_data, sizeof(raw_data))); // See if we can skip backwards buf.pos = 5; UASSERT(buf.getRawDataNoEx(raw_data, 3) == true);//.........这里部分代码省略.........
开发者ID:MultiCraftProject,项目名称:MultiCraft,代码行数:101,
示例16: v2fnegstatic inline ccVertex2F v2fneg(const ccVertex2F &p0){ return v2f(-p0.x, - p0.y);}
开发者ID:hgl888,项目名称:DialogGl,代码行数:4,
示例17: v2fnormalizestatic inline ccVertex2F v2fnormalize(const ccVertex2F &p){ CCPoint r = ccpNormalize(ccp(p.x, p.y)); return v2f(r.x, r.y);}
开发者ID:hgl888,项目名称:DialogGl,代码行数:5,
示例18: spvoid Clouds::render(){ video::IVideoDriver* driver = SceneManager->getVideoDriver(); if(SceneManager->getSceneNodeRenderPass() != scene::ESNRP_TRANSPARENT) //if(SceneManager->getSceneNodeRenderPass() != scene::ESNRP_SOLID) return; ScopeProfiler sp(g_profiler, "Rendering of clouds, avg", SPT_AVG); bool enable_3d = g_settings->getBool("enable_3d_clouds"); int num_faces_to_draw = enable_3d ? 6 : 1; m_material.setFlag(video::EMF_BACK_FACE_CULLING, enable_3d); driver->setTransform(video::ETS_WORLD, AbsoluteTransformation); driver->setMaterial(m_material); /* Clouds move from X+ towards X- */ const s16 cloud_radius_i = 12; const float cloud_size = BS*64; const v2f cloud_speed(0, -BS*2); const float cloud_full_radius = cloud_size * cloud_radius_i; // Position of cloud noise origin in world coordinates v2f world_cloud_origin_pos_f = m_time*cloud_speed; // Position of cloud noise origin from the camera v2f cloud_origin_from_camera_f = world_cloud_origin_pos_f - m_camera_pos; // The center point of drawing in the noise v2f center_of_drawing_in_noise_f = -cloud_origin_from_camera_f; // The integer center point of drawing in the noise v2s16 center_of_drawing_in_noise_i( MYROUND(center_of_drawing_in_noise_f.X / cloud_size), MYROUND(center_of_drawing_in_noise_f.Y / cloud_size) ); // The world position of the integer center point of drawing in the noise v2f world_center_of_drawing_in_noise_f = v2f( center_of_drawing_in_noise_i.X * cloud_size, center_of_drawing_in_noise_i.Y * cloud_size ) + world_cloud_origin_pos_f; /*video::SColor c_top(128,b*240,b*240,b*255); video::SColor c_side_1(128,b*230,b*230,b*255); video::SColor c_side_2(128,b*220,b*220,b*245); video::SColor c_bottom(128,b*205,b*205,b*230);*/ video::SColorf c_top_f(m_color); video::SColorf c_side_1_f(m_color); video::SColorf c_side_2_f(m_color); video::SColorf c_bottom_f(m_color); c_side_1_f.r *= 0.95; c_side_1_f.g *= 0.95; c_side_1_f.b *= 0.95; c_side_2_f.r *= 0.90; c_side_2_f.g *= 0.90; c_side_2_f.b *= 0.90; c_bottom_f.r *= 0.80; c_bottom_f.g *= 0.80; c_bottom_f.b *= 0.80; c_top_f.a = 0.9; c_side_1_f.a = 0.9; c_side_2_f.a = 0.9; c_bottom_f.a = 0.9; video::SColor c_top = c_top_f.toSColor(); video::SColor c_side_1 = c_side_1_f.toSColor(); video::SColor c_side_2 = c_side_2_f.toSColor(); video::SColor c_bottom = c_bottom_f.toSColor(); // Get fog parameters for setting them back later video::SColor fog_color(0,0,0,0); video::E_FOG_TYPE fog_type = video::EFT_FOG_LINEAR; f32 fog_start = 0; f32 fog_end = 0; f32 fog_density = 0; bool fog_pixelfog = false; bool fog_rangefog = false; driver->getFog(fog_color, fog_type, fog_start, fog_end, fog_density, fog_pixelfog, fog_rangefog); // Set our own fog driver->setFog(fog_color, fog_type, cloud_full_radius * 0.5, cloud_full_radius*1.2, fog_density, fog_pixelfog, fog_rangefog); // Read noise bool *grid = new bool[cloud_radius_i*2*cloud_radius_i*2]; for(s16 zi=-cloud_radius_i; zi<cloud_radius_i; zi++) for(s16 xi=-cloud_radius_i; xi<cloud_radius_i; xi++) { u32 i = (zi+cloud_radius_i)*cloud_radius_i*2 + xi+cloud_radius_i; v2s16 p_in_noise_i( xi+center_of_drawing_in_noise_i.X, zi+center_of_drawing_in_noise_i.Y );//.........这里部分代码省略.........
开发者ID:1CoreyDev1,项目名称:minetest,代码行数:101,
示例19: v2fsubstatic inline Vec2 v2fsub(const Vec2 &v0, const Vec2 &v1){ return v2f(v0.x-v1.x, v0.y-v1.y);}
开发者ID:TheWindShan,项目名称:Test,代码行数:4,
示例20: grid_speedvoid FarMesh::render(){ video::IVideoDriver* driver = SceneManager->getVideoDriver(); /*if(SceneManager->getSceneNodeRenderPass() != scene::ESNRP_TRANSPARENT) return;*/ if(SceneManager->getSceneNodeRenderPass() != scene::ESNRP_SOLID) return; /*if(SceneManager->getSceneNodeRenderPass() != scene::ESNRP_SKY_BOX) return;*/ driver->setTransform(video::ETS_WORLD, AbsoluteTransformation); //const s16 grid_radius_i = 12; //const float grid_size = BS*50; const s16 grid_radius_i = m_render_range/MAP_BLOCKSIZE; const float grid_size = BS*MAP_BLOCKSIZE; const v2f grid_speed(-BS*0, 0); // Position of grid noise origin in world coordinates v2f world_grid_origin_pos_f(0,0); // Position of grid noise origin from the camera v2f grid_origin_from_camera_f = world_grid_origin_pos_f - m_camera_pos; // The center point of drawing in the noise v2f center_of_drawing_in_noise_f = -grid_origin_from_camera_f; // The integer center point of drawing in the noise v2s16 center_of_drawing_in_noise_i( MYROUND(center_of_drawing_in_noise_f.X / grid_size), MYROUND(center_of_drawing_in_noise_f.Y / grid_size) ); // The world position of the integer center point of drawing in the noise v2f world_center_of_drawing_in_noise_f = v2f( center_of_drawing_in_noise_i.X * grid_size, center_of_drawing_in_noise_i.Y * grid_size ) + world_grid_origin_pos_f; for(s16 zi=-grid_radius_i; zi<grid_radius_i; zi++) for(s16 xi=-grid_radius_i; xi<grid_radius_i; xi++) { /*// Don't draw very close to player s16 dd = 3; if(zi > -dd && zi < dd && xi > -dd && xi < dd) continue;*/ v2s16 p_in_noise_i( xi+center_of_drawing_in_noise_i.X, zi+center_of_drawing_in_noise_i.Y ); // If sector was drawn, don't draw it this way if(m_client->m_env.getClientMap().sectorWasDrawn(p_in_noise_i)) continue; /*if((p_in_noise_i.X + p_in_noise_i.Y)%2==0) continue;*/ /*if((p_in_noise_i.X/2 + p_in_noise_i.Y/2)%2==0) continue;*/ v2f p0 = v2f(xi,zi)*grid_size + world_center_of_drawing_in_noise_f; /*double noise[4]; double d = 100*BS; noise[0] = d*noise2d_perlin( (float)(p_in_noise_i.X+0)*grid_size/BS/100, (float)(p_in_noise_i.Y+0)*grid_size/BS/100, m_seed, 3, 0.5); noise[1] = d*noise2d_perlin( (float)(p_in_noise_i.X+0)*grid_size/BS/100, (float)(p_in_noise_i.Y+1)*grid_size/BS/100, m_seed, 3, 0.5); noise[2] = d*noise2d_perlin( (float)(p_in_noise_i.X+1)*grid_size/BS/100, (float)(p_in_noise_i.Y+1)*grid_size/BS/100, m_seed, 3, 0.5); noise[3] = d*noise2d_perlin( (float)(p_in_noise_i.X+1)*grid_size/BS/100, (float)(p_in_noise_i.Y+0)*grid_size/BS/100, m_seed, 3, 0.5);*/ HeightPoint hps[5]; hps[0] = ground_height(m_seed, v2s16( (p_in_noise_i.X+0)*grid_size/BS, (p_in_noise_i.Y+0)*grid_size/BS)); hps[1] = ground_height(m_seed, v2s16( (p_in_noise_i.X+0)*grid_size/BS, (p_in_noise_i.Y+1)*grid_size/BS)); hps[2] = ground_height(m_seed, v2s16( (p_in_noise_i.X+1)*grid_size/BS, (p_in_noise_i.Y+1)*grid_size/BS)); hps[3] = ground_height(m_seed, v2s16( (p_in_noise_i.X+1)*grid_size/BS, (p_in_noise_i.Y+0)*grid_size/BS)); v2s16 centerpoint( (p_in_noise_i.X+0)*grid_size/BS+MAP_BLOCKSIZE/2, (p_in_noise_i.Y+0)*grid_size/BS+MAP_BLOCKSIZE/2); hps[4] = ground_height(m_seed, centerpoint); //.........这里部分代码省略.........
开发者ID:Neear,项目名称:minetest,代码行数:101,
示例21: v2fperpstatic inline Vec2 v2fperp(const Vec2 &p0){ return v2f(-p0.y, p0.x);}
开发者ID:TheWindShan,项目名称:Test,代码行数:4,
示例22: v2faddstatic inline ccVertex2F v2fadd(const ccVertex2F &v0, const ccVertex2F &v1){ return v2f(v0.x+v1.x, v0.y+v1.y);}
开发者ID:hgl888,项目名称:DialogGl,代码行数:4,
示例23: v2fforanglestatic inline Vec2 v2fforangle(float _a_){ return v2f(cosf(_a_), sinf(_a_));}
开发者ID:TheWindShan,项目名称:Test,代码行数:4,
示例24: v2fsubstatic inline ccVertex2F v2fsub(const ccVertex2F &v0, const ccVertex2F &v1){ return v2f(v0.x-v1.x, v0.y-v1.y);}
开发者ID:hgl888,项目名称:DialogGl,代码行数:4,
示例25: random_v3fvoid ParticleSpawner::step(float dtime, ClientEnvironment* env){ m_time += dtime; if (m_spawntime != 0) // Spawner exists for a predefined timespan { for(std::vector<float>::iterator i = m_spawntimes.begin(); i != m_spawntimes.end();) { if ((*i) <= m_time && m_amount > 0) { m_amount--; v3f pos = random_v3f(m_minpos, m_maxpos); v3f vel = random_v3f(m_minvel, m_maxvel); v3f acc = random_v3f(m_minacc, m_maxacc); float exptime = rand()/(float)RAND_MAX *(m_maxexptime-m_minexptime) +m_minexptime; float size = rand()/(float)RAND_MAX *(m_maxsize-m_minsize) +m_minsize; Particle* toadd = new Particle( m_gamedef, m_smgr, m_player, env, pos, vel, acc, exptime, size, m_collisiondetection, m_vertical, m_texture, v2f(0.0, 0.0), v2f(1.0, 1.0)); m_particlemanager->addParticle(toadd); i = m_spawntimes.erase(i); } else { i++; } } } else // Spawner exists for an infinity timespan, spawn on a per-second base { for (int i = 0; i <= m_amount; i++) { if (rand()/(float)RAND_MAX < dtime) { v3f pos = random_v3f(m_minpos, m_maxpos); v3f vel = random_v3f(m_minvel, m_maxvel); v3f acc = random_v3f(m_minacc, m_maxacc); float exptime = rand()/(float)RAND_MAX *(m_maxexptime-m_minexptime) +m_minexptime; float size = rand()/(float)RAND_MAX *(m_maxsize-m_minsize) +m_minsize; new Particle( m_gamedef, m_smgr, m_player, env, pos, vel, acc, exptime, size, m_collisiondetection, m_vertical, m_texture, v2f(0.0, 0.0), v2f(1.0, 1.0)); } } }}
开发者ID:proller,项目名称:minetest,代码行数:82,
示例26: v2fmultstatic inline ccVertex2F v2fmult(const ccVertex2F &v, float s){ return v2f(v.x * s, v.y * s);}
开发者ID:hgl888,项目名称:DialogGl,代码行数:4,
示例27: mapFromGlobalbool QTerrain::Update(){ if(isActiveWindow() && ds::Render::GetDevice()) { ds::Render::ClearTarget(ds::Color(0)); if(Map::Exist()) { QPoint l_Mouse = mapFromGlobal(QCursor::pos()); if(underMouse()) { Map::SetMousePosition(v2<int>(l_Mouse.x(), l_Mouse.y())); } else m_Hold = false; if(m_Hold) { if(m_Tool) m_Tool->OnUpdate(v2<int>(l_Mouse.x() + MapXDiff, l_Mouse.y() + MapYDiff) - Map::GetTransform().GetPosition() - v2f(0.0f, sin(dsDegToRad(ISO_PROJ)) * Map::GetTransform().GetPosition().Y)); } Map::Draw(); } } return true;}
开发者ID:Majchrzak,项目名称:Modern-Control,代码行数:29,
示例28: lock//.........这里部分代码省略......... video::IVideoDriver* driver = m_device->getVideoDriver(); assert(driver); video::ITexture *t = NULL; /* An image will be built from files and then converted into a texture. */ video::IImage *baseimg = NULL; // If a base image was found, copy it to baseimg if(base_image_id != 0) { JMutexAutoLock lock(m_atlaspointer_cache_mutex); SourceAtlasPointer ap = m_atlaspointer_cache[base_image_id]; video::IImage *image = ap.atlas_img; if(image == NULL) { infostream<<"getTextureIdDirect(): WARNING: NULL image in " <<"cache: /""<<base_image_name<<"/"" <<std::endl; } else { core::dimension2d<u32> dim = ap.intsize; baseimg = driver->createImage(video::ECF_A8R8G8B8, dim); core::position2d<s32> pos_to(0,0); core::position2d<s32> pos_from = ap.intpos; image->copyTo( baseimg, // target v2s32(0,0), // position in target core::rect<s32>(pos_from, dim) // from ); /*infostream<<"getTextureIdDirect(): Loaded /"" <<base_image_name<<"/" from image cache" <<std::endl;*/ } } /* Parse out the last part of the name of the image and act according to it */ std::string last_part_of_name = name.substr(last_separator_position+1); //infostream<<"last_part_of_name=/""<<last_part_of_name<<"/""<<std::endl; // Generate image according to part of name if(!generate_image(last_part_of_name, baseimg, m_device, &m_sourcecache)) { errorstream<<"getTextureIdDirect(): " "failed to generate /""<<last_part_of_name<<"/"" <<std::endl; } // If no resulting image, print a warning if(baseimg == NULL) { errorstream<<"getTextureIdDirect(): baseimg is NULL (attempted to" " create texture /""<<name<<"/""<<std::endl; } if(baseimg != NULL) { // Create texture from resulting image t = driver->addTexture(name.c_str(), baseimg); } /* Add texture to caches (add NULL textures too) */ JMutexAutoLock lock(m_atlaspointer_cache_mutex); u32 id = m_atlaspointer_cache.size(); AtlasPointer ap(id); ap.atlas = t; ap.pos = v2f(0,0); ap.size = v2f(1,1); ap.tiled = 0; core::dimension2d<u32> baseimg_dim(0,0); if(baseimg) baseimg_dim = baseimg->getDimension(); SourceAtlasPointer nap(name, ap, baseimg, v2s32(0,0), baseimg_dim); m_atlaspointer_cache.push_back(nap); m_name_to_id.insert(name, id); /*infostream<<"getTextureIdDirect(): " <<"Returning id="<<id<<" for name /""<<name<<"/""<<std::endl;*/ return id;}
开发者ID:fusionlightcat,项目名称:minetest,代码行数:101,
注:本文中的v2f函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ v2s16函数代码示例 C++ v1函数代码示例 |