Skip to content

Commit

Permalink
attachAstroChild working
Browse files Browse the repository at this point in the history
attachAstroChild works at a first try
  • Loading branch information
giogix2 committed Aug 15, 2016
1 parent 48847a1 commit 632ec14
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 12 deletions.
22 changes: 18 additions & 4 deletions PSphere.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -790,14 +790,23 @@ void PSphere::attachAstroChild(PSphere *object)

astroObjectsChild.push_back(object);

Ogre::Entity* entity = object->getEntity();
// Ogre::SceneNode* parent = entity->getParentSceneNode();
// Ogre::SceneNode* nodeObject;
// nodeObject = object->getNode();
// string nodeObjectName = nodeObject->getName();
// string secNodeName = "sec_node_";
// secNodeName = secNodeName+nodeObjectName;
// Ogre::SceneNode *nodeSecondary = this->node->createChildSceneNode(secNodeName);

string secNodeName = "sec_node_";
string nodeObjectName = "node_";
secNodeName = secNodeName + objectMeshName;
nodeObjectName = nodeObjectName + objectMeshName;
Ogre::SceneNode *nodeSecondary = this->node->createChildSceneNode(secNodeName);
// nodeSecondary->addChild(nodeObject);
// nodeSecondary->createChildSceneNode(nodeObjectName);
nodeSecondary->createChildSceneNode(nodeObjectName);
nodeSecondary->attachObject(entity);

nodeSecondary->setPosition(20.0f, 0.0f, -0.0f);
nodeSecondary->setOrientation(0.0f, -0.0f, -0.0f, -0.9144643269f);
}

void PSphere::setNode(Ogre::SceneNode *node)
Expand All @@ -815,6 +824,11 @@ Ogre::SceneNode* PSphere::getNode()
return node;
}

Ogre::Entity* PSphere::getEntity()
{
return entity;
}

bool PSphere::getGridLocation(Ogre::Vector3 location, Grid **face,
unsigned int &ix, unsigned int &iy)
{
Expand Down
2 changes: 2 additions & 0 deletions PSphere.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ class PSphere

Ogre::SceneNode* getNode();

Ogre::Entity* getEntity();

void moveObject(const std::string &objectName, int direction, float pace);

void moveObjectRevolution(const std::string &objectName, int direction, float pace);
Expand Down
16 changes: 8 additions & 8 deletions initOgre.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -197,14 +197,14 @@ void initOgre::setSceneAndRun(PSphere *planet){
// nodeSphere2->setOrientation(0.0f, -0.0f, -0.0f, -0.9144643269f);

// mySphere2->setNode(nodeSphere2);
// mySphere2->setEntity(entity2);

// Ogre::MaterialPtr textureMap2 = Ogre::MaterialManager::getSingleton()
// .create("TextureObject",Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
// textureMap2->getTechnique(0)->getPass(0)->createTextureUnitState("sphereTex2");
// textureMap2->getTechnique(0)->getPass(0)->setSceneBlending(Ogre::SBT_TRANSPARENT_ALPHA);
// // Set texture for the sphere
// entity2->setMaterial(textureMap2);
mySphere2->setEntity(entity2);

Ogre::MaterialPtr textureMap2 = Ogre::MaterialManager::getSingleton()
.create("TextureObject",Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
textureMap2->getTechnique(0)->getPass(0)->createTextureUnitState("sphereTex2");
textureMap2->getTechnique(0)->getPass(0)->setSceneBlending(Ogre::SBT_TRANSPARENT_ALPHA);
// Set texture for the sphere
entity2->setMaterial(textureMap2);

planet->attachAstroChild(mySphere2);
// ########################################################################################
Expand Down

0 comments on commit 632ec14

Please sign in to comment.