PlayerArea::PlayerArea(const position_type &where) : Rectangle( where, Texture("./resources/playerarea.png") ) { // set playerarea scale this->scale_x(25.f); this->scale_y(10.f); // play deck first, then discard deck, then war deck, so accessors grab the correct child this->add_child(Deck(true, this->position() + position_type(7, 0))); this->add_child(Deck(false, this->position() + position_type(-7, 0))); this->add_child(Deck(false, this->position() + position_type(0, 0))); }
/** * \brief Constructor. */ bear::visual::true_type_font::glyph_sheet::glyph_sheet() : m_image_size( 512, 512 ), m_image( m_image_size.x, m_image_size.y ), m_next_position( 0, 0 ), m_current_line_height(0) { claw::graphic::image img( m_image_size.x, m_image_size.y ); std::fill( img.begin(), img.end(), claw::graphic::transparent_pixel ); m_image.draw( img, position_type(0, 0) ); } // true_type_font::glyph_sheet::glyph_sheet()
void WRATHDefaultTextAttributePacker:: pack_attribute(enum WRATHFormattedTextStream::corner_type ct, const glyph_data &in_glyph, const vec2 &normalized_glyph_coordinate_float, vecN<GLshort,2> normalized_glyph_coordinate_short, const std::vector<int> &custom_data_use, c_array<uint8_t> packing_destination, const PackerState&) const { c_array<character_attribute> attr; attr=packing_destination .sub_array(0, sizeof(character_attribute)) .reinterpret_pointer<character_attribute>(); ivec2 native_bl(in_glyph.m_glyph->texel_lower_left()); ivec2 native_sz(in_glyph.m_glyph->texel_size()); attr[0].position()=position_type(in_glyph.m_native_position[0].x(), in_glyph.m_native_position[0].y(), in_glyph.m_z_position, in_glyph.m_scale); attr[0].glyph_stretch()=glyph_stretch_type(in_glyph.m_horizontal_stretching, in_glyph.m_vertical_stretching); attr[0].glyph_size_and_bottom_left() =glyph_size_and_bottom_left_type(native_sz.x(), native_sz.y(), native_bl.x(), native_bl.y()); attr[0].glyph_normalized_coordinate()=normalized_glyph_coordinate_short; if(ct==WRATHFormattedTextStream::not_corner) { attr[0].color()=interpolate_color(in_glyph.m_color, normalized_glyph_coordinate_float); } else { attr[0].color()=in_glyph.m_color[ct]; } if(!custom_data_use.empty()) { c_array<character_attribute_with_custom<1> > attr_with; attr_with=packing_destination .sub_array(0, sizeof(character_attribute_with_custom<1>)) .reinterpret_pointer<character_attribute_with_custom<1> >(); WRATHassert(&attr_with[0].m_base==&attr[0]); for(int i=0, endi=custom_data_use.size(); i<endi; ++i) { attr_with[0].m_custom[i]=in_glyph.m_glyph->fetch_custom_float(custom_data_use[i]); } } }
InputParameters validParams<CrackDataSampler>() { InputParameters params = validParams<VectorPostprocessor>(); params += validParams<SamplerBase>(); params.addRequiredParam<std::vector<PostprocessorName> >("postprocessors", "The postprocessors whose values are to be reported"); params.addRequiredParam<UserObjectName>("crack_front_definition","The CrackFrontDefinition user object name"); MooseEnum position_type("Angle Distance","Distance"); params.addParam<MooseEnum>("position_type", position_type, "The method used to calculate position along crack front. Options are: "+position_type.getRawNames()); params.addClassDescription("Outputs the values of a set of domain integral postprocessors as a vector, along with their positions along the crack front."); return params; }
World::World(const Context &cx) : Object( position_type( 0, 0 ) ) , dimensions(cx.window->getSize().x, cx.window->getSize().y) , mouseSensitivity(0.1f) { this->context() = cx; // set context // camera setup const GLfloat nearPlane = 0.1f , farPlane = 500.0f , FOV = 45.0f ; auto camera_pos = this->center().vec3() ; camera_pos.y += 20.f; // get off the ground auto look_pos = this->center().vec3(); // where we're looking at look_pos.z += 33.f; // hack:: look at the box look_pos.y += 50.f; // hack:: look at the box auto& c = *this->context().camera; c.setPosition( camera_pos ); c.setViewportAspectRatio(this->dimensions.x / this->dimensions.y); // c.setPerspective( FOV, this->dimensions.x / this->dimensions.y, nearPlane, farPlane ); c.setNearAndFarPlanes(nearPlane, farPlane); // c.LookAt = look_pos; c.lookAt( look_pos ); // this->context().camera->lookAt( look_pos ); auto &terrain = this->add_child( new Terrain( this->center() ) ); // Store the terrain scale, used to not run off the edge terrainScale = terrain.WIDTH; // set up lights this->lights = ::create_lights( this->context(), terrain.center() ); this->_clock.restart(); // restart animation clock } // World
void World::handle_event() { auto &what = *this->context().event; auto& window = *this->context().window; auto& camera = *this->context().camera; const auto camera_step = 20.f; // get light references auto& sunlight = this->lights[ 0 ]; auto& spotlight = this->lights[ 1 ]; // if the mouse is moved at all if (what.type == sf::Event::MouseMoved) { // get the current position of the mouse in the window sf::Vector2i localPosition = sf::Mouse::getPosition(window); // subtract the last known mouse position from the current position int mouseX = localPosition.x - mousePos.x; int mouseY = localPosition.y - mousePos.y; // move the camera by a factore of how much the mouse moved context().camera->offsetOrientation(mouseSensitivity * mouseY, mouseSensitivity * mouseX); if (mouseX != 0 || mouseY != 0) { // move the mouse to the center of the screen, this prevents running out of the window sf::Mouse::setPosition(sf::Vector2i(this->center().x, this->center().y), window); // set the mouse position to the current position mousePos = sf::Vector2i(this->center().x, this->center().y); } } // MouseMove if (what.type == sf::Event::KeyReleased){ switch (what.key.code) { case sf::Keyboard::T: // toggle the sun sunlight.enabled = !sunlight.enabled; break; case sf::Keyboard::F: // Toggle spot light spotlight.enabled = !spotlight.enabled; break; case sf::Keyboard::M: // Toggle shadow mapping this->_shadowmapping_enabled = !this->_shadowmapping_enabled; break; case sf::Keyboard::R: // debug quad this->_render_debug_quad = !this->_render_debug_quad; break; }; // switch } if (what.type == sf::Event::KeyReleased) { if (what.key.code == sf::Keyboard::P) // Drop a block { vec3 camDir = camera.forward(); // Move the camera forwards camera.offsetPosition(camera_step * vec3(camDir.x, 0, camDir.z)); // add a block to the center of the world auto& b = this->add_child<Block>(new Block(this->center())); auto bpos = b.position(); // move the block to the position of the camera vec3 camPos = camera.getPosition(); bpos.x = camPos.x; bpos.z = camPos.z; b.position(bpos); // Move the camera backwards camera.offsetPosition(camera_step * vec3(-camDir.x, 0, -camDir.z)); } } // always update spotlight position based on camera spotlight.direction = this->context().camera->forward(); spotlight.position = position_type( this->context().camera->getPosition() ); spotlight.position.y -= 5.f; // move down from eye level to better resemble a flashlight Object::handle_event();// forward to base method } // dispatch