Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit 27e61d6c authored by Inge Wallin's avatar Inge Wallin

First traces of Material.

This is NOT connected anywhere yet.
parent 238f5090
......@@ -89,7 +89,7 @@ Overall goal: To make Step a better teaching tool
For details, see the list above.
* Add missing object types
+ half plane (ground) taken: rahulch
+ half plane (ground) [rahulch]
+ rope(?)
* Add missing physics concepts
+ coefficient of restitution
......@@ -98,3 +98,10 @@ For details, see the list above.
+ Add timeline
+ Improve selection, moving and resizing of objects.
+
* New concepts
+ Add materials [ingwa]
* Step file format version 2.0
+ refactor
- Item::Color --> Material
+ Materials
......@@ -45,7 +45,7 @@ Legend
[time, timeScale, bodies, forces, joints, solvers...]
* Body{body.h} Anything that has dynamic variables that
require ODE integration
[material, =0] require ODE integration
* Particle
* ChargedParticle
* GasParticle
......@@ -94,6 +94,8 @@ Auxiliary classes
Used by ConstraintSolver
[...]
* Material stores material properties
* Factory Creates new objects from name
* MetaProperty Meta information about a property
......
......@@ -2,6 +2,8 @@
set(stepcore_SRCS
constants.cc
material.cc
# Base objects
object.cc
item.cc
......
......@@ -28,6 +28,7 @@
#include <vector> // XXX: Replace if Qt is enabled.
#include "types.h"
#include "material.h"
#include "item.h"
......@@ -35,6 +36,7 @@ namespace StepCore
{
class Material;
/** \ingroup bodies
* \brief Interface for bodies
*
......@@ -47,10 +49,17 @@ class Body : public Item
public:
Body(const QString& name = QString())
: Item(name)
, _material(&GenericMaterial)
, _variablesOffset(0)
{}
virtual ~Body() {}
/** Get the material of the body. */
Material *material() const { return _material; }
/** Set material of the body (FIXME: Must be enhanced with META_PROPERTY later) */
void setMaterial(Material *mtrl) { _material = mtrl; }
/** Get count of dynamic variables (not including velocities) */
virtual int variablesCount() = 0;
......@@ -91,6 +100,8 @@ public:
private:
friend class World;
Material *_material;
/** \internal Set offset of body's variables in global arrays */
void setVariablesOffset(int variablesOffset)
{
......
......@@ -49,8 +49,11 @@ class Item : public Object
public:
/** Constructs Item */
Item(const QString& name = QString())
: Object(name), _world(NULL), _group(NULL),
_objectErrors(NULL), _color(0xff000000) {}
: Object(name)
, _world(NULL)
, _group(NULL)
, _objectErrors(NULL)
, _color(0xff000000) {}
/** Constructs a copy of item */
Item(const Item& item) : Object() { *this = item; }
/** Destroys Item */
......
/* This file is part of StepCore library.
Copyright (C) 2007 Vladimir Kuznetsov <ks.vladimir@gmail.com>
Copyright (C) 2014 Inge Wallin <inge@lysator.liu.se>
StepCore library is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
StepCore library 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 General Public License for more details.
You should have received a copy of the GNU General Public License
along with StepCore; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "material.h"
namespace StepCore
{
//STEPCORE_META_OBJECT(Body, QT_TRANSLATE_NOOP("ObjectClass", "Body"), QT_TR_NOOP("Body"),
// MetaObject::ABSTRACT,,)
Material& Material::operator=(const Material& mtrl)
{
_name = mtrl._name;
_color = mtrl._color;
_density = mtrl._density;
return *this;
}
Material GenericMaterial("Bloontonium");
} // namespace StepCore
/* This file is part of StepCore library.
Copyright (C) 2014 Inge Wallin <inge@lysator.liu.se>
StepCore library is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
StepCore library 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 General Public License for more details.
You should have received a copy of the GNU General Public License
along with StepCore; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
/** \file material.h
* \brief Material is what an object is made from. It has a color, density and some other physical properties.
*/
#ifndef STEPCORE_MATERIAL_H
#define STEPCORE_MATERIAL_H
#include <vector> // XXX: Replace if Qt is enabled.
#include <QString>
#include "types.h"
namespace StepCore
{
/** \ingroup materials
* \brief Interface for bodies
*
* Material is anything that has dynamic variables that require ODE integration
*/
class Material
{
//STEPCORE_OBJECT(Material)
public:
Material(const QString& name = QString())
: _name(name)
, _color(0xff000000)
, _density(1.0)
{}
virtual ~Material() {}
Material &operator=(const Material &mtrl);
/** Get the name of the material. */
QString name() const { return _name; }
/** Set the name of the material. */
void setName(const QString &name) { _name = name; }
/** Get the color of the material. */
Color color() const { return _color; }
/** Set the color of the material. */
void setColor(const Color &color) { _color = color; }
/** Get the density of the material. */
double density() const { return _density; }
/** Set the density of the material. */
void setDensity(const double density) { _density = density; }
private:
QString _name;
Color _color;
double _density;
// ...more here? Charge? other stuff?
};
/** List of pointers to Material */
typedef std::vector<Material*> MaterialList;
extern Material GenericMaterial;
} // namespace StepCore
#endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment