コード例 #1
0
void star_particles::render() {
  static const int position_layout_id = 1;
  static const int attributes_layout_id = 2;

  static float rotation = 0.0;
  rotation += 0.0001;

  glm::mat4 view(glm::lookAt<float, glm::highp>(
    core::t_vec3f(0.0f, 0.0f, 30000.0f),
    core::t_vec3f(0.0f, 0.0f, 0.0f),
    core::t_vec3f(0.0f, 1.0f, 0.0f)
  ));
  glm::mat4 projection(glm::perspective<float>(45.0f, 16.0f/9.0f, 0.01, 100000000000.0f));
  glm::mat4 model(1.0f);
  glm::mat4 world = projection * view * model;

  m_vertex_array.activate();

  glEnable(GL_POINT_SPRITE);
  glEnable(GL_PROGRAM_POINT_SIZE);

  m_shader_program.activate();

  auto rotation_id = m_shader_program.get_uniform_location("world_matrix");
  glUniformMatrix4fv(rotation_id, 1, GL_FALSE, &world[0][0]);

  auto timer_id = m_shader_program.get_uniform_location("time");
  glUniform1f(timer_id, (float)m_timer.elapsed_time());

  auto pi_id = m_shader_program.get_uniform_location("pi");
  glUniform1f(pi_id, glm::pi<float>());

  m_stars_buffer.activate();

  // use a, b, theta and angle
  glVertexAttribPointer(position_layout_id,   4, GL_FLOAT, GL_FALSE, 3 * sizeof(double), nullptr);
  core::vertex_attribute_array position(position_layout_id);

  // use theta velocity, temperature and brightness
  glVertexAttribPointer(attributes_layout_id, 3, GL_FLOAT, GL_FALSE, 4 * sizeof(double), (void*)(4 * sizeof(double)));
  core::vertex_attribute_array attributes(attributes_layout_id);

  glDrawArrays(GL_POINTS, 0, m_number_of_stars);
}
コード例 #2
0
ファイル: cotest.c プロジェクト: nathanmkaya/ksh-arch
int
main(int argc, char** argv)
{
	register Coshell_t*	sp;
	register char*		s;
	register int		op;
	Coattr_t		attr;

	NoP(argc);
	NoP(argv);
	error(-1, "debug");
	init();
	while ((s = sfgetr(sfstdin, '\n', 0)) && sfvalue(sfstdin) > 1) switch (s[sfvalue(sfstdin) - 1] = 0, op = *s == ':' ? (s++, *s++) : '?')
	{
	case '#':
		break;
	case '?':
	case ':':
		attributes(s, &attr, NiL);
		sp = state.shell;
		do
		{
			if (match(sp, &attr, 0))
			{
				if (op == '?') sfputr(sfstdout, sp->name, '\n');
				else
				{
					sfputr(sfstdout, sp->name, '\t');
					sfputr(sfstdout, sp->misc, '\n');
				}
			}
		} while ((sp = sp->next) != state.shell);
		break;
	case '=':
		if (!search(SET, s, NiL, NiL))
			error(2, "%s: invalid host name", s);
		break;
	default:
		error(2, "`%s': invalid command", s - 2);
		break;
	}
	exit(0);
}
コード例 #3
0
void CollectionConfigReader::readMenuTexts()
{
    while (!atEnd())
    {
        readNext();
        if (isStartElement()) {
            if (name() == QLatin1String("text")) {
                QString lang = attributes().value(QLatin1String("language")).toString();
                if (lang.isEmpty())
                    lang = QLatin1String("default");
                m_aboutMenuTexts.insert(lang, readElementText());
            } else {
                raiseErrorWithLine();
            }
        } else if (isEndElement() && name() == QLatin1String("aboutMenuText")) {
            break;
        }
    }
}
コード例 #4
0
ファイル: Mesh.cpp プロジェクト: pcman75/libgdx-cpp
Mesh::Mesh(bool isStatic,const VertexAttribute& attribute) 
{
    init();
	VertexAttributes attributes(&attribute, 1);
	if (Gdx.isGLInitialised() || forceVBO) 
	{
		m_vertices = new VertexBufferObject(isStatic, attributes);
		m_indices = new IndexBufferObject(isStatic);
		m_isVertexArray = false;
	} 
	else 
	{
		m_vertices = new VertexArray(attributes);
		m_indices = new IndexBufferObject(isStatic);
		m_isVertexArray = true;
	}
    
	addManagedMesh(this);
}
コード例 #5
0
void QHelpProjectDataPrivate::readData(const QByteArray &contents)
{
	addData(contents);
	while (!atEnd()) {
		readNext();
		if (isStartElement()) {
			if (name() == QLatin1String("QtHelpProject") 
                && attributes().value(QLatin1String("version")) == QLatin1String("1.0"))
				readProject();
			else
                raiseError(QObject::tr("Unknown token. Expected \"QtHelpProject\"!"));
		}
	}

    if (hasError()) {
        raiseError(QObject::tr("Error in line %1: %2").arg(lineNumber())
            .arg(errorString()));
    }
}
コード例 #6
0
void Element::setAttribute(const QualifiedName& name, const AtomicString& value, ExceptionCode&)
{
    document()->incDOMTreeVersion();

    // allocate attributemap if necessary
    Attribute* old = attributes(false)->getAttributeItem(name);

    if (name == idAttr)
        updateId(old ? old->value() : nullAtom, value);
    
    if (old && value.isNull())
        namedAttrMap->removeAttribute(name);
    else if (!old && !value.isNull())
        namedAttrMap->addAttribute(createAttribute(name, value));
    else if (old) {
        old->setValue(value);
        attributeChanged(old);
    }
}
コード例 #7
0
    //_______________________________________________________
    void DemoWidget::realize( void )
    {
        assert( !_mainWidget );
        assert( _widget );

        // create main widget (vbox)
        _mainWidget = gtk_box_new( GTK_ORIENTATION_VERTICAL, 0 );
        gtk_box_set_spacing( GTK_BOX( _mainWidget ), 10 );
        gtk_widget_show( _mainWidget );

        // horizontal box
        GtkWidget* hbox( gtk_box_new( GTK_ORIENTATION_HORIZONTAL, 0 ) );
        gtk_box_pack_start( GTK_BOX( _mainWidget ), hbox, false, true, 0 );
        gtk_widget_show( hbox );

        // label
        std::string comments( _comments.empty() ? _name:_comments );
        GtkWidget* label( gtk_label_new( comments.c_str() ) );

        PangoAttrList* attributes( pango_attr_list_new() );
        pango_attr_list_insert( attributes, pango_attr_weight_new( PANGO_WEIGHT_BOLD ) );
        gtk_label_set_attributes( GTK_LABEL( label ), attributes );
        pango_attr_list_unref( attributes );

        gtk_box_pack_start( GTK_BOX( hbox ), label, false, true, 0 );

        gtk_widget_show( label );

        // icon
        if( !_iconName.empty() )
        {
            GtkIconTheme* theme( gtk_icon_theme_get_default() );
            GdkPixbuf* icon( gtk_icon_theme_load_icon( theme, _iconName.c_str(), 22, (GtkIconLookupFlags) 0, 0L ) );
            GtkWidget* image( gtk_image_new_from_pixbuf( icon ) );
            gtk_box_pack_end( GTK_BOX( hbox ), image, false, false, 0 );
            gtk_widget_show( image );

        }

        // main content
        gtk_box_pack_start( GTK_BOX( _mainWidget ), _widget, true, true, 0 );
        gtk_widget_show( _widget );
    }
コード例 #8
0
ファイル: pdmlreader.cpp プロジェクト: anju61188/ostinato
void PdmlReader::readPdml()
{
    QStringList creator;

    Q_ASSERT(isStartElement() && name() == "pdml");

    isMldSupport_ = true;
    creator = attributes().value("creator").toString().split('/');
    if ((creator.size() >= 2) && (creator.at(0) == "wireshark"))
    {
        QList<uint> minMldVer;  
        minMldVer << 1 << 5 << 0;
        QStringList version = creator.at(1).split('.');
        
        for (int i = 0; i < qMin(version.size(), minMldVer.size()); i++)
        {
            if (version.at(i).toUInt() < minMldVer.at(i))
            {
                isMldSupport_ = false;
                break;
            }
        }
    }

    packetCount_ = 1;

    while (!atEnd())
    {
        readNext();

        if (isEndElement())
            break;

        if (isStartElement())
        {
            if (name() == "packet")
                readPacket();
            else
                skipElement();
        }
    }
}
コード例 #9
0
void ConfigurationParser::readGeometry()
{
    Q_ASSERT(isStartElement()
              && name() == "geometry");

    QString path;
    double heightDimension = 1.0;
    QString geometryName = attributes().value("name").toString();
    QString layerSizesPath;

    while(!atEnd()) {
        readNext();

        if(isEndElement())
            break;

        if(isStartElement()) {
            if(name() == "layers") {
                path = readCharacters();
            }
            else if(name() == "heightDimension") {
                heightDimension = readCharacters().toDouble();
            }
            else if(name() == "depths") {
                layerSizesPath = readCharacters();
            }
            else {
                readUnknownElement();
            }
        }
    }

    QFile file(path);

    MapGeometryParser parser;
    parser.setFile(&file);
    parser.setLayerSizesPath(layerSizesPath);
    
    MapGeometry geometry = parser.mapGeometry();
    geometry.setHeightDimension(heightDimension);
    m_geometries.insert(geometryName, geometry);
}
コード例 #10
0
ファイル: modxreader.cpp プロジェクト: phpbb/modx_editor
QList<Action> ModXReader::readEdit()
{
    QList<Action> actions;

    while (!atEnd())
    {
        readNext();

        if (isEndElement())
        {
            break;
        }

        if (isStartElement())
        {
            if (name() == "find")
            {
                Action action;
                action.type = Action::Find;
                action.find = readElementText();
                actions << action;
            }
            else if (name() == "action")
            {
                Action action;
                action.type = Action::Edit;
                action.editType = Action::editTypes.key(attributes().value("type").toString(), Action::BeforeAdd);
                action.edit = readElementText();
                actions << action;
            }
            else if (name() == "inline-edit")
            {
                actions << readInlineEdit();
            }
            else
            {
                readUnknownElement();
            }
        }
    }
    return actions;
}
コード例 #11
0
void InstanceParser::readBin()
{
    Q_ASSERT(isStartElement()
             && name() == "bin");

    QXmlStreamAttributes elementAttributes = attributes();
    if(elementAttributes.hasAttribute("height")) {
        m_sizes.append(elementAttributes.value("height").toString().toInt());
    }

    while(!atEnd()) {
        readNext();

        if(isEndElement())
            break;

        if(isStartElement())
            readUnknownElement();
    }
}
コード例 #12
0
ファイル: OggEncoder.cpp プロジェクト: HaikuArchives/Hare
int32
OggEncoder::WriteDetails(argument* args) {
	PRINT(("OggEncoder::WriteDetails(argument*)\n"));

	dev_t device = dev_for_path(args->outputFile);
	BVolume volume(device);
	if (volume.InitCheck() != B_OK) {
		return B_ERROR;
	}

	BFile oggFile(args->outputFile, B_READ_WRITE);
	if (oggFile.InitCheck() != B_OK) {
		return B_ERROR;
	}

	if (volume.KnowsMime()) {
		BNodeInfo info(&oggFile);
		if (info.InitCheck() != B_OK) {
			return B_ERROR;
		}
		if (info.SetType(OGG_MIME_TYPE) != B_OK) {
			return B_ERROR;
		}
	}

	if (volume.KnowsAttr()) {
		AudioAttributes attributes(&oggFile);
		attributes.SetArtist(args->artist);
		attributes.SetAlbum(args->album);
		attributes.SetTitle(args->title);
		attributes.SetYear(args->year);
		attributes.SetComment(args->comment);
		attributes.SetTrack(args->track);
		attributes.SetGenre(args->genre);
		if (attributes.Write() != B_OK) {
			return B_ERROR;
		}
	}

	return B_OK;
}
コード例 #13
0
    void xml_preserve_handler::startElement(
            const XMLCh* const /*uri*/,
            const XMLCh* const /*localname*/,
            const XMLCh* const qname,
            const xercesc::Attributes& attrs )
    {
        try
        {
            const std::string element_name = xml_utility::transcode(qname);

            boost::shared_ptr<element_info> context(new element_info());

            context->m_element = &m_stack.top()->element().insert(element_name, variant(variant::Bag), variant::ReturnItem);

            variant attributes(variant::Bag);
            xml_utility::get_attributes(attrs, attributes);

            if (attributes.size()>0)
            {
                context->m_element->insert(xml_attributes, attributes);
            }

            m_stack.push(context);
        }
        catch(const std::exception& e)
        {
            if (m_locator)
            {
                XMLFileLoc lineNo = m_locator->getLineNumber();
                boost::throw_exception(variant_error((boost::format("line %d: %s") % (int)lineNo % e.what()).str()));
            }
            else
            {
                boost::throw_exception(variant_error(e.what()));
            }
        }
        catch(...)
        {
            boost::throw_exception(variant_error("Unhandled exception"));
        }
    }
コード例 #14
0
ファイル: main.cpp プロジェクト: Fale/qtmoko
void CollectionConfigReader::readData(const QByteArray &contents)
{
    m_enableFilterFunctionality = true;
    m_hideFilterFunctionality = true;
    m_enableAddressBar = true;
    m_hideAddressBar = true;
    m_enableDocumentationManager = true;

    addData(contents);
    while (!atEnd()) {
        readNext();
        if (isStartElement()) {
            if (name() == QLatin1String("QHelpCollectionProject")
                && attributes().value(QLatin1String("version")) == QLatin1String("1.0"))
                readConfig();
            else
                raiseError(QObject::tr("Unknown token at line %1. Expected \"QtHelpCollectionProject\"!")
                .arg(lineNumber()));
        }
    }
}
コード例 #15
0
void Instances::buildNominalAtts(WrapDataSource *_source)
{
	//throw and exception if all the attributes are not nominal
	vector<EncodedAttributeInfo *> original_atts = _source->codedAttributes();
	vector<AbstractAtt *> attributes(original_atts.size());
	initialiseWeights(attributes.size());

	//m_type = original_atts[0]->bitStreamAt(0)->Type();
	BitStreamInfo * _info = original_atts[0]->vBitStreams()[0];
	m_type = _info->Type();
	for (size_t i = 0 ; i < attributes.size(); i++)
	{
		if(original_atts[i]->attributeType() == MULTICAT_VAL)
		{
		attributes[i] = new NominalAttribute(m_weights[i],getDistinctValues(original_atts[i]));
		attributes[i]->name(original_atts[i]->attributeName());
		}
	}
	m_attributes = attributes;

}
コード例 #16
0
PassRefPtr<Attr> Element::removeAttributeNode(Attr* attr, ExceptionCode& ec)
{
    if (!attr) {
        ec = TYPE_MISMATCH_ERR;
        return 0;
    }
    if (attr->ownerElement() != this) {
        ec = NOT_FOUND_ERR;
        return 0;
    }
    if (document() != attr->document()) {
        ec = WRONG_DOCUMENT_ERR;
        return 0;
    }

    NamedAttrMap *attrs = attributes(true);
    if (!attrs)
        return 0;

    return static_pointer_cast<Attr>(attrs->removeNamedItem(attr->qualifiedName(), ec));
}
コード例 #17
0
/*!
   \brief Calculate a scale division

   \param x1 First interval limit
   \param x2 Second interval limit
   \param maxMajSteps Maximum for the number of major steps
   \param maxMinSteps Maximum number of minor steps
   \param stepSize Step size. If stepSize == 0, the scaleEngine
                   calculates one.
*/
QwtScaleDiv Log2ScaleEngine::divideScale(double x1, double x2,
    int maxMajSteps, int maxMinSteps, double stepSize) const
{
    QwtDoubleInterval interval = QwtDoubleInterval(x1, x2).normalized();
    interval = interval.limited(LOG_MIN, LOG_MAX);

    if (interval.width() <= 0 )
        return QwtScaleDiv();

    if (interval.maxValue() / interval.minValue() < 2){
        // scale width is less than 2 -> build linear scale
        QwtLinearScaleEngine linearScaler;
        linearScaler.setAttributes(attributes());
        linearScaler.setReference(reference());
        linearScaler.setMargins(lowerMargin(), upperMargin());

        return linearScaler.divideScale(x1, x2,
            maxMajSteps, maxMinSteps, stepSize);
    }

    stepSize = qwtAbs(stepSize);
    if ( stepSize == 0.0 ){
        if ( maxMajSteps < 1 )
            maxMajSteps = 1;

		stepSize = ceil(log2(interval).width()/double(maxMajSteps));
    }

    QwtScaleDiv scaleDiv;
    if ( stepSize != 0.0 ){
        QwtValueList ticks[QwtScaleDiv::NTickTypes];
		buildTicks(interval, stepSize, maxMinSteps, ticks);
        scaleDiv = QwtScaleDiv(interval, ticks);
    }

    if ( x1 > x2 )
        scaleDiv.invert();

    return scaleDiv;
}
コード例 #18
0
void PropertyCondition::dumpInContext(PrintStream& out, DumpContext* context) const
{
    if (!*this) {
        out.print("<invalid>");
        return;
    }
    
    out.print(m_kind, " of ", m_uid);
    switch (m_kind) {
    case Presence:
        out.print(" at ", offset(), " with attributes ", attributes());
        return;
    case Absence:
    case AbsenceOfSetter:
        out.print(" with prototype ", inContext(JSValue(prototype()), context));
        return;
    case Equivalence:
        out.print(" with ", inContext(requiredValue(), context));
        return;
    }
    RELEASE_ASSERT_NOT_REACHED();
}
コード例 #19
0
ファイル: osm_pbf.cpp プロジェクト: bleausard/meije-carto
void
QcOsmPbfReader::read_nodes(OSMPBF::PrimitiveGroup primitive_group)
{
  enter_node_transactions();

  int number_of_nodes = primitive_group.nodes_size();
  for (int i = 0; i < number_of_nodes; i++) {
    OSMPBF::Node node = primitive_group.nodes(i);
    int64_t node_id = node.id();
    int64_t longitude = node.lon();
    int64_t latitude = node.lat();
    // qDebug() << "        node " << i << node_id << to_wgs(longitude, latitude);

    int number_of_attributes = node.keys_size();
    QVector<KeyValPair> attributes(number_of_attributes);
    for (int i = 0; i < number_of_attributes; i++) {
      int32_t key_id = node.keys(i);
      int32_t val_id = node.vals(i);
      // qDebug() << "key_val" << node_id << m_string_table[key_id] << m_string_table[val_id];
    }

    yield_node(node_id, longitude, latitude, attributes);

    if (m_read_metadatas and node.has_info()) {
      // qDebug().nospace() << "        with meta-info";
      OSMPBF::Info info = node.info();
      int32_t version = info.version();
      int64_t timestamp = to_timestamp(info.timestamp());
      int64_t changeset = info.changeset();
      int32_t uid = info.uid();
      int32_t user_sid = info.user_sid();
      // bool visible = info.visible();
      // qDebug() << "Meta information:" << version << timestamp << changeset << uid << user_sid;
      // yield_node_metadata(node_id, version, timestamp, changeset, uid, user_sid);
    }
  }

  leave_node_transactions();
}
コード例 #20
0
ファイル: routefinder.cpp プロジェクト: nikobockerman/AtoBe
RoutePoint* parseStop(QXmlStreamReader &reader)
{
    //qDebug() << "Parsing STOP";

    QDateTime arrival, departure;
    QString x, y, name;

    QXmlStreamAttributes attributes(reader.attributes());
    x = attributes.value("x").toString();
    y = attributes.value("y").toString();

    while (!reader.atEnd() && !(reader.name() == "STOP" && reader.tokenType() == QXmlStreamReader::EndElement))
    {
        reader.readNext();

        if (reader.name() == "ARRIVAL" && reader.isStartElement())
        {
            arrival = parseArrivalDeparture(reader);
        }
        else if (reader.name() == "DEPARTURE" && reader.isStartElement())
        {
            departure = parseArrivalDeparture(reader);
        }
        else if (reader.name() == "NAME" && reader.isStartElement())
        {
            // There may be one or two NAME elements.
            // Finnish name has attribute lang="1".
            // Swedish name has attribute lang="2".
            if (reader.attributes().value("lang") == "1")
                name = reader.attributes().value("val").toString();
        }
    }

    RoutePoint* point = RoutePointGenerator::createPointStop(arrival, departure, x, y, name);

    //qDebug() << "STOP parsed";

    return point;
}
コード例 #21
0
ファイル: xbel.cpp プロジェクト: eagafonov/qtmoko
void XbelReader::readBookmarkNode(BookmarkNode *parent)
{
    Q_ASSERT(isStartElement() && name() == QLatin1String("bookmark"));
    BookmarkNode *bookmark = new BookmarkNode(BookmarkNode::Bookmark, parent);
    bookmark->url = attributes().value(QLatin1String("href")).toString();
    while (!atEnd()) {
        readNext();
        if (isEndElement())
            break;

        if (isStartElement()) {
            if (name() == QLatin1String("title"))
                readTitle(bookmark);
            else if (name() == QLatin1String("desc"))
                readDescription(bookmark);
            else
                skipUnknownElement();
        }
    }
    if (bookmark->title.isEmpty())
        bookmark->title = QObject::tr("Unknown title");
}
コード例 #22
0
ファイル: xbel.cpp プロジェクト: RaoHaocheng/FormScada
void XbelReader::readFolder(BookmarkNode *parent)
{
    Q_ASSERT(isStartElement() && name() == QLatin1String("folder"));

    BookmarkNode *folder = new BookmarkNode(BookmarkNode::Folder, parent);
    folder->expanded = (attributes().value(QLatin1String("folded")) == QLatin1String("no"));

    while (readNextStartElement()) {
        if (name() == QLatin1String("title"))
            readTitle(folder);
        else if (name() == QLatin1String("desc"))
            readDescription(folder);
        else if (name() == QLatin1String("folder"))
            readFolder(folder);
        else if (name() == QLatin1String("bookmark"))
            readBookmarkNode(folder);
        else if (name() == QLatin1String("separator"))
            readSeparator(folder);
        else
            skipCurrentElement();
    }
}
コード例 #23
0
KoFilter::ConversionStatus PptxXmlCommentAuthorsReader::read_cmAuthor()
{
    READ_PROLOGUE

    QXmlStreamAttributes attrs( attributes() );

    READ_ATTR_WITHOUT_NS(id)
    READ_ATTR_WITHOUT_NS(name)

    d->context->authors.insert(id.toInt(), name);

    while (!atEnd()) {
        readNext();
        BREAK_IF_END_OF(CURRENT_EL)
//         if (isStartElement()) {
//             TRY_READ_IF(extLst)
//             ELSE_WRONG_FORMAT
//         }
    }

    READ_EPILOGUE
}
コード例 #24
0
void Fidelity::Engine::SimulationXmlReader::readComponent()
{
	SimulationXmlComponent component;

	// Get component attributes
	component.setIdentifier(attributes().value("identifier").toString());
	component.setLabel(attributes().value("label").toString());
	component.setWorkbenchXPos(attributes().value("workbenchX").toString());
	component.setWorkbenchYPos(attributes().value("workbenchY").toString());
	component.setRotation(attributes().value("rotation").toString());
	component.setUuid(attributes().value("uuid").toString());
	
	while(!atEnd()) {
		readNext();

		// Stop here if component tag completed
		if(isEndElement() && name() == "component") {
			break;
		}

		// Evaluate child tags
		if (isStartElement()) {
			// We expect parameter tags only
			if (name() == "parameter") {
				// Add parameter to list
				component.Parameters()->append(readParameter());
			}
			else {
				unknownElement();
			}
		}
	}

	// Validate identifier
	if(component.Identifier().isEmpty()) {
		unknownElement();
	}
	// Validate UUID
	else if(component.Uuid().isEmpty()) {
		unknownElement();
	}
	else if(m_ContinueParsing) {
		// Everything's fine -> propagate component
		emit componentFound(component);
	}
}
コード例 #25
0
void* OgreNewtonSceneBody::AddTerrain (Terrain* const terrain)
{
	OgreNewtonWorld* const world = (OgreNewtonWorld*) GetNewton();

	int width = terrain->getSize() - 1;
	int height = terrain->getSize() - 1;
	int size = width * height;
//	Real min = terrain->getMinHeight();
//	Real max = terrain->getMaxHeight();
	Real horizontalScale = (terrain->getWorldSize() / (terrain->getSize() - 1));

	dNewtonScopeBuffer<dFloat> elevations(size);
	dNewtonScopeBuffer<char> attributes(size);
	
	for (int i = 0; i < width; i++) {	
		int index = i * height;
		for (int k = 0; k < height; k++) {
			// for now make collsionID zero, until we can get material information from the terrain tile
			attributes[index] = 0;
			elevations[index] = terrain->getHeightAtPoint(i, k);
			index ++;
		}
	}

	// build the height field collision
	dNewtonCollisionHeightField terrainCollision (world, width, height, 5, 0, 1.0f, horizontalScale, &elevations[0], &attributes[0], 0);

	// set the offset matrix for this collision shape
	Vector3 posit (-(width / 2.0f) * horizontalScale, 0.0f, (height / 2.0f) * horizontalScale);
	Quaternion rot(Ogre::Degree(90.0f), Ogre::Vector3(0.0f, 1.0f, 0.0f));

	Matrix4 matrix;
	matrix.makeTransform (posit, Vector3(1.0f, 1.0f, 1.0f), rot);
	matrix = matrix.transpose();

	terrainCollision.SetMatrix (&matrix[0][0]);
	return AddCollision (&terrainCollision);
}
コード例 #26
0
/*
 * Parses information inside one <typeface_set> field.
 */
bool HbTypefaceXmlParser::matchLanguageAndCountry() const
{
	Q_ASSERT(isStartElement() && name() == TYPEFACE_SET);
	QString language, country;
	bool positioned(false);

	HbExtendedLocale systemLocale = HbExtendedLocale::system();
	QString attrName, typefaceLocaleName, systemLocaleName;
	QXmlStreamAttributes attrs = attributes();

	foreach (const QXmlStreamAttribute &attr, attrs) {
		attrName = attr.name().toString();

		if (attrName == TYPEFACE_LANGUAGE_ATT) {
			language = attr.value().toString().toLower();
		}
		else if (attrName == TYPEFACE_COUNTRY_ATT) {
			country = attr.value().toString().toUpper();
		}
		else {
			qDebug("Unrecognized attribute");
		}
	}
コード例 #27
0
void XbelReader::readBookmark(QTreeWidgetItem *item)
{
    Q_ASSERT(isStartElement() && name() == "bookmark");

    QTreeWidgetItem *bookmark = createChildItem(item);
    bookmark->setFlags(bookmark->flags() | Qt::ItemIsEditable);
    bookmark->setIcon(0, bookmarkIcon);
    bookmark->setText(0, QObject::tr("Unknown title"));
    bookmark->setText(1, attributes().value("href").toString());
    while (!atEnd()) {
        readNext();

        if (isEndElement())
            break;

        if (isStartElement()) {
            if (name() == "title")
                readTitle(bookmark);
            else
                readUnknownElement();
        }
    }
}
コード例 #28
0
void Fidelity::Engine::SimulationXmlReader::readEngine()
{
	SimulationXmlEngine engine;

	// Get engine attributes
	engine.setIdentifier(attributes().value("identifier").toString());

	while(!atEnd()) {
		readNext();

		// Stop here if engine tag completed
		if(isEndElement() && name() == "engine") {
			break;
		}

		// Evaluate child tags
		if (isStartElement()) {
			// We expect parameter tags only
			if (name() == "parameter") {
				// Add parameter to list
				engine.Parameters()->append(readParameter());
			}
			else {
				unknownElement();
			}
		}
	}

	// Validate identifier
	if(engine.Identifier().isEmpty()) {
		unknownElement();
	}
	else if(m_ContinueParsing) {
		// Everything's fine -> propagate engine
		emit engineFound(engine);
	}
}
コード例 #29
0
ファイル: GLTFWriter.cpp プロジェクト: nil84/glTF
shared_ptr <GLTF::JSONObject> serializePrimitive(GLTFPrimitive* primitive, void *context)
{
    void** primitiveContext = (void**)context;
    shared_ptr <GLTF::JSONObject> primitiveObject(new GLTF::JSONObject());

    GLTFMesh* mesh = (GLTFMesh*)primitiveContext[0];

    void** serializationContext = (void**)primitiveContext[1];

    GLTFConverterContext *converterContext = (GLTFConverterContext*)serializationContext[3];

    primitiveObject->setUnsignedInt32("primitive", converterContext->profile->getGLenumForString(primitive->getType()));

    primitiveObject->setString("material", primitive->getMaterialID());

    shared_ptr <GLTF::JSONObject> attributes(new GLTF::JSONObject());
    primitiveObject->setValue("attributes", attributes);

    size_t count = primitive->getVertexAttributesCount();
    for (size_t j = 0 ; j < count ; j++) {
        GLTF::Semantic semantic = primitive->getSemanticAtIndex(j);

        std::string semanticAndSet = GLTFUtils::getStringForSemantic(semantic);

        unsigned int indexOfSet = 0;
        if (semantic == GLTF::TEXCOORD) {
            indexOfSet = primitive->getIndexOfSetAtIndex(j);
            semanticAndSet += "_" + GLTFUtils::toString(indexOfSet);
        }
        attributes->setString(semanticAndSet, mesh->getMeshAttributesForSemantic(semantic)[indexOfSet]->getID());
    }
    shared_ptr <GLTF::GLTFIndices> uniqueIndices = primitive->getUniqueIndices();
    primitiveObject->setString("indices", uniqueIndices->getID());

    return primitiveObject;
}
コード例 #30
0
void ProjectReader::readScripts()
{
  while (!atEnd()) {
    readNext();
    tokenDebug();

    if (isEndElement())
      break;

    if (isStartElement()) {
      if (name() == "script")
      {
        int condition = attributes().value("condition").toString().toInt();
        QString script = readElementText();

        RPGEngine::addScript(condition, script);
      }
      else
      {
        readUnknownElement();
      }
    }
  }
}