29 #include <Inventor/SbRotation.h>
30 #include <Inventor/SbVec3f.h>
31 #include <Inventor/nodes/SoCone.h>
32 #include <Inventor/nodes/SoMaterial.h>
33 #include <Inventor/nodes/SoSeparator.h>
40 Operation(operation.getMemoryXController(), operation.getScene()),
41 objectName(operation.objectName),
42 objectCollection(operation.objectCollection),
43 objectPosition(operation.objectPosition),
44 objectRotation(operation.objectRotation)
53 const std::shared_ptr<memoryxcontroller::MemoryXController>& memoryXController,
54 const std::shared_ptr<scene3D::Scene>& scene,
55 const std::string& objectName,
56 const std::string& objectCollection,
57 const SbVec3f& objectPosition,
58 const SbRotation& objectRotation,
59 const std::string& objectId) :
60 Operation(memoryXController, scene, objectId),
61 objectName(objectName),
62 objectCollection(objectCollection),
63 objectPosition(objectPosition),
64 objectRotation(objectRotation)
69 const std::shared_ptr<memoryxcontroller::MemoryXController>& memoryXController,
70 const std::shared_ptr<scene3D::Scene>& scene,
71 const std::string& objectName,
72 const std::string& objectCollection,
73 const SbVec3f& objectPosition,
74 const SbRotation& objectRotation) :
76 objectName(objectName),
77 objectCollection(objectCollection),
78 objectPosition(objectPosition),
79 objectRotation(objectRotation)
85 const std::shared_ptr<memoryxcontroller::MemoryXController>& memoryXController,
86 const std::shared_ptr<scene3D::Scene>& scene,
87 const std::string& objectName,
88 const std::string& objectCollection) :
90 objectName(objectName),
91 objectCollection(objectCollection),
92 objectPosition(0, 0, 0),
93 objectRotation(SbVec3f(1, 0, 0), 0)
99 controller::AddOperation::createRandomId()
101 static const char chars[] =
"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
102 const int length = 20;
104 std::shared_ptr<scene3D::Scene> scene = getScene();
105 char random[length + 1];
109 for (
int i = 0; i < length; ++i)
111 random[i] = chars[rand() % (
sizeof(chars) - 1)];
115 }
while (scene->getObjectManager()->getObjectById(random));
117 std::string
id = random;
124 std::shared_ptr<controller::Operation> inverseOperation(
132 return inverseOperation;
144 memoryXController->getPriorKnowlegdeController()->getObjectClassPtr(objectName,
149 std::string newObjectId =
150 memoryXController->getWorkingMemoryController()->addObjectInstance(objectName, objectClass);
151 setObjectId(newObjectId);
154 getMemoryXController()->getWorkingMemoryController()->rotateTranslateObject(
155 newObjectId, objectRotation, objectPosition);
161 std::shared_ptr<scene3D::Scene> scene = getScene();
163 getMemoryXController()->getPriorKnowlegdeController();
165 priorKnowledgeController->getObjectClassPtr(objectName, objectCollection);
166 SoNode* geometryNode = priorKnowledgeController->getCoinVisualisation(objectClass,
false);
167 SoNode* collisionNode = priorKnowledgeController->getCoinVisualisation(objectClass,
true);
171 ARMARX_WARNING_S <<
"object \"" << objectName <<
"\" has no collison model";
172 collisionNode =
new SoSeparator;
173 SoMaterial* material =
new SoMaterial;
174 material->ambientColor.setValue(1.0f, 0.0f, 0.0f);
175 material->diffuseColor.setValue(1.0f, 0.0f, 0.0f);
176 SoCone* cone =
new SoCone;
177 cone->bottomRadius.setValue(0.03);
178 cone->height.setValue(0.3);
179 ((SoSeparator*)collisionNode)->addChild(material);
180 ((SoSeparator*)collisionNode)->addChild(cone);
185 ARMARX_WARNING_S <<
"object \"" << objectName <<
"\" has no visualisation model";
186 geometryNode =
new SoSeparator;
187 SoMaterial* material =
new SoMaterial;
188 material->ambientColor.setValue(1.0f, 0.0f, 0.0f);
189 material->diffuseColor.setValue(1.0f, 0.0f, 0.0f);
190 SoCone* cone =
new SoCone;
191 cone->bottomRadius.setValue(0.03);
192 cone->height.setValue(0.3);
193 ((SoSeparator*)geometryNode)->addChild(material);
194 ((SoSeparator*)geometryNode)->addChild(cone);
197 SoSeparator* geometry =
new SoSeparator();
198 geometry->addChild(geometryNode);
199 SoSeparator* collision =
new SoSeparator();
200 collision->addChild(collisionNode);
204 object->setRotation(objectRotation);
205 object->setTranslation(objectPosition);
206 scene->getObjectManager()->addObject(
object);