yake-svn Mailing List for Yake Engine
Status: Beta
Brought to you by:
psyclonist
You can subscribe to this list here.
2006 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(17) |
Sep
(51) |
Oct
(2) |
Nov
(18) |
Dec
(66) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2007 |
Jan
(44) |
Feb
(13) |
Mar
(73) |
Apr
(61) |
May
|
Jun
(4) |
Jul
(19) |
Aug
(50) |
Sep
(47) |
Oct
(7) |
Nov
(7) |
Dec
(14) |
2008 |
Jan
(2) |
Feb
|
Mar
(4) |
Apr
(4) |
May
(5) |
Jun
(7) |
Jul
(4) |
Aug
|
Sep
(5) |
Oct
|
Nov
(1) |
Dec
(4) |
2009 |
Jan
|
Feb
(22) |
Mar
(12) |
Apr
(1) |
May
(1) |
Jun
(4) |
Jul
(4) |
Aug
|
Sep
|
Oct
(17) |
Nov
(3) |
Dec
|
2010 |
Jan
|
Feb
|
Mar
(12) |
Apr
(11) |
May
|
Jun
(5) |
Jul
(3) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <psy...@us...> - 2010-07-06 17:25:06
|
Revision: 2037 http://yake.svn.sourceforge.net/yake/?rev=2037&view=rev Author: psyclonist Date: 2010-07-06 17:25:00 +0000 (Tue, 06 Jul 2010) Log Message: ----------- qt: refactored TreeWidget and TreeWidgetMaker Modified Paths: -------------- branches/yake2/yake/src/qt/tree_widget.cpp branches/yake2/yake/yake/qt/tree_widget.h Modified: branches/yake2/yake/src/qt/tree_widget.cpp =================================================================== --- branches/yake2/yake/src/qt/tree_widget.cpp 2010-07-06 17:17:27 UTC (rev 2036) +++ branches/yake2/yake/src/qt/tree_widget.cpp 2010-07-06 17:25:00 UTC (rev 2037) @@ -3,18 +3,19 @@ namespace yake { namespace qt { - TreeWidget::TreeWidget(QWidget* parent) : - QTreeWidget(parent), + //------------------------------------------------------ + TreeWidgetMaker::TreeWidgetMaker(TreeWidget& tree) : + m_tree(tree), m_mode(M_TOPLEVEL) { } - TreeWidget& TreeWidget::make_toplevel() + TreeWidgetMaker& TreeWidgetMaker::toplevel() { m_mode = M_TOPLEVEL; m_currentMakeItem.clear(); return *this; } - TreeWidget& TreeWidget::sub() + TreeWidgetMaker& TreeWidgetMaker::sub() { m_mode = M_SUBITEM; @@ -26,20 +27,20 @@ return *this; } - TreeWidget& TreeWidget::pop() + TreeWidgetMaker& TreeWidgetMaker::pop() { if (!m_currentMakeItem.empty()) m_currentMakeItem.pop_back(); return *this; } - TreeWidget& TreeWidget::make_item(const QString& text, const Value& value) + TreeWidgetMaker& TreeWidgetMaker::item(const QString& text, const Value& value) { QTreeWidgetItem* item = 0; if (m_mode == M_TOPLEVEL || m_currentMakeItem.empty()) { - item = new QTreeWidgetItem(this); - this->addTopLevelItem(item); + item = new QTreeWidgetItem(&m_tree); + m_tree.addTopLevelItem(item); m_currentMakeItem.clear(); m_currentMakeItem.push_back(item); @@ -53,5 +54,10 @@ return *this; } + //------------------------------------------------------ + TreeWidget::TreeWidget(QWidget* parent) : + QTreeWidget(parent) + { + } } // qt } // yake Modified: branches/yake2/yake/yake/qt/tree_widget.h =================================================================== --- branches/yake2/yake/yake/qt/tree_widget.h 2010-07-06 17:17:27 UTC (rev 2036) +++ branches/yake2/yake/yake/qt/tree_widget.h 2010-07-06 17:25:00 UTC (rev 2037) @@ -10,27 +10,42 @@ namespace yake { namespace qt { - class YAKE_QT_API TreeWidget : public QTreeWidget - { - Q_OBJECT - public: - TreeWidget(QWidget* parent); + class TreeWidget; + class YAKE_QT_API TreeWidgetMaker : public boost::noncopyable + { + public: + TreeWidgetMaker(TreeWidget& tree); + TreeWidgetMaker& toplevel(); + TreeWidgetMaker& sub(); + TreeWidgetMaker& pop(); + TreeWidgetMaker& item(const QString& text, const Value& value); + private: + TreeWidget& m_tree; - TreeWidget& make_toplevel(); - TreeWidget& sub(); - TreeWidget& pop(); - TreeWidget& make_item(const QString& text, const Value& value); - private: - std::deque<QTreeWidgetItem*> m_currentMakeItem; - QTreeWidgetItem* m_lastItem; + std::deque<QTreeWidgetItem*> m_currentMakeItem; + QTreeWidgetItem* m_lastItem; - enum Mode { - M_TOPLEVEL, - M_SUBITEM - }; - Mode m_mode; + enum Mode { + M_TOPLEVEL, + M_SUBITEM }; + Mode m_mode; + }; + class YAKE_QT_API TreeWidget : public QTreeWidget + { + Q_OBJECT + public: + TreeWidget(QWidget* parent); + +// virtual void reset() = 0; +// virtual Value currentValue() const = 0; +// virtual void read(const Value& v) = 0; +// virtual void setValue(const Value& value) = 0; +// virtual bool varies() const = 0; + private: + }; + } // qt } // yake This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <psy...@us...> - 2010-07-06 17:17:34
|
Revision: 2036 http://yake.svn.sourceforge.net/yake/?rev=2036&view=rev Author: psyclonist Date: 2010-07-06 17:17:27 +0000 (Tue, 06 Jul 2010) Log Message: ----------- qt: updated multi-edit ComboBox code Modified Paths: -------------- branches/yake2/yake/src/qt/combo.cpp branches/yake2/yake/yake/qt/edit_base.h branches/yake2/yake/yake/qt/editor_types.h Modified: branches/yake2/yake/src/qt/combo.cpp =================================================================== --- branches/yake2/yake/src/qt/combo.cpp 2010-07-06 17:16:19 UTC (rev 2035) +++ branches/yake2/yake/src/qt/combo.cpp 2010-07-06 17:17:27 UTC (rev 2036) @@ -2,17 +2,61 @@ #include "yake/qt/combo.moc" #include <QAbstractItemView> +#include <QLineEdit> namespace yake { namespace qt { - Combo::Combo(QWidget* parent) : QComboBox(parent), m_combo(this) + QString getString_VARIES() { + static const QString s_VARIES = "--VARIES--"; + return s_VARIES; + } + Combo::Combo(QWidget* parent) : QComboBox(parent), m_combo(this), m_noValueSet(true) + { // Make sure the combo box gets the focus: //this->setFocusProxy(m_combo); this->setEditable(false); this->setDuplicatesEnabled( false ); //this->view()->setMinimumHeight(this->view()->minimumHeight()*1.5); + + connect(this,SIGNAL(currentIndexChanged(int)),this,SLOT(onCurrentIndexChanged(int))); + connect(this,SIGNAL(editTextChanged(const QString&)),this,SLOT(onEditTextChanged(const QString&))); } + void Combo::onCurrentIndexChanged(int index) + { + if (m_reader.varies() && index > 0) + { + // clear 'varies' text + assert(this->itemText(0) == getString_VARIES()); + this->removeItem(0); + + // clear 'varies' flag + m_reader.reset(); + } + } + void Combo::onEditTextChanged(const QString& text) + { + if (m_reader.varies() && text!=getString_VARIES() && this->isEditable()) + { + assert( this->lineEdit() ); + + // clear 'varies' flag + m_reader.reset(); + + // clear 'varies' text + assert(this->itemText(0) == getString_VARIES()); + + const int cursorPos = this->lineEdit()->cursorPosition(); + + const bool blocked = this->blockSignals(true); + this->removeItem(0); // triggers onEditTextChanged() so block signals... + this->blockSignals(blocked); + + // removeItem has reset the text - so set it again + this->setEditText(text); + this->lineEdit()->setCursorPosition(cursorPos); + } + } void Combo::showPopup() { #if 1 @@ -31,21 +75,46 @@ void Combo::setEqualFn(const IsValueEqualFn& isEqualFn) { m_isEqual = isEqualFn; + m_reader.setEqualFn(m_isEqual); } void Combo::setValues(const NameValueList& values) { + m_noValueSet = true; m_combo->clear(); m_values = values; for (size_t i=0; i<m_values.size(); ++i) m_combo->addItem( m_values.at(i).first, QVariant::fromValue(m_values.at(i).second) ); } - void Combo::select(const Value& value) + void Combo::reset() + { + m_noValueSet = true; + m_reader.reset(); + } + void Combo::read(const Value& v) + { + const bool varied = m_reader.varies(); + m_reader.read(v); + if (!varied && m_reader.varies()) + { + this->insertItem(0, getString_VARIES(), QVariant::fromValue(getString_VARIES())); + this->setCurrentIndex(0); + } + } + void Combo::setValue(const Value& value) { assert( m_isEqual ); + const int idx = m_combo->currentIndex(); for (size_t i=0; i<m_values.size(); ++i) { if (m_isEqual(m_values.at(i).second, value)) + { m_combo->setCurrentIndex(i); + if (m_noValueSet) // Avoid triggering signal when setting initial value. + m_noValueSet = false; + else + emit valueChanged(this); + break; + } } } Value Combo::currentValue() const @@ -56,5 +125,9 @@ { return m_combo->currentText(); } + bool Combo::varies() const + { + return m_reader.varies(); + } } // qt -} // yake \ No newline at end of file +} // yake Modified: branches/yake2/yake/yake/qt/edit_base.h =================================================================== --- branches/yake2/yake/yake/qt/edit_base.h 2010-07-06 17:16:19 UTC (rev 2035) +++ branches/yake2/yake/yake/qt/edit_base.h 2010-07-06 17:17:27 UTC (rev 2036) @@ -64,7 +64,7 @@ virtual void reset() = 0; virtual Value currentValue() const = 0; virtual void read(const Value& v) = 0; - virtual void selectValue(const Value& value) = 0; + virtual void setValue(const Value& value) = 0; virtual bool varies() const = 0; }; } // qt Modified: branches/yake2/yake/yake/qt/editor_types.h =================================================================== --- branches/yake2/yake/yake/qt/editor_types.h 2010-07-06 17:16:19 UTC (rev 2035) +++ branches/yake2/yake/yake/qt/editor_types.h 2010-07-06 17:17:27 UTC (rev 2036) @@ -11,6 +11,8 @@ namespace qt { typedef std::string string; //@todo fixme + YAKE_QT_API QString getString_VARIES(); + /** Roles for a specific QModelIndex, as used by qt::* delegates. */ enum ItemRole { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <psy...@us...> - 2010-07-06 17:16:25
|
Revision: 2035 http://yake.svn.sourceforge.net/yake/?rev=2035&view=rev Author: psyclonist Date: 2010-07-06 17:16:19 +0000 (Tue, 06 Jul 2010) Log Message: ----------- qt: added LineEdit and TreeWidget Added Paths: ----------- branches/yake2/yake/src/qt/line_edit.cpp branches/yake2/yake/src/qt/tree_widget.cpp branches/yake2/yake/yake/qt/line_edit.h branches/yake2/yake/yake/qt/tree_widget.h Added: branches/yake2/yake/src/qt/line_edit.cpp =================================================================== --- branches/yake2/yake/src/qt/line_edit.cpp (rev 0) +++ branches/yake2/yake/src/qt/line_edit.cpp 2010-07-06 17:16:19 UTC (rev 2035) @@ -0,0 +1,78 @@ +#include "yake/qt/line_edit.h" +#include "yake/qt/line_edit.moc" + +#include <QAbstractItemView> +#include <QLineEdit> +#include <boost/optional.hpp> + +namespace yake { + namespace qt { + LineEdit::LineEdit(QWidget* parent) : QLineEdit(parent), m_edit(this), m_noValueSet(true) + { + connect(this,SIGNAL(editTextChanged(const QString&)),this,SLOT(onEditTextChanged(const QString&))); + } + void LineEdit::onEditTextChanged(const QString& text) + { + if (m_reader.varies() && text!=getString_VARIES()) + { + // clear 'varies' flag + m_reader.reset(); + } + } + void LineEdit::setEditorValidators(const IsValueEqualFn& equalFn, const ValueToStringFn& v2s, const StringToValueFn& s2v) + { + m_isEqual = equalFn; + m_v2s = v2s; + m_s2v = s2v; + m_reader.setEqualFn(m_isEqual); + } + void LineEdit::reset() + { + m_noValueSet = true; + m_reader.reset(); + m_edit->clear(); + } + void LineEdit::read(const Value& v) + { + const bool varied = m_reader.varies(); + m_reader.read(v); + if (!varied && m_reader.varies()) + { + m_edit->setText(getString_VARIES()); + } + else + setValue(v); + } + void LineEdit::setValue(const Value& value) + { + assert( m_isEqual ); + assert( m_s2v ); + + const boost::optional<QString> text = m_v2s(value); + assert( text && "could not convert value to text" ); + if (!text) + return; + + m_edit->setText(*text); + + if (m_noValueSet) // Avoid triggering signal when setting initial value. + m_noValueSet = false; + else + emit valueChanged(this); + } + Value LineEdit::currentValue() const + { + assert( m_s2v ); + if (!m_s2v) + return Value(); + + const boost::optional<Value> value = m_s2v(m_edit->text()); + assert( value && "could not convert from string to value" ); + return value ? *value : Value(); + } + bool LineEdit::varies() const + { + return m_reader.varies(); + } + } // qt +} // yake \ No newline at end of file Added: branches/yake2/yake/src/qt/tree_widget.cpp =================================================================== --- branches/yake2/yake/src/qt/tree_widget.cpp (rev 0) +++ branches/yake2/yake/src/qt/tree_widget.cpp 2010-07-06 17:16:19 UTC (rev 2035) @@ -0,0 +1,57 @@ +#include "yake/qt/tree_widget.h" +#include "yake/qt/tree_widget.moc" + +namespace yake { +namespace qt { + TreeWidget::TreeWidget(QWidget* parent) : + QTreeWidget(parent), + m_mode(M_TOPLEVEL) + { + } + TreeWidget& TreeWidget::make_toplevel() + { + m_mode = M_TOPLEVEL; + m_currentMakeItem.clear(); + return *this; + } + TreeWidget& TreeWidget::sub() + { + m_mode = M_SUBITEM; + + if (m_lastItem) + { + if (m_currentMakeItem.empty() || m_currentMakeItem.back() != m_lastItem) + m_currentMakeItem.push_back(m_lastItem); + } + + return *this; + } + TreeWidget& TreeWidget::pop() + { + if (!m_currentMakeItem.empty()) + m_currentMakeItem.pop_back(); + return *this; + } + TreeWidget& TreeWidget::make_item(const QString& text, const Value& value) + { + QTreeWidgetItem* item = 0; + + if (m_mode == M_TOPLEVEL || m_currentMakeItem.empty()) + { + item = new QTreeWidgetItem(this); + this->addTopLevelItem(item); + + m_currentMakeItem.clear(); + m_currentMakeItem.push_back(item); + } + else + item = new QTreeWidgetItem(m_currentMakeItem.back()); + + item->setText(0, text); + + m_lastItem = item; + + return *this; + } +} // qt +} // yake Added: branches/yake2/yake/yake/qt/line_edit.h =================================================================== --- branches/yake2/yake/yake/qt/line_edit.h (rev 0) +++ branches/yake2/yake/yake/qt/line_edit.h 2010-07-06 17:16:19 UTC (rev 2035) @@ -0,0 +1,77 @@ +#ifndef YAKE_QT_LINEEDIT_H +#define YAKE_QT_LINEEDIT_H + +#include "prerequisites.h" +#include "editor_types.h" +#include "edit_base.h" + +#include <QLineEdit> + +namespace yake { +namespace qt { + + /* + class YAKE_QT_API Validator : public boost::noncopyable + { + virtual ~Validator() {} + + virtual Value validate(const QString&) const = 0; + virtual boost::optional<QString> reformat(const Value&) const = 0; + }; + class YAKE_QT_API StringValidator : public Validator + { + StringValidator(const size_t maxLength = std::numeric_limits<size_t>::max()); + + virtual Value validate(const QString&) const; + virtual boost::optional<QString> reformat(const Value&) const; + private: + size_t maxLength_; + }; + class YAKE_QT_API IntValidator : public Validator + { + IntegralValidator(); + IntegralValidator(const int min = 0, const int max = std::numeric_limits<int>::max()); + + private: + }; + */ + + /** A QLineEdit equivalent but using the 'name/value' and multi-edit interface. + */ + class YAKE_QT_API LineEdit : public QLineEdit, public EditBase + { + Q_OBJECT + public: + LineEdit(QWidget* parent); + + void setEditorValidators( + const IsValueEqualFn& equalFn, + const ValueToStringFn& v2s, + const StringToValueFn& s2v); + + virtual void reset(); + virtual void read(const Value& v); + virtual Value currentValue() const; + virtual void setValue(const Value& value); + virtual bool varies() const; + + private Q_SLOTS: + void onEditTextChanged(const QString&); + + Q_SIGNALS: + void valueChanged(EditBase*); + + private: + QLineEdit* m_edit; + bool m_noValueSet; + ValueReader m_reader; + IsValueEqualFn m_isEqual; + + ValueToStringFn m_v2s; + StringToValueFn m_s2v; + }; + +} // qt +} // yake + +#endif Added: branches/yake2/yake/yake/qt/tree_widget.h =================================================================== --- branches/yake2/yake/yake/qt/tree_widget.h (rev 0) +++ branches/yake2/yake/yake/qt/tree_widget.h 2010-07-06 17:16:19 UTC (rev 2035) @@ -0,0 +1,37 @@ +#ifndef YAKE_QT_TREEWIDGET_H +#define YAKE_QT_TREEWIDGET_H + +#include "prerequisites.h" +#include "editor_types.h" +#include "edit_base.h" + +#include <QTreeWidget> + +namespace yake { +namespace qt { + + class YAKE_QT_API TreeWidget : public QTreeWidget + { + Q_OBJECT + public: + TreeWidget(QWidget* parent); + + TreeWidget& make_toplevel(); + TreeWidget& sub(); + TreeWidget& pop(); + TreeWidget& make_item(const QString& text, const Value& value); + private: + std::deque<QTreeWidgetItem*> m_currentMakeItem; + QTreeWidgetItem* m_lastItem; + + enum Mode { + M_TOPLEVEL, + M_SUBITEM + }; + Mode m_mode; + }; + +} // qt +} // yake + +#endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <psy...@us...> - 2010-06-16 22:32:28
|
Revision: 2034 http://yake.svn.sourceforge.net/yake/?rev=2034&view=rev Author: psyclonist Date: 2010-06-16 22:32:22 +0000 (Wed, 16 Jun 2010) Log Message: ----------- qt::Combo is the first multi-edit control/widget Modified Paths: -------------- branches/yake2/yake/yake/qt/combo.h branches/yake2/yake/yake/qt/prerequisites.h branches/yake2/yake/yake/qt/property_browser.h Added Paths: ----------- branches/yake2/yake/yake/qt/edit_base.h Modified: branches/yake2/yake/yake/qt/combo.h =================================================================== --- branches/yake2/yake/yake/qt/combo.h 2010-06-15 15:53:32 UTC (rev 2033) +++ branches/yake2/yake/yake/qt/combo.h 2010-06-16 22:32:22 UTC (rev 2034) @@ -3,28 +3,49 @@ #include "prerequisites.h" #include "editor_types.h" +#include "edit_base.h" #include <QComboBox> namespace yake { namespace qt { + /** A QComboBox equivalent but using the 'name/value' interface. */ - class YAKE_QT_API Combo : public QComboBox + class YAKE_QT_API Combo : public QComboBox, public EditBase { + Q_OBJECT public: Combo(QWidget* parent); virtual void showPopup(); - void setEqualFn(const IsValueEqualFn& isEqualFn); + + void setEqualFn(const IsValueEqualFn& isEqualFn); void setValues(const NameValueList& values); - void select(const Value& value); - Value currentValue() const; + QString currentText() const; + + virtual void reset(); + virtual void read(const Value& v); + virtual Value currentValue() const; + virtual void setValue(const Value& value); + virtual bool varies() const; + + private Q_SLOTS: + void onCurrentIndexChanged(int index); + void onEditTextChanged(const QString&); + + Q_SIGNALS: + void valueChanged(EditBase*); + private: QComboBox* m_combo; IsValueEqualFn m_isEqual; NameValueList m_values; + bool m_noValueSet; + + ValueReader m_reader; }; + } // qt } // yake Added: branches/yake2/yake/yake/qt/edit_base.h =================================================================== --- branches/yake2/yake/yake/qt/edit_base.h (rev 0) +++ branches/yake2/yake/yake/qt/edit_base.h 2010-06-16 22:32:22 UTC (rev 2034) @@ -0,0 +1,73 @@ +#ifndef YAKE_QT_EDITBASE_H +#define YAKE_QT_EDITBASE_H + +#include "prerequisites.h" + +#include <boost/noncopyable.hpp> +#include <yake/base/type_info.h> + +namespace yake { +namespace qt { + struct ValueReaderBase : public boost::noncopyable + { + virtual ~ValueReaderBase() {} + virtual void reset() = 0; + virtual void read(const qt::Value& v) = 0; + virtual bool varies() const = 0; + }; + struct ValueReader : public ValueReaderBase + { + ValueReader() : m_first(true), m_varies(false) + { + } + void setEqualFn(qt::IsValueEqualFn isEqualFn) + { + m_isEqual = isEqualFn; + } + virtual void reset() + { + m_first = true; + m_varies = false; + m_value = qt::Value(); + } + virtual void read(const qt::Value& v) + { + if (m_first) + { + m_first = false; + m_value = v; + } + else if (!m_varies) + { + assert(m_isEqual); + if (TypeInfo(&m_value.type()) != TypeInfo(&v.type()) || + !m_isEqual(m_value, v)) + m_varies = true; + } + } + virtual bool varies() const + { + return m_varies; + } + private: + bool m_first; + bool m_varies; + qt::Value m_value; + qt::IsValueEqualFn m_isEqual; + }; + + class YAKE_QT_API EditBase : public boost::noncopyable + { + protected: + virtual ~EditBase() {} + public: + virtual void reset() = 0; + virtual Value currentValue() const = 0; + virtual void read(const Value& v) = 0; + virtual void selectValue(const Value& value) = 0; + virtual bool varies() const = 0; + }; +} // qt +} // yake + +#endif Modified: branches/yake2/yake/yake/qt/prerequisites.h =================================================================== --- branches/yake2/yake/yake/qt/prerequisites.h 2010-06-15 15:53:32 UTC (rev 2033) +++ branches/yake2/yake/yake/qt/prerequisites.h 2010-06-16 22:32:22 UTC (rev 2034) @@ -26,8 +26,24 @@ typedef std::deque<Value> ValueList; typedef std::deque<Name> NameList; typedef std::map<Name,Value> NameToValue; - typedef std::deque<std::pair<Name,Value> > NameValueList; + typedef std::pair<Name,Value> NameValuePair; + typedef std::deque<NameValuePair> NameValueList; + struct MakeNameValueList + { + MakeNameValueList& operator << (const NameValuePair& nvp) + { + nv_.push_back(nvp); + return *this; + } + operator const NameValueList& () const + { + return nv_; + } + private: + NameValueList nv_; + }; + } // qt } // yake Modified: branches/yake2/yake/yake/qt/property_browser.h =================================================================== --- branches/yake2/yake/yake/qt/property_browser.h 2010-06-15 15:53:32 UTC (rev 2033) +++ branches/yake2/yake/yake/qt/property_browser.h 2010-06-16 22:32:22 UTC (rev 2034) @@ -27,6 +27,7 @@ private Q_SLOTS: void onItemChanged(QTreeWidgetItem *item, int column); void onItemActivated(QTreeWidgetItem *item, int column); + void onValueChanged(EditBase*); public: Value getCurrentValue(QTreeWidgetItem* item) const; @@ -64,7 +65,40 @@ return item; } - template<typename Vt> + + template<typename Vt> + qt::Combo* _addEnumBox(const QString& name) + { + QTreeWidgetItem* item = m_parent ? new QTreeWidgetItem(m_parent) : new QTreeWidgetItem(m_tree); + if (!m_parent) + m_tree->addTopLevelItem(item); + + item->setText(0,name); + + qt::Combo* editor = new qt::Combo(m_tree); + m_tree->setItemWidget(item, 1, editor); + + connect(editor,SIGNAL(valueChanged(EditBase*)),this,SLOT(onValueChanged(EditBase*))); + + return editor; + } + + void addEditor(const QString& name, QWidget* editor) + { + QTreeWidgetItem* item = m_parent ? new QTreeWidgetItem(m_parent) : new QTreeWidgetItem(m_tree); + if (!m_parent) + m_tree->addTopLevelItem(item); + + item->setText(0,name); + + m_tree->setItemWidget(item, 1, editor); + } + QWidget* editorParent() const + { + return m_tree; + } + + template<typename Vt> QTreeWidgetItem* addEnumBox(const QString& name, const Vt& v, const NameValueList& values) { QTreeWidgetItem* item = m_parent ? new QTreeWidgetItem(m_parent) : new QTreeWidgetItem(m_tree); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <psy...@us...> - 2010-06-15 15:53:40
|
Revision: 2033 http://yake.svn.sourceforge.net/yake/?rev=2033&view=rev Author: psyclonist Date: 2010-06-15 15:53:32 +0000 (Tue, 15 Jun 2010) Log Message: ----------- added demo: qt-demo-1 Modified Paths: -------------- branches/yake2/yake/premake4.lua Added Paths: ----------- branches/yake2/yake/samples/qt-demo-1/ branches/yake2/yake/samples/qt-demo-1/demo.cpp Modified: branches/yake2/yake/premake4.lua =================================================================== --- branches/yake2/yake/premake4.lua 2010-06-15 15:46:34 UTC (rev 2032) +++ branches/yake2/yake/premake4.lua 2010-06-15 15:53:32 UTC (rev 2033) @@ -612,6 +612,9 @@ requires_lib "physics" requires_lib "qtogre" requires_lib "qt" + project_exe("qt-demo-1", {require_package = {"boost","qt"}}) + requires_lib "log" + requires_lib "qt" end --[[ project "demo1" Added: branches/yake2/yake/samples/qt-demo-1/demo.cpp =================================================================== --- branches/yake2/yake/samples/qt-demo-1/demo.cpp (rev 0) +++ branches/yake2/yake/samples/qt-demo-1/demo.cpp 2010-06-15 15:53:32 UTC (rev 2033) @@ -0,0 +1,37 @@ +// yake/qt for this demo: for displaying a styled dialog +#include <yake/qt/dialog.h> +#include <yake/qt/utils.h> +#include <yake/qt/property_browser.h> + +// Qt +#include <QApplication> +#include <QVboxLayout> + + +int main(int argc, char** argv) +{ + using namespace yake; + + // create Qt application + QApplication app(argc, argv); + app.setWindowIcon(QPixmap("icons/bricks.png")); // optional: set your application's icon + const QString appName("demo"); // We re-use the application name in several places. + + // create main window + Qt layout + QDialog dlg; + QVBoxLayout* dlgL = new QVBoxLayout(&dlg); + + // create a property browser/container + qt::PropertyBrowser* browser = new qt::PropertyBrowser(&dlg); + dlgL->addWidget(browser); + + // create a simple editing widget with 2 possible values, selecting the 2nd by default. + qt::Combo* c = browser->_addEnumBox<int>("Int Property"); + c->setEqualFn(&qt::isValueEqualTo<int>); + c->setValues(qt::MakeNameValueList() << qt::NameValuePair("Default",1) << qt::NameValuePair("Default 2",2)); + c->selectValue(2); + + dlg.exec(); + + return 0; +} \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <psy...@us...> - 2010-06-15 15:46:40
|
Revision: 2032 http://yake.svn.sourceforge.net/yake/?rev=2032&view=rev Author: psyclonist Date: 2010-06-15 15:46:34 +0000 (Tue, 15 Jun 2010) Log Message: ----------- added build/vc-rules/moc.rules Added Paths: ----------- branches/yake2/yake/build/ branches/yake2/yake/build/vc-rules/ branches/yake2/yake/build/vc-rules/moc.rules Added: branches/yake2/yake/build/vc-rules/moc.rules =================================================================== --- branches/yake2/yake/build/vc-rules/moc.rules (rev 0) +++ branches/yake2/yake/build/vc-rules/moc.rules 2010-06-15 15:46:34 UTC (rev 2032) @@ -0,0 +1,19 @@ +<?xml version="1.0" encoding="utf-8"?> +<VisualStudioToolFile + Name="moc" + Version="8,00" + > + <Rules> + <CustomBuildRule + Name="moc" + DisplayName="moc" + CommandLine="D:\dep\qt-everywhere-opensource-src-4.6.2\bin\moc $(InputDir)\$(InputName).h -o $(InputDir)\$(InputName).moc" + Outputs="$(InputDir)\$(InputName).moc" + FileExtensions="*.h" + ExecutionDescription="MOC $(InputDir)\$(InputName).h" + > + <Properties> + </Properties> + </CustomBuildRule> + </Rules> +</VisualStudioToolFile> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <psy...@us...> - 2010-06-15 15:19:54
|
Revision: 2031 http://yake.svn.sourceforge.net/yake/?rev=2031&view=rev Author: psyclonist Date: 2010-06-15 15:19:48 +0000 (Tue, 15 Jun 2010) Log Message: ----------- added qtogre Added Paths: ----------- branches/yake2/yake/src/qtogre/ branches/yake2/yake/src/qtogre/detail/ branches/yake2/yake/src/qtogre/detail/ogre_graphics_view.cpp branches/yake2/yake/src/qtogre/detail/ogre_graphics_view.h branches/yake2/yake/src/qtogre/main_window.cpp branches/yake2/yake/yake/qtogre/ branches/yake2/yake/yake/qtogre/launch_options.h branches/yake2/yake/yake/qtogre/main_window.h branches/yake2/yake/yake/qtogre/prerequisites.h branches/yake2/yake/yake/qtogre/qtogre.h Added: branches/yake2/yake/src/qtogre/detail/ogre_graphics_view.cpp =================================================================== Added: branches/yake2/yake/src/qtogre/detail/ogre_graphics_view.h =================================================================== --- branches/yake2/yake/src/qtogre/detail/ogre_graphics_view.h (rev 0) +++ branches/yake2/yake/src/qtogre/detail/ogre_graphics_view.h 2010-06-15 15:19:48 UTC (rev 2031) @@ -0,0 +1,130 @@ +#ifndef YAKE_QTOGRE_GRAPHICSVIEW_H +#define YAKE_QTOGRE_GRAPHICSVIEW_H + +#include "yake/qtogre/launch_options.h" +#include "yake/base/templates/yakeSmartAssert.h" + +// Qt +#include <QtCore/QTimer> +#include <QtOpenGL/QGLWidget> +#include <QtGui/QGraphicsView> +#include <QtGui/QPaintEngine> +#include <QtGui/QGraphicsItem> +#include <QtGui/QGraphicsProxyWidget> + +// Ogre +#include "OgreRenderWindow.h" +#include "OgreStringConverter.h" +#include "OgreRoot.h" + +namespace yake { +namespace qt { + /** This view represents a top-level window, enabling OpenGL rendering of Qt and OGRE. + @note Currently, this code is Windows specific of calls to wgl*() and use of HDC etc. It + shouldn't be difficult to port to other window systems, though. + @note Where did I get the original code from? Was it Ogre's wiki? The forum? + */ + class OgreGraphicsView : public QGraphicsView + { + public: + OgreGraphicsView(Ogre::Root* root) : + opengl_(0), + root_(root), + renderWindow_(0) + { + YAKE_ASSERT( root ); + } + void initialize(const MainWindowLaunchOptions& launchOptions) + { + YAKE_ASSERT( root_ ); + + // setup OpenGL as main window + opengl_ = new QGLWidget(QGLFormat()); // @todo what about destruction... + this->setViewport(opengl_); + this->setViewportUpdateMode(QGraphicsView::FullViewportUpdate); + + // resize + YAKE_ASSERT(launchOptions.width>0 && launchOptions.height>0); + this->resize(launchOptions.width, launchOptions.height); + + // setup ogre to use an external window handle + Ogre::NameValuePairList params; + params["externalWindowHandle"] = Ogre::StringConverter::toString((unsigned int)(opengl_->winId())); + params["externalGLControl"] = "true"; + params["colourDepth"] = Ogre::StringConverter::toString(launchOptions.colourDepth); + if (launchOptions.fsaa > 0) + params["FSAA"] = Ogre::StringConverter::toString(launchOptions.fsaa); + + renderWindow_ = root_->createRenderWindow("Ogre Render Window", this->width(), this->height(), false, ¶ms); + +#if YAKE_PLATFORM == PLATFORM_WIN32 + ogreHDC = wglGetCurrentDC(); + ogreHGLRC = wglGetCurrentContext(); +#else // Linux + ogreHGLRC = glXGetCurrentContext(); +#endif + } + private: + virtual void drawBackground(QPainter *painter, const QRectF &rect) + { + // Sanity check: + YAKE_ASSERT( painter->paintEngine()->type() == QPaintEngine::OpenGL || painter->paintEngine()->type() == QPaintEngine::OpenGL2 ); + if (painter->paintEngine()->type() != QPaintEngine::OpenGL && + painter->paintEngine()->type() != QPaintEngine::OpenGL2) + return; + + // Switch GL context to Ogre's: + wglMakeCurrent(ogreHDC, ogreHGLRC); + + // + root_->_fireFrameStarted(); + renderWindow_->update(false); + root_->_fireFrameEnded(); + + // And restore Qt's GL context: + opengl_->makeCurrent(); + } + public: + Ogre::RenderWindow* getOgreRenderWindow() + { + return renderWindow_; + } + + protected: + virtual void resizeEvent(QResizeEvent *event) + { + //This was just taken from the sample. I guess we need it. + if (scene()) + { + qWarning("Resizing graphics view"); + scene()->setSceneRect(QRect(QPoint(0, 0), event->size())); + } + + wglMakeCurrent(ogreHDC, ogreHGLRC); + + renderWindow_->windowMovedOrResized(); + + opengl_->makeCurrent(); + + QGraphicsView::resizeEvent(event); + } + + private: + //These are WIN32 device context and OpenGL resource context types. + //They are used to keep track of the Ogre OpenGL context. + HGLRC ogreHGLRC; + HDC ogreHDC; + + //Ogre stuff + Ogre::Root *root_; + Ogre::RenderWindow *renderWindow_; + + public: + //The OpenGL widget which is used for drawing both the Ogre scene and the test dialog + QGLWidget* opengl_; //@todo Can this be static? Or does this interfere with "this"'s destruction? + }; +} // namespace qt +} // namespace yake + + +#endif Added: branches/yake2/yake/src/qtogre/main_window.cpp =================================================================== --- branches/yake2/yake/src/qtogre/main_window.cpp (rev 0) +++ branches/yake2/yake/src/qtogre/main_window.cpp 2010-06-15 15:19:48 UTC (rev 2031) @@ -0,0 +1,144 @@ +#include "yake/qtogre/main_window.h" +#include "detail/ogre_graphics_view.h" + +// Qt +#include <QtGui/QApplication> + +// Ogre +#include "OgreRoot.h" +#include "OgreEntity.h" + +namespace yake { +namespace qt { + std::auto_ptr<MainOgreWindow> MainOgreWindow::s_instance; + MainOgreWindow& MainOgreWindow::instance(Ogre::Root* root /*= 0*/, MainWindowLaunchOptions* launchOptions /*= 0*/) + { + if (!s_instance.get()) + s_instance.reset(new MainOgreWindow(root,launchOptions)); + return *s_instance; + } + void MainOgreWindow::shutdown() + { + s_instance.reset(); + } + MainOgreWindow::MainOgreWindow(Ogre::Root* root, MainWindowLaunchOptions* launchOptions) : root_(0) + { + //Initialize the Ogre root and the OpenGL Render system. + if (root) + root_ = root; + else + { + root_ = new Ogre::Root("","yake.graphics.ogre_resources.cfg"); +#if defined(YAKE_DEBUG) + root_->loadPlugin("RenderSystem_GL_d"); +#else + root_->loadPlugin("RenderSystem_GL"); +#endif + } + Ogre::RenderSystemList *list = root_->getAvailableRenderers(); + Ogre::RenderSystemList::iterator i = list->begin(); + root_->setRenderSystem(*i); + root_->initialise(false); + + //Create the Ogre graphics view. + view_.reset(new OgreGraphicsView(root_)); + view_->initialize(launchOptions ? *launchOptions : MainWindowLaunchOptions()); + + //Create the graphics scene object and attach it to the graphics view + view_->setScene(&scene_); + + //Now we are on to initializing Ogre + //@todo Is this not done by yake::graphicsOgre? + Ogre::SceneManager* sceneManager = root_->createSceneManager(Ogre::ST_GENERIC); + +//@todo move to graphics::ICamera +// // Let the camera automatically recalculate the aspect ratio if the viewport is resized. +// // This can happen, for example, in windowed mode when the user resizes the window. +// cam->setAutoAspectRatio(true); + + + // Ogre has been setup and is now ready for rendering. + // We hook up a timer to generate update events for our graphics view + QTimer *timer = new QTimer(qApp); + assert( qApp ); + qApp->connect(timer, SIGNAL(timeout()), view_->opengl_, SLOT(update())); + timer->start(0); + } + MainOgreWindow::~MainOgreWindow() + { + delete root_; + root_ = 0; + } + void MainOgreWindow::setWindowed(const bool windowed) + { + if (windowed) + view_->setWindowState(view_->windowState() &= ~Qt::WindowFullScreen); + else + view_->setWindowState(view_->windowState() | Qt::WindowFullScreen); + } + void MainOgreWindow::addWidget(QWidget* w) + { + QGraphicsProxyWidget* proxy = 0; +#if 0 // This was a special case for doing some special rendering for the Dialog2 class: + const std::string cls(w->metaObject()->className()); + if (cls == "yake::qt::Dialog2" || cls == "yake::qt::Dialog") + { + proxy = new Dialog2GraphicsProxy(); + proxy->setWidget(w); + m_scene.addItem(proxy); + } + else +#endif + proxy = scene_.addWidget(w); + proxy->setCacheMode(QGraphicsItem::NoCache); + //proxy->setCacheMode(QGraphicsItem::ItemCoordinateCache); + proxy->setCacheMode(QGraphicsItem::DeviceCoordinateCache); + +#if 0 // test code + // NOTE: NoCache is required when using custom transform, it seems: + proxy->setCacheMode(QGraphicsItem::NoCache); + QTransform xform; + xform.rotate(5,Qt::YAxis); + proxy->setTransform(xform,true); +#endif + } + void MainOgreWindow::show() + { + view_->show(); + } + void MainOgreWindow::hide() + { + view_->hide(); + } + void MainOgreWindow::setWindowTitle(const QString& title) + { + view_->setWindowTitle(title); + } + QString MainOgreWindow::getOgreRenderWindowAsString() const + { + const intptr_t t = reinterpret_cast<intptr_t>(view_->getOgreRenderWindow()); + return QString("%1").arg(t); + } + void MainOgreWindow::invalidateView() + { + /* + m_view->invalidateScene(); + m_view->resetCachedContent(); + */ + } + void MainOgreWindow::updateView() + { + /* + invalidateView(); + m_view->m_glWidget->update(); + m_view->repaint(); + m_view->update(); + */ + } + bool MainOgreWindow::isVisible() const + { + return view_->isVisible(); + } + +} // namespace qt +} // namespace yake Added: branches/yake2/yake/yake/qtogre/launch_options.h =================================================================== --- branches/yake2/yake/yake/qtogre/launch_options.h (rev 0) +++ branches/yake2/yake/yake/qtogre/launch_options.h 2010-06-15 15:19:48 UTC (rev 2031) @@ -0,0 +1,25 @@ +#ifndef YAKE_QTOGRE_LAUNCH_OPTIONS_H +#define YAKE_QTOGRE_LAUNCH_OPTIONS_H + +#include "prerequisites.h" +#include <QGraphicsView> + +namespace yake { +namespace qt { + + struct YAKE_QTOGRE_API MainWindowLaunchOptions + { + bool windowed; + int fsaa; + int colourDepth; + int width; + int height; + MainWindowLaunchOptions() : windowed(true), fsaa(0), colourDepth(32), width(640), height(480) + {} + }; + +} // namespace qt +} // namespace yake + + +#endif Added: branches/yake2/yake/yake/qtogre/main_window.h =================================================================== --- branches/yake2/yake/yake/qtogre/main_window.h (rev 0) +++ branches/yake2/yake/yake/qtogre/main_window.h 2010-06-15 15:19:48 UTC (rev 2031) @@ -0,0 +1,52 @@ +#ifndef YAKE_QTOGRE_MAINWINDOW_H +#define YAKE_QTOGRE_MAINWINDOW_H + +#include "prerequisites.h" +#include "launch_options.h" + +#include <QGraphicsScene> + +namespace Ogre { + class Root; +} // namespace Ogre + +namespace yake { +namespace qt { + + class OgreGraphicsView; + struct YAKE_QTOGRE_API MainOgreWindow + { + private: + MainOgreWindow(Ogre::Root* root = 0, MainWindowLaunchOptions* launchOptions = 0); + public: + ~MainOgreWindow(); + private: + // noncopyable + MainOgreWindow(const MainOgreWindow&); + const MainOgreWindow& operator = (const MainOgreWindow&); + public: + void addWidget(QWidget*); + void setWindowed(const bool windowed); + void show(); + void hide(); + void setWindowTitle(const QString& title); + bool isVisible() const; + + static MainOgreWindow& instance(Ogre::Root* root = 0, MainWindowLaunchOptions* launchOptions = 0); + static void shutdown(); + + QString getOgreRenderWindowAsString() const; + + void invalidateView(); + void updateView(); + private: + std::auto_ptr<OgreGraphicsView> view_; + QGraphicsScene scene_; + Ogre::Root* root_; + static std::auto_ptr<MainOgreWindow> s_instance; + }; + +} // namespace qt +} // namespace yake + +#endif Added: branches/yake2/yake/yake/qtogre/prerequisites.h =================================================================== --- branches/yake2/yake/yake/qtogre/prerequisites.h (rev 0) +++ branches/yake2/yake/yake/qtogre/prerequisites.h 2010-06-15 15:19:48 UTC (rev 2031) @@ -0,0 +1,12 @@ +#ifndef YAKE_QTOGRE_PREREQUISITES_H +#define YAKE_QTOGRE_PREREQUISITES_H + +#include <yake/base/yakePrerequisites.h> + +#if defined( YAKE_QTOGRE_EXPORTS ) +# define YAKE_QTOGRE_API DLLEXPORT +#else +# define YAKE_QTOGRE_API DLLIMPORT +#endif + +#endif Added: branches/yake2/yake/yake/qtogre/qtogre.h =================================================================== --- branches/yake2/yake/yake/qtogre/qtogre.h (rev 0) +++ branches/yake2/yake/yake/qtogre/qtogre.h 2010-06-15 15:19:48 UTC (rev 2031) @@ -0,0 +1,8 @@ +#ifndef YAKE_QTOGRE_LAUNCH_OPTIONS_H +#define YAKE_QTOGRE_LAUNCH_OPTIONS_H + +#include "prerequisites.h" +#include "launch_options.h" +#include "main_window.h" + +#endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <psy...@us...> - 2010-06-15 15:17:24
|
Revision: 2030 http://yake.svn.sourceforge.net/yake/?rev=2030&view=rev Author: psyclonist Date: 2010-06-15 15:17:17 +0000 (Tue, 15 Jun 2010) Log Message: ----------- removed unnecessary if and asserts Modified Paths: -------------- branches/yake2/yake/src/qt/style.cpp Modified: branches/yake2/yake/src/qt/style.cpp =================================================================== --- branches/yake2/yake/src/qt/style.cpp 2010-04-10 08:46:10 UTC (rev 2029) +++ branches/yake2/yake/src/qt/style.cpp 2010-06-15 15:17:17 UTC (rev 2030) @@ -24,15 +24,12 @@ void applyStyleFileTo(QWidget& w, const std::string& filename) { const std::string style = getFileContents(filename); - assert(!style.empty()); - if (!style.empty()) - w.setStyleSheet(style.c_str()); - } + w.setStyleSheet(style.c_str()); + } void applyStyleFileTo(QApplication& app, const std::string& filename) { const std::string style = getFileContents(filename); - if (!style.empty()) - app.setStyleSheet(style.c_str()); + app.setStyleSheet(style.c_str()); } } // qt } // yake \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <psy...@us...> - 2010-04-10 08:46:16
|
Revision: 2029 http://yake.svn.sourceforge.net/yake/?rev=2029&view=rev Author: psyclonist Date: 2010-04-10 08:46:10 +0000 (Sat, 10 Apr 2010) Log Message: ----------- property: modified flag and added makeFunctorProperty() Modified Paths: -------------- branches/yake2/yake/yake/property/detail/property.impl.h branches/yake2/yake/yake/property/property.h Modified: branches/yake2/yake/yake/property/detail/property.impl.h =================================================================== --- branches/yake2/yake/yake/property/detail/property.impl.h 2010-04-10 08:45:18 UTC (rev 2028) +++ branches/yake2/yake/yake/property/detail/property.impl.h 2010-04-10 08:46:10 UTC (rev 2029) @@ -48,7 +48,8 @@ PropertyBase( const String& type, const std::type_info* typeInfo) : typeName_(type), - typeInfo_(typeInfo) + typeInfo_(typeInfo), + modified_(false) { } virtual ~PropertyBase() @@ -83,10 +84,17 @@ { out << "property<" << typeName_ << ">"; } + + bool modified() const + { + return modified_; + } private: - String typeName_; + String typeName_; //property_def_base& def_; const std::type_info* typeInfo_; + protected: + bool modified_; }; /** */ @@ -105,6 +113,7 @@ void set(const T& v) { acc->set(v); + modified_ = true; } T get() const { @@ -115,6 +124,7 @@ { try { acc->set( boost::any_cast<T>(v) ); + modified_ = true; } catch (boost::bad_any_cast&) { Modified: branches/yake2/yake/yake/property/property.h =================================================================== --- branches/yake2/yake/yake/property/property.h 2010-04-10 08:45:18 UTC (rev 2028) +++ branches/yake2/yake/yake/property/property.h 2010-04-10 08:46:10 UTC (rev 2029) @@ -48,6 +48,11 @@ { return new Property<T>(makeValueHolder<T>(defaultValue)); } + template<typename T, typename Setter, typename Getter> + inline Property<T>* makeFunctorProperty(Setter setter, Getter getter) + { + return new Property<T>(makeFunctionAccessor<T>(setter, getter)); + } } // namespace property } // namespace yake This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <psy...@us...> - 2010-04-10 08:45:24
|
Revision: 2028 http://yake.svn.sourceforge.net/yake/?rev=2028&view=rev Author: psyclonist Date: 2010-04-10 08:45:18 +0000 (Sat, 10 Apr 2010) Log Message: ----------- updated DEPENDENCIES Modified Paths: -------------- branches/yake2/yake/dependencies/DEPENDENCIES Modified: branches/yake2/yake/dependencies/DEPENDENCIES =================================================================== --- branches/yake2/yake/dependencies/DEPENDENCIES 2010-04-10 08:27:20 UTC (rev 2027) +++ branches/yake2/yake/dependencies/DEPENDENCIES 2010-04-10 08:45:18 UTC (rev 2028) @@ -94,6 +94,8 @@ - zip: http://downloads.sourceforge.net/tinyxml/tinyxml_2_5_3.zip?modtime=1178462706&big_mirror=0 - tar.gz: http://downloads.sourceforge.net/tinyxml/tinyxml_2_5_3.tar.gz?modtime=1178462695&big_mirror=0 +qt/ current: Qt 4.5.x (4.6.x should also work fine) + OIS This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <psy...@us...> - 2010-04-10 08:27:26
|
Revision: 2027 http://yake.svn.sourceforge.net/yake/?rev=2027&view=rev Author: psyclonist Date: 2010-04-10 08:27:20 +0000 (Sat, 10 Apr 2010) Log Message: ----------- replaced custom Vector<> with std::vector<> Modified Paths: -------------- branches/yake2/yake/src/plugins/physicsODE/OdeActor.cpp Modified: branches/yake2/yake/src/plugins/physicsODE/OdeActor.cpp =================================================================== --- branches/yake2/yake/src/plugins/physicsODE/OdeActor.cpp 2010-04-10 08:25:13 UTC (rev 2026) +++ branches/yake2/yake/src/plugins/physicsODE/OdeActor.cpp 2010-04-10 08:27:20 UTC (rev 2027) @@ -312,7 +312,7 @@ //----------------------------------------------------- void OdeActor::postStep( const real timeElapsed, const real simTime ) { - Vector< OdeActor* > its; + std::deque< OdeActor* > its; //std::cout << "OdeActor::postStep() @ " << simTime << " cache " << int(mCollisions.size()) << "\n"; for (CollisionCache::iterator it = mCollisions.begin(); it != mCollisions.end(); ++it) { @@ -332,7 +332,7 @@ info.timeSinceCollision_ += timeElapsed; } - VectorIterator< Vector< OdeActor* > > itErase( its.begin(), its.end() ); + VectorIterator< std::deque< OdeActor* > > itErase( its.begin(), its.end() ); while (itErase.hasMoreElements()) { CollisionCache::iterator itFind = mCollisions.find( itErase.getNext() ); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <psy...@us...> - 2010-04-10 08:25:19
|
Revision: 2026 http://yake.svn.sourceforge.net/yake/?rev=2026&view=rev Author: psyclonist Date: 2010-04-10 08:25:13 +0000 (Sat, 10 Apr 2010) Log Message: ----------- cleanup Modified Paths: -------------- branches/yake2/yake/samples/property2/demo.cpp Modified: branches/yake2/yake/samples/property2/demo.cpp =================================================================== --- branches/yake2/yake/samples/property2/demo.cpp 2010-04-10 08:22:47 UTC (rev 2025) +++ branches/yake2/yake/samples/property2/demo.cpp 2010-04-10 08:25:13 UTC (rev 2026) @@ -120,16 +120,18 @@ // Note: The actual name in classes/objects can differ from the default name as it is // possible to add more than one instance of a component to the same class/object. + // Prepare common initialiation parameters for components: + ParamHolder componentParams; + componentParams["graphics::IWorld*"] = gfxWorld.get(); // for "simple_visual" component + // This demo loads the component dynamically from a dll. // A more advanced application may load the dll names from a configuration file. - + // Load the component dll. base::Library simple_visual_component_lib(YAKE_DYNLIB_NAME("c_simple_visual")); // Create an instance of the component, the "simple_visual" component requires a pointer // to the graphics::IWorld instance, so pass it to the creation method. - ParamHolder componentParams; - componentParams["graphics::IWorld*"] = gfxWorld.get(); SharedPtr<component_base> visuals = create<component_base>("simple_visual",componentParams); YAKE_ASSERT(visuals); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <psy...@us...> - 2010-04-10 08:22:53
|
Revision: 2025 http://yake.svn.sourceforge.net/yake/?rev=2025&view=rev Author: psyclonist Date: 2010-04-10 08:22:47 +0000 (Sat, 10 Apr 2010) Log Message: ----------- c_simple_visual: added property "scale" Modified Paths: -------------- branches/yake2/yake/yake/property2_components/c_simple_visual/simple_visual.h Modified: branches/yake2/yake/yake/property2_components/c_simple_visual/simple_visual.h =================================================================== --- branches/yake2/yake/yake/property2_components/c_simple_visual/simple_visual.h 2010-04-10 08:21:25 UTC (rev 2024) +++ branches/yake2/yake/yake/property2_components/c_simple_visual/simple_visual.h 2010-04-10 08:22:47 UTC (rev 2025) @@ -4,6 +4,7 @@ #include <yake/base/yakePrerequisites.h> #include <yake/base/templates/yakePointer.h> #include <yake/property2/component_base.h> +#include <yake/base/math/yakeVector3.h> #ifdef YAKE_C_SIMPLE_VISUAL_EXPORTS # define YAKE_C_SIMPLE_VISUAL_API DLLEXPORT @@ -20,6 +21,7 @@ namespace property { static const propertyid pid_position = propertyid("position"); + static const propertyid pid_scale = propertyid("scale"); static const propertyid pid_mesh_name = propertyid("mesh_name"); static const componentid cid_visual1 = componentid("visual"); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <psy...@us...> - 2010-04-10 08:21:32
|
Revision: 2024 http://yake.svn.sourceforge.net/yake/?rev=2024&view=rev Author: psyclonist Date: 2010-04-10 08:21:25 +0000 (Sat, 10 Apr 2010) Log Message: ----------- premake4.lua: * removed dependency to QtWebKit4 * reactivated libs: input, bindings.lua * added new demo Modified Paths: -------------- branches/yake2/yake/premake4.lua Modified: branches/yake2/yake/premake4.lua =================================================================== --- branches/yake2/yake/premake4.lua 2010-04-10 08:19:59 UTC (rev 2023) +++ branches/yake2/yake/premake4.lua 2010-04-10 08:21:25 UTC (rev 2024) @@ -7,8 +7,14 @@ DEBUG_DLL_SUFFIX = "dll" YAKE_LIBFILE_PREFIX = "yake_" + YAKE_LUA_BINDINGS = true ENABLE_LUA_BASE = true +ENABLE_LUA_PHYSICS = true +ENABLE_LUA_GRAPHICS = true +ENABLE_LUA_GRAPHICS_OGRE = true +ENABLE_LUA_INPUT = true +ENABLE_LUA_RES = true -- local yake_deps = {} @@ -79,10 +85,10 @@ }, libdirs = { DEP_DIR.."qt/lib" }, links = { - ["DebugLib"] = { "QtCored4","QtGuid4","QtWebKitd4","QtOpenGLd4" }, - ["DebugDLL"] = { "QtCored4","QtGuid4","QtWebKitd4","QtOpenGLd4" }, - ["ReleaseLib"] = { "QtCore4","QtGui4","QtWebKit4","QtOpenGL4" }, - ["ReleaseDLL"] = { "QtCore4","QtGui4","QtWebKit4","QtOpenGL4" }, + ["DebugLib"] = { "QtCored4","QtGuid4","QtOpenGLd4" }, + ["DebugDLL"] = { "QtCored4","QtGuid4","QtOpenGLd4" }, + ["ReleaseLib"] = { "QtCore4","QtGui4","QtOpenGL4" }, + ["ReleaseDLL"] = { "QtCore4","QtGui4","QtOpenGL4" }, } } yake_deps["gl"] = { @@ -253,17 +259,17 @@ f:write("#define YAKE_LIBFILE_PREFIX \"" .. YAKE_LIBFILE_PREFIX .. "\"\n") f:write("#define YAKE_LUA_BINDINGS " .. bool_to_int(LUA_BINDINGS) .. "\n") f:write("#define YAKE_ENABLE_LUA_BASE " .. bool_to_int(ENABLE_LUA_BASE) .. "\n") + f:write("#define YAKE_ENABLE_LUA_GRAPHICS " .. bool_to_int(ENABLE_LUA_GRAPHICS) .. "\n") + f:write("#define YAKE_ENABLE_LUA_GRAPHICS_OGRE " .. bool_to_int(ENABLE_LUA_GRAPHICS_OGRE) .. "\n") + f:write("#define YAKE_ENABLE_LUA_PHYSICS " .. bool_to_int(ENABLE_LUA_PHYSICS) .. "\n") + f:write("#define YAKE_ENABLE_LUA_INPUT " .. bool_to_int(ENABLE_LUA_INPUT) .. "\n") + f:write("#define YAKE_ENABLE_LUA_RES " .. bool_to_int(ENABLE_LUA_RES) .. "\n") --[[ f:write("#define YAKE_ENABLE_LUA_MODEL " .. bool_to_int(ENABLE_LUA_MODEL) .. "\n") f:write("#define YAKE_ENABLE_LUA_TASK " .. bool_to_int(ENABLE_LUA_TASK) .. "\n") f:write("#define YAKE_ENABLE_LUA_ENT " .. bool_to_int(ENABLE_LUA_ENT) .. "\n") f:write("#define YAKE_ENABLE_LUA_PROPERTY " .. bool_to_int(ENABLE_LUA_PROPERTY) .. "\n") - f:write("#define YAKE_ENABLE_LUA_GRAPHICS " .. bool_to_int(ENABLE_LUA_GRAPHICS) .. "\n") - f:write("#define YAKE_ENABLE_LUA_GRAPHICS_OGRE " .. bool_to_int(ENABLE_LUA_GRAPHICS_OGRE) .. "\n") - f:write("#define YAKE_ENABLE_LUA_PHYSICS " .. bool_to_int(ENABLE_LUA_PHYSICS) .. "\n") - f:write("#define YAKE_ENABLE_LUA_INPUT " .. bool_to_int(ENABLE_LUA_INPUT) .. "\n") f:write("#define YAKE_ENABLE_LUA_RAF " .. bool_to_int(ENABLE_LUA_RAF) .. "\n") - f:write("#define YAKE_ENABLE_LUA_RES " .. bool_to_int(ENABLE_LUA_RES) .. "\n") f:write("#define YAKE_ENABLE_LUA_UI " .. bool_to_int(ENABLE_LUA_UI) .. "\n") f:write("\n") f:write("#define YAKE_RAF_USES_CEGUI " .. bool_to_int(ENABLE_RAF_CEGUI) .. "\n") @@ -349,6 +355,12 @@ end flags { "Optimize" } + +local function make_project_api_define(name) + local out = "YAKE_" .. name:gsub("%p","_"):upper() .. "_EXPORTS" + --print(out) + return out +end -- kind (solution/project/configuration): ConsoleApp, WindowedApp, SharedLib, StaticLib --[[project "base" location ( ROOT_DIR .. "build/" .. _ACTION ) @@ -381,7 +393,7 @@ configuration "ReleaseDLL" targetname(YAKE_LIBFILE_PREFIX.. name.."_"..mapActionToCompilerName[_ACTION]) - defines { "YAKE_" .. name:upper() .. "_EXPORTS" } + defines { make_project_api_define(name) } require_package_links( "ReleaseDLL", opt.require_package ) if os.is("windows") then links { "winmm" } @@ -390,7 +402,7 @@ configuration "DebugDLL" targetname(YAKE_LIBFILE_PREFIX.. name.."_"..mapActionToCompilerName[_ACTION].."_d") - defines { "YAKE_" .. name:upper() .. "_EXPORTS" } + defines { make_project_api_define(name) } require_package_links( "DebugDLL", opt.require_package ) if os.is("windows") then links { "winmm" } @@ -510,6 +522,10 @@ requires_lib "base" requires_lib "log" +project_lib("input", {require_package = {"boost"}}) + requires_lib "base" + requires_lib "log" + project_lib("audio", {require_package = {"boost"}}) requires_lib "base" requires_lib "log" @@ -527,7 +543,7 @@ requires_lib "log" project_lib("qtogre", {require_package = {"qt","ogre","gl"}}) - --requires_lib "base" + requires_lib "base" -- for YAKE_ASSERT --requires_lib "log" project_lib("object", {require_package = {"boost"}}) @@ -538,6 +554,17 @@ requires_lib "base" requires_lib "log" requires_lib "object" + +project_lib("bindings.lua", {require_package = {"boost","lua","luabind","ogre"}}) + requires_lib "base" + requires_lib "log" + requires_lib "graphics" + requires_lib "physics" + requires_lib "input" + requires_lib "res" + requires_lib "scripting" + requires_plugin "scriptingLua" + requires_plugin "graphicsOgre" -- plugins project_plugin("graphicsOgre", {require_package = {"boost","ogre"}}) @@ -578,8 +605,13 @@ requires_lib "graphics" requires_lib "qtogre" requires_lib "qt" - project_exe "property3" + project_exe("property2_physics", {require_package = {"boost","qt"}}) requires_lib "log" + requires_lib "property2" + requires_lib "graphics" + requires_lib "physics" + requires_lib "qtogre" + requires_lib "qt" end --[[ project "demo1" This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <psy...@us...> - 2010-04-10 08:20:05
|
Revision: 2023 http://yake.svn.sourceforge.net/yake/?rev=2023&view=rev Author: psyclonist Date: 2010-04-10 08:19:59 +0000 (Sat, 10 Apr 2010) Log Message: ----------- always use the double version of ode Modified Paths: -------------- branches/yake2/yake/yake/plugins/physicsODE/yakePCH.h Modified: branches/yake2/yake/yake/plugins/physicsODE/yakePCH.h =================================================================== --- branches/yake2/yake/yake/plugins/physicsODE/yakePCH.h 2010-04-10 08:19:16 UTC (rev 2022) +++ branches/yake2/yake/yake/plugins/physicsODE/yakePCH.h 2010-04-10 08:19:59 UTC (rev 2023) @@ -27,6 +27,10 @@ #ifndef __INC_PCH_H__ #define __INC_PCH_H__ +#ifndef dDOUBLE +#define dDOUBLE +#endif + #include <ode/ode.h> #include <ode/odecpp.h> #include <ode/odecpp_collision.h> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <psy...@us...> - 2010-04-10 08:19:23
|
Revision: 2022 http://yake.svn.sourceforge.net/yake/?rev=2022&view=rev Author: psyclonist Date: 2010-04-10 08:19:16 +0000 (Sat, 10 Apr 2010) Log Message: ----------- fixed include path Modified Paths: -------------- branches/yake2/yake/src/bindings.lua/detail/base.lua.cpp Modified: branches/yake2/yake/src/bindings.lua/detail/base.lua.cpp =================================================================== --- branches/yake2/yake/src/bindings.lua/detail/base.lua.cpp 2010-04-10 08:18:27 UTC (rev 2021) +++ branches/yake2/yake/src/bindings.lua/detail/base.lua.cpp 2010-04-10 08:19:16 UTC (rev 2022) @@ -28,6 +28,7 @@ #if YAKE_ENABLE_LUA_BASE == 1 #include <yake/base/yake.h> +#include <yake/log/log.h> // The order of the following 4 includes is very important! // -> see task.cpp for more information! This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <psy...@us...> - 2010-04-10 08:18:32
|
Revision: 2021 http://yake.svn.sourceforge.net/yake/?rev=2021&view=rev Author: psyclonist Date: 2010-04-10 08:18:27 +0000 (Sat, 10 Apr 2010) Log Message: ----------- base: operator [] means write, not read Modified Paths: -------------- branches/yake2/yake/src/base/yakeParamHolder.cpp Modified: branches/yake2/yake/src/base/yakeParamHolder.cpp =================================================================== --- branches/yake2/yake/src/base/yakeParamHolder.cpp 2010-04-10 08:17:59 UTC (rev 2020) +++ branches/yake2/yake/src/base/yakeParamHolder.cpp 2010-04-10 08:18:27 UTC (rev 2021) @@ -68,7 +68,7 @@ } ParamHolder::Value& ParamHolder::operator [] ( const String & id ) { - return getValue( id ); + return mParams[ id ]; } bool ParamHolder::set( const String & id, const Value& value ) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <psy...@us...> - 2010-04-10 08:18:05
|
Revision: 2020 http://yake.svn.sourceforge.net/yake/?rev=2020&view=rev Author: psyclonist Date: 2010-04-10 08:17:59 +0000 (Sat, 10 Apr 2010) Log Message: ----------- log: could not get luabind 0.9 to ignore the (unaccessible) destructor, so workaround is to make it public. Modified Paths: -------------- branches/yake2/yake/yake/log/log.h Modified: branches/yake2/yake/yake/log/log.h =================================================================== --- branches/yake2/yake/yake/log/log.h 2010-04-10 08:17:05 UTC (rev 2019) +++ branches/yake2/yake/yake/log/log.h 2010-04-10 08:17:59 UTC (rev 2020) @@ -79,10 +79,11 @@ struct YAKE_LOG_API logger : public noncopyable { friend struct detail::logger_impl; - //YAKE_BUILD_PHOENIX_SINGLETON(logger) //public - private: //Make it private if PHOENIX is not used! + private: logger(); + public: // should be private, too, but I had trouble to get Luabind 0.9 to ignore the destructor: ~logger(); + private: static logger instance_; public: static logger& instance(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <psy...@us...> - 2010-04-10 08:17:11
|
Revision: 2019 http://yake.svn.sourceforge.net/yake/?rev=2019&view=rev Author: psyclonist Date: 2010-04-10 08:17:05 +0000 (Sat, 10 Apr 2010) Log Message: ----------- base/input: * replaced custom Vector<> with std::vector<> * fixed include paths Modified Paths: -------------- branches/yake2/yake/yake/base/templates/yakeVector.h branches/yake2/yake/yake/input/yakeActionMap.h branches/yake2/yake/yake/input/yakePCH.h branches/yake2/yake/yake/physics/yakeAffectorZone.h branches/yake2/yake/yake/physics/yakePhysicsBodyGroup.h Modified: branches/yake2/yake/yake/base/templates/yakeVector.h =================================================================== --- branches/yake2/yake/yake/base/templates/yakeVector.h 2010-03-23 19:26:09 UTC (rev 2018) +++ branches/yake2/yake/yake/base/templates/yakeVector.h 2010-04-10 08:17:05 UTC (rev 2019) @@ -35,161 +35,8 @@ #include "../yakePrerequisites.h" #endif -//============================================================================ -// INTERFACE STRUCTURES / UTILITY CLASSES -//============================================================================ namespace yake { -template< class _Value, class _Alloc = std::allocator< _Value > > -class Vector : private std::vector< _Value > -{ -// Types -private: - typedef std::vector< _Value > _MyBase; - -public: - typedef typename _MyBase::value_type value_type; - typedef typename _MyBase::iterator iterator; - typedef typename _MyBase::const_iterator const_iterator; - typedef typename _MyBase::size_type size_type; - typedef typename _MyBase::difference_type difference_type; - typedef typename _MyBase::reverse_iterator reverse_iterator; - typedef typename _MyBase::const_reverse_iterator const_reverse_iterator; - typedef typename _MyBase::pointer pointer; - typedef typename _MyBase::const_pointer const_pointer; - - typedef typename _Alloc::reference reference; - typedef typename _Alloc::const_reference const_reference; - -// Class -public: - explicit Vector( const _Alloc& rAlloc = _Alloc() ) : _MyBase( rAlloc ) {} - -// Methods -public: - // Iterators - iterator begin() - { return _MyBase::begin(); } - - const_iterator begin() const - { return _MyBase::begin(); } - - iterator end() - { return _MyBase::end(); } - - const_iterator end() const - { return _MyBase::end(); } - - reverse_iterator rbegin() - { return _MyBase::rbegin(); } - - const_reverse_iterator rbegin() const - { return _MyBase::rbegin(); } - - reverse_iterator rend() - { return _MyBase::rend(); } - - const_reverse_iterator rend() const - { return _MyBase::rend(); } - - - // Capacity - size_type size() const - { return _MyBase::size(); } - - size_type max_size() - { return _MyBase::max_size(); } - - bool empty() const - { return _MyBase::empty(); } - - void reserve(size_t n) - { - _MyBase::reserve(n); - } - - - // Insert/Delete - void push_back( const _Value& Value ) - { _MyBase::push_back( Value ); } - - void pop_back() - { _MyBase::pop_back(); } - - iterator insert( iterator Where, const _Value& Value ) - { return _MyBase::insert( Where, Value ); } - - void insert( iterator Where, size_type Count, const _Value& Value ) - { _MyBase::insert( Where, Count, Value ); } - - void erase( iterator pos ) - { _MyBase::erase( pos ); } - - void erase(iterator first, iterator last) - { _MyBase::erase(first, last); } - - void clear() - { _MyBase::clear(); } - - void resize( size_type Newsize ) - { _MyBase::resize( Newsize ); } - - void resize( size_type Newsize, _Value Value ) - { _MyBase::resize( Newsize, Value ); } - - - // Assign - Vector& operator=( const Vector& rVector ) - { - Vector( rVector ).swap( *this ); - return *this; - } - - void assign( size_type Count, const _Value& rValue ) - { _MyBase::assign( Count, rValue ); } - - void swap( Vector& rOther ) - { - using std::swap; - _MyBase::swap( rOther ); - } - - - // Elements - reference operator[]( size_type Pos ) - { return _MyBase::operator[]( Pos ); } - - const_reference operator[]( size_type Pos ) const - { return _MyBase::operator[]( Pos ); } - - reference at( size_type Pos ) - { return _MyBase::at( Pos ); } - - const_reference at( size_type Pos ) const - { return _MyBase::at( Pos ); } - - reference front() - { return _MyBase::front(); } - - const_reference front() const - { return _MyBase::front(); } - - reference back() - { return _MyBase::back(); } - - const_reference back() const - { return _MyBase::back(); } - - - // Compare - friend bool operator==( const Vector& lhs, const Vector& rhs ) - { - const _MyBase& me = lhs; - return me == rhs; - } - -}; - /** The VectorIterator and ConstVectorIterator are based on the templates of the same name from OGRE (http://www.ogre3d.org). */ @@ -284,9 +131,9 @@ template< typename T > - Vector< T > split( const T& where, const T& separator ) + std::vector< T > split( const T& where, const T& separator ) { - Vector< T > result; + std::vector< T > result; typename T::size_type oldpos = 0, pos = 0; while( ( pos = where.find( separator, pos ) ) != T::npos ) @@ -303,9 +150,9 @@ } template<class _Value,class _Alloc> inline std::ostream& operator << (std::ostream& out, - const Vector<_Value,_Alloc>& rhs) + const std::vector<_Value,_Alloc>& rhs) { - out << "Vector"; + out << "std::vector"; //out << "<" << typeid(_Value).name() << ">"; out << "[" << int(rhs.size()) << "]"; out << "("; Modified: branches/yake2/yake/yake/input/yakeActionMap.h =================================================================== --- branches/yake2/yake/yake/input/yakeActionMap.h 2010-03-23 19:26:09 UTC (rev 2018) +++ branches/yake2/yake/yake/input/yakeActionMap.h 2010-04-10 08:17:05 UTC (rev 2019) @@ -30,6 +30,7 @@ #ifndef YAKE_INPUT_PREREQUISITES_H #include <yake/input/yakePrerequisites.h> #endif +#include <yake/base/templates/yakeFastMap.h> //#include <boost/tuple/tuple.hpp> @@ -360,7 +361,7 @@ friend struct ConditionConnection; void unreg( const ActionId&, void * ); private: - typedef Vector< ActionId > ActionIdList; + typedef std::deque< ActionId > ActionIdList; typedef std::deque<SharedPtr<ActionCondition> > ConditionList; struct ActionMapEntry { ActionMapEntry() : alive(true) Modified: branches/yake2/yake/yake/input/yakePCH.h =================================================================== --- branches/yake2/yake/yake/input/yakePCH.h 2010-03-23 19:26:09 UTC (rev 2018) +++ branches/yake2/yake/yake/input/yakePCH.h 2010-04-10 08:17:05 UTC (rev 2019) @@ -31,4 +31,4 @@ #include <iostream> // Yake #include <yake/base/yake.h> -#include <yake/base/yakeLog.h> +#include <yake/log/log.h> Modified: branches/yake2/yake/yake/physics/yakeAffectorZone.h =================================================================== --- branches/yake2/yake/yake/physics/yakeAffectorZone.h 2010-03-23 19:26:09 UTC (rev 2018) +++ branches/yake2/yake/yake/physics/yakeAffectorZone.h 2010-04-10 08:17:05 UTC (rev 2019) @@ -103,7 +103,7 @@ class YAKE_PHYSICS_API AffectorZone { protected: - typedef Vector< SharedPtr<IBodyAffector> > AffectorList; + typedef std::deque< SharedPtr<IBodyAffector> > AffectorList; AffectorList mAffectors; BodyGroup mAffectedBodies; @@ -135,7 +135,7 @@ virtual void update( const real timeElapsed ); protected: - typedef Vector< SharedPtr<AffectorZone> > ZoneList; + typedef std::deque< SharedPtr<AffectorZone> > ZoneList; ZoneList mZones; SharedPtr<physics::IWorld> mWorld; SignalConnection mStepSigConn; Modified: branches/yake2/yake/yake/physics/yakePhysicsBodyGroup.h =================================================================== --- branches/yake2/yake/yake/physics/yakePhysicsBodyGroup.h 2010-03-23 19:26:09 UTC (rev 2018) +++ branches/yake2/yake/yake/physics/yakePhysicsBodyGroup.h 2010-04-10 08:17:05 UTC (rev 2019) @@ -30,6 +30,7 @@ #ifndef YAKE_PHYSICS_PREQREQUISITES_H # include <yake/physics/yakePhysicsPrerequisites.h> #endif +#include <yake/base/templates/yakeVector.h> #include "yakePhysicsBody.h" namespace yake { @@ -40,7 +41,7 @@ class YAKE_PHYSICS_API BodyGroup { public: - typedef Vector<IBodyPtr> BodyVector; + typedef std::deque<IBodyPtr> BodyVector; typedef BodyVector::iterator iterator; typedef BodyVector::const_iterator const_iterator; typedef BodyVector::value_type value_type; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <psy...@us...> - 2010-03-23 19:26:28
|
Revision: 2018 http://yake.svn.sourceforge.net/yake/?rev=2018&view=rev Author: psyclonist Date: 2010-03-23 19:26:09 +0000 (Tue, 23 Mar 2010) Log Message: ----------- premake4.lua: * added dependencies: qt, open gl * added several projects Modified Paths: -------------- branches/yake2/yake/premake4.lua Modified: branches/yake2/yake/premake4.lua =================================================================== --- branches/yake2/yake/premake4.lua 2010-03-23 19:24:43 UTC (rev 2017) +++ branches/yake2/yake/premake4.lua 2010-03-23 19:26:09 UTC (rev 2018) @@ -69,6 +69,32 @@ ["ReleaseDLL"] = { "ode_double" }, } } + yake_deps["qt"] = { + includedirs = { + DEP_DIR.."qt/Include", + DEP_DIR.."qt/Include/QtCore", + DEP_DIR.."qt/Include/QtGui", + DEP_DIR.."qt/Include/QtWebKit", + DEP_DIR.."qt/Include/QtOpenGL", + }, + libdirs = { DEP_DIR.."qt/lib" }, + links = { + ["DebugLib"] = { "QtCored4","QtGuid4","QtWebKitd4","QtOpenGLd4" }, + ["DebugDLL"] = { "QtCored4","QtGuid4","QtWebKitd4","QtOpenGLd4" }, + ["ReleaseLib"] = { "QtCore4","QtGui4","QtWebKit4","QtOpenGL4" }, + ["ReleaseDLL"] = { "QtCore4","QtGui4","QtWebKit4","QtOpenGL4" }, + } + } + yake_deps["gl"] = { + include_dirs = {}, + libdirs = {}, + links = { + ["DebugLib"] = { "opengl32" }, + ["DebugDLL"] = { "opengl32" }, + ["ReleaseLib"] = { "opengl32" }, + ["ReleaseDLL"] = { "opengl32" }, + } + } end local function require_package_incs(name) print("require_package_incs",name) @@ -296,19 +322,31 @@ configuration { "DebugDLL" } kind "SharedLib" defines { "_DEBUG" } + if os.is("windows") then + --defines { "NOMINMAX", "WIN32_LEAN_AND_MEAN", "_SECURE_SCL=0", "_HAS_ITERATOR_DEBUGGING=0" } + end flags { "Symbols" } configuration { "ReleaseDLL" } kind "SharedLib" defines { "NDEBUG" } + if os.is("windows") then + --defines { "NOMINMAX", "WIN32_LEAN_AND_MEAN", "_SECURE_SCL=0", "_HAS_ITERATOR_DEBUGGING=0" } + end flags { "Optimize" } -- static targets: configuration { "DebugLib" } kind "SharedLib" defines { "_DEBUG" } + if os.is("windows") then + --defines { "NOMINMAX", "WIN32_LEAN_AND_MEAN", "_SECURE_SCL=0", "_HAS_ITERATOR_DEBUGGING=0" } + end flags { "Symbols" } configuration { "ReleaseLib" } kind "SharedLib" defines { "NDEBUG" } + if os.is("windows") then + --defines { "NOMINMAX", "WIN32_LEAN_AND_MEAN", "_SECURE_SCL=0", "_HAS_ITERATOR_DEBUGGING=0" } + end flags { "Optimize" } -- kind (solution/project/configuration): ConsoleApp, WindowedApp, SharedLib, StaticLib @@ -397,6 +435,21 @@ links { name } end +-- project_component +local function project_component(name,opt) + opt = opt or {} + opt.files = opt.files or { + ROOT_DIR .. "src/property2_components/"..name.."/**.cpp", + ROOT_DIR .. "yake/property2_components/"..name.."/**.h", + ROOT_DIR .. "yake/property2_components/"..name.."/**.inl" + } + project_lib_basic(name,opt) +end +local function requires_component( name ) + includedirs { ROOT_DIR .. "yake/property2_components/" .. name .. "/**" } + links { name } +end + -- project_exe local function project_exe(name,opt) assert(name,"no name specified for project_exe") @@ -469,6 +522,23 @@ requires_lib "base" requires_lib "log" +project_lib("qt", {require_package = {"boost","qt"}}) + requires_lib "base" + requires_lib "log" + +project_lib("qtogre", {require_package = {"qt","ogre","gl"}}) + --requires_lib "base" + --requires_lib "log" + +project_lib("object", {require_package = {"boost"}}) + requires_lib "base" + requires_lib "log" + +project_lib("ent", {require_package = {"boost"}}) + requires_lib "base" + requires_lib "log" + requires_lib "object" + -- plugins project_plugin("graphicsOgre", {require_package = {"boost","ogre"}}) requires_lib "base" @@ -486,6 +556,12 @@ requires_lib "log" requires_lib "physics" +project_component("c_simple_visual", {require_package = {"boost","ogre"}}) + requires_lib "base" + requires_lib "property2" + requires_lib "graphics" + requires_plugin "graphicsOgre" + -- samples --debug: for k,v in pairs(_OPTIONS) do print("OPT",k,v) end @@ -496,9 +572,14 @@ project_exe "property1" requires_lib "base" requires_lib "log" - project_exe "property2" + project_exe("property2", {require_package = {"boost","qt"}}) requires_lib "log" requires_lib "property2" + requires_lib "graphics" + requires_lib "qtogre" + requires_lib "qt" + project_exe "property3" + requires_lib "log" end --[[ project "demo1" This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <psy...@us...> - 2010-03-23 19:25:19
|
Revision: 2017 http://yake.svn.sourceforge.net/yake/?rev=2017&view=rev Author: psyclonist Date: 2010-03-23 19:24:43 +0000 (Tue, 23 Mar 2010) Log Message: ----------- base: fixed YAKE_DYNLIB_NAME define (and removed deprecated define) Modified Paths: -------------- branches/yake2/yake/yake/base/prerequisites/yakePrerequisitesVC.h branches/yake2/yake/yake/base/yakeLibrary.h branches/yake2/yake/yake/base/yakePrerequisites.h Modified: branches/yake2/yake/yake/base/prerequisites/yakePrerequisitesVC.h =================================================================== --- branches/yake2/yake/yake/base/prerequisites/yakePrerequisitesVC.h 2010-03-23 19:22:50 UTC (rev 2016) +++ branches/yake2/yake/yake/base/prerequisites/yakePrerequisitesVC.h 2010-03-23 19:24:43 UTC (rev 2017) @@ -40,6 +40,7 @@ # include <hash_map> # include <xhash> # include "yakePrerequisitesVC71Types.h" +# define YAKE_DYNLIB_TOOLSET_ID "vc71" # elif(YAKE_COMP_VER == 1400) # //pragma message("Yake platform/compiler config: yake.prerequisites.vc80") # include "yakePrerequisitesVC8Warnings.h" @@ -47,6 +48,7 @@ # include <hash_map> # include <xhash> # include "yakePrerequisitesVC8Types.h" +# define YAKE_DYNLIB_TOOLSET_ID "vc80" # elif(YAKE_COMP_VER == 1500) # //pragma message("Yake platform/compiler config: yake.prerequisites.vc90") # include "yakePrerequisitesVC8Warnings.h" @@ -54,6 +56,7 @@ # include <hash_map> # include <xhash> # include "yakePrerequisitesVC8Types.h" +# define YAKE_DYNLIB_TOOLSET_ID "vc90" # else # error("Yake platform/compiler error: no configuration file for this compiler!") # endif Modified: branches/yake2/yake/yake/base/yakeLibrary.h =================================================================== --- branches/yake2/yake/yake/base/yakeLibrary.h 2010-03-23 19:22:50 UTC (rev 2016) +++ branches/yake2/yake/yake/base/yakeLibrary.h 2010-03-23 19:24:43 UTC (rev 2017) @@ -36,14 +36,6 @@ //============================================================================ -// Define YAKE_LIB() to be used by Configuration objects. -#if defined(YAKE_DEBUG) -# define YAKE_LIB_SUFFIX "_d" -#else -# define YAKE_LIB_SUFFIX "" -#endif -#define YAKE_LIB(NAME) String(String("yake_")+NAME+YAKE_LIB_SUFFIX) - namespace yake { namespace base { Modified: branches/yake2/yake/yake/base/yakePrerequisites.h =================================================================== --- branches/yake2/yake/yake/base/yakePrerequisites.h 2010-03-23 19:22:50 UTC (rev 2016) +++ branches/yake2/yake/yake/base/yakePrerequisites.h 2010-03-23 19:24:43 UTC (rev 2017) @@ -141,6 +141,6 @@ # define YAKE_DYNLIB_POSTFIX #endif #define YAKE_DYNLIB_NAME(X) \ - (yake::String("yake_" X YAKE_DYNLIB_POSTFIX) + "." + LIBRARY_EXTENSION).c_str() + (yake::String("yake_" X "_" YAKE_DYNLIB_TOOLSET_ID YAKE_DYNLIB_POSTFIX) + "." + LIBRARY_EXTENSION).c_str() #endif // YAKE_BASE_PREREQUISITES_H This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <psy...@us...> - 2010-03-23 19:23:31
|
Revision: 2016 http://yake.svn.sourceforge.net/yake/?rev=2016&view=rev Author: psyclonist Date: 2010-03-23 19:22:50 +0000 (Tue, 23 Mar 2010) Log Message: ----------- added property2 component: simple_visual Added Paths: ----------- branches/yake2/yake/yake/property2_components/ branches/yake2/yake/yake/property2_components/c_simple_visual/ branches/yake2/yake/yake/property2_components/c_simple_visual/simple_visual.h Added: branches/yake2/yake/yake/property2_components/c_simple_visual/simple_visual.h =================================================================== --- branches/yake2/yake/yake/property2_components/c_simple_visual/simple_visual.h (rev 0) +++ branches/yake2/yake/yake/property2_components/c_simple_visual/simple_visual.h 2010-03-23 19:22:50 UTC (rev 2016) @@ -0,0 +1,61 @@ +#ifndef YAKE_PROPERTY2_COMPONENT_SIMPLE_VISUAL_H +#define YAKE_PROPERTY2_COMPONENT_SIMPLE_VISUAL_H + +#include <yake/base/yakePrerequisites.h> +#include <yake/base/templates/yakePointer.h> +#include <yake/property2/component_base.h> + +#ifdef YAKE_C_SIMPLE_VISUAL_EXPORTS +# define YAKE_C_SIMPLE_VISUAL_API DLLEXPORT +#else +# define YAKE_C_SIMPLE_VISUAL_API DLLIMPORT +#endif + +namespace yake { +namespace graphics { + class ISceneNode; + class IEntity; + class IWorld; +} // graphics +namespace property { + + static const propertyid pid_position = propertyid("position"); + static const propertyid pid_mesh_name = propertyid("mesh_name"); + static const componentid cid_visual1 = componentid("visual"); + + struct YAKE_C_SIMPLE_VISUAL_API component_visual : public component_base + { + YAKE_DECLARE_CONCRETE(component_visual,"simple_visual"); + component_visual(const ParamHolder& params, const std::string& name = "simple_visual"); + private: + /** @todo move into base */ + template<typename T, typename Ctr, typename Kt> + static boost::optional<T> get_any_map_optional(Ctr ctr, Kt key) + { + const typename Ctr::const_iterator it = ctr.find(key); + return (it == ctr.end()) ? boost::optional<T>() : boost::any_cast<T>(it->second); + } + public: + virtual void onAdded(const objectid oid, const componentid cid, const InstantiationParams& params); + virtual bool getPropertyValue(const objectid oid, const componentid& cid, const propertyid pid, value_holder& v) const; + virtual void setPropertyValue(const objectid oid, const componentid& cid, const propertyid pid, const value_holder& v); + virtual void clear(); + private: + graphics::IWorld* gfx_; + /** + @note An entry owns a node, but the entity is actually owned (and destroyed on shutdown!) by the node! + */ + struct entry { + SharedPtr<graphics::ISceneNode> node_; // could be Ogre::SceneNode, or yake::graphics::SceneNode ... + graphics::IEntity* ent_; + boost::optional<std::string> mesh_; + + entry() : ent_(0) + {} + }; + std::map<std::pair<objectid,componentid>,entry> entries_; + }; +} // property +} // yake + +#endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <psy...@us...> - 2010-03-23 19:22:29
|
Revision: 2015 http://yake.svn.sourceforge.net/yake/?rev=2015&view=rev Author: psyclonist Date: 2010-03-23 19:22:21 +0000 (Tue, 23 Mar 2010) Log Message: ----------- demo property2: now loads visual component from a dll Modified Paths: -------------- branches/yake2/yake/samples/property2/demo.cpp Modified: branches/yake2/yake/samples/property2/demo.cpp =================================================================== --- branches/yake2/yake/samples/property2/demo.cpp 2010-03-23 19:20:55 UTC (rev 2014) +++ branches/yake2/yake/samples/property2/demo.cpp 2010-03-23 19:22:21 UTC (rev 2015) @@ -16,7 +16,7 @@ // yake: object/class/property system #include <yake/property2/property.h> -#include <yake/property2_components/simple_visual.h> +#include <yake/property2_components/c_simple_visual/simple_visual.h> // optional: used for ids - could use strings instead. // Qt to setup rendering #include <QApplication> @@ -37,7 +37,7 @@ // create Qt application QApplication app(argc, argv); app.setWindowIcon(QPixmap("icons/bricks.png")); // optional: set your application's icon - const QString appName("storm"); // We re-use the application name in several places. + const QString appName("demo"); // We re-use the application name in several places. // create a dialog to display some text while the application starts: boost::shared_ptr<qt::Dialog> launchingDlg(new qt::Dialog()); @@ -119,11 +119,23 @@ // create a component, with the default name 'visual'. // Note: The actual name in classes/objects can differ from the default name as it is // possible to add more than one instance of a component to the same class/object. - component_visual visuals(*gfxWorld, oSys.oMgr(), "visual"); + // This demo loads the component dynamically from a dll. + // A more advanced application may load the dll names from a configuration file. + + // Load the component dll. + base::Library simple_visual_component_lib(YAKE_DYNLIB_NAME("c_simple_visual")); + + // Create an instance of the component, the "simple_visual" component requires a pointer + // to the graphics::IWorld instance, so pass it to the creation method. + ParamHolder componentParams; + componentParams["graphics::IWorld*"] = gfxWorld.get(); + SharedPtr<component_base> visuals = create<component_base>("simple_visual",componentParams); + YAKE_ASSERT(visuals); + // create a class, representing a visual representation of a box, with an edge length of 1 unit. object_class boxBase = cSys.get(cSys.createEmpty()); - cSys.addComponentTo(boxBase.id(), cid_visual1, visuals); + cSys.addComponentTo(boxBase.id(), cid_visual1, *visuals); boxBase.setPropertyValue(cid_visual1,propertyid("mesh_name"),std::string("box_1x1x1.mesh")); // instantiate the 'box' class @@ -266,7 +278,8 @@ // Cleanup components // Note: In this cases this has to happen before gfxWorld is destructed to avoid // referencing destroyed objects! - visuals.clear(); + visuals->clear(); + visuals.reset(); // Just for clarity - the lifetime of this component instance ends here. } gfxWorld.reset(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <psy...@us...> - 2010-03-23 19:22:14
|
Revision: 2014 http://yake.svn.sourceforge.net/yake/?rev=2014&view=rev Author: psyclonist Date: 2010-03-23 19:20:55 +0000 (Tue, 23 Mar 2010) Log Message: ----------- base: added yakeTimer.cpp Added Paths: ----------- branches/yake2/yake/src/base/yakeTimer.cpp Added: branches/yake2/yake/src/base/yakeTimer.cpp =================================================================== --- branches/yake2/yake/src/base/yakeTimer.cpp (rev 0) +++ branches/yake2/yake/src/base/yakeTimer.cpp 2010-03-23 19:20:55 UTC (rev 2014) @@ -0,0 +1,62 @@ +/* + ------------------------------------------------------------------------------------ + This file is part of YAKE + Copyright (c) 2004 - 2008 The YAKE Team + For the latest information visit http://www.yake.org + ------------------------------------------------------------------------------------ + This program is free software; you can redistribute it and/or modify it under + the terms of the GNU Lesser General Public License as published by the Free Software + Foundation; either version 2 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 Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser 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, or go to + http://www.gnu.org/copyleft/lesser.txt. + ------------------------------------------------------------------------------------ + If you are interested in another license model contact the Yake Team via + E-Mail: te...@ya.... + For more information see the LICENSE file in the root directory of the + source code distribution. + ------------------------------------------------------------------------------------ +*/ + +#include <yake/base/yakePCH.h> +#include <yake/base/yakeTimer.h> +#include <yake/base/native/yakeNative.h> + +namespace yake { + namespace timer + { + class TimerImpl : public Timer + { + public: + TimerImpl() : startTime_(native::getTime()) + { + } + virtual void reset() + { + startTime_ = native::getTime(); + } + virtual uint32 getMilliseconds() + { + return 1000. * (native::getTime() - startTime_); + } + virtual real getSeconds() + { + return native::getTime() - startTime_; + } + private: + real startTime_; + }; + + Timer* createTimer() + { + return new TimerImpl(); + } + } +} // namespace yake This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <psy...@us...> - 2010-03-22 23:01:03
|
Revision: 2013 http://yake.svn.sourceforge.net/yake/?rev=2013&view=rev Author: psyclonist Date: 2010-03-22 23:00:57 +0000 (Mon, 22 Mar 2010) Log Message: ----------- added samples/property2 Added Paths: ----------- branches/yake2/yake/samples/property2/ branches/yake2/yake/samples/property2/demo.cpp Added: branches/yake2/yake/samples/property2/demo.cpp =================================================================== --- branches/yake2/yake/samples/property2/demo.cpp (rev 0) +++ branches/yake2/yake/samples/property2/demo.cpp 2010-03-22 23:00:57 UTC (rev 2013) @@ -0,0 +1,287 @@ +#include <iostream> + +// yake: required to load plugin and use a timer +#include <yake/base/yakeLibrary.h> +#include <yake/base/yakeTimer.h> + +// yake/graphics: for rendering! :) +#include <yake/graphics/yakeGraphics.h> + +// yake/qt: main rendering window +#include <yake/qtogre/main_window.h> + +// yake/qt for this demo: for displaying a styled dialog +#include <yake/qt/dialog.h> +#include <yake/qt/utils.h> + +// yake: object/class/property system +#include <yake/property2/property.h> +#include <yake/property2_components/simple_visual.h> + +// Qt to setup rendering +#include <QApplication> +#include <QPixmapCache> + +// Qt for this sample: for icons, a few widgets etc. +#include <QPixmap> +#include <QIcon> +#include <QDialog> +#include <QVBoxLayout> +#include <QLabel> +#include <QMessageBox> + +int main(int argc, char** argv) +{ + using namespace yake; + + // create Qt application + QApplication app(argc, argv); + app.setWindowIcon(QPixmap("icons/bricks.png")); // optional: set your application's icon + const QString appName("storm"); // We re-use the application name in several places. + + // create a dialog to display some text while the application starts: + boost::shared_ptr<qt::Dialog> launchingDlg(new qt::Dialog()); + launchingDlg->setCaption(appName); + { + // create a layout and add a text + QVBoxLayout* layout = new QVBoxLayout(launchingDlg->content()); + layout->addWidget(new QLabel("Starting...",launchingDlg->content())); + } + launchingDlg->show(); + qt::centerOnPrimaryScreen(launchingDlg.get()); + // To actually display the dialog we let Qt process the outstanding messages: + QCoreApplication::processEvents(); + + // Performance: Setup a pixmap cache, used by widgets to store their rendering + // buffer inorder to avoid redraws even though most of the widgets usually won't + // change. + QPixmapCache::setCacheLimit(1024 * 100); //100MB + + try { + // create main rendering window + qt::MainWindowLaunchOptions launchOptions; //-> see the docs for more options like bit depth, FSAA etc. + launchOptions.windowed = true; + launchOptions.width = 800; + launchOptions.height = 600; + qt::MainOgreWindow& mainWin = qt::MainOgreWindow::instance(0, &launchOptions); + + // load yake's rendering plugin "graphicsOgre": + base::Library graphicsPlugin(YAKE_DYNLIB_NAME("graphicsOgre")); + + // setup initialization data for the graphics system to be created: + graphics::IGraphicsSystem::ParamMap gfxParams; + gfxParams["windowAlreadyCreated"] = "yes"; + gfxParams["renderWindowPtr"] = qt::MainOgreWindow::instance().getOgreRenderWindowAsString().toStdString().c_str(); + gfxParams["shutdownOgre"] = "no"; + + // create the graphics system: + SharedPtr<graphics::IGraphicsSystem> gfxSys = create<graphics::IGraphicsSystem>("ogre3d",gfxParams); + YAKE_ASSERT(gfxSys); + + // create a graphics world, i.e. a container/manager of nodes, entities, lights, meshes, particle systems etc. + SharedPtr<graphics::IWorld> gfxWorld = gfxSys->createWorld(); + YAKE_ASSERT( gfxWorld ); + + // Note: scope to ensure that the lifetime of the SharedPtrs created below is shorter + // than the lifetime of gfxWorld to avoid referencing destroyed objects during + // shutdown. + { + // create a camera and set it up to use a fixed Y-axis for yaw'ing. + SharedPtr<graphics::ICamera> cam(gfxWorld->createCamera()); + cam->setNearClipDistance(.5); + cam->setFarClipDistance(500.); + cam->setFixedYawAxis(Vector3::kUnitY); + cam->setFixedYawEnabled(true); + cam->setPosition(Point3(100,10,100)); + cam->lookAt(Point3(0,0,0)); + + // create & setup a (full-window) viewport for the camera: + SharedPtr<graphics::IViewport> vp(gfxWorld->createViewport(cam.get())); + vp->setBackgroundColor(Color(.2,.2,.3)); + + // light our scene with a simple directional light: + SharedPtr<graphics::ILight> lt(gfxWorld->createLight()); + lt->setType(graphics::ILight::LT_DIRECTIONAL); + lt->setDirection(Vector3(1,1,1)); + lt->setDiffuseColour(Color(1,1,.8)); + lt->setEnabled(true); + + //-- now we setup the object/class/property system. + using namespace property; + + // create a class system, managing classes, their components, properties and inheritance. + class_system cSys( class_system::flags::enable_browser ); + + // create an object system, linked to the class system. it manages + // instantiating objects for classes, property management etc. + object_system oSys(cSys, object_system::flags::enable_browser); + + // create a component, with the default name 'visual'. + // Note: The actual name in classes/objects can differ from the default name as it is + // possible to add more than one instance of a component to the same class/object. + component_visual visuals(*gfxWorld, oSys.oMgr(), "visual"); + + // create a class, representing a visual representation of a box, with an edge length of 1 unit. + object_class boxBase = cSys.get(cSys.createEmpty()); + cSys.addComponentTo(boxBase.id(), cid_visual1, visuals); + boxBase.setPropertyValue(cid_visual1,propertyid("mesh_name"),std::string("box_1x1x1.mesh")); + + // instantiate the 'box' class + object o = oSys.getObject(oSys.instantiateObject(boxBase.id())); + + // override the "visual"'s component's "mesh_name" property to use a different mesh, + // here: a sphere 1 unit in diameter. + o.setPropertyValue(cid_visual1,propertyid("mesh_name"),std::string("sphere_d1.mesh")); //<- crashes! + + // now we create a grid of objects, derived from the box class. + std::set<objectid> ids; + for (size_t x=0; x<10; ++x) + { + for (size_t y=0; y<10; ++y) + { + // create object + object o = oSys.getObject(oSys.instantiateObject(boxBase.id())); + assert( o && "invalid object" ); + ids.insert(o.id()); + + // position object + o.setPropertyValue(cid_visual1,pid_position,Point3(x*1.4,0,y*1.4)); + + // use a different mesh for some of the objects: + if (y % 3) + o.setPropertyValue(cid_visual1,propertyid("mesh_name"),std::string("sphere_d1.mesh")); +#ifdef YAKE_DEBUG + else + { + // assert that the inherited property's value is correct: + value_holder v; + o.getPropertyValue(cid_visual1,propertyid("mesh_name"),v); + assert( boost::any_cast<std::string>(v) == "box_1x1x1.mesh" ); + } +#endif + } + } + + // create a dialog for displaying frame statistics + qt::Dialog* dlg = new qt::Dialog(); + dlg->setWindowTitle("Statistics"); + dlg->move(120,120); + QVBoxLayout* dlgL = new QVBoxLayout(dlg->content()); + QLabel* label = new QLabel("test",dlg->content()); + dlgL->addWidget(label); + mainWin.addWidget(dlg); + + // now that initialization is nearly done, hide the "starting..." dialog. + launchingDlg->hide(); + launchingDlg.reset(); + + // ... and show the main rendering window! + // Note: Actually, it's shown when QCoreApplication::processEvents() is next called, + // but that's fine because then the first frame will be rendered. + mainWin.setWindowed(launchOptions.windowed); + mainWin.setWindowTitle(appName); + mainWin.show(); + + // setup a timer for use in frame-dependent calculations + SharedPtr<Timer> frameTimer(yake::timer::createTimer()); + const real t_start = frameTimer->getSeconds(); + real t0 = t_start; + + // A few variables which we use to switch some object's meshes every + // few seconds (in order to illustrate dynamic properties): + real t_switch = 0.; + int which = 0; + std::vector<std::string> meshes; + meshes.push_back("box_1x1x1.mesh"); + meshes.push_back("sphere_d1.mesh"); + size_t frames = 0; + + // We run the loop as long as the rendering window is visible, i.e. not closed + // by the user, for example: + for (;mainWin.isVisible();++frames) + { + const real t1 = frameTimer->getSeconds(); + if (t1 > 30) // quit after 30 sec + break; + + // Note: dt can be < 0 during core switches - @todo more documentation + real dt = (t1-t0); + if (dt < 0.) + dt = 0.001; + + // update camera to make it rotate around (0,0,0), with a distance of 100 units: + static real distanceFrom0 = 100; + cam->setPosition(Point3(0,10,0) + distanceFrom0 * Vector3(cos(t0*0.1),0,sin(t0*0.1))); + cam->lookAt(Point3(0,0,0)); + +#if 1 + // Switch meshes for some of the objects, every 2 seconds: + t_switch += dt; + const bool do_switch = t_switch >= 2.; + if (do_switch) + { + t_switch = 0.; + // select mesh to switch to: + ++which; + if (which >= meshes.size()) + which = 0; + } + + // update the position of half of the objects. + // also, if do_switch is set to true, switch the mesh used for some of the objects. + + size_t i=ids.size() / 2; + for (std::set<objectid>::const_iterator it = ids.begin(), end = ids.end(); i>0/*it != end*/; ++it, --i) + { + // retrieve object + object o = oSys.getObject(*it); + + // retrieve "position" + value_holder v; + o.getPropertyValue(cid_visual1,pid_position,v); + Point3 pos = boost::any_cast<Point3>(v); + + // update "position" + pos.y = cos((pos.x+t0)*.5) * 3; + o.setPropertyValue(cid_visual1,pid_position,pos); + + // switch mesh? + if (do_switch && (i % 2 == 0)) + o.setPropertyValue(cid_visual1,propertyid("mesh_name"),meshes.at(which)); + } +#endif + // prepare for next frame + t0 = t1; + + // Every 100 frames we display the average amount of time elapsed per frame: + if (frames % 100 == 0) + { + label->setText(QString("%1 sec/f").arg((t0-t_start)/double(frames))); + } + + //@todo gfxWorld->render(dt) triggers a few more events - we need to trigger them, too! + QCoreApplication::processEvents(); + } + + // Cleanup components + // Note: In this cases this has to happen before gfxWorld is destructed to avoid + // referencing destroyed objects! + visuals.clear(); + } + + gfxWorld.reset(); + gfxSys.reset(); + qt::MainOgreWindow::shutdown(); + } + catch (yake::Exception& ex) + { + std::cerr << "EXCEPTION: " << ex.what(); + } + catch (std::exception& ex) + { + std::cerr << "EXCEPTION: " << ex.what(); + } + std::cout << "press ENTER...\n"; + std::cin.get(); + return 0; +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |