3 Copyright (C) 2010-2013 celeron55, Perttu Ahola <celeron55@gmail.com>
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as published by
7 the Free Software Foundation; either version 2.1 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public License along
16 with this program; if not, write to the Free Software Foundation, Inc.,
17 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24 #include "clientmap.h" // MapDrawControl
28 #include "wieldmesh.h"
29 #include "noise.h" // easeCurve
33 #include "util/numeric.h"
34 #include "constants.h"
35 #include "fontengine.h"
36 #include "script/scripting_client.h"
38 #define CAMERA_OFFSET_STEP 200
42 Camera::Camera(scene::ISceneManager* smgr, MapDrawControl& draw_control,
44 m_draw_control(draw_control),
47 //dstream<<FUNCTION_NAME<<std::endl;
49 m_driver = smgr->getVideoDriver();
50 // note: making the camera node a child of the player node
51 // would lead to unexpected behaviour, so we don't do that.
52 m_playernode = smgr->addEmptySceneNode(smgr->getRootSceneNode());
53 m_headnode = smgr->addEmptySceneNode(m_playernode);
54 m_cameranode = smgr->addCameraSceneNode(smgr->getRootSceneNode());
55 m_cameranode->bindTargetAndRotation(true);
57 // This needs to be in its own scene manager. It is drawn after
58 // all other 3D scene nodes and before the GUI.
59 m_wieldmgr = smgr->createNewSceneManager();
60 m_wieldmgr->addCameraSceneNode();
61 m_wieldnode = new WieldMeshSceneNode(m_wieldmgr->getRootSceneNode(), m_wieldmgr, -1, false);
62 m_wieldnode->setItem(ItemStack(), m_client);
63 m_wieldnode->drop(); // m_wieldmgr grabbed it
65 /* TODO: Add a callback function so these can be updated when a setting
66 * changes. At this point in time it doesn't matter (e.g. /set
67 * is documented to change server settings only)
69 * TODO: Local caching of settings is not optimal and should at some stage
70 * be updated to use a global settings object for getting thse values
71 * (as opposed to the this local caching). This can be addressed in
74 m_cache_fall_bobbing_amount = g_settings->getFloat("fall_bobbing_amount");
75 m_cache_view_bobbing_amount = g_settings->getFloat("view_bobbing_amount");
76 m_cache_fov = g_settings->getFloat("fov");
77 m_cache_zoom_fov = g_settings->getFloat("zoom_fov");
78 m_arm_inertia = g_settings->getBool("arm_inertia");
87 bool Camera::successfullyCreated(std::string &error_message)
90 error_message = "Failed to create the player scene node";
91 } else if (!m_headnode) {
92 error_message = "Failed to create the head scene node";
93 } else if (!m_cameranode) {
94 error_message = "Failed to create the camera scene node";
95 } else if (!m_wieldmgr) {
96 error_message = "Failed to create the wielded item scene manager";
97 } else if (!m_wieldnode) {
98 error_message = "Failed to create the wielded item scene node";
100 error_message.clear();
103 if (g_settings->getBool("enable_client_modding")) {
104 m_client->getScript()->on_camera_ready(this);
106 return error_message.empty();
109 // Returns the fractional part of x
110 inline f32 my_modf(f32 x)
113 return modf(x, &dummy);
116 void Camera::step(f32 dtime)
118 if(m_view_bobbing_fall > 0)
120 m_view_bobbing_fall -= 3 * dtime;
121 if(m_view_bobbing_fall <= 0)
122 m_view_bobbing_fall = -1; // Mark the effect as finished
125 bool was_under_zero = m_wield_change_timer < 0;
126 m_wield_change_timer = MYMIN(m_wield_change_timer + dtime, 0.125);
128 if (m_wield_change_timer >= 0 && was_under_zero)
129 m_wieldnode->setItem(m_wield_item_next, m_client);
131 if (m_view_bobbing_state != 0)
133 //f32 offset = dtime * m_view_bobbing_speed * 0.035;
134 f32 offset = dtime * m_view_bobbing_speed * 0.030;
135 if (m_view_bobbing_state == 2) {
136 // Animation is getting turned off
137 if (m_view_bobbing_anim < 0.25) {
138 m_view_bobbing_anim -= offset;
139 } else if (m_view_bobbing_anim > 0.75) {
140 m_view_bobbing_anim += offset;
143 if (m_view_bobbing_anim < 0.5) {
144 m_view_bobbing_anim += offset;
145 if (m_view_bobbing_anim > 0.5)
146 m_view_bobbing_anim = 0.5;
148 m_view_bobbing_anim -= offset;
149 if (m_view_bobbing_anim < 0.5)
150 m_view_bobbing_anim = 0.5;
153 if (m_view_bobbing_anim <= 0 || m_view_bobbing_anim >= 1 ||
154 fabs(m_view_bobbing_anim - 0.5) < 0.01) {
155 m_view_bobbing_anim = 0;
156 m_view_bobbing_state = 0;
160 float was = m_view_bobbing_anim;
161 m_view_bobbing_anim = my_modf(m_view_bobbing_anim + offset);
162 bool step = (was == 0 ||
163 (was < 0.5f && m_view_bobbing_anim >= 0.5f) ||
164 (was > 0.5f && m_view_bobbing_anim <= 0.5f));
166 MtEvent *e = new SimpleTriggerEvent("ViewBobbingStep");
167 m_client->event()->put(e);
172 if (m_digging_button != -1)
174 f32 offset = dtime * 3.5;
175 float m_digging_anim_was = m_digging_anim;
176 m_digging_anim += offset;
177 if (m_digging_anim >= 1)
180 m_digging_button = -1;
183 if(m_digging_anim_was < lim && m_digging_anim >= lim)
185 if(m_digging_button == 0)
187 MtEvent *e = new SimpleTriggerEvent("CameraPunchLeft");
188 m_client->event()->put(e);
189 } else if(m_digging_button == 1) {
190 MtEvent *e = new SimpleTriggerEvent("CameraPunchRight");
191 m_client->event()->put(e);
197 void Camera::addArmInertia(f32 player_yaw, f32 frametime)
199 m_cam_vel.X = std::fabs((m_last_cam_pos.X - player_yaw) / m_timer.X) * 0.01f;
200 m_cam_vel.Y = std::fabs((m_last_cam_pos.Y - m_camera_direction.Y) / m_timer.Y);
202 if (m_cam_vel.X > 1.0f || m_cam_vel.Y > 1.0f) {
204 the arm moves when the camera moves fast enough.
207 if (m_cam_vel.X > 1.0f) {
209 m_timer.X += frametime;
211 if (m_cam_vel.X > m_cam_vel_old.X)
212 m_cam_vel_old.X = m_cam_vel.X;
214 if (m_last_cam_pos.X > player_yaw)
216 m_wieldmesh_offset.X -= (0.1f + frametime) * m_cam_vel.X;
219 m_wieldmesh_offset.X += (0.1f + frametime) * m_cam_vel.X;
221 if (m_last_cam_pos.X != player_yaw)
222 m_last_cam_pos.X = player_yaw;
224 m_wieldmesh_offset.X = rangelim(m_wieldmesh_offset.X, 48.0f, 62.0f);
227 if (m_cam_vel.Y > 1.0f) {
229 m_timer.Y += frametime;
231 if (m_cam_vel.Y > m_cam_vel_old.Y)
232 m_cam_vel_old.Y = m_cam_vel.Y;
234 if (m_last_cam_pos.Y > m_camera_direction.Y)
236 m_wieldmesh_offset.Y += (0.1f + frametime) * m_cam_vel.Y;
239 m_wieldmesh_offset.Y -= (0.1f + frametime) * m_cam_vel.Y;
241 if (m_last_cam_pos.Y != m_camera_direction.Y)
242 m_last_cam_pos.Y = m_camera_direction.Y;
244 m_wieldmesh_offset.Y = rangelim(m_wieldmesh_offset.Y, -45.0f, -30.0f);
248 the arm now gets back to its default position when the camera stops.
251 if (floor(m_wieldmesh_offset.X) == 55.0f) {
252 m_cam_vel_old.X = 0.0f;
253 m_wieldmesh_offset.X = 55.0f;
256 if (m_wieldmesh_offset.X > 55.0f)
257 m_wieldmesh_offset.X -= (0.05f + frametime) * m_cam_vel_old.X;
258 if (m_wieldmesh_offset.X < 55.0f)
259 m_wieldmesh_offset.X += (0.05f + frametime) * m_cam_vel_old.X;
261 if (floor(m_wieldmesh_offset.Y) == -35.0f) {
262 m_cam_vel_old.Y = 0.0f;
263 m_wieldmesh_offset.Y = -35.0f;
266 if (m_wieldmesh_offset.Y > -35.0f)
267 m_wieldmesh_offset.Y -= (0.05f + frametime) * m_cam_vel_old.Y;
268 if (m_wieldmesh_offset.Y < -35.0f)
269 m_wieldmesh_offset.Y += (0.05f + frametime) * m_cam_vel_old.Y;
273 void Camera::update(LocalPlayer* player, f32 frametime, f32 busytime,
274 f32 tool_reload_ratio, ClientEnvironment &c_env)
276 // Get player position
277 // Smooth the movement when walking up stairs
278 v3f old_player_position = m_playernode->getPosition();
279 v3f player_position = player->getPosition();
280 if (player->isAttached && player->parent)
281 player_position = player->parent->getPosition();
282 //if(player->touching_ground && player_position.Y > old_player_position.Y)
283 if(player->touching_ground &&
284 player_position.Y > old_player_position.Y)
286 f32 oldy = old_player_position.Y;
287 f32 newy = player_position.Y;
288 f32 t = exp(-23*frametime);
289 player_position.Y = oldy * t + newy * (1-t);
292 // Set player node transformation
293 m_playernode->setPosition(player_position);
294 m_playernode->setRotation(v3f(0, -1 * player->getYaw(), 0));
295 m_playernode->updateAbsolutePosition();
297 // Get camera tilt timer (hurt animation)
298 float cameratilt = fabs(fabs(player->hurt_tilt_timer-0.75)-0.75);
300 // Fall bobbing animation
301 float fall_bobbing = 0;
302 if(player->camera_impact >= 1 && m_camera_mode < CAMERA_MODE_THIRD)
304 if(m_view_bobbing_fall == -1) // Effect took place and has finished
305 player->camera_impact = m_view_bobbing_fall = 0;
306 else if(m_view_bobbing_fall == 0) // Initialize effect
307 m_view_bobbing_fall = 1;
309 // Convert 0 -> 1 to 0 -> 1 -> 0
310 fall_bobbing = m_view_bobbing_fall < 0.5 ? m_view_bobbing_fall * 2 : -(m_view_bobbing_fall - 0.5) * 2 + 1;
311 // Smoothen and invert the above
312 fall_bobbing = sin(fall_bobbing * 0.5 * M_PI) * -1;
313 // Amplify according to the intensity of the impact
314 fall_bobbing *= (1 - rangelim(50 / player->camera_impact, 0, 1)) * 5;
316 fall_bobbing *= m_cache_fall_bobbing_amount;
319 // Calculate players eye offset for different camera modes
320 v3f PlayerEyeOffset = player->getEyeOffset();
321 if (m_camera_mode == CAMERA_MODE_FIRST)
322 PlayerEyeOffset += player->eye_offset_first;
324 PlayerEyeOffset += player->eye_offset_third;
326 // Set head node transformation
327 m_headnode->setPosition(PlayerEyeOffset+v3f(0,cameratilt*-player->hurt_tilt_strength+fall_bobbing,0));
328 m_headnode->setRotation(v3f(player->getPitch(), 0, cameratilt*player->hurt_tilt_strength));
329 m_headnode->updateAbsolutePosition();
331 // Compute relative camera position and target
332 v3f rel_cam_pos = v3f(0,0,0);
333 v3f rel_cam_target = v3f(0,0,1);
334 v3f rel_cam_up = v3f(0,1,0);
336 if (m_cache_view_bobbing_amount != 0.0f && m_view_bobbing_anim != 0.0f &&
337 m_camera_mode < CAMERA_MODE_THIRD) {
338 f32 bobfrac = my_modf(m_view_bobbing_anim * 2);
339 f32 bobdir = (m_view_bobbing_anim < 0.5) ? 1.0 : -1.0;
343 f32 bobtmp = sin(pow(bobfrac, bobknob) * M_PI);
344 //f32 bobtmp2 = cos(pow(bobfrac, bobknob) * M_PI);
347 0.3 * bobdir * sin(bobfrac * M_PI),
348 -0.28 * bobtmp * bobtmp,
351 //rel_cam_pos += 0.2 * bobvec;
352 //rel_cam_target += 0.03 * bobvec;
353 //rel_cam_up.rotateXYBy(0.02 * bobdir * bobtmp * M_PI);
355 f *= m_cache_view_bobbing_amount;
356 rel_cam_pos += bobvec * f;
357 //rel_cam_target += 0.995 * bobvec * f;
358 rel_cam_target += bobvec * f;
359 rel_cam_target.Z -= 0.005 * bobvec.Z * f;
360 //rel_cam_target.X -= 0.005 * bobvec.X * f;
361 //rel_cam_target.Y -= 0.005 * bobvec.Y * f;
362 rel_cam_up.rotateXYBy(-0.03 * bobdir * bobtmp * M_PI * f);
364 f32 angle_deg = 1 * bobdir * sin(bobfrac * M_PI);
365 f32 angle_rad = angle_deg * M_PI / 180;
369 r * (cos(angle_rad) - 1),
372 //rel_cam_target += off;
373 rel_cam_up.rotateXYBy(angle_deg);
378 // Compute absolute camera position and target
379 m_headnode->getAbsoluteTransformation().transformVect(m_camera_position, rel_cam_pos);
380 m_headnode->getAbsoluteTransformation().rotateVect(m_camera_direction, rel_cam_target - rel_cam_pos);
383 m_headnode->getAbsoluteTransformation().rotateVect(abs_cam_up, rel_cam_up);
385 // Seperate camera position for calculation
386 v3f my_cp = m_camera_position;
388 // Reposition the camera for third person view
389 if (m_camera_mode > CAMERA_MODE_FIRST)
391 if (m_camera_mode == CAMERA_MODE_THIRD_FRONT)
392 m_camera_direction *= -1;
396 // Calculate new position
398 for (int i = BS; i <= BS*2.75; i++)
400 my_cp.X = m_camera_position.X + m_camera_direction.X*-i;
401 my_cp.Z = m_camera_position.Z + m_camera_direction.Z*-i;
403 my_cp.Y = m_camera_position.Y + (m_camera_direction.Y*-i);
405 // Prevent camera positioned inside nodes
406 INodeDefManager *nodemgr = m_client->ndef();
407 MapNode n = c_env.getClientMap().getNodeNoEx(floatToInt(my_cp, BS));
408 const ContentFeatures& features = nodemgr->get(n);
409 if(features.walkable)
411 my_cp.X += m_camera_direction.X*-1*-BS/2;
412 my_cp.Z += m_camera_direction.Z*-1*-BS/2;
413 my_cp.Y += m_camera_direction.Y*-1*-BS/2;
419 // If node blocks camera position don't move y to heigh
420 if (abort && my_cp.Y > player_position.Y+BS*2)
421 my_cp.Y = player_position.Y+BS*2;
424 // Update offset if too far away from the center of the map
425 m_camera_offset.X += CAMERA_OFFSET_STEP*
426 (((s16)(my_cp.X/BS) - m_camera_offset.X)/CAMERA_OFFSET_STEP);
427 m_camera_offset.Y += CAMERA_OFFSET_STEP*
428 (((s16)(my_cp.Y/BS) - m_camera_offset.Y)/CAMERA_OFFSET_STEP);
429 m_camera_offset.Z += CAMERA_OFFSET_STEP*
430 (((s16)(my_cp.Z/BS) - m_camera_offset.Z)/CAMERA_OFFSET_STEP);
432 // Set camera node transformation
433 m_cameranode->setPosition(my_cp-intToFloat(m_camera_offset, BS));
434 m_cameranode->setUpVector(abs_cam_up);
435 // *100.0 helps in large map coordinates
436 m_cameranode->setTarget(my_cp-intToFloat(m_camera_offset, BS) + 100 * m_camera_direction);
438 // update the camera position in front-view mode to render blocks behind player
439 if (m_camera_mode == CAMERA_MODE_THIRD_FRONT)
440 m_camera_position = my_cp;
444 if (player->getPlayerControl().zoom && m_client->checkLocalPrivilege("zoom")) {
445 fov_degrees = m_cache_zoom_fov;
447 fov_degrees = m_cache_fov;
449 fov_degrees = rangelim(fov_degrees, 7.0, 160.0);
451 // FOV and aspect ratio
452 m_aspect = (f32) porting::getWindowSize().X / (f32) porting::getWindowSize().Y;
453 m_fov_y = fov_degrees * M_PI / 180.0;
454 // Increase vertical FOV on lower aspect ratios (<16:10)
455 m_fov_y *= MYMAX(1.0, MYMIN(1.4, sqrt(16./10. / m_aspect)));
456 m_fov_x = 2 * atan(m_aspect * tan(0.5 * m_fov_y));
457 m_cameranode->setAspectRatio(m_aspect);
458 m_cameranode->setFOV(m_fov_y);
461 addArmInertia(player->getYaw(), frametime);
463 // Position the wielded item
464 //v3f wield_position = v3f(45, -35, 65);
465 v3f wield_position = v3f(m_wieldmesh_offset.X, m_wieldmesh_offset.Y, 65);
466 //v3f wield_rotation = v3f(-100, 120, -100);
467 v3f wield_rotation = v3f(-100, 120, -100);
468 wield_position.Y += fabs(m_wield_change_timer)*320 - 40;
469 if(m_digging_anim < 0.05 || m_digging_anim > 0.5)
472 if(m_digging_anim > 0.5)
473 frac = 2.0 * (m_digging_anim - 0.5);
474 // This value starts from 1 and settles to 0
475 f32 ratiothing = pow((1.0f - tool_reload_ratio), 0.5f);
476 //f32 ratiothing2 = pow(ratiothing, 0.5f);
477 f32 ratiothing2 = (easeCurve(ratiothing*0.5))*2.0;
478 wield_position.Y -= frac * 25.0 * pow(ratiothing2, 1.7f);
479 //wield_position.Z += frac * 5.0 * ratiothing2;
480 wield_position.X -= frac * 35.0 * pow(ratiothing2, 1.1f);
481 wield_rotation.Y += frac * 70.0 * pow(ratiothing2, 1.4f);
482 //wield_rotation.X -= frac * 15.0 * pow(ratiothing2, 1.4f);
483 //wield_rotation.Z += frac * 15.0 * pow(ratiothing2, 1.0f);
485 if (m_digging_button != -1)
487 f32 digfrac = m_digging_anim;
488 wield_position.X -= 50 * sin(pow(digfrac, 0.8f) * M_PI);
489 wield_position.Y += 24 * sin(digfrac * 1.8 * M_PI);
490 wield_position.Z += 25 * 0.5;
492 // Euler angles are PURE EVIL, so why not use quaternions?
493 core::quaternion quat_begin(wield_rotation * core::DEGTORAD);
494 core::quaternion quat_end(v3f(80, 30, 100) * core::DEGTORAD);
495 core::quaternion quat_slerp;
496 quat_slerp.slerp(quat_begin, quat_end, sin(digfrac * M_PI));
497 quat_slerp.toEuler(wield_rotation);
498 wield_rotation *= core::RADTODEG;
500 f32 bobfrac = my_modf(m_view_bobbing_anim);
501 wield_position.X -= sin(bobfrac*M_PI*2.0) * 3.0;
502 wield_position.Y += sin(my_modf(bobfrac*2.0)*M_PI) * 3.0;
504 m_wieldnode->setPosition(wield_position);
505 m_wieldnode->setRotation(wield_rotation);
507 m_wieldnode->setColor(player->light_color);
509 // Set render distance
510 updateViewingRange();
512 // If the player is walking, swimming, or climbing,
513 // view bobbing is enabled and free_move is off,
514 // start (or continue) the view bobbing animation.
515 v3f speed = player->getSpeed();
516 const bool movement_XZ = hypot(speed.X, speed.Z) > BS;
517 const bool movement_Y = fabs(speed.Y) > BS;
519 const bool walking = movement_XZ && player->touching_ground;
520 const bool swimming = (movement_XZ || player->swimming_vertical) && player->in_liquid;
521 const bool climbing = movement_Y && player->is_climbing;
522 if ((walking || swimming || climbing) &&
523 (!g_settings->getBool("free_move") || !m_client->checkLocalPrivilege("fly"))) {
525 m_view_bobbing_state = 1;
526 m_view_bobbing_speed = MYMIN(speed.getLength(), 70);
528 else if (m_view_bobbing_state == 1)
531 m_view_bobbing_state = 2;
532 m_view_bobbing_speed = 60;
536 void Camera::updateViewingRange()
538 f32 viewing_range = g_settings->getFloat("viewing_range");
539 m_draw_control.wanted_range = viewing_range;
540 if (m_draw_control.range_all) {
541 m_cameranode->setFarValue(100000.0);
544 m_cameranode->setFarValue((viewing_range < 2000) ? 2000 * BS : viewing_range * BS);
547 void Camera::setDigging(s32 button)
549 if (m_digging_button == -1)
550 m_digging_button = button;
553 void Camera::wield(const ItemStack &item)
555 if (item.name != m_wield_item_next.name ||
556 item.metadata != m_wield_item_next.metadata) {
557 m_wield_item_next = item;
558 if (m_wield_change_timer > 0)
559 m_wield_change_timer = -m_wield_change_timer;
560 else if (m_wield_change_timer == 0)
561 m_wield_change_timer = -0.001;
565 void Camera::drawWieldedTool(irr::core::matrix4* translation)
567 // Clear Z buffer so that the wielded tool stay in front of world geometry
568 m_wieldmgr->getVideoDriver()->clearZBuffer();
570 // Draw the wielded node (in a separate scene manager)
571 scene::ICameraSceneNode* cam = m_wieldmgr->getActiveCamera();
572 cam->setAspectRatio(m_cameranode->getAspectRatio());
573 cam->setFOV(72.0*M_PI/180.0);
574 cam->setNearValue(10);
575 cam->setFarValue(1000);
576 if (translation != NULL)
578 irr::core::matrix4 startMatrix = cam->getAbsoluteTransformation();
579 irr::core::vector3df focusPoint = (cam->getTarget()
580 - cam->getAbsolutePosition()).setLength(1)
581 + cam->getAbsolutePosition();
583 irr::core::vector3df camera_pos =
584 (startMatrix * *translation).getTranslation();
585 cam->setPosition(camera_pos);
586 cam->setTarget(focusPoint);
588 m_wieldmgr->drawAll();
591 void Camera::drawNametags()
593 core::matrix4 trans = m_cameranode->getProjectionMatrix();
594 trans *= m_cameranode->getViewMatrix();
596 for (std::list<Nametag *>::const_iterator
597 i = m_nametags.begin();
598 i != m_nametags.end(); ++i) {
599 Nametag *nametag = *i;
600 if (nametag->nametag_color.getAlpha() == 0) {
601 // Enforce hiding nametag,
602 // because if freetype is enabled, a grey
603 // shadow can remain.
606 v3f pos = nametag->parent_node->getAbsolutePosition() + v3f(0.0, 1.1 * BS, 0.0);
607 f32 transformed_pos[4] = { pos.X, pos.Y, pos.Z, 1.0f };
608 trans.multiplyWith1x4Matrix(transformed_pos);
609 if (transformed_pos[3] > 0) {
610 std::string nametag_colorless = unescape_enriched(nametag->nametag_text);
611 core::dimension2d<u32> textsize =
612 g_fontengine->getFont()->getDimension(
613 utf8_to_wide(nametag_colorless).c_str());
614 f32 zDiv = transformed_pos[3] == 0.0f ? 1.0f :
615 core::reciprocal(transformed_pos[3]);
616 v2u32 screensize = m_driver->getScreenSize();
618 screen_pos.X = screensize.X *
619 (0.5 * transformed_pos[0] * zDiv + 0.5) - textsize.Width / 2;
620 screen_pos.Y = screensize.Y *
621 (0.5 - transformed_pos[1] * zDiv * 0.5) - textsize.Height / 2;
622 core::rect<s32> size(0, 0, textsize.Width, textsize.Height);
623 g_fontengine->getFont()->draw(utf8_to_wide(nametag->nametag_text).c_str(),
624 size + screen_pos, nametag->nametag_color);
629 Nametag *Camera::addNametag(scene::ISceneNode *parent_node,
630 std::string nametag_text, video::SColor nametag_color)
632 Nametag *nametag = new Nametag(parent_node, nametag_text, nametag_color);
633 m_nametags.push_back(nametag);
637 void Camera::removeNametag(Nametag *nametag)
639 m_nametags.remove(nametag);