本文整理汇总了C++中TransformNode类的典型用法代码示例。如果您正苦于以下问题:C++ TransformNode类的具体用法?C++ TransformNode怎么用?C++ TransformNode使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TransformNode类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Matrix
void Scene::render(Pixel* px, Vertex *eyePoint, double attenuation)
{
//create the zbuffer matrix
int width = px->getWidth();
int height = px->getHeight();
Matrix* zbuffer = new Matrix(height, width); //rows come first
//populate zbuffer with -1
for (int i = 1; i <= height; i++)
{
for (int j = 1; j <= width; j++)
{
zbuffer->setElement(i, j, -1.0);
}
}
//loop over all the Instance instances in the Scene and render them
ListIterator<TransformNode>* ioIter = transformNodes->iterator();
while (ioIter->hasNext())
{
TransformNode* tn = ioIter->next();
tn->render(px, sceneTransform, zbuffer, ambientLight, pointLight, eyePoint, attenuation);
}
delete ioIter;
delete zbuffer;
}
示例2: size
Node *update(Node *old) {
if (old)
return old;
vec2 s = size();
vec2 s3 = s / 3;
// Root has origin in screen center
TransformNode *root = TransformNode::create();
root->setMatrix(mat4::translate2D(s.x * 0.5, s.y * 0.5));
OpacityNode *opacityNode = OpacityNode::create();
// opacityNode->setOpacity(0.5);
root->append(opacityNode);
vec4 color(0.5, 0.5, 0.8, 1.0);
*opacityNode << RectangleNode::create(rect2d::fromPosSize(-s3, s3), color)
<< RectangleNode::create(rect2d::fromPosSize(-s3/2, s3), color)
<< RectangleNode::create(rect2d::fromPosSize(vec2(), s3), color);
AnimationClosure<OpacityNode> *anim = new AnimationClosure<OpacityNode>(opacityNode);
anim->setDuration(3);
anim->setDirection(Animation::Alternate);
anim->setIterations(-1);
anim->keyFrames.times() << 0 << 1;
anim->keyFrames.addValues<double, OpacityNode_setOpacity>() << 0 << 1;
animationManager()->startAnimation(anim);
return root;
}
示例3: Vector3
Vector3 Bone::CalculateNodePositionInSkeletonSpace(
const std::vector<int>& node_locator,
uint& index,
const Transform& parent_transform,
const TransformNode& parent_transform_node
) const
{
if( (uint)node_locator.size() == index )
{
return parent_transform * m_vOffset;
}
int bone_and_node_index = node_locator[index];
const int num_children = (int)m_vecChild.size();
if( num_children <= bone_and_node_index
|| parent_transform_node.GetNumChildren() <= bone_and_node_index )
{
return Vector3(0,0,0);
}
index++;
const TransformNode& child_transform_node = parent_transform_node.GetChildNode(bone_and_node_index);
Transform offset_transform = Transform( Quaternion().FromRotationMatrix(Matrix33Identity()), m_vOffset );
Matrix34 transform;
CalculateWorldTransform( transform, parent_transform.ToMatrix34(), child_transform_node );
return m_vecChild[bone_and_node_index].CalculateNodePositionInSkeletonSpace(
node_locator,
index,
parent_transform * child_transform_node.GetLocalTransform() * offset_transform,
child_transform_node
);
}
示例4: ConstructWall
SceneNode* ConstructWall(PresentationNode* material,PresentationNode* containedMaterial,SceneNode* contained){
SceneNode* wall = new TransformNode;
wall->AddChild(material);
wall->AddChild(containedMaterial);
SceneNode* box = ConstructBox(200,6,25);
TransformNode* t = new TransformNode;
t->AddChild(box);
t->Translate(0,14.6f,12.5f);
material->AddChild(t);
TransformNode* t2 = new TransformNode;
t2->AddChild(box);
t2->Translate(0,-14.6f,12.5f);
material->AddChild(t2);
TransformNode* inner = new TransformNode;
inner->AddChild(ConstructBox(200,26.2,15));
inner->Translate(0,0,7.5f);
material->AddChild(inner);
TransformNode* top = new TransformNode;
top->AddChild(contained);
top->Translate(0,0,20);
containedMaterial->AddChild(top);
return wall;
}
示例5: update
void RotateBehavior::update(SceneNode* node, InputHandler* input, double deltaTime)
{
TransformNode* transformNode = (TransformNode *)node->getParent();
glm::highp_mat4 trans = transformNode->getTransform();
//glm::highp_vec3 translation = glm::highp_vec3(trans[3][0], trans[3][1], trans[3][2]);
glm::highp_vec3 translation = glm::highp_vec3(0, 0, -0.30);
trans = glm::translate(trans, -translation);
trans = glm::rotate(trans, -1., glm::highp_vec3(0, 1, 0));
trans = glm::translate(trans, translation);
transformNode->setNewTransform(trans);
}
示例6:
TransformNode *SceneGraph::findTransformNode(char *name) {
if (!name || strlen(name) <= 0)
return NULL;
for (TransformNode *node = findTransformNode(); node; node = node->nextTraversal()) {
const char *nodeName = node->getName();
if (nodeName && strlen(nodeName)) {
if (!strcmp(name, nodeName))
return node;
}
}
return NULL;
}
示例7: groupSelectedObjects
// Function to process the Group menu command.
void groupSelectedObjects()
{
if (!onlySiblingsSelected()) return;
if (lastSelected == sceneRoot)
{
sceneRoot = new TransformNode(NULL);
sceneRoot->addChild(lastSelected);
lastSelected->setParent(sceneRoot);
}
TransformNode* oldParent = lastSelected->getParent();
oldParent->groupObjects(selections);
}
示例8: while
Scene::~Scene()
{
//clean up all of the basic object heap-allocated memory
ListIterator<TransformNode>* ioIter = transformNodes->iterator();
while (ioIter->hasNext())
{
TransformNode* tn = ioIter->next();
tn->removeRef();
}
delete ioIter;
delete transformNodes;
delete sceneTransform;
}
示例9: noParentAncestorSelections
// Function to verify that no ancestor of the last selected node
// is a member of the selection set.
bool noParentAncestorSelections()
{
TransformNode* current = lastSelected->getParent();
while (current)
{
if (selections.find(current) != selections.end())
{
cerr << "Operation not valid for selection set." << endl;
cerr << "An ancestor of the last selected item is also selected." << endl;
return false;
}
current = current->getParent();
}
return true;
}
示例10: lastSelectedLeft
// Change last selection to previous sibling.
void lastSelectedLeft()
{
TransformNode* parent = lastSelected->getParent();
if (parent)
{
TransformNode* node = parent->previousChild(lastSelected);
if (node)
{
lastSelected->deSelect();
selections.erase(lastSelected);
lastSelected = node;
lastSelected->select();
selections.insert(lastSelected);
}
}
}
示例11: calcOrientation
static void calcOrientation(TransformNode& node, const ofVec3f& orientation)
{
switch(node.getRotationOrder()) {
case TransformNode::ROTATION_ORDER_XYZ:
node.setOrientation(orientation.x,ofVec3f(1,0,0),
orientation.y,ofVec3f(0,1,0),
orientation.z,ofVec3f(0,0,1));
break;
case TransformNode::ROTATION_ORDER_YZX:
node.setOrientation(orientation.y,ofVec3f(0,1,0),
orientation.z,ofVec3f(0,0,1),
orientation.x,ofVec3f(1,0,0));
break;
case TransformNode::ROTATION_ORDER_ZXY:
node.setOrientation(orientation.z,ofVec3f(0,0,1),
orientation.x,ofVec3f(1,0,0),
orientation.y,ofVec3f(0,1,0));
break;
case TransformNode::ROTATION_ORDER_XZY:
node.setOrientation(orientation.x,ofVec3f(1,0,0),
orientation.z,ofVec3f(0,0,1),
orientation.y,ofVec3f(0,1,0));
break;
case TransformNode::ROTATION_ORDER_YXZ:
node.setOrientation(orientation.y,ofVec3f(0,1,0),
orientation.x,ofVec3f(1,0,0),
orientation.z,ofVec3f(0,0,1));
break;
case TransformNode::ROTATION_ORDER_ZYX:
node.setOrientation(orientation.z,ofVec3f(0,0,1),
orientation.y,ofVec3f(0,1,0),
orientation.x,ofVec3f(1,0,0));
break;
}
}
示例12: getTranslationMatrix
void Node::getTranslationMatrix(SFMatrix *mxOut) const
{
mxOut->init();
for (const Node *node=this; node; node=node->getParentNode()) {
if (node->isTransformNode() || node->isBillboardNode()) {
SFMatrix mxNode;
if (node->isTransformNode()) {
float translation[3];
TransformNode *transNode = (TransformNode *)node;
transNode->getTranslation(translation);
mxNode.setTranslation(translation);
}
mxNode.add(mxOut);
mxOut->setValue(&mxNode);
}
}
}
示例13: Color
void Picture::render(Pixel* px)
{
Color *ambient = new Color(1, 1, 1);
Vertex *eye = new Vertex(0,0,0);
Light *light = new Light();
double attenuation = 0;
//while(true)
//{
char* fileName = "sphere.txt";
//cout<<"calling read object"<<endl;
BasicObject* sphere = readObject(fileName);
sphere->computeSandT();
//sphere->printFaces();
//cout<<"called it bitches"<<endl;
//delete[] fileName; //mingw appears to delete this automatically
fileName = "trs.txt";
InstanceObject* sphereInstance = buildInstanceObject(fileName, sphere);
//delete[] fileName;
//obtaining the window transform
int widthPixels = px->getWidth(); //the dimensions of the panel on which the drawing will occur
int heightPixels = px->getHeight();
getShaderInfo(eye, ambient, light, &attenuation);
Scene* scene = new Scene(light, ambient);
scene->buildTransform(getCameraTransform("camera.txt"));
scene->buildTransform(getPerspectiveTransform("fov.txt", widthPixels, heightPixels));
scene->buildTransform(AffineTransforms::window(widthPixels, heightPixels));
TransformNode* tn = new TransformNode();
tn->addChild(sphereInstance);
scene->addTransformNode(tn);
//for(;;)
//{
scene->render(px, eye, attenuation);
//}
delete scene;
//}
}
示例14: CalculateWorldTransform
void Bone::CalculateWorldTransform( Matrix34& dest_transform, const Matrix34& parent_transform, const TransformNode& input_node ) const
{
if( g_htrans_rev == 3 )
{
if( false/*m_TransformStyle & APPLY_LOCAL_ROTATION_TO_OFFSET*/ )
{
const Matrix33 matLocalRot = input_node.GetLocalRotationQuaternion().ToRotationMatrix();
const Vector3 vLocalTrans = input_node.GetLocalTranslation() + m_vOffset;
/* dest_transform.vPosition = parent_transform.matOrient * matLocalRot * vLocalTrans + parent_transform.vPosition;
dest_transform.matOrient = parent_transform.matOrient * matLocalRot;
*/
dest_transform
= parent_transform
* Matrix34( input_node.GetLocalTranslation(), matLocalRot );
// * Matrix34( -m_vOffset, Matrix33Transpose(m_matOrient) );
// * Matrix34( m_vOffset, m_matOrient ).GetInverseROT();
// * Matrix34( Vector3(0,0,0), m_matOrient );
}
else
{
Matrix33 matRotation = input_node.GetLocalRotationQuaternion().ToRotationMatrix() * m_matOrient;
dest_transform
= parent_transform
// * Matrix34( input_node.GetLocalTranslation(), input_node.GetLocalRotationQuaternion().ToRotationMatrix() )
// * Matrix34( m_vOffset, Matrix33Identity() );
/// * Matrix34( input_node.GetLocalTranslation() + m_vOffset, input_node.GetLocalRotationQuaternion().ToRotationMatrix() );
/// * Matrix34( input_node.GetLocalTranslation() + m_vOffset, matRotation );
/// * Matrix34( Vector3(0,0,0), matRotation ) * Matrix34( input_node.GetLocalTranslation() + m_vOffset, Matrix33Identity() );
/// * Matrix34( Vector3(0,0,0), m_matOrient ) * Matrix34( input_node.GetLocalTranslation() + m_vOffset, input_node.GetLocalRotationQuaternion().ToRotationMatrix() );
// * Matrix34( input_node.GetLocalTranslation(), input_node.GetLocalRotationQuaternion().ToRotationMatrix() ) * Matrix34( m_vOffset, m_matOrient );
// * Matrix34( input_node.GetLocalTranslation(), input_node.GetLocalRotationQuaternion().ToRotationMatrix() ) * Matrix34( Vector3(0,0,0), m_matOrient ) * Matrix34( m_vOffset, Matrix33Identity() );
// Transforms for arms are not correctly calculated.
// The root and other nodes are not correctly transformed for run motion.
* Matrix34( m_vOffset, m_matOrient ) * Matrix34( input_node.GetLocalTranslation(), input_node.GetLocalRotationQuaternion().ToRotationMatrix() );
}
}
else // if( sg_rev == 2 )
{
//
}
}
示例15: noAncestorDescendantSelections
// Function to verify that selection set includes no two nodes, one of
// which is an ancestor of the other.
bool noAncestorDescendantSelections()
{
for (set<TransformNode*>::const_iterator iter = selections.begin();
iter != selections.end();
++iter)
{
TransformNode* current = (*iter)->getParent();
while (current)
{
if (selections.find(current) != selections.end())
{
cerr << "Operation not valid for selection set." << endl;
cerr << "An ancestor of a selected item is also selected." << endl;
return false;
}
current = current->getParent();
}
}
return true;
}