// SuperTuxKart - a fun racing game with go-kart // Copyright (C) 2011-2013 Marianne Gagnon // based on code Copyright 2002-2010 Nikolaus Gebhardt // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License // as published by the Free Software Foundation; either version 3 // of the License, or (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "graphics/camera.hpp" #include "graphics/irr_driver.hpp" #include "graphics/lod_node.hpp" #include "graphics/hardware_skinning.hpp" #include "graphics/material_manager.hpp" #include "graphics/material.hpp" #include "config/user_config.hpp" #include "karts/abstract_kart.hpp" #include #include #include #include /** * @param group_name Only useful for getGroupName() */ LODNode::LODNode(std::string group_name, scene::ISceneNode* parent, scene::ISceneManager* mgr, s32 id) : ISceneNode(parent, mgr, id) { assert(mgr != NULL); assert(parent != NULL); m_group_name = group_name; m_previous_visibility = FIRST_PASS; // At this stage refcount is two: one because of the object being // created, and once because it is a child of the parent. Drop once, // so that only the reference from the parent is active, causing this // node to be deleted when it is removed from the parent. drop(); m_forced_lod = -1; m_last_tick = 0; } LODNode::~LODNode() { } void LODNode::render() { //ISceneNode::render(); } /** Returns the level to use, or -1 if the object is too far * away. */ int LODNode::getLevel() { // If a level is forced, use it if(m_forced_lod>-1) return m_forced_lod; scene::ICameraSceneNode* curr_cam = irr_driver->getSceneManager()->getActiveCamera(); Camera* camera = Camera::getActiveCamera(); if (camera == NULL) return m_detail.size() - 1; AbstractKart* kart = camera->getKart(); const Vec3 &pos = kart->getFrontXYZ(); // Assumes all children are at the same location const int dist = (int)((getPosition() + m_nodes[0]->getPosition()).getDistanceFromSQ( core::vector3df(pos.getX(), pos.getY(), pos.getZ()))); for (unsigned int n=0; n