/** * @brief Applies a given state to a NodePath * @details This applies a shader to the given NodePath which is used when the * NodePath is rendered by any registered camera of the container. * * @param container The container which is used to store the state * @param np The nodepath to apply the shader to * @param shader A handle to the shader to apply * @param name Name of the state, should be a unique identifier * @param sort Changes the sort with which the shader will be applied. */ void TagStateManager::apply_state(StateContainer& container, NodePath np, Shader* shader, const string &name, int sort) { if (tagstatemgr_cat.is_spam()) { tagstatemgr_cat.spam() << "Constructing new state " << name << " with shader " << shader << endl; } // Construct the render state CPT(RenderState) state = RenderState::make_empty(); // Disable color write for all stages except the environment container if (!container.write_color) { state = state->set_attrib(ColorWriteAttrib::make(ColorWriteAttrib::C_off), 10000); } state = state->set_attrib(ShaderAttrib::make(shader, sort), sort); // Emit a warning if we override an existing state if (container.tag_states.count(name) != 0) { tagstatemgr_cat.warning() << "Overriding existing state " << name << endl; } // Store the state, this is required whenever we attach a new camera, so // it can also track the existing states container.tag_states[name] = state; // Save the tag on the node path np.set_tag(container.tag_name, name); // Apply the state on all cameras which are attached so far for (size_t i = 0; i < container.cameras.size(); ++i) { container.cameras[i]->set_tag_state(name, state); } }
void SGNode::add_for_draw(CullTraverser *trav, CullTraverserData &data) { CPT(TransformState) internal_transform = data.get_internal_transform(trav); // TODO: Construct a correct matrix which contains the MVP of the node _handler->add_for_draw(_dataset_ref, get_transform()->get_mat()); }
/** * @brief Registers a new camera to a given container * @details This registers a new camera to a container, and sets its initial * state as well as the camera mask. * * @param container The container to add the camera to * @param source The camera to add */ void TagStateManager::register_camera(StateContainer& container, Camera* source) { source->set_tag_state_key(container.tag_name); source->set_camera_mask(container.mask); // Construct an initial state which also disables color write, additionally // to the ColorWriteAttrib on each unique state. CPT(RenderState) state = RenderState::make_empty(); if (!container.write_color) { state = state->set_attrib(ColorWriteAttrib::make(ColorWriteAttrib::C_off), 10000); } source->set_initial_state(state); // Store the camera so we can keep track of it container.cameras.push_back(source); }
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * */ #include "MeshSplitter.h" #include <limits.h> #include <algorithm> #include "datagram.h" void MeshSplitter::read_triangles(CPT(Geom) geom, TriangleList &result) { // Create a vertex reader to simplify the reading of positions CPT(GeomVertexData) vertex_data = geom->get_vertex_data(); GeomVertexReader vertex_reader(vertex_data, "vertex"); GeomVertexReader normal_reader(vertex_data, "normal"); GeomVertexReader uv_reader(vertex_data, "texcoord"); bool has_uv = uv_reader.has_column(); if (!normal_reader.has_column()) { cout << "ERROR: Mesh has no stored normals!" << endl; return; } if (!has_uv) {