这篇教程C++ v3f函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中v3f函数的典型用法代码示例。如果您正苦于以下问题:C++ v3f函数的具体用法?C++ v3f怎么用?C++ v3f使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了v3f函数的30个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: NoiseParamsMapgenV6Params::MapgenV6Params(){ np_terrain_base = NoiseParams(-4, 20.0, v3f(250.0, 250.0, 250.0), 82341, 5, 0.6, 2.0); np_terrain_higher = NoiseParams(20, 16.0, v3f(500.0, 500.0, 500.0), 85039, 5, 0.6, 2.0); np_steepness = NoiseParams(0.85, 0.5, v3f(125.0, 125.0, 125.0), -932, 5, 0.7, 2.0); np_height_select = NoiseParams(0, 1.0, v3f(250.0, 250.0, 250.0), 4213, 5, 0.69, 2.0); np_mud = NoiseParams(4, 2.0, v3f(200.0, 200.0, 200.0), 91013, 3, 0.55, 2.0); np_beach = NoiseParams(0, 1.0, v3f(250.0, 250.0, 250.0), 59420, 3, 0.50, 2.0); np_biome = NoiseParams(0, 1.0, v3f(500.0, 500.0, 500.0), 9130, 3, 0.50, 2.0); np_cave = NoiseParams(6, 6.0, v3f(250.0, 250.0, 250.0), 34329, 3, 0.50, 2.0); np_humidity = NoiseParams(0.5, 0.5, v3f(500.0, 500.0, 500.0), 72384, 3, 0.50, 2.0); np_trees = NoiseParams(0, 1.0, v3f(125.0, 125.0, 125.0), 2, 4, 0.66, 2.0); np_apple_trees = NoiseParams(0, 1.0, v3f(100.0, 100.0, 100.0), 342902, 3, 0.45, 2.0);}
开发者ID:4Evergreen4,项目名称:minetest,代码行数:14,
示例2: setPitchvoid LocalPlayer::applyControl(float dtime, ClientEnvironment *env){ // Clear stuff swimming_vertical = false; setPitch(control.pitch); setYaw(control.yaw); // Nullify speed and don't run positioning code if the player is attached if(isAttached) { setSpeed(v3f(0,0,0)); return; } v3f move_direction = v3f(0,0,1); move_direction.rotateXZBy(getYaw()); v3f speedH = v3f(0,0,0); // Horizontal (X, Z) v3f speedV = v3f(0,0,0); // Vertical (Y) bool fly_allowed = m_gamedef->checkLocalPrivilege("fly"); bool fast_allowed = m_gamedef->checkLocalPrivilege("fast"); free_move = fly_allowed && g_settings->getBool("free_move"); bool fast_move = fast_allowed && g_settings->getBool("fast_move"); // When aux1_descends is enabled the fast key is used to go down, so fast isn't possible bool fast_climb = fast_move && control.aux1 && !g_settings->getBool("aux1_descends"); bool continuous_forward = g_settings->getBool("continuous_forward"); bool fast_pressed = false; // Whether superspeed mode is used or not superspeed = false; if(g_settings->getBool("always_fly_fast") && free_move && fast_move) superspeed = true; // Old descend control if(g_settings->getBool("aux1_descends")) { // If free movement and fast movement, always move fast if(free_move && fast_move) superspeed = true; // Auxiliary button 1 (E) if(control.aux1) { if(free_move) { // In free movement mode, aux1 descends if(fast_move) speedV.Y = -movement_speed_fast; else speedV.Y = -movement_speed_walk; } else if(in_liquid || in_liquid_stable) { speedV.Y = -movement_speed_walk; swimming_vertical = true; } else if(is_climbing) { speedV.Y = -movement_speed_climb; } else { // If not free movement but fast is allowed, aux1 is // "Turbo button" if(fast_allowed) superspeed = true; } } } // New minecraft-like descend control else { // Auxiliary button 1 (E) if(control.aux1) { if(!is_climbing) { // aux1 is "Turbo button" if(fast_allowed) superspeed = true; } if(fast_allowed) fast_pressed = true; } if(control.sneak) { if(free_move) { // In free movement mode, sneak descends if(fast_move && (control.aux1 || g_settings->getBool("always_fly_fast"))) speedV.Y = -movement_speed_fast; else speedV.Y = -movement_speed_walk; } else if(in_liquid || in_liquid_stable) {//.........这里部分代码省略.........
开发者ID:hdastwb,项目名称:freeminer,代码行数:101,
示例3: getPositionvoid LocalPlayer::move(f32 dtime, Environment *env, f32 pos_max_d, std::list<CollisionInfo> *collision_info){ Map *map = &env->getMap(); INodeDefManager *nodemgr = m_gamedef->ndef(); v3f position = getPosition(); v3f old_speed = m_speed; // Copy parent position if local player is attached if(isAttached) { setPosition(overridePosition); m_sneak_node_exists = false; return; } // Skip collision detection if noclip mode is used bool fly_allowed = m_gamedef->checkLocalPrivilege("fly"); bool noclip = m_gamedef->checkLocalPrivilege("noclip") && g_settings->getBool("noclip"); bool free_move = noclip && fly_allowed && g_settings->getBool("free_move"); if(free_move) { position += m_speed * dtime; setPosition(position); m_sneak_node_exists = false; return; } /* Collision detection */ /* Check if player is in liquid (the oscillating value) */ try{ // If in liquid, the threshold of coming out is at higher y if(in_liquid) { v3s16 pp = floatToInt(position + v3f(0,BS*0.1,0), BS); in_liquid = nodemgr->get(map->getNode(pp).getContent()).isLiquid(); liquid_viscosity = nodemgr->get(map->getNode(pp).getContent()).liquid_viscosity; } // If not in liquid, the threshold of going in is at lower y else { v3s16 pp = floatToInt(position + v3f(0,BS*0.5,0), BS); in_liquid = nodemgr->get(map->getNode(pp).getContent()).isLiquid(); liquid_viscosity = nodemgr->get(map->getNode(pp).getContent()).liquid_viscosity; } } catch(InvalidPositionException &e) { in_liquid = false; } /* Check if player is in liquid (the stable value) */ try{ v3s16 pp = floatToInt(position + v3f(0,0,0), BS); in_liquid_stable = nodemgr->get(map->getNode(pp).getContent()).isLiquid(); } catch(InvalidPositionException &e) { in_liquid_stable = false; } /* Check if player is climbing */ try { v3s16 pp = floatToInt(position + v3f(0,0.5*BS,0), BS); v3s16 pp2 = floatToInt(position + v3f(0,-0.2*BS,0), BS); is_climbing = ((nodemgr->get(map->getNode(pp).getContent()).climbable || nodemgr->get(map->getNode(pp2).getContent()).climbable) && !free_move); } catch(InvalidPositionException &e) { is_climbing = false; } /* Collision uncertainty radius Make it a bit larger than the maximum distance of movement */ //f32 d = pos_max_d * 1.1; // A fairly large value in here makes moving smoother f32 d = 0.15*BS; // This should always apply, otherwise there are glitches assert(d > pos_max_d); // Maximum distance over border for sneaking f32 sneak_max = BS*0.4;//.........这里部分代码省略.........
开发者ID:hdastwb,项目名称:freeminer,代码行数:101,
示例4: m_visible//! constructorSky::Sky(scene::ISceneNode* parent, scene::ISceneManager* mgr, s32 id, ITextureSource *tsrc): scene::ISceneNode(parent, mgr, id), m_visible(true), m_fallback_bg_color(255,255,255,255), m_first_update(true), m_brightness(0.5), m_cloud_brightness(0.5), m_bgcolor_bright_f(1,1,1,1), m_skycolor_bright_f(1,1,1,1), m_cloudcolor_bright_f(1,1,1,1){ setAutomaticCulling(scene::EAC_OFF); Box.MaxEdge.set(0,0,0); Box.MinEdge.set(0,0,0); // create material video::SMaterial mat; mat.Lighting = false; mat.ZBuffer = video::ECFN_NEVER; mat.ZWriteEnable = false; mat.AntiAliasing=0; mat.TextureLayer[0].TextureWrapU = video::ETC_CLAMP_TO_EDGE; mat.TextureLayer[0].TextureWrapV = video::ETC_CLAMP_TO_EDGE; mat.BackfaceCulling = false; m_materials[0] = mat; m_materials[1] = mat; //m_materials[1].MaterialType = video::EMT_TRANSPARENT_VERTEX_ALPHA; m_materials[1].MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL; m_materials[2] = mat; m_materials[2].setTexture(0, tsrc->getTextureForMesh("sunrisebg.png")); m_materials[2].MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL; //m_materials[2].MaterialType = video::EMT_TRANSPARENT_ADD_COLOR; m_sun_texture = tsrc->isKnownSourceImage("sun.png") ? tsrc->getTextureForMesh("sun.png") : NULL; m_moon_texture = tsrc->isKnownSourceImage("moon.png") ? tsrc->getTextureForMesh("moon.png") : NULL; m_sun_tonemap = tsrc->isKnownSourceImage("sun_tonemap.png") ? tsrc->getTexture("sun_tonemap.png") : NULL; m_moon_tonemap = tsrc->isKnownSourceImage("moon_tonemap.png") ? tsrc->getTexture("moon_tonemap.png") : NULL; if (m_sun_texture){ m_materials[3] = mat; m_materials[3].setTexture(0, m_sun_texture); m_materials[3].MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL; if (m_sun_tonemap) m_materials[3].Lighting = true; } if (m_moon_texture){ m_materials[4] = mat; m_materials[4].setTexture(0, m_moon_texture); m_materials[4].MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL; if (m_moon_tonemap) m_materials[4].Lighting = true; } for(u32 i=0; i<SKY_STAR_COUNT; i++){ m_stars[i] = v3f( myrand_range(-10000,10000), myrand_range(-10000,10000), myrand_range(-10000,10000) ); m_stars[i].normalize(); } m_directional_colored_fog = g_settings->getBool("directional_colored_fog"); sun_moon_light = mgr->addLightSceneNode(this, core::vector3df(0,MAP_GENERATION_LIMIT*BS*2,0), video::SColorf(1.0f, 0.6f, 0.7f, 1.0f), MAP_GENERATION_LIMIT*BS*5);}
开发者ID:prodigeni,项目名称:freeminer,代码行数:76,
示例5: v3f//#include "serverobject.h"#include "content_sao.h"#include "nodedef.h"#include "content_mapnode.h" // For content_mapnode_get_new_name#include "voxelalgorithms.h"#include "profiler.h"#include "settings.h" // For g_settings#include "main.h" // For g_profiler#include "emerge.h"#include "dungeongen.h"#include "treegen.h"#include "mapgen_v6.h"/////////////////// Mapgen V6 perlin noise default valuesNoiseParams nparams_v6_def_terrain_base = {-AVERAGE_MUD_AMOUNT, 20.0, v3f(250.0, 250.0, 250.0), 82341, 5, 0.6};NoiseParams nparams_v6_def_terrain_higher = {20.0, 16.0, v3f(500.0, 500.0, 500.0), 85039, 5, 0.6};NoiseParams nparams_v6_def_steepness = {0.85, 0.5, v3f(125.0, 125.0, 125.0), -932, 5, 0.7};NoiseParams nparams_v6_def_height_select = {0.5, 1.0, v3f(250.0, 250.0, 250.0), 4213, 5, 0.69};NoiseParams nparams_v6_def_mud = {AVERAGE_MUD_AMOUNT, 2.0, v3f(200.0, 200.0, 200.0), 91013, 3, 0.55};NoiseParams nparams_v6_def_beach = {0.0, 1.0, v3f(250.0, 250.0, 250.0), 59420, 3, 0.50};NoiseParams nparams_v6_def_biome = {0.0, 1.0, v3f(250.0, 250.0, 250.0), 9130, 3, 0.50};NoiseParams nparams_v6_def_cave = {6.0, 6.0, v3f(250.0, 250.0, 250.0), 34329, 3, 0.50};NoiseParams nparams_v6_def_humidity =
开发者ID:BlindBanana,项目名称:minetest,代码行数:31,
示例6: v3fvoid ClientLauncher::speed_tests(){ // volatile to avoid some potential compiler optimisations volatile static s16 temp16; volatile static f32 tempf; static v3f tempv3f1; static v3f tempv3f2; static std::string tempstring; static std::string tempstring2; tempv3f1 = v3f(); tempv3f2 = v3f(); tempstring = std::string(); tempstring2 = std::string(); { infostream << "The following test should take around 20ms." << std::endl; TimeTaker timer("Testing std::string speed"); const u32 jj = 10000; for (u32 j = 0; j < jj; j++) { tempstring = ""; tempstring2 = ""; const u32 ii = 10; for (u32 i = 0; i < ii; i++) { tempstring2 += "asd"; } for (u32 i = 0; i < ii+1; i++) { tempstring += "asd"; if (tempstring == tempstring2) break; } } } infostream << "All of the following tests should take around 100ms each." << std::endl; { TimeTaker timer("Testing floating-point conversion speed"); tempf = 0.001; for (u32 i = 0; i < 4000000; i++) { temp16 += tempf; tempf += 0.001; } } { TimeTaker timer("Testing floating-point vector speed"); tempv3f1 = v3f(1, 2, 3); tempv3f2 = v3f(4, 5, 6); for (u32 i = 0; i < 10000000; i++) { tempf += tempv3f1.dotProduct(tempv3f2); tempv3f2 += v3f(7, 8, 9); } } { TimeTaker timer("Testing std::map speed"); std::map<v2s16, f32> map1; tempf = -324; const s16 ii = 300; for (s16 y = 0; y < ii; y++) { for (s16 x = 0; x < ii; x++) { map1[v2s16(x, y)] = tempf; tempf += 1; } } for (s16 y = ii - 1; y >= 0; y--) { for (s16 x = 0; x < ii; x++) { tempf = map1[v2s16(x, y)]; } } } { infostream << "Around 5000/ms should do well here." << std::endl; TimeTaker timer("Testing mutex speed"); JMutex m; u32 n = 0; u32 i = 0; do { n += 10000; for (; i < n; i++) { m.Lock(); m.Unlock(); } } // Do at least 10ms while(timer.getTimerTime() < 10); u32 dtime = timer.stop(); u32 per_ms = n / dtime; infostream << "Done. " << dtime << "ms, " << per_ms << "/ms" << std::endl; }}
开发者ID:Calinou,项目名称:minetest,代码行数:98,
示例7: v3fint ClientMap::getBackgroundBrightness(float max_d, u32 daylight_factor, int oldvalue, bool *sunlight_seen_result){ const bool debugprint = false; INodeDefManager *ndef = m_gamedef->ndef(); static v3f z_directions[50] = { v3f(-100, 0, 0) }; static f32 z_offsets[sizeof(z_directions)/sizeof(*z_directions)] = { -1000, }; if(z_directions[0].X < -99){ for(u32 i=0; i<sizeof(z_directions)/sizeof(*z_directions); i++){ z_directions[i] = v3f( 0.01 * myrand_range(-100, 100), 1.0, 0.01 * myrand_range(-100, 100) ); z_offsets[i] = 0.01 * myrand_range(0,100); } } if(debugprint) std::cerr<<"In goes "<<PP(m_camera_direction)<<", out comes "; int sunlight_seen_count = 0; float sunlight_min_d = max_d*0.8; if(sunlight_min_d > 35*BS) sunlight_min_d = 35*BS; core::array<int> values; for(u32 i=0; i<sizeof(z_directions)/sizeof(*z_directions); i++){ v3f z_dir = z_directions[i]; z_dir.normalize(); core::CMatrix4<f32> a; a.buildRotateFromTo(v3f(0,1,0), z_dir); v3f dir = m_camera_direction; a.rotateVect(dir); int br = 0; float step = BS*1.5; if(max_d > 35*BS) step = max_d / 35 * 1.5; float off = step * z_offsets[i]; bool sunlight_seen_now = false; bool ok = getVisibleBrightness(this, m_camera_position, dir, step, 1.0, max_d*0.6+off, max_d, ndef, daylight_factor, sunlight_min_d, &br, &sunlight_seen_now); if(sunlight_seen_now) sunlight_seen_count++; if(!ok) continue; values.push_back(br); // Don't try too much if being in the sun is clear if(sunlight_seen_count >= 20) break; } int brightness_sum = 0; int brightness_count = 0; values.sort(); u32 num_values_to_use = values.size(); if(num_values_to_use >= 10) num_values_to_use -= num_values_to_use/2; else if(num_values_to_use >= 7) num_values_to_use -= num_values_to_use/3; u32 first_value_i = (values.size() - num_values_to_use) / 2; if(debugprint){ for(u32 i=0; i < first_value_i; i++) std::cerr<<values[i]<<" "; std::cerr<<"["; } for(u32 i=first_value_i; i < first_value_i+num_values_to_use; i++){ if(debugprint) std::cerr<<values[i]<<" "; brightness_sum += values[i]; brightness_count++; } if(debugprint){ std::cerr<<"]"; for(u32 i=first_value_i+num_values_to_use; i < values.size(); i++) std::cerr<<values[i]<<" "; } int ret = 0; if(brightness_count == 0){ MapNode n = getNodeNoEx(floatToInt(m_camera_position, BS)); if(ndef->get(n).param_type == CPT_LIGHT){ ret = decode_light(n.getLightBlend(daylight_factor, ndef)); } else { ret = oldvalue; //ret = blend_light(255, 0, daylight_factor); } } else { /*float pre = (float)brightness_sum / (float)brightness_count; float tmp = pre; const float d = 0.2; pre *= 1.0 + d*2; pre -= tmp * d; int preint = pre; ret = MYMAX(0, MYMIN(255, preint));*/ ret = brightness_sum / brightness_count; } if(debugprint) std::cerr<<"Result: "<<ret<<" sunlight_seen_count="//.........这里部分代码省略.........
开发者ID:AMDmi3,项目名称:minetest,代码行数:101,
示例8: DSTACKint RemoteClient::GetNextBlocks ( ServerEnvironment *env, EmergeManager * emerge, float dtime, double m_uptime, std::vector<PrioritySortedBlockTransfer> &dest){ DSTACK(FUNCTION_NAME); auto lock = lock_unique_rec(); if (!lock->owns_lock()) return 0; // Increment timers m_nothing_to_send_pause_timer -= dtime; m_nearest_unsent_reset_timer += dtime; m_time_from_building += dtime; if (m_nearest_unsent_reset) { m_nearest_unsent_reset = 0; m_nearest_unsent_reset_timer = 999; m_nothing_to_send_pause_timer = 0; m_time_from_building = 999; } if(m_nothing_to_send_pause_timer >= 0) return 0; Player *player = env->getPlayer(peer_id); // This can happen sometimes; clients and players are not in perfect sync. if(player == NULL) return 0; v3f playerpos = player->getPosition(); v3f playerspeed = player->getSpeed(); if(playerspeed.getLength() > 1000.0*BS) //cheater or bug, ignore him return 0; v3f playerspeeddir(0,0,0); if(playerspeed.getLength() > 1.0*BS) playerspeeddir = playerspeed / playerspeed.getLength(); // Predict to next block v3f playerpos_predicted = playerpos + playerspeeddir*MAP_BLOCKSIZE*BS; v3s16 center_nodepos = floatToInt(playerpos_predicted, BS); v3s16 center = getNodeBlockPos(center_nodepos); // Camera position and direction v3f camera_pos = player->getEyePosition(); v3f camera_dir = v3f(0,0,1); camera_dir.rotateYZBy(player->getPitch()); camera_dir.rotateXZBy(player->getYaw()); //infostream<<"camera_dir=("<<camera_dir<<")"<< " camera_pos="<<camera_pos<<std::endl; /* Get the starting value of the block finder radius. */ if(m_last_center != center) { m_last_center = center; m_nearest_unsent_reset_timer = 999; } if (m_last_direction.getDistanceFrom(camera_dir)>0.4) { // 1 = 90deg m_last_direction = camera_dir; m_nearest_unsent_reset_timer = 999; } /*infostream<<"m_nearest_unsent_reset_timer=" <<m_nearest_unsent_reset_timer<<std::endl;*/ // Reset periodically to workaround for some bugs or stuff if(m_nearest_unsent_reset_timer > 120.0) { m_nearest_unsent_reset_timer = 0; m_nearest_unsent_d = 0; m_nearest_unsent_reset = 0; //infostream<<"Resetting m_nearest_unsent_d for "<<peer_id<<std::endl; } //s16 last_nearest_unsent_d = m_nearest_unsent_d; s16 d_start = m_nearest_unsent_d; //infostream<<"d_start="<<d_start<<std::endl; static const u16 max_simul_sends_setting = g_settings->getU16 ("max_simultaneous_block_sends_per_client"); static const u16 max_simul_sends_usually = max_simul_sends_setting; /* Check the time from last addNode/removeNode. Decrease send rate if player is building stuff. */ static const auto full_block_send_enable_min_time_from_building = g_settings->getFloat("full_block_send_enable_min_time_from_building"); if(m_time_from_building < full_block_send_enable_min_time_from_building) { /*//.........这里部分代码省略.........
开发者ID:carriercomm,项目名称:freeminer,代码行数:101,
示例9: expvoid Camera::update(LocalPlayer* player, f32 frametime, f32 busytime, v2u32 screensize, f32 tool_reload_ratio, int current_camera_mode, ClientEnvironment &c_env){ // Get player position // Smooth the movement when walking up stairs v3f old_player_position = m_playernode->getPosition(); v3f player_position = player->getPosition(); if (player->isAttached && player->parent) player_position = player->parent->getPosition(); //if(player->touching_ground && player_position.Y > old_player_position.Y) if(player->touching_ground && player_position.Y > old_player_position.Y) { f32 oldy = old_player_position.Y; f32 newy = player_position.Y; f32 t = exp(-23*frametime); player_position.Y = oldy * t + newy * (1-t); } // Set player node transformation m_playernode->setPosition(player_position); m_playernode->setRotation(v3f(0, -1 * player->getYaw(), 0)); m_playernode->updateAbsolutePosition(); // Get camera tilt timer (hurt animation) float cameratilt = fabs(fabs(player->hurt_tilt_timer-0.75)-0.75); // Fall bobbing animation float fall_bobbing = 0; if(player->camera_impact >= 1 && current_camera_mode < CAMERA_MODE_THIRD) { if(m_view_bobbing_fall == -1) // Effect took place and has finished player->camera_impact = m_view_bobbing_fall = 0; else if(m_view_bobbing_fall == 0) // Initialize effect m_view_bobbing_fall = 1; // Convert 0 -> 1 to 0 -> 1 -> 0 fall_bobbing = m_view_bobbing_fall < 0.5 ? m_view_bobbing_fall * 2 : -(m_view_bobbing_fall - 0.5) * 2 + 1; // Smoothen and invert the above fall_bobbing = sin(fall_bobbing * 0.5 * M_PI) * -1; // Amplify according to the intensity of the impact fall_bobbing *= (1 - rangelim(50 / player->camera_impact, 0, 1)) * 5; fall_bobbing *= g_settings->getFloat("fall_bobbing_amount"); } // Calculate players eye offset for different camera modes v3f PlayerEyeOffset = player->getEyeOffset(); if (current_camera_mode == CAMERA_MODE_FIRST) PlayerEyeOffset += player->eye_offset_first; else PlayerEyeOffset += player->eye_offset_third; // Set head node transformation m_headnode->setPosition(PlayerEyeOffset+v3f(0,cameratilt*-player->hurt_tilt_strength+fall_bobbing,0)); m_headnode->setRotation(v3f(player->getPitch(), 0, cameratilt*player->hurt_tilt_strength)); m_headnode->updateAbsolutePosition(); // Compute relative camera position and target v3f rel_cam_pos = v3f(0,0,0); v3f rel_cam_target = v3f(0,0,1); v3f rel_cam_up = v3f(0,1,0); if (m_view_bobbing_anim != 0 && current_camera_mode < CAMERA_MODE_THIRD) { f32 bobfrac = my_modf(m_view_bobbing_anim * 2); f32 bobdir = (m_view_bobbing_anim < 0.5) ? 1.0 : -1.0; #if 1 f32 bobknob = 1.2; f32 bobtmp = sin(pow(bobfrac, bobknob) * M_PI); //f32 bobtmp2 = cos(pow(bobfrac, bobknob) * M_PI); v3f bobvec = v3f( 0.3 * bobdir * sin(bobfrac * M_PI), -0.28 * bobtmp * bobtmp, 0.); //rel_cam_pos += 0.2 * bobvec; //rel_cam_target += 0.03 * bobvec; //rel_cam_up.rotateXYBy(0.02 * bobdir * bobtmp * M_PI); float f = 1.0; f *= g_settings->getFloat("view_bobbing_amount"); rel_cam_pos += bobvec * f; //rel_cam_target += 0.995 * bobvec * f; rel_cam_target += bobvec * f; rel_cam_target.Z -= 0.005 * bobvec.Z * f; //rel_cam_target.X -= 0.005 * bobvec.X * f; //rel_cam_target.Y -= 0.005 * bobvec.Y * f; rel_cam_up.rotateXYBy(-0.03 * bobdir * bobtmp * M_PI * f); #else f32 angle_deg = 1 * bobdir * sin(bobfrac * M_PI); f32 angle_rad = angle_deg * M_PI / 180; f32 r = 0.05; v3f off = v3f( r * sin(angle_rad), r * (cos(angle_rad) - 1), 0); rel_cam_pos += off;//.........这里部分代码省略.........
开发者ID:FessWolf,项目名称:minetest,代码行数:101,
示例10: log_deprecated// add_particle({pos=, velocity=, acceleration=, expirationtime=,// size=, collisiondetection=, collision_removal=, object_collision=,// vertical=, texture=, player=})// pos/velocity/acceleration = {x=num, y=num, z=num}// expirationtime = num (seconds)// size = num// collisiondetection = bool// collision_removal = bool// object_collision = bool// vertical = bool// texture = e.g."default_wood.png"// animation = TileAnimation definition// glow = numint ModApiParticles::l_add_particle(lua_State *L){ MAP_LOCK_REQUIRED; // Get parameters v3f pos, vel, acc; float expirationtime, size; expirationtime = size = 1; bool collisiondetection, vertical, collision_removal, object_collision; collisiondetection = vertical = collision_removal = object_collision = false; struct TileAnimationParams animation; animation.type = TAT_NONE; std::string texture; std::string playername; u8 glow = 0; if (lua_gettop(L) > 1) // deprecated { log_deprecated(L, "Deprecated add_particle call with individual parameters instead of definition"); pos = check_v3f(L, 1); vel = check_v3f(L, 2); acc = check_v3f(L, 3); expirationtime = luaL_checknumber(L, 4); size = luaL_checknumber(L, 5); collisiondetection = readParam<bool>(L, 6); texture = luaL_checkstring(L, 7); if (lua_gettop(L) == 8) // only spawn for a single player playername = luaL_checkstring(L, 8); } else if (lua_istable(L, 1)) { lua_getfield(L, 1, "pos"); pos = lua_istable(L, -1) ? check_v3f(L, -1) : v3f(); lua_pop(L, 1); lua_getfield(L, 1, "vel"); if (lua_istable(L, -1)) { vel = check_v3f(L, -1); log_deprecated(L, "The use of vel is deprecated. " "Use velocity instead"); } lua_pop(L, 1); lua_getfield(L, 1, "velocity"); vel = lua_istable(L, -1) ? check_v3f(L, -1) : vel; lua_pop(L, 1); lua_getfield(L, 1, "acc"); if (lua_istable(L, -1)) { acc = check_v3f(L, -1); log_deprecated(L, "The use of acc is deprecated. " "Use acceleration instead"); } lua_pop(L, 1); lua_getfield(L, 1, "acceleration"); acc = lua_istable(L, -1) ? check_v3f(L, -1) : acc; lua_pop(L, 1); expirationtime = getfloatfield_default(L, 1, "expirationtime", 1); size = getfloatfield_default(L, 1, "size", 1); collisiondetection = getboolfield_default(L, 1, "collisiondetection", collisiondetection); collision_removal = getboolfield_default(L, 1, "collision_removal", collision_removal); object_collision = getboolfield_default(L, 1, "object_collision", object_collision); vertical = getboolfield_default(L, 1, "vertical", vertical); lua_getfield(L, 1, "animation"); animation = read_animation_definition(L, -1); lua_pop(L, 1); texture = getstringfield_default(L, 1, "texture", ""); playername = getstringfield_default(L, 1, "playername", ""); glow = getintfield_default(L, 1, "glow", 0); } getServer(L)->spawnParticle(playername, pos, vel, acc, expirationtime, size, collisiondetection, collision_removal, object_collision, vertical, texture, animation, glow); return 1;}
开发者ID:Gael-de-Sailly,项目名称:minetest,代码行数:96,
示例11: checkobject// hud_add(self, form)int ObjectRef::l_hud_add(lua_State *L){ NO_MAP_LOCK_REQUIRED; ObjectRef *ref = checkobject(L, 1); RemotePlayer *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:theDrake,项目名称:minetest,代码行数:62,
示例12: makeFastFacestatic void makeFastFace(TileSpec tile, u16 li0, u16 li1, u16 li2, u16 li3, v3f p, v3s16 dir, v3f scale, u8 light_source, std::vector<FastFace> &dest){ FastFace face; // Position is at the center of the cube. v3f pos = p * BS; float x0 = 0.0; float y0 = 0.0; float w = 1.0; float h = 1.0; v3f vertex_pos[4]; v3s16 vertex_dirs[4]; getNodeVertexDirs(dir, vertex_dirs); v3s16 t; u16 t1; switch (tile.rotation) { case 0: break; case 1: //R90 t = vertex_dirs[0]; vertex_dirs[0] = vertex_dirs[3]; vertex_dirs[3] = vertex_dirs[2]; vertex_dirs[2] = vertex_dirs[1]; vertex_dirs[1] = t; t1=li0; li0=li3; li3=li2; li2=li1; li1=t1; break; case 2: //R180 t = vertex_dirs[0]; vertex_dirs[0] = vertex_dirs[2]; vertex_dirs[2] = t; t = vertex_dirs[1]; vertex_dirs[1] = vertex_dirs[3]; vertex_dirs[3] = t; t1 = li0; li0 = li2; li2 = t1; t1 = li1; li1 = li3; li3 = t1; break; case 3: //R270 t = vertex_dirs[0]; vertex_dirs[0] = vertex_dirs[1]; vertex_dirs[1] = vertex_dirs[2]; vertex_dirs[2] = vertex_dirs[3]; vertex_dirs[3] = t; t1 = li0; li0 = li1; li1 = li2; li2 = li3; li3 = t1; break; case 4: //FXR90 t = vertex_dirs[0]; vertex_dirs[0] = vertex_dirs[3]; vertex_dirs[3] = vertex_dirs[2]; vertex_dirs[2] = vertex_dirs[1]; vertex_dirs[1] = t; t1 = li0; li0 = li3; li3 = li2; li2 = li1; li1 = t1; y0 += h; h *= -1; break; case 5: //FXR270 t = vertex_dirs[0]; vertex_dirs[0] = vertex_dirs[1]; vertex_dirs[1] = vertex_dirs[2]; vertex_dirs[2] = vertex_dirs[3]; vertex_dirs[3] = t; t1 = li0; li0 = li1; li1 = li2; li2 = li3; li3 = t1; y0 += h; h *= -1; break; case 6: //FYR90 t = vertex_dirs[0]; vertex_dirs[0] = vertex_dirs[3]; vertex_dirs[3] = vertex_dirs[2]; vertex_dirs[2] = vertex_dirs[1]; vertex_dirs[1] = t; t1 = li0; li0 = li3; li3 = li2; li2 = li1; li1 = t1;//.........这里部分代码省略.........
开发者ID:nsd2,项目名称:freeminer,代码行数:101,
示例13: clearHardwareBuffer//.........这里部分代码省略......... if (p.vertices[j].Normal.Y < -0.5) { applyFacesShading (vc, 0.447213); } else if (p.vertices[j].Normal.X > 0.5) { applyFacesShading (vc, 0.670820); } else if (p.vertices[j].Normal.X < -0.5) { applyFacesShading (vc, 0.670820); } else if (p.vertices[j].Normal.Z > 0.5) { applyFacesShading (vc, 0.836660); } else if (p.vertices[j].Normal.Z < -0.5) { applyFacesShading (vc, 0.836660); } } if(!m_enable_shaders) { // - Classic lighting (shaders handle this by themselves) // Set initial real color and store for later updates u8 day = vc.getRed(); u8 night = vc.getGreen(); finalColorBlend(vc, day, night, 1000); if(day != night) m_daynight_diffs[i][j] = std::make_pair(day, night); } } // Create material video::SMaterial material; material.setFlag(video::EMF_LIGHTING, false); material.setFlag(video::EMF_BACK_FACE_CULLING, true); material.setFlag(video::EMF_BILINEAR_FILTER, false); material.setFlag(video::EMF_FOG_ENABLE, true); //material.setFlag(video::EMF_WIREFRAME, true); material.setTexture(0, p.tile.texture); if (p.tile.material_flags & MATERIAL_FLAG_HIGHLIGHTED) { material.MaterialType = video::EMT_TRANSPARENT_ADD_COLOR; } else { if (m_enable_shaders) { material.MaterialType = shdrsrc->getShaderInfo(p.tile.shader_id).material; p.tile.applyMaterialOptionsWithShaders(material); if (p.tile.normal_texture) { material.setTexture(1, p.tile.normal_texture); material.setTexture(2, tsrc->getTexture("enable_img.png")); } else { material.setTexture(2, tsrc->getTexture("disable_img.png")); } } else { p.tile.applyMaterialOptions(material); } } // Create meshbuffer // This is a "Standard MeshBuffer", // it's a typedeffed CMeshBuffer<video::S3DVertex> scene::SMeshBuffer *buf = new scene::SMeshBuffer(); // Set material buf->Material = material; // Add to mesh m_mesh->addMeshBuffer(buf); // Mesh grabbed it buf->drop(); buf->append(&p.vertices[0], p.vertices.size(), &p.indices[0], p.indices.size()); } m_camera_offset = camera_offset; /* Do some stuff to the mesh */ v3f t = v3f(0,0,0); if (step>1) { scaleMesh(m_mesh, v3f(step,step,step)); // TODO: remove this wrong numbers, find formula good test: fly above ocean if (step == 2) t = v3f(BS/2, BS/2, BS/2); if (step == 4) t = v3f(BS*1.666, -BS/3.0, BS*1.666); if (step == 8) t = v3f(BS*2.666, -BS*2.4, BS*2.666); if (step == 16) t = v3f(BS*6.4, -BS*6.4, BS*6.4); } translateMesh(m_mesh, intToFloat(data->m_blockpos * MAP_BLOCKSIZE - camera_offset, BS) + t); if(m_mesh) {#if 0 // Usually 1-700 faces and 1-7 materials infostream<<"Updated MapBlock mesh p="<<data->m_blockpos<<" has "<<fastfaces_new.size()<<" faces " <<"and uses "<<m_mesh->getMeshBufferCount() <<" materials "<<" step="<<step<<" range="<<data->range<< " mesh="<<m_mesh<<std::endl;#endif } //std::cout<<"added "<<fastfaces.getSize()<<" faces."<<std::endl; // Check if animation is required for this mesh m_has_animation = !m_crack_materials.empty() || !m_daynight_diffs.empty() || !m_animation_tiles.empty() || !m_highlighted_materials.empty();}
开发者ID:nsd2,项目名称:freeminer,代码行数:101,
示例14: assertvoid MapgenV6::makeChunk(BlockMakeData *data){ // Pre-conditions assert(data->vmanip); assert(data->nodedef); assert(data->blockpos_requested.X >= data->blockpos_min.X && data->blockpos_requested.Y >= data->blockpos_min.Y && data->blockpos_requested.Z >= data->blockpos_min.Z); assert(data->blockpos_requested.X <= data->blockpos_max.X && data->blockpos_requested.Y <= data->blockpos_max.Y && data->blockpos_requested.Z <= data->blockpos_max.Z); this->generating = true; this->vm = data->vmanip; this->ndef = data->nodedef; // Hack: use minimum block coords for old code that assumes a single block v3s16 blockpos_min = data->blockpos_min; v3s16 blockpos_max = data->blockpos_max; // Area of central chunk node_min = blockpos_min * MAP_BLOCKSIZE; node_max = (blockpos_max + v3s16(1, 1, 1)) * MAP_BLOCKSIZE - v3s16(1, 1, 1); // Full allocated area full_node_min = (blockpos_min - 1) * MAP_BLOCKSIZE; full_node_max = (blockpos_max + 2) * MAP_BLOCKSIZE - v3s16(1, 1, 1); central_area_size = node_max - node_min + v3s16(1, 1, 1); assert(central_area_size.X == central_area_size.Z); int volume_blocks = (blockpos_max.X - blockpos_min.X + 1) * (blockpos_max.Y - blockpos_min.Y + 1) * (blockpos_max.Z - blockpos_max.Z + 1); volume_nodes = volume_blocks * MAP_BLOCKSIZE * MAP_BLOCKSIZE * MAP_BLOCKSIZE; // Create a block-specific seed blockseed = get_blockseed(data->seed, full_node_min); // Make some noise calculateNoise(); // Maximum height of the stone surface and obstacles. // This is used to guide the cave generation s16 stone_surface_max_y; // Generate general ground level to full area stone_surface_max_y = generateGround(); // Create initial heightmap to limit caves updateHeightmap(node_min, node_max); const s16 max_spread_amount = MAP_BLOCKSIZE; // Limit dirt flow area by 1 because mud is flown into neighbors. s16 mudflow_minpos = -max_spread_amount + 1; s16 mudflow_maxpos = central_area_size.X + max_spread_amount - 2; // Loop this part, it will make stuff look older and newer nicely const u32 age_loops = 2; for (u32 i_age = 0; i_age < age_loops; i_age++) { // Aging loop // Make caves (this code is relatively horrible) if (flags & MG_CAVES) generateCaves(stone_surface_max_y); // Add mud to the central chunk addMud(); // Flow mud away from steep edges if (spflags & MGV6_MUDFLOW) flowMud(mudflow_minpos, mudflow_maxpos); } // Update heightmap after mudflow updateHeightmap(node_min, node_max); // Add dungeons if ((flags & MG_DUNGEONS) && (stone_surface_max_y >= node_min.Y)) { DungeonParams dp; dp.seed = seed; dp.c_water = c_water_source; dp.c_river_water = c_water_source; dp.only_in_ground = true; dp.corridor_len_min = 1; dp.corridor_len_max = 13; dp.rooms_min = 2; dp.rooms_max = 16; dp.y_min = -MAX_MAP_GENERATION_LIMIT; dp.y_max = MAX_MAP_GENERATION_LIMIT; dp.np_density = NoiseParams(0.9, 0.5, v3f(500.0, 500.0, 500.0), 0, 2, 0.8, 2.0); dp.np_alt_wall = NoiseParams(-0.4, 1.0, v3f(40.0, 40.0, 40.0), 32474, 6, 1.1, 2.0); if (getBiome(0, v2s16(node_min.X, node_min.Z)) == BT_DESERT) {//.........这里部分代码省略.........
开发者ID:4Evergreen4,项目名称:minetest,代码行数:101,
示例15: generate_image//.........这里部分代码省略......... str_replace_char(part_of_name, '&', '^'); Strfnd sf(part_of_name); sf.next("{"); std::string imagename_top = sf.next("{"); std::string imagename_left = sf.next("{"); std::string imagename_right = sf.next("{"); // Generate images for the faces of the cube video::IImage *img_top = generate_image_from_scratch( imagename_top, device, sourcecache); video::IImage *img_left = generate_image_from_scratch( imagename_left, device, sourcecache); video::IImage *img_right = generate_image_from_scratch( imagename_right, device, sourcecache); assert(img_top && img_left && img_right); // Create textures from images video::ITexture *texture_top = driver->addTexture( (imagename_top + "__temp__").c_str(), img_top); video::ITexture *texture_left = driver->addTexture( (imagename_left + "__temp__").c_str(), img_left); video::ITexture *texture_right = driver->addTexture( (imagename_right + "__temp__").c_str(), img_right); assert(texture_top && texture_left && texture_right); // Drop images img_top->drop(); img_left->drop(); img_right->drop(); /* Draw a cube mesh into a render target texture */ scene::IMesh* cube = createCubeMesh(v3f(1, 1, 1)); setMeshColor(cube, video::SColor(255, 255, 255, 255)); cube->getMeshBuffer(0)->getMaterial().setTexture(0, texture_top); cube->getMeshBuffer(1)->getMaterial().setTexture(0, texture_top); cube->getMeshBuffer(2)->getMaterial().setTexture(0, texture_right); cube->getMeshBuffer(3)->getMaterial().setTexture(0, texture_right); cube->getMeshBuffer(4)->getMaterial().setTexture(0, texture_left); cube->getMeshBuffer(5)->getMaterial().setTexture(0, texture_left); core::dimension2d<u32> dim(64,64); std::string rtt_texture_name = part_of_name + "_RTT"; v3f camera_position(0, 1.0, -1.5); camera_position.rotateXZBy(45); v3f camera_lookat(0, 0, 0); core::CMatrix4<f32> camera_projection_matrix; // Set orthogonal projection camera_projection_matrix.buildProjectionMatrixOrthoLH( 1.65, 1.65, 0, 100); video::SColorf ambient_light(0.2,0.2,0.2); v3f light_position(10, 100, -50); video::SColorf light_color(0.5,0.5,0.5); f32 light_radius = 1000; video::ITexture *rtt = generateTextureFromMesh( cube, device, dim, rtt_texture_name, camera_position, camera_lookat, camera_projection_matrix, ambient_light, light_position, light_color,
开发者ID:AMDmi3,项目名称:minetest,代码行数:67,
示例16: DSTACKvoid RemoteClient::GetNextBlocks( ServerEnvironment *env, EmergeManager * emerge, float dtime, std::vector<PrioritySortedBlockTransfer> &dest){ DSTACK(__FUNCTION_NAME); // Increment timers m_nothing_to_send_pause_timer -= dtime; m_nearest_unsent_reset_timer += dtime; if(m_nothing_to_send_pause_timer >= 0) return; Player *player = env->getPlayer(peer_id); // This can happen sometimes; clients and players are not in perfect sync. if(player == NULL) return; // Won't send anything if already sending if(m_blocks_sending.size() >= g_settings->getU16 ("max_simultaneous_block_sends_per_client")) { //infostream<<"Not sending any blocks, Queue full."<<std::endl; return; } v3f playerpos = player->getPosition(); v3f playerspeed = player->getSpeed(); v3f playerspeeddir(0,0,0); if(playerspeed.getLength() > 1.0*BS) playerspeeddir = playerspeed / playerspeed.getLength(); // Predict to next block v3f playerpos_predicted = playerpos + playerspeeddir*MAP_BLOCKSIZE*BS; v3s16 center_nodepos = floatToInt(playerpos_predicted, BS); v3s16 center = getNodeBlockPos(center_nodepos); // Camera position and direction v3f camera_pos = player->getEyePosition(); v3f camera_dir = v3f(0,0,1); camera_dir.rotateYZBy(player->getPitch()); camera_dir.rotateXZBy(player->getYaw()); /*infostream<<"camera_dir=("<<camera_dir.X<<","<<camera_dir.Y<<"," <<camera_dir.Z<<")"<<std::endl;*/ /* Get the starting value of the block finder radius. */ if(m_last_center != center) { m_nearest_unsent_d = 0; m_last_center = center; } /*infostream<<"m_nearest_unsent_reset_timer=" <<m_nearest_unsent_reset_timer<<std::endl;*/ // Reset periodically to workaround for some bugs or stuff if(m_nearest_unsent_reset_timer > 20.0) { m_nearest_unsent_reset_timer = 0; m_nearest_unsent_d = 0; //infostream<<"Resetting m_nearest_unsent_d for " // <<server->getPlayerName(peer_id)<<std::endl; } //s16 last_nearest_unsent_d = m_nearest_unsent_d; s16 d_start = m_nearest_unsent_d; //infostream<<"d_start="<<d_start<<std::endl; u16 max_simul_sends_setting = g_settings->getU16 ("max_simultaneous_block_sends_per_client"); u16 max_simul_sends_usually = max_simul_sends_setting; /* Check the time from last addNode/removeNode. Decrease send rate if player is building stuff. */ m_time_from_building += dtime; if(m_time_from_building < g_settings->getFloat( "full_block_send_enable_min_time_from_building")) { max_simul_sends_usually = LIMITED_MAX_SIMULTANEOUS_BLOCK_SENDS; } /* Number of blocks sending + number of blocks selected for sending */ u32 num_blocks_selected = m_blocks_sending.size(); /*//.........这里部分代码省略.........
开发者ID:MetaDucky,项目名称:minetest,代码行数:101,
示例17: collisionMoveSimplecollisionMoveResult collisionMoveSimple(Environment *env, IGameDef *gamedef, f32 pos_max_d, const aabb3f &box_0, f32 stepheight, f32 dtime, v3f &pos_f, v3f &speed_f, v3f &accel_f,ActiveObject* self, bool collideWithObjects){ static bool time_notification_done = false; Map *map = &env->getMap(); //TimeTaker tt("collisionMoveSimple"); ScopeProfiler sp(g_profiler, "collisionMoveSimple avg", SPT_AVG); collisionMoveResult result; /* Calculate new velocity */ if (dtime > 0.5) { if (!time_notification_done) { time_notification_done = true; infostream << "collisionMoveSimple: maximum step interval exceeded," " lost movement details!"<<std::endl; } dtime = 0.5; } else { time_notification_done = false; } speed_f += accel_f * dtime; // If there is no speed, there are no collisions if(speed_f.getLength() == 0) return result; // Limit speed for avoiding hangs speed_f.Y=rangelim(speed_f.Y,-5000,5000); speed_f.X=rangelim(speed_f.X,-5000,5000); speed_f.Z=rangelim(speed_f.Z,-5000,5000); /* Collect node boxes in movement range */ std::vector<aabb3f> cboxes; std::vector<bool> is_unloaded; std::vector<bool> is_step_up; std::vector<bool> is_object; std::vector<int> bouncy_values; std::vector<v3s16> node_positions; { //TimeTaker tt2("collisionMoveSimple collect boxes"); ScopeProfiler sp(g_profiler, "collisionMoveSimple collect boxes avg", SPT_AVG); v3s16 oldpos_i = floatToInt(pos_f, BS); v3s16 newpos_i = floatToInt(pos_f + speed_f * dtime, BS); s16 min_x = MYMIN(oldpos_i.X, newpos_i.X) + (box_0.MinEdge.X / BS) - 1; s16 min_y = MYMIN(oldpos_i.Y, newpos_i.Y) + (box_0.MinEdge.Y / BS) - 1; s16 min_z = MYMIN(oldpos_i.Z, newpos_i.Z) + (box_0.MinEdge.Z / BS) - 1; s16 max_x = MYMAX(oldpos_i.X, newpos_i.X) + (box_0.MaxEdge.X / BS) + 1; s16 max_y = MYMAX(oldpos_i.Y, newpos_i.Y) + (box_0.MaxEdge.Y / BS) + 1; s16 max_z = MYMAX(oldpos_i.Z, newpos_i.Z) + (box_0.MaxEdge.Z / BS) + 1; bool any_position_valid = false; for(s16 x = min_x; x <= max_x; x++) for(s16 y = min_y; y <= max_y; y++) for(s16 z = min_z; z <= max_z; z++) { v3s16 p(x,y,z); bool is_position_valid; MapNode n = map->getNodeNoEx(p, &is_position_valid); if (is_position_valid) { // Object collides into walkable nodes any_position_valid = true; const ContentFeatures &f = gamedef->getNodeDefManager()->get(n); if(f.walkable == false) continue; int n_bouncy_value = itemgroup_get(f.groups, "bouncy"); std::vector<aabb3f> nodeboxes = n.getCollisionBoxes(gamedef->ndef()); for(std::vector<aabb3f>::iterator i = nodeboxes.begin(); i != nodeboxes.end(); ++i) { aabb3f box = *i; box.MinEdge += v3f(x, y, z)*BS; box.MaxEdge += v3f(x, y, z)*BS; cboxes.push_back(box); is_unloaded.push_back(false); is_step_up.push_back(false); bouncy_values.push_back(n_bouncy_value); node_positions.push_back(p); is_object.push_back(false); } } else { // Collide with unloaded nodes aabb3f box = getNodeBox(p, BS); cboxes.push_back(box);//.........这里部分代码省略.........
开发者ID:taserman21,项目名称:minetest,代码行数:101,
示例18: void//.........这里部分代码省略......... case NDT_MESH: f->solidness = 0; f->backface_culling = false; break; case NDT_TORCHLIKE: case NDT_SIGNLIKE: case NDT_FENCELIKE: case NDT_RAILLIKE: case NDT_NODEBOX: f->solidness = 0; break; }#ifndef SERVER if (is_liquid) { material_type = (f->alpha == 255) ? TILE_MATERIAL_LIQUID_OPAQUE : TILE_MATERIAL_LIQUID_TRANSPARENT; if (f->name == "default:water_source") is_water_surface = true; } u32 tile_shader[6]; if (shdsrc) { for (u16 j = 0; j < 6; j++) { tile_shader[j] = shdsrc->getShader("nodes_shader", material_type, f->drawtype); } if (is_water_surface) { tile_shader[0] = shdsrc->getShader("water_surface_shader", material_type, f->drawtype); } } if (tsrc) { // Tiles (fill in f->tiles[]) for (u16 j = 0; j < 6; j++) { fillTileAttribs(tsrc, &f->tiles[j], &tiledef[j], tile_shader[j], use_normal_texture, f->backface_culling, f->alpha, material_type); } // Special tiles (fill in f->special_tiles[]) for (u16 j = 0; j < CF_SPECIAL_COUNT; j++) { fillTileAttribs(tsrc, &f->special_tiles[j], &f->tiledef_special[j], tile_shader[j], use_normal_texture, f->tiledef_special[j].backface_culling, f->alpha, material_type); } if ((f->drawtype == NDT_MESH) && (f->mesh != "")) { // Meshnode drawtype // Read the mesh and apply scale f->mesh_ptr[0] = gamedef->getMesh(f->mesh); if (f->mesh_ptr[0]){ v3f scale = v3f(1.0, 1.0, 1.0) * BS * f->visual_scale; scaleMesh(f->mesh_ptr[0], scale); recalculateBoundingBox(f->mesh_ptr[0]); meshmanip->recalculateNormals(f->mesh_ptr[0], true, false); } } else if ((f->drawtype == NDT_NODEBOX) && ((f->node_box.type == NODEBOX_REGULAR) || (f->node_box.type == NODEBOX_FIXED)) && (!f->node_box.fixed.empty())) { //Convert regular nodebox nodes to meshnodes //Change the drawtype and apply scale if (!server) f->drawtype = NDT_MESH; f->mesh_ptr[0] = convertNodeboxNodeToMesh(f); v3f scale = v3f(1.0, 1.0, 1.0) * f->visual_scale; scaleMesh(f->mesh_ptr[0], scale); recalculateBoundingBox(f->mesh_ptr[0]); meshmanip->recalculateNormals(f->mesh_ptr[0], true, false); } //Cache 6dfacedir and wallmounted rotated clones of meshes if (enable_mesh_cache && f->mesh_ptr[0] && (f->param_type_2 == CPT2_FACEDIR)) { for (u16 j = 1; j < 24; j++) { f->mesh_ptr[j] = cloneMesh(f->mesh_ptr[0]); rotateMeshBy6dFacedir(f->mesh_ptr[j], j); recalculateBoundingBox(f->mesh_ptr[j]); meshmanip->recalculateNormals(f->mesh_ptr[j], true, false); } } else if (enable_mesh_cache && f->mesh_ptr[0] && (f->param_type_2 == CPT2_WALLMOUNTED)) { static const u8 wm_to_6d[6] = {20, 0, 16+1, 12+3, 8, 4+2}; for (u16 j = 1; j < 6; j++) { f->mesh_ptr[j] = cloneMesh(f->mesh_ptr[0]); rotateMeshBy6dFacedir(f->mesh_ptr[j], wm_to_6d[j]); recalculateBoundingBox(f->mesh_ptr[j]); meshmanip->recalculateNormals(f->mesh_ptr[j], true, false); } rotateMeshBy6dFacedir(f->mesh_ptr[0], wm_to_6d[0]); recalculateBoundingBox(f->mesh_ptr[0]); meshmanip->recalculateNormals(f->mesh_ptr[0], true, false); } } if (progress_callback) progress_callback(progress_callback_args, i, size);#endif }}
开发者ID:cyisfor,项目名称:freeminer,代码行数:101,
示例19: 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); // 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, 70, 120, 50)); 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, 96, 134, 49));#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 first_loop = true; /* Menu-game loop */ bool retval = true; bool *kill = porting::signal_handler_killstatus(); while (device->run() && !*kill && !g_gamecallback->shutdown_requested) {//.........这里部分代码省略.........
开发者ID:Calinou,项目名称:minetest,代码行数:101,
示例20: switch//.........这里部分代码省略......... if (waving == 1) material_type = TILE_MATERIAL_WAVING_LEAVES; break; case NDT_PLANTLIKE: solidness = 0; if (waving == 1) material_type = TILE_MATERIAL_WAVING_PLANTS; break; case NDT_FIRELIKE: solidness = 0; break; case NDT_MESH: solidness = 0; break; case NDT_TORCHLIKE: case NDT_SIGNLIKE: case NDT_FENCELIKE: case NDT_RAILLIKE: case NDT_NODEBOX: solidness = 0; break; } if (is_liquid) { material_type = (alpha == 255) ? TILE_MATERIAL_LIQUID_OPAQUE : TILE_MATERIAL_LIQUID_TRANSPARENT; if (name == "default:water_source") is_water_surface = true; } u32 tile_shader[6]; for (u16 j = 0; j < 6; j++) { tile_shader[j] = shdsrc->getShader("nodes_shader", material_type, drawtype); } if (is_water_surface) { tile_shader[0] = shdsrc->getShader("water_surface_shader", material_type, drawtype); } // Tiles (fill in f->tiles[]) for (u16 j = 0; j < 6; j++) { fillTileAttribs(tsrc, &tiles[j], &tdef[j], tile_shader[j], tsettings.use_normal_texture, tiledef[j].backface_culling, alpha, material_type); } // Special tiles (fill in f->special_tiles[]) for (u16 j = 0; j < CF_SPECIAL_COUNT; j++) { fillTileAttribs(tsrc, &special_tiles[j], &tiledef_special[j], tile_shader[j], tsettings.use_normal_texture, tiledef_special[j].backface_culling, alpha, material_type); } if ((drawtype == NDT_MESH) && (mesh != "")) { // Meshnode drawtype // Read the mesh and apply scale mesh_ptr[0] = gamedef->getMesh(mesh); if (mesh_ptr[0]){ v3f scale = v3f(1.0, 1.0, 1.0) * BS * visual_scale; scaleMesh(mesh_ptr[0], scale); recalculateBoundingBox(mesh_ptr[0]); meshmanip->recalculateNormals(mesh_ptr[0], true, false); } } else if ((drawtype == NDT_NODEBOX) && ((node_box.type == NODEBOX_REGULAR) || (node_box.type == NODEBOX_FIXED)) && (!node_box.fixed.empty())) { //Convert regular nodebox nodes to meshnodes //Change the drawtype and apply scale drawtype = NDT_MESH; mesh_ptr[0] = convertNodeboxesToMesh(node_box.fixed); v3f scale = v3f(1.0, 1.0, 1.0) * visual_scale; scaleMesh(mesh_ptr[0], scale); recalculateBoundingBox(mesh_ptr[0]); meshmanip->recalculateNormals(mesh_ptr[0], true, false); } //Cache 6dfacedir and wallmounted rotated clones of meshes if (tsettings.enable_mesh_cache && mesh_ptr[0] && (param_type_2 == CPT2_FACEDIR)) { for (u16 j = 1; j < 24; j++) { mesh_ptr[j] = cloneMesh(mesh_ptr[0]); rotateMeshBy6dFacedir(mesh_ptr[j], j); recalculateBoundingBox(mesh_ptr[j]); meshmanip->recalculateNormals(mesh_ptr[j], true, false); } } else if (tsettings.enable_mesh_cache && mesh_ptr[0] && (param_type_2 == CPT2_WALLMOUNTED)) { static const u8 wm_to_6d[6] = {20, 0, 16+1, 12+3, 8, 4+2}; for (u16 j = 1; j < 6; j++) { mesh_ptr[j] = cloneMesh(mesh_ptr[0]); rotateMeshBy6dFacedir(mesh_ptr[j], wm_to_6d[j]); recalculateBoundingBox(mesh_ptr[j]); meshmanip->recalculateNormals(mesh_ptr[j], true, false); } rotateMeshBy6dFacedir(mesh_ptr[0], wm_to_6d[0]); recalculateBoundingBox(mesh_ptr[0]); meshmanip->recalculateNormals(mesh_ptr[0], true, false); }}
开发者ID:Bremaweb,项目名称:voxeladventures-client,代码行数:101,
示例21: translate//.........这里部分代码省略......... } driver->drawIndexedTriangleFan(&vertices[0], 4, indices, 2); } else { driver->setMaterial(m_materials[4]); float d = moonsize * 1.9; video::SColor c; if (m_moon_tonemap) c = video::SColor (0,0,0,0); else c = video::SColor (255,255,255,255); vertices[0] = video::S3DVertex(-d,-d,-1, 0,0,1, c, t, t); vertices[1] = video::S3DVertex( d,-d,-1, 0,0,1, c, o, t); vertices[2] = video::S3DVertex( d, d,-1, 0,0,1, c, o, o); vertices[3] = video::S3DVertex(-d, d,-1, 0,0,1, c, t, o); for(u32 i=0; i<4; i++){ // Switch from -Z (south) to -X (west) sky_rotate(camera, SKY_ROTATE::MOON, wicked_time_of_day, vertices[i].Pos); } driver->drawIndexedTriangleFan(&vertices[0], 4, indices, 2); } if (!sun_light_drawed && sun_moon_light) { auto light_vector = core::vector3df(0, -MAP_GENERATION_LIMIT*BS*2, 0); sky_rotate(camera, SKY_ROTATE::MOONLIGHT, wicked_time_of_day, light_vector); if (light_vector.Y > 0) sun_moon_light->setPosition(light_vector); } } // Stars driver->setMaterial(m_materials[1]); do{ float starbrightness = MYMAX(0, MYMIN(1, (0.285 - fabs(wicked_time_of_day < 0.5 ? wicked_time_of_day : (1.0 - wicked_time_of_day))) * 10)); float f = starbrightness; float d = 0.007; video::SColor starcolor(255, f*90,f*90,f*90); if(starcolor.getBlue() < m_skycolor.getBlue()) break; u16 indices[SKY_STAR_COUNT*4]; video::S3DVertex vertices[SKY_STAR_COUNT*4]; for(u32 i=0; i<SKY_STAR_COUNT; i++){ indices[i*4+0] = i*4+0; indices[i*4+1] = i*4+1; indices[i*4+2] = i*4+2; indices[i*4+3] = i*4+3; v3f p = m_stars[i]; core::CMatrix4<f32> a; a.buildRotateFromTo(v3f(0,1,0), v3f(d,1+d/2,0)); v3f p1 = p; a.rotateVect(p1); a.buildRotateFromTo(v3f(0,1,0), v3f(d,1,d)); v3f p2 = p; a.rotateVect(p2); a.buildRotateFromTo(v3f(0,1,0), v3f(0,1-d/2,d)); v3f p3 = p; a.rotateVect(p3); p.rotateXYBy(wicked_time_of_day * 360 - 90); p1.rotateXYBy(wicked_time_of_day * 360 - 90); p2.rotateXYBy(wicked_time_of_day * 360 - 90); p3.rotateXYBy(wicked_time_of_day * 360 - 90); vertices[i*4+0].Pos = p; vertices[i*4+0].Color = starcolor; vertices[i*4+1].Pos = p1; vertices[i*4+1].Color = starcolor; vertices[i*4+2].Pos = p2; vertices[i*4+2].Color = starcolor; vertices[i*4+3].Pos = p3; vertices[i*4+3].Color = starcolor; } driver->drawVertexPrimitiveList(vertices, SKY_STAR_COUNT*4, indices, SKY_STAR_COUNT, video::EVT_STANDARD, scene::EPT_QUADS, video::EIT_16BIT); }while(0); for(u32 j=0; j<2; j++) { //video::SColor c = m_skycolor; video::SColor c = cloudyfogcolor; vertices[0] = video::S3DVertex(-1,-1.0,-1, 0,0,1, c, t, t); vertices[1] = video::S3DVertex( 1,-1.0,-1, 0,0,1, c, o, t); vertices[2] = video::S3DVertex( 1,-0.02+shifty,-1, 0,0,1, c, o, o); vertices[3] = video::S3DVertex(-1,-0.02+shifty,-1, 0,0,1, c, t, o); for(u32 i=0; i<4; i++){ //if(wicked_time_of_day < 0.5) if(j==0) // Switch from -Z (south) to +X (east) vertices[i].Pos.rotateXZBy(90); else // Switch from -Z (south) to -X (west) vertices[i].Pos.rotateXZBy(-90); } driver->drawIndexedTriangleFan(&vertices[0], 4, indices, 2); } }}
开发者ID:prodigeni,项目名称:freeminer,代码行数:101,
示例22: ifvoid NodeBox::serialize(std::ostream &os, u16 protocol_version) const{ int version = 1; if (protocol_version >= 27) version = 3; else if (protocol_version >= 21) version = 2; writeU8(os, version); switch (type) { case NODEBOX_LEVELED: case NODEBOX_FIXED: if (version == 1) writeU8(os, NODEBOX_FIXED); else writeU8(os, type); writeU16(os, fixed.size()); for (std::vector<aabb3f>::const_iterator i = fixed.begin(); i != fixed.end(); ++i) { writeV3F1000(os, i->MinEdge); writeV3F1000(os, i->MaxEdge); } break; case NODEBOX_WALLMOUNTED: writeU8(os, type); writeV3F1000(os, wall_top.MinEdge); writeV3F1000(os, wall_top.MaxEdge); writeV3F1000(os, wall_bottom.MinEdge); writeV3F1000(os, wall_bottom.MaxEdge); writeV3F1000(os, wall_side.MinEdge); writeV3F1000(os, wall_side.MaxEdge); break; case NODEBOX_CONNECTED: if (version <= 2) { // send old clients nodes that can't be walked through // to prevent abuse writeU8(os, NODEBOX_FIXED); writeU16(os, 1); writeV3F1000(os, v3f(-BS/2, -BS/2, -BS/2)); writeV3F1000(os, v3f(BS/2, BS/2, BS/2)); } else { writeU8(os, type);#define WRITEBOX(box) do { / writeU16(os, (box).size()); / for (std::vector<aabb3f>::const_iterator / i = (box).begin(); / i != (box).end(); ++i) { / writeV3F1000(os, i->MinEdge); / writeV3F1000(os, i->MaxEdge); / }; } while (0) WRITEBOX(fixed); WRITEBOX(connect_top); WRITEBOX(connect_bottom); WRITEBOX(connect_front); WRITEBOX(connect_left); WRITEBOX(connect_back); WRITEBOX(connect_right); } break; default: writeU8(os, type); break; }}
开发者ID:Bremaweb,项目名称:voxeladventures-client,代码行数:71,
示例23: playerpos_s16 << "unsupported ser_fmt_ver"<< std::endl; return; } m_server_ser_ver = server_ser_ver; // We can be totally wrong with this guess // but we only need some value < 25. m_proto_ver = 24; // Get player position v3s16 playerpos_s16(0, BS * 2 + BS * 20, 0); if (pkt->getSize() >= 1 + 6) { *pkt >> playerpos_s16; } v3f playerpos_f = intToFloat(playerpos_s16, BS) - v3f(0, BS / 2, 0); // Set player position Player *player = m_env.getLocalPlayer(); assert(player != NULL); player->setPosition(playerpos_f); if (pkt->getSize() >= 1 + 6 + 8) { // Get map seed *pkt >> m_map_seed; infostream << "Client: received map seed: " << m_map_seed << std::endl; } if (pkt->getSize() >= 1 + 6 + 8 + 4) { *pkt >> m_recommended_send_interval;
开发者ID:4aiman,项目名称:minetest,代码行数:31,
示例24: nparams_dungeon_density*/#include "dungeongen.h"#include "mapgen.h"#include "voxel.h"#include "noise.h"#include "mapblock.h"#include "mapnode.h"#include "map.h"#include "nodedef.h"#include "profiler.h"#include "settings.h"//#define DGEN_USE_TORCHESNoiseParams nparams_dungeon_density(0.9, 0.5, v3f(500.0, 500.0, 500.0), 0, 2, 0.8, 2.0);NoiseParams nparams_dungeon_alt_wall(-0.4, 1.0, v3f(40.0, 40.0, 40.0), 32474, 6, 1.1, 2.0);///////////////////////////////////////////////////////////////////////////////DungeonGen::DungeonGen(INodeDefManager *ndef, GenerateNotifier *gennotify, DungeonParams *dparams){ assert(ndef); this->ndef = ndef; this->gennotify = gennotify;#ifdef DGEN_USE_TORCHES
开发者ID:ChunHungLiu,项目名称:freeminer,代码行数:31,
示例25: NoisePerlin2Dvoid MapgenV6::generateCaves(int max_stone_y) { // 24ms @cs=8 //TimeTaker timer1("caves"); /*double cave_amount = 6.0 + 6.0 * noise2d_perlin( 0.5+(double)node_min.X/250, 0.5+(double)node_min.Y/250, data->seed+34329, 3, 0.50);*/ const s16 max_spread_amount = MAP_BLOCKSIZE; float cave_amount = NoisePerlin2D(np_cave, node_min.X, node_min.Y, seed); cave_amount = MYMAX(0.0, cave_amount); u32 caves_count = cave_amount * volume_nodes / 50000; u32 bruises_count = 1; PseudoRandom ps(blockseed + 21343); PseudoRandom ps2(blockseed + 1032); if (ps.range(1, 6) == 1) bruises_count = ps.range(0, ps.range(0, 2)); if (getBiome(v2s16(node_min.X, node_min.Z)) == BT_DESERT) { caves_count /= 3; bruises_count /= 3; } for(u32 jj = 0; jj < caves_count + bruises_count; jj++) { /*int avg_height = (int) ((base_rock_level_2d(data->seed, v2s16(node_min.X, node_min.Z)) + base_rock_level_2d(data->seed, v2s16(node_max.X, node_max.Z))) / 2); if ((node_max.Y + node_min.Y) / 2 > avg_height) break;*/ bool large_cave = (jj >= caves_count); Cave cave; defineCave(cave, ps, node_min, large_cave); v3f main_direction(0,0,0); // Allowed route area size in nodes v3s16 ar = central_area_size; // Area starting point in nodes v3s16 of = node_min; // Allow a bit more //(this should be more than the maximum radius of the tunnel) s16 insure = 10; s16 more = max_spread_amount - cave.max_tunnel_diameter / 2 - insure; ar += v3s16(1,0,1) * more * 2; of -= v3s16(1,0,1) * more; s16 route_y_min = 0; // Allow half a diameter + 7 over stone surface s16 route_y_max = -of.Y + max_stone_y + cave.max_tunnel_diameter/2 + 7; // Limit maximum to area route_y_max = rangelim(route_y_max, 0, ar.Y-1); if(large_cave) { s16 min = 0; if(node_min.Y < water_level && node_max.Y > water_level) { min = water_level - cave.max_tunnel_diameter/3 - of.Y; route_y_max = water_level + cave.max_tunnel_diameter/3 - of.Y; } route_y_min = ps.range(min, min + cave.max_tunnel_diameter); route_y_min = rangelim(route_y_min, 0, route_y_max); } s16 route_start_y_min = route_y_min; s16 route_start_y_max = route_y_max; route_start_y_min = rangelim(route_start_y_min, 0, ar.Y-1); route_start_y_max = rangelim(route_start_y_max, route_start_y_min, ar.Y-1); // Randomize starting position v3f orp( (float)(ps.next()%ar.X)+0.5, (float)(ps.range(route_start_y_min, route_start_y_max))+0.5, (float)(ps.next()%ar.Z)+0.5 ); v3s16 startp(orp.X, orp.Y, orp.Z); startp += of; MapNode airnode(CONTENT_AIR); MapNode waternode(c_water_source); MapNode lavanode(c_lava_source); /* Generate some tunnel starting from orp */ for(u16 j=0; j<cave.tunnel_routepoints; j++) { if(j%cave.dswitchint==0 && large_cave == false) { main_direction = v3f( ((float)(ps.next()%20)-(float)10)/10,//.........这里部分代码省略.........
开发者ID:BlindBanana,项目名称:minetest,代码行数:101,
示例26: switch//.........这里部分代码省略......... case NDT_TORCHLIKE: case NDT_SIGNLIKE: case NDT_FENCELIKE: case NDT_RAILLIKE: solidness = 0; break; case NDT_PLANTLIKE_ROOTED: solidness = 2; break; } if (is_liquid) { // Vertex alpha is no longer supported, correct if necessary. correctAlpha(tdef, 6); correctAlpha(tdef_overlay, 6); correctAlpha(tdef_spec, CF_SPECIAL_COUNT); material_type = (alpha == 255) ? TILE_MATERIAL_LIQUID_OPAQUE : TILE_MATERIAL_LIQUID_TRANSPARENT; } u32 tile_shader = shdsrc->getShader("nodes_shader", material_type, drawtype); u8 overlay_material = material_type; if (overlay_material == TILE_MATERIAL_OPAQUE) overlay_material = TILE_MATERIAL_BASIC; else if (overlay_material == TILE_MATERIAL_LIQUID_OPAQUE) overlay_material = TILE_MATERIAL_LIQUID_TRANSPARENT; u32 overlay_shader = shdsrc->getShader("nodes_shader", overlay_material, drawtype); // Tiles (fill in f->tiles[]) for (u16 j = 0; j < 6; j++) { tiles[j].world_aligned = isWorldAligned(tdef[j].align_style, tsettings.world_aligned_mode, drawtype); fillTileAttribs(tsrc, &tiles[j].layers[0], tiles[j], tdef[j], color, material_type, tile_shader, tdef[j].backface_culling, tsettings); if (!tdef_overlay[j].name.empty()) fillTileAttribs(tsrc, &tiles[j].layers[1], tiles[j], tdef_overlay[j], color, overlay_material, overlay_shader, tdef[j].backface_culling, tsettings); } u8 special_material = material_type; if (drawtype == NDT_PLANTLIKE_ROOTED) { if (waving == 1) special_material = TILE_MATERIAL_WAVING_PLANTS; else if (waving == 2) special_material = TILE_MATERIAL_WAVING_LEAVES; } u32 special_shader = shdsrc->getShader("nodes_shader", special_material, drawtype); // Special tiles (fill in f->special_tiles[]) for (u16 j = 0; j < CF_SPECIAL_COUNT; j++) fillTileAttribs(tsrc, &special_tiles[j].layers[0], special_tiles[j], tdef_spec[j], color, special_material, special_shader, tdef_spec[j].backface_culling, tsettings); if (param_type_2 == CPT2_COLOR || param_type_2 == CPT2_COLORED_FACEDIR || param_type_2 == CPT2_COLORED_WALLMOUNTED) palette = tsrc->getPalette(palette_name); if (drawtype == NDT_MESH && !mesh.empty()) { // Meshnode drawtype // Read the mesh and apply scale mesh_ptr[0] = client->getMesh(mesh); if (mesh_ptr[0]){ v3f scale = v3f(1.0, 1.0, 1.0) * BS * visual_scale; scaleMesh(mesh_ptr[0], scale); recalculateBoundingBox(mesh_ptr[0]); meshmanip->recalculateNormals(mesh_ptr[0], true, false); } } //Cache 6dfacedir and wallmounted rotated clones of meshes if (tsettings.enable_mesh_cache && mesh_ptr[0] && (param_type_2 == CPT2_FACEDIR || param_type_2 == CPT2_COLORED_FACEDIR)) { for (u16 j = 1; j < 24; j++) { mesh_ptr[j] = cloneMesh(mesh_ptr[0]); rotateMeshBy6dFacedir(mesh_ptr[j], j); recalculateBoundingBox(mesh_ptr[j]); meshmanip->recalculateNormals(mesh_ptr[j], true, false); } } else if (tsettings.enable_mesh_cache && mesh_ptr[0] && (param_type_2 == CPT2_WALLMOUNTED || param_type_2 == CPT2_COLORED_WALLMOUNTED)) { static const u8 wm_to_6d[6] = { 20, 0, 16 + 1, 12 + 3, 8, 4 + 2 }; for (u16 j = 1; j < 6; j++) { mesh_ptr[j] = cloneMesh(mesh_ptr[0]); rotateMeshBy6dFacedir(mesh_ptr[j], wm_to_6d[j]); recalculateBoundingBox(mesh_ptr[j]); meshmanip->recalculateNormals(mesh_ptr[j], true, false); } rotateMeshBy6dFacedir(mesh_ptr[0], wm_to_6d[0]); recalculateBoundingBox(mesh_ptr[0]); meshmanip->recalculateNormals(mesh_ptr[0], true, false); }}
开发者ID:EXio4,项目名称:minetest,代码行数:101,
示例27: floatToIntv3s16 LocalPlayer::getStandingNodePos(){ if(m_sneak_node_exists) return m_sneak_node; return floatToInt(getPosition() - v3f(0, BS, 0), BS);}
开发者ID:hdastwb,项目名称:freeminer,代码行数:6,
示例28: floatToIntv3s16 Player::getLightPosition() const{ return floatToInt(m_position + v3f(0,BS+BS/2,0), BS);}
开发者ID:Imberflur,项目名称:minetest,代码行数:4,
示例29: random_v3fv3f random_v3f(v3f min, v3f max){ return v3f( rand()/(float)RAND_MAX*(max.X-min.X)+min.X, rand()/(float)RAND_MAX*(max.Y-min.Y)+min.Y, rand()/(float)RAND_MAX*(max.Z-min.Z)+min.Z);}
开发者ID:AnnXGame,项目名称:Minetest,代码行数:6,
示例30: updateTexturesAndMeshes virtual void updateTexturesAndMeshes(IGameDef *gamedef) {#ifndef SERVER infostream<<"ItemDefManager::updateTexturesAndMeshes(): Updating " <<"textures and meshes in item definitions"<<std::endl; ITextureSource *tsrc = gamedef->getTextureSource(); INodeDefManager *nodedef = gamedef->getNodeDefManager(); IrrlichtDevice *device = tsrc->getDevice(); video::IVideoDriver *driver = device->getVideoDriver(); for(std::map<std::string, ItemDefinition*>::iterator i = m_item_definitions.begin(); i != m_item_definitions.end(); i++) { ItemDefinition *def = i->second; bool need_node_mesh = false; // Create an inventory texture def->inventory_texture = NULL; if(def->inventory_image != "") { def->inventory_texture = tsrc->getTextureRaw(def->inventory_image); } else if(def->type == ITEM_NODE) { need_node_mesh = true; } // Create a wield mesh if(def->wield_mesh != NULL) { def->wield_mesh->drop(); def->wield_mesh = NULL; } if(def->type == ITEM_NODE && def->wield_image == "") { need_node_mesh = true; } else if(def->wield_image != "" || def->inventory_image != "") { // Extrude the wield image into a mesh std::string imagename; if(def->wield_image != "") imagename = def->wield_image; else imagename = def->inventory_image; def->wield_mesh = createExtrudedMesh( tsrc->getTextureRaw(imagename), driver, def->wield_scale * v3f(40.0, 40.0, 4.0)); if(def->wield_mesh == NULL) { infostream<<"ItemDefManager: WARNING: " <<"updateTexturesAndMeshes(): " <<"Unable to create extruded mesh for item " <<def->name<<std::endl; } } if(need_node_mesh) { /* Get node properties */ content_t id = nodedef->getId(def->name); const ContentFeatures &f = nodedef->get(id); u8 param1 = 0; if(f.param_type == CPT_LIGHT) param1 = 0xee; /* Make a mesh from the node */ MeshMakeData mesh_make_data(gamedef); MapNode mesh_make_node(id, param1, 0); mesh_make_data.fillSingleNode(&mesh_make_node); MapBlockMesh mapblock_mesh(&mesh_make_data); scene::IMesh *node_mesh = mapblock_mesh.getMesh(); assert(node_mesh); setMeshColor(node_mesh, video::SColor(255, 255, 255, 255)); /* Scale and translate the mesh so it's a unit cube centered on the origin */ scaleMesh(node_mesh, v3f(1.0/BS, 1.0/BS, 1.0/BS)); translateMesh(node_mesh, v3f(-1.0, -1.0, -1.0)); /* Draw node mesh into a render target texture */ if(def->inventory_texture == NULL) { core::dimension2d<u32> dim(64,64);//.........这里部分代码省略.........
开发者ID:AMDmi3,项目名称:minetest,代码行数:101,
注:本文中的v3f函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ v3s16函数代码示例 C++ v3函数代码示例 |