//---------- void Fixture::update() { //calculate DMX vector<DMX::Value> output; for (int i = 0; i < this->channels.size(); i++) { auto channel = this->channels[i]; if (channel->enabled.get() == false) { //break on first disabled channel break; } auto & generator = channel->generateValue; if (generator) { auto value = generator(); channel->value.set(value); } output.push_back(this->channels[i]->value); } //transmit DMX auto transmit = this->getInput<DMX::Transmit>(); if (transmit) { auto universe = transmit->getUniverse(this->universeIndex.get()); if (universe) { universe->setChannels(this->channelIndex.get(), &output[0], output.size()); } else { RULR_ERROR << "Universe index " << this->universeIndex << " is out of bounds for this sender"; } } }
void EntityModel::setEntityPosition(int index, float value) { Lumix::Vec3 v = getUniverse()->getPosition(m_entity); ((float*)&v)[index] = value; Lumix::StackAllocator<256> allocator; Lumix::Array<Lumix::Entity> entities(allocator); Lumix::Array<Lumix::Vec3> positions(allocator); entities.push(m_entity); positions.push(v); m_editor.setEntitiesPositions(entities, positions); }
void EntityModel::setEntityRotation(int index, float value) { auto axis_angle = getUniverse()->getRotation(m_entity).getAxisAngle(); ((float*)&axis_angle)[index] = value; axis_angle.axis.normalize(); Lumix::StackAllocator<256> allocator; Lumix::Array<Lumix::Entity> entities(allocator); Lumix::Array<Lumix::Quat> rotations(allocator); entities.push(m_entity); rotations.push(Lumix::Quat(axis_angle.axis, axis_angle.angle)); m_editor.setEntitiesRotations(entities, rotations); }
/** * @brief Finds the Cell within this Lattice that a LocalCoords is in. * @details This method first find the Lattice cell, then searches the * Universe inside that Lattice cell. If LocalCoords is outside * the bounds of the Lattice, this method will return NULL. * @param coords the LocalCoords of interest * @param universes a std::map of all Universes passed in from the geometry * @return a pointer to the Cell this LocalCoord is in or NULL */ Cell* Lattice::findCell(LocalCoords* coords, std::map<int, Universe*> universes) { /* Set the LocalCoord to be a LAT type at this level */ coords->setType(LAT); /* Compute the x and y indices for the Lattice cell this coord is in */ int lat_x = (int)floor((coords->getX() - _origin.getX()) / _width_x); int lat_y = (int)floor((coords->getY() - _origin.getY()) / _width_y); /* Check if the LocalCoord is on the Lattice boundaries and if so adjust * x or y Lattice cell indices */ if (fabs(fabs(coords->getX()) - _num_x*_width_x*0.5) < ON_LATTICE_CELL_THRESH) { if (coords->getX() > 0) lat_x = _num_x - 1; else lat_x = 0; } if (fabs(fabs(coords->getY()) - _num_y*_width_y*0.5) < ON_LATTICE_CELL_THRESH) { if (coords->getY() > 0) lat_y = _num_y - 1; else lat_y = 0; } /* If the indices are outside the bound of the Lattice */ if (lat_x < 0 || lat_x >= _num_x || lat_y < 0 || lat_y >= _num_y) { return NULL; } /* Compute local position of Point in the next level Universe */ double nextX = coords->getX() - (_origin.getX() + (lat_x + 0.5) * _width_x); double nextY = coords->getY() - (_origin.getY() + (lat_y + 0.5) * _width_y); /* Create a new LocalCoords object for the next level Universe */ LocalCoords* next_coords; if (coords->getNext() == NULL) next_coords = new LocalCoords(nextX, nextY); else next_coords = coords->getNext(); int universe_id = getUniverse(lat_x, lat_y)->getId(); Universe* univ = universes.at(universe_id); next_coords->setUniverse(universe_id); /* Set Lattice indices */ coords->setLattice(_id); coords->setLatticeX(lat_x); coords->setLatticeY(lat_y); coords->setNext(next_coords); next_coords->setPrev(coords); /* Search the next lowest level Universe for the Cell */ return univ->findCell(next_coords, universes); }
void EntityModel::addPositionProperty() { Node& position_node = getRoot().addChild("position"); position_node.m_getter = [this]() -> QVariant { Lumix::Vec3 pos = getUniverse()->getPosition(m_entity); return QString("%1; %2; %3") .arg(pos.x, 0, 'f', 6) .arg(pos.y, 0, 'f', 6) .arg(pos.z, 0, 'f', 6); }; Node& x_node = position_node.addChild("x"); x_node.m_getter = [this]() -> QVariant { return getUniverse()->getPosition(m_entity).x; }; x_node.m_setter = [this](const QVariant& value) { setEntityPosition(0, value.toFloat()); }; Node& y_node = position_node.addChild("y"); y_node.m_getter = [this]() -> QVariant { return getUniverse()->getPosition(m_entity).y; }; y_node.m_setter = [this](const QVariant& value) { setEntityPosition(1, value.toFloat()); }; Node& z_node = position_node.addChild("z"); z_node.m_getter = [this]() -> QVariant { return getUniverse()->getPosition(m_entity).z; }; z_node.m_setter = [this](const QVariant& value) { setEntityPosition(2, value.toFloat()); }; Node& rotation_node = getRoot().addChild("rotation"); rotation_node.m_getter = [this]() -> QVariant { auto rot = getUniverse()->getRotation(m_entity).getAxisAngle(); return QString("[%1; %2; %3] %4") .arg(rot.axis.x, 0, 'f', 6) .arg(rot.axis.y, 0, 'f', 6) .arg(rot.axis.z, 0, 'f', 6) .arg(Lumix::Math::radiansToDegrees(rot.angle), 0, 'f', 6); }; { Node& x_node = rotation_node.addChild("x"); x_node.m_getter = [this]() -> QVariant { return getUniverse()->getRotation(m_entity).getAxisAngle().axis.x; }; x_node.m_setter = [this](const QVariant& value) { setEntityRotation(0, value.toFloat()); }; Node& y_node = rotation_node.addChild("y"); y_node.m_getter = [this]() -> QVariant { return getUniverse()->getRotation(m_entity).getAxisAngle().axis.y; }; y_node.m_setter = [this](const QVariant& value) { setEntityRotation(1, value.toFloat()); }; Node& z_node = rotation_node.addChild("z"); z_node.m_getter = [this]() -> QVariant { return getUniverse()->getRotation(m_entity).getAxisAngle().axis.z; }; z_node.m_setter = [this](const QVariant& value) { setEntityRotation(2, value.toFloat()); }; Node& angle_node = rotation_node.addChild("angle"); angle_node.m_getter = [this]() -> QVariant { return Lumix::Math::radiansToDegrees( getUniverse()->getRotation(m_entity).getAxisAngle().angle); }; angle_node.m_setter = [this](const QVariant& value) { setEntityRotation(3, Lumix::Math::degreesToRadians(value.toFloat())); }; DynamicObjectModel::setSliderEditor(angle_node, 0, 360, 5); } Node& scale_node = getRoot().addChild("scale"); scale_node.m_getter = [this]() -> QVariant { return getUniverse()->getScale(m_entity); }; scale_node.m_setter = [this](const QVariant& value) { setEntityScale(value.toFloat()); }; m_editor.getUniverse() ->entityTransformed() .bind<EntityModel, &EntityModel::onEntityPosition>(this); }