void GameBodyObject::render(float) 
	{
	#if (NX_UNSTABLE_USE_SCENE_ACTIVE_TRANSFORM == 1)

		NxMat34 nm = mActor->getGlobalPose();
		NxVec3 nv(nm.t);
		NxQuat nq(nm.M);
		if (mNode != NULL)
		{
			mNode->setPosition(nv.x, nv.y, nv.z);
			mNode->setOrientation(nq.w,nq.x,nq.y,nq.z);
		}
		shapeRender(0);
	#else
		if ((mActor != NULL) && (mNode != NULL))
		{
			mNode->setPosition(getGlobalPosition());
			mNode->setOrientation(getGlobalOrientation());
			shapeRender(dT);
		}	
	#endif

		// Update the prevGlobalTransform value
		if (mNode != NULL)
		{
			prevGlobalPosition = mNode->_getDerivedPosition();
			prevGlobalOrientation = mNode->_getDerivedOrientation();
		}
	}
Beispiel #2
0
void NoteStaffNode::renderSelf(Renderer& renderer) {
    renderer.setColor(0, 0, 0, 255);
    
    int lastX = windowWidth - STAFF_LINE_HORIZONTAL_PADDING;
    
    int lineY = getGlobalPosition().y;
    
    for (int i = 0; i < 4; ++i) {
        renderer.drawLine(getGlobalPosition().x, lineY, lastX, lineY);
        lineY += NOTE_STAFF_LINE_VERTICAL_PADDING;
    }
    renderer.drawLine(position.x, lineY, lastX, lineY);
    
    lineY = getGlobalPosition().y;
    
    renderer.drawLine(getGlobalPosition().x, lineY, getGlobalPosition().x, lineY + NOTE_STAFF_LINE_VERTICAL_PADDING * 4);
}
FbxAMatrix FbxToHkxConverter::getGlobalPosition(FbxNode* pNode, const FbxTime& pTime, FbxPose* pPose, FbxAMatrix* pParentGlobalPosition)
{
	FbxAMatrix lGlobalPosition;
	bool        lPositionFound = false;

	if (pPose)
	{
		int lNodeIndex = pPose->Find(pNode);

		if (lNodeIndex > -1)
		{
			// The bind pose is always a global matrix.
			// If we have a rest pose, we need to check if it is
			// stored in global or local space.
			if (pPose->IsBindPose() || !pPose->IsLocalMatrix(lNodeIndex))
			{
				lGlobalPosition = GetPoseMatrix(pPose, lNodeIndex);
			}
			else
			{
				// We have a local matrix, we need to convert it to
				// a global space matrix.
				FbxAMatrix lParentGlobalPosition;

				if (pParentGlobalPosition)
				{
					lParentGlobalPosition = *pParentGlobalPosition;
				}
				else
				{
					if (pNode->GetParent())
					{
						lParentGlobalPosition = getGlobalPosition(pNode->GetParent(), pTime, pPose);
					}
				}

				FbxAMatrix lLocalPosition = GetPoseMatrix(pPose, lNodeIndex);
				lGlobalPosition = lParentGlobalPosition * lLocalPosition;
			}

			lPositionFound = true;
		}
	}

	if (!lPositionFound)
	{
		// There is no pose entry for that node, get the current global position instead.

		// Ideally this would use parent global position and local position to compute the global position.
		// Unfortunately the equation 
		//    lGlobalPosition = pParentGlobalPosition * lLocalPosition
		// does not hold when inheritance type is other than "Parent" (RSrs).
		// To compute the parent rotation and scaling is tricky in the RrSs and Rrs cases.
		lGlobalPosition = pNode->EvaluateGlobalTransform(pTime);
	}

	return lGlobalPosition;
}
	void GameBodyObject::restoreCustom(NxOgre::StringPairList spl) 
	{

		mNode = mpScene->getOgreSceneManager()->getRootSceneNode()->createChildSceneNode();

		for (NxOgre::StringPairList::StringPair sp = spl.begin();spl.hasNext();) 
		{
			sp = spl.next();
	/*
			std::stringstream ss;
			ss << sp.first;
			ss << " => ";
			ss << sp.second;
			ss << std::endl;

			NxDebug(ss.str());
	*/
			NxOgre::NxString key = sp.first;
			Ogre::StringUtil::toLowerCase(key);

			if (key == "entity" || key == "node") 
			{

				Ogre::Entity* entity = mpScene->getOgreSceneManager()->createEntity(
					mName + "-" + sp.second + "-" + Ogre::StringConverter::toString(mNode->numAttachedObjects()), 
					sp.second
				);

				mNode->attachObject(entity);

			}

			if (key == "node-scale") 
			{
				mNode->setScale(Ogre::StringConverter::parseVector3(sp.second));
			}

		}

		// Assign first Attached Object that is an entity to mEntity

		Ogre::SceneNode::ObjectIterator object_it = mNode->getAttachedObjectIterator();
		Ogre::MovableObject *m;
		while(object_it.hasMoreElements()) 
		{
			m = object_it.getNext();
			if (m->getMovableType() == "Entity")
			{
				mEntity = (Ogre::Entity*) m;
				break;
			}
		}

		mNode->setPosition(getGlobalPosition());
		mNode->setOrientation(getGlobalOrientation());

	}
Beispiel #5
0
mat4 Transform::getModelMatrix()
{
	mat4 out = translate(glm::mat4(), getGlobalPosition());
	out = rotate(out, getGlobalRotation().x, vec3(1.0f, 0.0f, 0.0f));
	out = rotate(out, getGlobalRotation().y, vec3(0.0f, 1.0f, 0.0f));
	out = rotate(out, getGlobalRotation().z, vec3(0.0f, 0.0f, 1.0f));
	out = scale(out, getGlobalScale());
	return out;
}
Beispiel #6
0
//----------------------------------------
void ofNode::lookAt(const ofVec3f& lookAtPosition){
    auto relPosition = (getGlobalPosition() - lookAtPosition);
    auto radius = relPosition.length();
    if(radius>0){
        auto latitude = ofRadToDeg(acos(relPosition.y / radius)) - 90;
        auto longitude = ofRadToDeg(atan2(relPosition.x , relPosition.z));
        ofQuaternion q(latitude, ofVec3f(1,0,0), longitude, ofVec3f(0,1,0), 0, ofVec3f(0,0,1));
        setGlobalOrientation(q);
    }

}
Beispiel #7
0
//----------------------------------------
void ofNode::rotateAround(const glm::quat& q, const glm::vec3& point) {
	//	ofLogVerbose("ofNode") << "rotateAround(const glm::quat& q, const ofVec3f& point) not implemented yet";
	//	ofMatrix4x4 m = getLocalTransformMatrix();
	//	m.setTranslation(point);
	//	m.rotate(q);
	
	setGlobalPosition(q * (getGlobalPosition() - point) + point);
	
	onOrientationChanged();
	onPositionChanged();
}
Beispiel #8
0
//----------------------------------------
void ofNode::lookAt(const glm::vec3& lookAtPosition){
    auto relPosition = (getGlobalPosition() - lookAtPosition);
	auto radius = glm::length(relPosition);
    if(radius>0){
		float latitude = acos(relPosition.y / radius) - glm::half_pi<float>();
		float longitude = atan2(relPosition.x , relPosition.z);
		glm::quat q = glm::angleAxis(latitude, glm::vec3(1,0,0)) * glm::angleAxis(longitude, glm::vec3(0,1,0)) * glm::angleAxis(0.f, glm::vec3(0,0,1));
        setGlobalOrientation(q);
    }

}
Beispiel #9
0
void ofxFBXCamera::updateLookAt(){
	float  length = (target - getGlobalPosition()).length();

	ofVec3f rotationVector(1.0,0,0);
	ofVec3f center = getGlobalOrientation() * rotationVector;
	center *= length;
	center += getPosition();


	rotationVector.set(0,1.0,0);
    ofVec3f up = getGlobalOrientation() * rotationVector;

    ofVec3f forward = center - getGlobalPosition();
    forward.normalize();
    ofVec3f right = up.cross(forward);
    right.normalize();
    up = forward.cross(right);
    up.normalize();

	lookAt(center,up);
}
Beispiel #10
0
//----------------------------------------
void ofNode::lookAt(const ofVec3f& lookAtPosition, ofVec3f upVector) {
	if(parent) upVector = upVector * ofMatrix4x4::getInverseOf(parent->getGlobalTransformMatrix());
	ofVec3f zaxis = (getGlobalPosition() - lookAtPosition).normalized();
	ofVec3f xaxis = upVector.getCrossed(zaxis).normalized();
	ofVec3f yaxis = zaxis.getCrossed(xaxis);
	
	ofMatrix4x4 m;
	m._mat[0].set(xaxis.x, xaxis.y, xaxis.z, 0);
	m._mat[1].set(yaxis.x, yaxis.y, yaxis.z, 0);
	m._mat[2].set(zaxis.x, zaxis.y, zaxis.z, 0);
	
	setGlobalOrientation(m.getRotate());
}
void BasicInteractiveObject::addMultiTouch(mtRay ray, int touchId){
	MultiTouchPoint* mtp = new MultiTouchPoint();
	
	plane.pos	= getGlobalPosition();
	plane.norm	= ofVec3f(0,0,1)*getGlobalOrientation();
	
	float u		= plane.norm.dot(plane.pos-ray.pos)/plane.norm.dot(ray.dir);
	ofVec3f gintersection = ray.pos+ray.dir*u;
	
	mtp->screenpos.set(ray.screenpos);
	mtp->globalstartpos.set(gintersection);	
	mtp->localstartpos	= globalToLocal(mtp->globalstartpos);
	mtp->localpos		= mtp->localstartpos;
	mtp->localoffset	= mtp->localstartpos-getPosition();
	mtp->globalpos		= mtp->globalstartpos;
	mtp->globalmovedist	= 0;
	mtp->starttime		= ofGetElapsedTimeMillis();	
	
	activeMultiTouches[touchId] = mtp;
	mtcounter++;
    
    
    // Flipped order (was before)
    
	if(activeMultiTouches.size() == 1){
		// Start of Scope
		mtstarttime		= ofGetElapsedTimeMillis();
		mtscoperunning	= true;
		MultiTouchEvent params(this, mtp);
		ofNotifyEvent(firstTouchDownEvent,params,this);
	}
	
    
	if(activeMultiTouches.size()>=2){
		MultiTouchEvent params(this);
		ofNotifyEvent(startMultiTouchScopeEvent,params,this);
	}
    
    // Flipped order (was after)
    
    mttranslatedist	= 0;
	mtrotatedist	= 0;
	mtscaledist		= 0;
	
	mttranslatespeed.set(0,0,0);
	mtrotatespeed.set(0,0,0,1);
	mtscalespeed=0;
	
    resetMTStartValues();
}
FbxAMatrix	LoaderFbxMesh::parseTransformMatrixAssociateModel(FbxCluster* cluster, FbxMesh* mesh, FbxPose* fbxPose, FbxAMatrix globalPosition)
{
	FbxAMatrix associateGeometry;
	FbxAMatrix associateGlobalInitPosition;
	FbxAMatrix associateGlobalCurrentPosition;

	FbxAMatrix referenceGeometry;
	FbxAMatrix referenceGlobalInitPosition;
	FbxAMatrix referenceGlobalCurrentPosition;

	FbxAMatrix clusterGeometry;
	FbxAMatrix clusterGlobalInitPosition;
	FbxAMatrix clusterGlobalCurrentPosition;

	FbxTime time(0);

	cluster->GetTransformAssociateModelMatrix(associateGlobalInitPosition);
	associateGeometry = getGeometry(cluster->GetAssociateModel());
	associateGlobalInitPosition *= associateGeometry;
	associateGlobalCurrentPosition = getGlobalPosition(cluster->GetAssociateModel(), time, fbxPose, nullptr);

	cluster->GetTransformMatrix(referenceGlobalInitPosition);
	referenceGeometry = getGeometry(mesh->GetNode());
	referenceGlobalInitPosition *= referenceGeometry;
	referenceGlobalCurrentPosition = globalPosition;

	cluster->GetTransformLinkMatrix(clusterGlobalInitPosition);
	clusterGeometry = getGeometry(cluster->GetLink());
	clusterGlobalInitPosition *= clusterGeometry;
	clusterGlobalCurrentPosition = getGlobalPosition(cluster->GetLink(), time, fbxPose, nullptr);

	FbxAMatrix offsetMatrix;
	offsetMatrix = referenceGlobalInitPosition.Inverse() * associateGlobalInitPosition * associateGlobalCurrentPosition.Inverse() *
			clusterGlobalCurrentPosition * clusterGlobalInitPosition.Inverse() * referenceGlobalInitPosition;

	return offsetMatrix;
}
Beispiel #13
0
void StickyNoteActor::onRender(uint flags)
{
	if (!isActorType(Invisible))
	{
		if (_stickyNoteTextureId == 0)
			syncStickyNoteWithFileContents();
		
		setTextureID("icon.custom.stickyNote");
		Actor::onRender(flags);
#ifdef DXRENDER
		dxr->device->SetRenderState(D3DRS_ZENABLE, false);
		dxr->renderSideLessBox(getGlobalPosition(), getGlobalOrientation(), getDims(), _stickyNoteTextureId);
		dxr->device->SetRenderState(D3DRS_ZENABLE, true);
#endif
	}
}
Beispiel #14
0
//----------------------------------------
void ofNode::clearParent(bool bMaintainGlobalTransform) {
	if(parent){
		parent->removeListener(*this);
	}
	if(bMaintainGlobalTransform && parent) {
		auto orientation = getGlobalOrientation();
		auto position = getGlobalPosition();
		auto scale = getGlobalScale();
		this->parent = nullptr;
		setOrientation(orientation);
		setPosition(position);
		setScale(scale);
	}else{
		this->parent = nullptr;
	}

}
Beispiel #15
0
void patch::resetSize(int _width, int _height) {

    width = _width;
    height = _height;
    
    int offSet;
    if (title != NULL)
        offSet = 15;
    textureCorners[0].set(0.0, offSet);
    textureCorners[1].set(width, offSet);
    textureCorners[2].set(width, height + offSet);
    textureCorners[3].set(0.0, height + offSet);
    
    move( ofPoint(x,y) );
    scale(0.5);
    setPosition(getGlobalPosition()*((ofCamera*)getParent())->getScale());
}
Beispiel #16
0
//----------------------------------------
void ofNode::lookAt(const glm::vec3& lookAtPosition, glm::vec3 upVector) {
	if(parent){
		auto upVector4 = glm::inverse(parent->getGlobalTransformMatrix()) * glm::vec4(upVector, 1.0);
		upVector = upVector4.xyz() / upVector4.w;
	}
	auto zaxis = glm::normalize(getGlobalPosition() - lookAtPosition);
	if (glm::length(zaxis) > 0) {
		auto xaxis = glm::normalize(glm::cross(upVector, zaxis));
		auto yaxis = glm::cross(zaxis, xaxis);
		glm::mat4 m;
		m[0] = glm::vec4(xaxis, 0.f);
		m[1] = glm::vec4(yaxis, 0.f);
		m[2] = glm::vec4(zaxis, 0.f);

		setGlobalOrientation(glm::toQuat(m));
	}
}
void PoseEstimationTaskContext::updateOutputs()
{
  getState(state_);
  state_output_.write(state_);

  if (imu_output_.connected()) {
    imu_out_.header = state_.header;
    imu_out_.orientation = state_.pose.pose.orientation;
    getImuWithBiases(imu_out_.linear_acceleration, imu_out_.angular_velocity);
    imu_output_.write(imu_out_);
  }

  if (pose_output_.connected()) {
    pose_.header = state_.header;
    pose_.pose = state_.pose.pose;
    pose_output_.write(pose_);
  }

  if (velocity_output_.connected()) {
    velocity_.header = state_.header;
    velocity_.vector = state_.twist.twist.linear;
    velocity_output_.write(velocity_);
  }

  if (global_position_output_.connected()) {
    global_position_.header = state_.header;
    getGlobalPosition(global_position_.latitude, global_position_.longitude, global_position_.altitude);
    global_position_.latitude *= 180.0/M_PI;
    global_position_.longitude *= 180.0/M_PI;
    if (getSystemStatus() & STATE_XY_POSITION) {
      global_position_.status.status = sensor_msgs::NavSatStatus::STATUS_FIX;
    } else {
      global_position_.status.status = sensor_msgs::NavSatStatus::STATUS_NO_FIX;
    }
    global_position_output_.write(global_position_);
  }

  if (angular_velocity_bias_output_.connected() || linear_acceleration_bias_output_.connected()) {
    getHeader(angular_velocity_bias_.header);
    getHeader(linear_acceleration_bias_.header);
    getBias(angular_velocity_bias_, linear_acceleration_bias_);
    angular_velocity_bias_output_.write(angular_velocity_bias_);
    linear_acceleration_bias_output_.write(linear_acceleration_bias_);
  }
}
Beispiel #18
0
//----------------------------------------
void ofEasyCam::updateRotation(){
	if (bApplyInertia) {
		xRot *=drag; 
		yRot *=drag;
		zRot *=drag;
		
		if (ABS(xRot) <= minDifference && ABS(yRot) <= minDifference && ABS(zRot) <= minDifference) {
			bApplyInertia = false;
			bDoRotate = false;
		}
		curRot = ofQuaternion(xRot, getXAxis(), yRot, getYAxis(), zRot, getZAxis());
		setPosition((getGlobalPosition()-target.getGlobalPosition())*curRot +target.getGlobalPosition());
		rotate(curRot);
	}else{
		curRot = ofQuaternion(xRot, prevAxisX, yRot, prevAxisY, zRot, prevAxisZ);
		setPosition((prevPosition-target.getGlobalPosition())*curRot +target.getGlobalPosition());
		setOrientation(prevOrientation * curRot);
	}
}
void		LoaderFbxMesh::parseTransformMatrix(FbxCluster* cluster, FbxMesh* mesh, FbxPose* fbxPose, LoaderFbxMeshDesc* meshDesc, int index)
{
	FbxCluster::ELinkMode clusterMode = cluster->GetLinkMode();

	FbxAMatrix globalPosition = getGlobalPosition(mesh->GetNode(), FbxTime(0), fbxPose, &globalPosition);
	globalPosition *= getGeometry(mesh->GetNode());

	FbxAMatrix fbxMatrix;
//	if(clusterMode == FbxCluster::eAdditive && cluster->GetAssociateModel())
//		fbxMatrix = parseTransformMatrixAssociateModel(cluster, mesh, fbxPose, globalPosition);
//	else
//		fbxMatrix = parseTransformMatrixOther(cluster, mesh, fbxPose, globalPosition);

	fbxMatrix = parseTransformMatrix_debug(cluster, mesh, fbxPose, globalPosition);

//	fbxMatrix = convertToLeftHanded(fbxMatrix);

	Float4x4 offsetMatrix = translateMatrixToFloat4x4(fbxMatrix);

	meshDesc->setOffsetMatrix(index, offsetMatrix);
}
void BasicInteractiveObject::updateMultiTouch(mtRay ray, int touchId){
	if(isMultiTouchActive(touchId)){
	
		plane.pos	= getGlobalPosition();
		plane.norm	= ofVec3f(0,0,1)*getGlobalOrientation();
		
		float u		= plane.norm.dot(plane.pos-ray.pos)/plane.norm.dot(ray.dir);
		ofVec3f gintersection = ray.pos+ray.dir*u;
		
		MultiTouchPoint* mtp = activeMultiTouches[touchId];

		mtp->screenpos.set(ray.screenpos);
		mtp->globalposbef.set(mtp->globalpos);
		mtp->globalpos.set(gintersection);
		mtp->globalspeed.set(mtp->globalpos-mtp->globalposbef);
		mtp->localposbef.set(mtp->localpos);
		mtp->localpos.set(globalToLocal(mtp->globalpos));
		mtp->localspeeddamped.set((mtp->localspeed + (mtp->localpos-mtp->localposbef))/2);
		mtp->localspeed.set(mtp->localpos-mtp->localposbef);		
		mtp->globalmovedist += mtp->globalspeed.length();
	}
}
Beispiel #21
0
//----------------------------------------
void ofEasyCam::updateRotation(){
	if(bApplyInertia){
		xRot *=drag; 
		yRot *=drag;
		zRot *=drag;

		if(ABS(xRot) <= minDifference && ABS(yRot) <= minDifference && ABS(zRot) <= minDifference){
			xRot = 0;
			yRot = 0;
			zRot = 0;
			bApplyInertia = false;
			bDoRotate = false;
		}
		curRot = glm::angleAxis(zRot, getZAxis()) * glm::angleAxis(yRot, up()) * glm::angleAxis(xRot, getXAxis());
		setPosition(curRot * (getGlobalPosition()-target.getGlobalPosition()) + target.getGlobalPosition());
		rotate(curRot);
	}else if(bDoRotate){
		curRot = glm::angleAxis(zRot, prevAxisZ) * glm::angleAxis(yRot, up()) * glm::angleAxis(xRot, prevAxisX);
		setPosition(curRot * (prevPosition-target.getGlobalPosition()) + target.getGlobalPosition());
		setOrientation(curRot * prevOrientation);
	}
}
Beispiel #22
0
void CSkeleton::drawSkeleton(void)
{
	for(size_t i = 0; i < joints.size(); i++)
		if(isRoot(i))
			updateGlobalPostures(i);
	size_t n = joints.size();
	Quaterniond rot, a;
	Vector3d pos;
	for(size_t i = 1; i < n; i++)
	{
		rot = getGlobalRotation( i );
		pos = getGlobalPosition( i );
		a = rot.Log();

		glPushMatrix();
		glTranslated(pos.X(), pos.Y(), pos.Z());
		glRotated(a.W()*180/M_PI, a.X(), a.Y(), a.Z());
		glColor3ub(255, 255, 0);
		glBegin(GL_LINES);
		glVertex3f(0, 0, 0);
		glVertex3f(0, 0, joints[i].getScale().Z());
		glEnd();

		glBegin(GL_LINES);
		glColor3ub(255, 0, 0);
		glVertex3f(0, 0, 0);
		glVertex3f(0.1, 0, 0);

		glColor3ub(0, 255, 0);
		glVertex3f(0, 0, 0);
		glVertex3f(0, 0.1, 0);

		glColor3ub(0, 0, 255);
		glVertex3f(0, 0, 0);
		glVertex3f(0, 0, 0.1);
		glEnd();
		glPopMatrix();
	}
}
Beispiel #23
0
void uiNode::mouseUp(float x,float y){
    ofRectangle globalBoundingBox = boundingBox;
    ofVec2f globalPosition = getGlobalPosition();
    
    globalBoundingBox.x += globalPosition.x;
    globalBoundingBox.y += globalPosition.y;
    
    if(globalBoundingBox.inside(x, y)){
        cout << "BANG!" << name << std::endl;
        ofNotifyEvent(clickedInside, name, this);

    }
    
    if(childrenEnabled){
        for(uiNode* child : children){
            child->mouseUp(x, y);
        }
    }

    
    
    
}
FbxAMatrix	LoaderFbxMesh::getGlobalPosition(FbxNode* node, FbxTime time, FbxPose* pose, FbxAMatrix* parentGlobalPosition)
{
	FbxAMatrix globalPosition;

	bool positionFound = false;

	if(pose)
	{
		int nodeIndex = pose->Find(node);
		if(nodeIndex > -1)
		{
			if(pose->IsBindPose() || !pose->IsLocalMatrix(nodeIndex))
				globalPosition = getPoseMatrix(pose, nodeIndex);
			else
			{
				FbxAMatrix localParentGlobalPosition;
				if(parentGlobalPosition)
					localParentGlobalPosition = *parentGlobalPosition;
				else
				{
					if(node->GetParent())
						localParentGlobalPosition = getGlobalPosition(node->GetParent(), time, pose, nullptr);
				}

				FbxAMatrix localPosition = getPoseMatrix(pose, nodeIndex);
				globalPosition = localParentGlobalPosition * localPosition;
			}
			positionFound = true;
		}
	}

	if(!positionFound)
		globalPosition = node->EvaluateGlobalTransform(time);

	return globalPosition;
}
Beispiel #25
0
bool FileSystemActor::serializeToPb(PbBumpObject * pbObject)
{
	assert(pbObject);

	// NOTE: if this actor is pileized, then sync the position of this actor to the pile
	if (isPileized())
	{
		BumpObject * lastPileItem = pileizedPile->getLastItem();
		assert(lastPileItem);
		if (lastPileItem)
		{
			Vec3 pos = lastPileItem->getGlobalPosition();
			pos.y = getGlobalPosition().z;
			setGlobalPosition(pos);
		}
	}

	// serialize the core actor properties
	if (!Actor::serializeToPb(pbObject))
		return false;

	// write the full path
	pbObject->SetExtension(PbFileSystemActor::full_path, stdString(getFullPath()));
	
	// write the launch override path
	pbObject->SetExtension(PbFileSystemActor::launch_override_path, stdString(getLaunchOverride()));

	// write the texture override path
	QString overrideTexturePath;
	getTextureOverride(overrideTexturePath);
	pbObject->SetExtension(PbFileSystemActor::texture_override_path, stdString(overrideTexturePath));

	// write the pilelized state
	bool pileized = (pileizedPile != NULL);
	pbObject->SetExtension(PbFileSystemActor::pileized, pileized);

	// write the thumbnail state
	pbObject->SetExtension(PbFileSystemActor::thumbnailized, useThumbnail);

	// write the launch count
	pbObject->SetExtension(PbFileSystemActor::launch_count, useThumbnail);

	// NOTE: if the actor was pileized, then push it back underground
	if (isPileized())
		PushBelowGround(this);

	// write all the cached previous children sizes if this filesystem actor was pileized
	if (isFileSystemType(Folder))
	{
		QHashIterator<QString, Vec3> iter(_prevPileizedActorDims);
		while (iter.hasNext()) 
		{
			iter.next();
			PbFileSystemActor_PbCachedFilePathDims * dims = pbObject->AddExtension(PbFileSystemActor::prev_pileized_children_dims);
			dims->set_file_path(stdString(iter.key()));
			toPbVec3(iter.value(), dims->mutable_dims());
		}
	}

	return pbObject->IsInitialized();
}
Beispiel #26
0
FileSystemPile *FileSystemActor::pileize()
{
	StrList dirListing;
	QString dirPath;
	vector<Actor *> objListing;
	FileSystemActor *obj = NULL;
	FileSystemPile *p = NULL;

	// Don't allow Piles to be created recursively
	if (isParentType(BumpPile))
	{
		MessageClearPolicy clearPolicy;
			clearPolicy.setTimeout(4);
		scnManager->messages()->addMessage(new Message("pileize_recPiles", QT_TR_NOOP("Sorry, Items within Piles cannot be viewed as Piles at this time.\nThis feature will be implemented in a later version of BumpTop"), Message::Ok, clearPolicy));
		return NULL;
	}

	// If this item has been pileized, then just return its pile
	if (pileizedPile)
	{
		return pileizedPile;
	}

	if (isFileSystemType(Folder))
	{
		// Get a Directory listing of this folder
		dirPath = getTargetPath();
		dirListing = fsManager->getDirectoryContents(dirPath);

		// Check if this Folder has anything in it
		if (dirListing.empty())
		{
			MessageClearPolicy clearPolicy;
				clearPolicy.setTimeout(4);
			scnManager->messages()->addMessage(new Message("pileize_emptyFolder", QT_TR_NOOP("This folder is empty, so it can't be expanded to a pile"), Message::Ok, clearPolicy));
			return NULL;
		}

		// Create a new Pile
		p = new FileSystemPile();
		if (p)
		{
			for (uint i = 0; i < dirListing.size(); i++)
			{
				obj =  FileSystemActorFactory::createFileSystemActor(dirListing[i]);

				// Create new Actors that represent each item in that directory
				// NOTE: we need to set the initial size of the object, since we try and sync the post it
				//		 in the setFilePath call, which means that it will try and fill to the dims of the
				//		 object, which, in it's default size, is not visible text-wise.
				if (_prevPileizedActorDims.contains(dirListing[i].toLower()))
					obj->setDims(Vec3(_prevPileizedActorDims.value(dirListing[i].toLower())));
				else
					obj->setDims(getDims());
				obj->setGlobalPose(getGlobalPose());
				obj->setFilePath(dirListing[i]);

				objListing.push_back(obj);
			}

			// Add items to this Pile
			for (uint i = 0; i < objListing.size(); i++)
			{
				p->addToPile(objListing[i]);
			}

			// Save and setup initial states
			p->setOwner(this);
			p->setText(getFullText());
			p->stack(getGlobalPosition());
			
			// set the icon to be this actor's 
			if (isFileSystemType(Folder))
				p->setTextIcon(getTextureID());

			// Create custom Animations
			for (uint i = 0; i < objListing.size(); i++)
			{
				objListing[i]->setAlphaAnim(0.0f, 1.0f, 15);
			}

			// Make this actor Non-existent
			this->hideAndDisable();

			// Finish up by setting the pile as the current selection
			pileizedPile = p;
			sel->remove((BumpObject *) this);
			sel->add((Pile *) p);

			textManager->invalidate();

			// record this pilization
			statsManager->getStats().bt.interaction.piles.pilized++;
			return p;
		}		
	}

	return NULL;
}
Beispiel #27
0
bool Body::advance(float step, const NxOgre::Enums::Priority&, const NxOgre::Enums::SceneFunction&)
{
    mNode->setPosition( getGlobalPosition().as<Ogre::Vector3>() );
    mNode->setOrientation( getGlobalOrientationQuat().as<Ogre::Quaternion>() );
    return true;
}
Beispiel #28
0
void FileSystemActor::onLaunch()
{
	assert(!filePath.isNull());

	if (!_onLaunchHandler.empty())
		_onLaunchHandler(this);

	// override for widgets
	Widget * w = widgetManager->getActiveWidgetForFile(getFullPath());
	if (w && w->isWidgetOverrideActor(this))
	{
		w->launchWidgetOverride(this);
		return;
	}
	
	// Do a quick pass to determine what needs to be created or not
	bool isWatchingHighlighted = cam->isWatchedActorHighlighted(this);
	bool zoomIntoImage = isFileSystemType(Image) && !isWatchingHighlighted && texMgr->isTextureState(thumbnailID, TextureLoaded);
	bool launchImage = (isFileSystemType(Image) && isWatchingHighlighted) && !texMgr->isTextureState(thumbnailID, TextureLoaded);
	bool createTemporaryActor = !zoomIntoImage && !launchImage;
	bool createRandomAnimPath = createTemporaryActor;

	Actor * obj = NULL;
	if (createTemporaryActor)
	{
		obj = new Actor();
		Vec3 startPosition;

		// Set up the state of the Actor
		obj->pushActorType(Temporary);
		obj->setDims(getDims());
		obj->setGravity(false);
		obj->setCollisions(false);
		obj->setAlphaAnim(getAlpha(), 0.2f, 40);
		obj->setGlobalPose(getGlobalPose());
		obj->setObjectToMimic(this);
	}

	// Special case for launching a pileized actor
	Vec3 startPosition;
	if (isPileized())
	{
		startPosition = pileizedPile->getGlobalPosition();
	}else{
		startPosition = getGlobalPosition();
	}

	// create random animation path from the icon up to the camera eye
	if (createRandomAnimPath)
	{
		// Set an animation that moves the icon into the camera
 		CreateRandomAnimPath(obj, startPosition, cam->getEye(), 40);

		// Delete the object after the random animation is over.
		animManager->removeAnimation(obj);
		animManager->addAnimation(AnimationEntry(obj, (FinishedCallBack) DeleteActorAfterAnim));
	}

	// handle the launch override if there is one
	if (!getLaunchOverride().isEmpty())
	{
		fsManager->launchFileAsync(getLaunchOverride());
		return;
	}

	// Execute this Icon
	if (!isFileSystemType(Virtual))
	{
		// If this is a folder, then try and browse to it
		if (scnManager->isShellExtension && isFileSystemType(Folder))
		{			
			// try and send a custom message to the proxy window to move to the child
			incrementNumTimesLaunched();
			animManager->finishAnimation(this);
			SaveSceneToFile();
			winOS->ShellExtBrowseToChild(filePath);
			return;
		}
		// This is an image, so zoom to it if we are not already watching it
		else if (zoomIntoImage && isFileSystemType(Image) && texMgr->isTextureState(thumbnailID, TextureLoaded))
		{
			Key_EnableSlideShow();
			this->putToSleep();

			// record this zoom interaction
			statsManager->getStats().bt.interaction.actors.highlightedImage++;
			return;
		}

		// Execute it as normal
		// QString lnkTarget, lnkArgs, lnkWorkingDir;
		bool fileLaunched = false;
		/*
		if (isFileSystemType(Link))
		{
			fsManager->getShortcutTarget(getFullPath(), &lnkTarget, &lnkArgs, &lnkWorkingDir);
			fileLaunched = fsManager->launchFileAsync(lnkTarget, lnkArgs, lnkWorkingDir);
		}
		else
		*/
		fileLaunched = fsManager->launchFileAsync(filePath);

		if (fileLaunched)
		{
			// otherwise, just increment this file launch count and execute it
			// it is decided that images do not auto-grow (was a design decision)
			if (!launchImage)
			{
				incrementNumTimesLaunched();
			}

			// record this launch
			statsManager->getStats().bt.interaction.actors.launchedFile++;
		}
	}
	else
	{
		incrementNumTimesLaunched();
		fsManager->launchFile(filePath);
	}
}
void ramNode::drawNodeName(int floatPos) const
{
	ofVec3f pos = getGlobalPosition();
	pos.y += floatPos;
	ofDrawBitmapString(ofToString(getName()), pos);
}
Beispiel #30
0
void Sprite::draw()
{

	if (!_visible)
	{
		return;
	}




	//fix bug of transform of difference window size

	Vec2 windowSize = Director::getInstance()->getWindowSize();

	auto originalSize = _texture2d->getRect();
	Vec2 localAnchorPoint(originalSize.x*_anchor.x, originalSize.y*_anchor.y);

	Vec2 vertexes[4] = { -localAnchorPoint, { originalSize.x - localAnchorPoint.x, -localAnchorPoint.y }, originalSize - localAnchorPoint, { -localAnchorPoint.x, originalSize.y - localAnchorPoint.y } };

	auto globalPosition = getGlobalPosition();

	auto globalScale = getGlobalScale();
	auto globalRotation = getGlobalRotation();
	  Vec2 _glScale{ 2 / windowSize.x, 2 / windowSize.y };
	// init for rotating
	auto sin = Math::sin(globalRotation);
	auto cos = Math::cos(globalRotation);
	for (auto &vertex : vertexes)
	{
		// local transform
		// rotate
		{
			auto tempX = vertex.x;
			vertex.x = tempX*cos - vertex.y*sin;
			vertex.y = tempX*sin + vertex.y*cos;
		}
		vertex.x *= globalScale.x; vertex.y *= globalScale.y; // scale

		// global transform
		vertex.x += globalPosition.x;
		vertex.y += globalPosition.y;

		// gl transform
		vertex.x *= _glScale.x;
		vertex.y *= _glScale.y;
		vertex.x -= 1;
		vertex.y -= 1;


	}

	// draw

	float *_coord2f = _texture2d->getCoord2fPoints();

	int _index_1 = 0;
	int _index_2 = 1;
	int _index_3 = 2;
	int _index_4 = 3;

	if (_is_flipx)
	{
		_index_1 = 2; _index_3 = 0;
	}
	if (_is_flipy)
	{
		_index_2 = 3;	_index_4 = 1;
	}
	if (!cmd)
	{

	cmd = new RenderCmd_Quad;
	}
	cmd->_vertex[0] = vertexes[_index_1];
	cmd->_vertex[1] = vertexes[_index_2];
	cmd->_vertex[2] = vertexes[_index_3];
	cmd->_vertex[3] = vertexes[_index_4];

	cmd->_coord2f = _coord2f;
	cmd->tex = _texture2d;
	cmd->_opacity = _opactiy;

	Director::getInstance()->getRenderCmdQueue()->addRenderCmd(cmd);
	/*
	there are two methods to slove flip
	*/


	/*


	//method one

	int _index_1 = 0;
	int _index_2 = 1;
	int _index_3 = 2;
	int _index_4 = 3;

	if (_is_flipx)
	{
	_index_1 = 2; _index_3 = 0;
	}
	if (_is_flipy)
	{
	_index_2 = 3;	_index_4 = 1;
	}


	glTexCoord2f(_coord2f[0], _coord2f[1]); glVertex2f(vertexes[_index_1].x, vertexes[_index_1].y);
	glTexCoord2f(_coord2f[2], _coord2f[3]); glVertex2f(vertexes[_index_2].x, vertexes[_index_2].y);
	glTexCoord2f(_coord2f[4], _coord2f[5]); glVertex2f(vertexes[_index_3].x, vertexes[_index_3].y);
	glTexCoord2f(_coord2f[6], _coord2f[7]); glVertex2f(vertexes[_index_4].x, vertexes[_index_4].y);



	// method two
	if (_is_flipx == false && _is_flipy == false)
	{
	glTexCoord2f(_coord2f[0], _coord2f[1]); glVertex2f(vertexes[0].x, vertexes[0].y);
	glTexCoord2f(_coord2f[2], _coord2f[3]); glVertex2f(vertexes[1].x, vertexes[1].y);
	glTexCoord2f(_coord2f[4], _coord2f[5]); glVertex2f(vertexes[2].x, vertexes[2].y);
	glTexCoord2f(_coord2f[6], _coord2f[7]); glVertex2f(vertexes[3].x, vertexes[3].y);
	}
	else if (_is_flipx == true && _is_flipy == false)
	{
	glTexCoord2f(_coord2f[0], _coord2f[1]); glVertex2f(vertexes[1].x, vertexes[1].y);
	glTexCoord2f(_coord2f[2], _coord2f[3]); glVertex2f(vertexes[0].x, vertexes[0].y);
	glTexCoord2f(_coord2f[4], _coord2f[5]); glVertex2f(vertexes[3].x, vertexes[3].y);
	glTexCoord2f(_coord2f[6], _coord2f[7]); glVertex2f(vertexes[2].x, vertexes[2].y);
	}
	else if (_is_flipx == false && _is_flipy == true)
	{
	glTexCoord2f(_coord2f[0], _coord2f[1]); glVertex2f(vertexes[3].x, vertexes[3].y);
	glTexCoord2f(_coord2f[2], _coord2f[3]); glVertex2f(vertexes[2].x, vertexes[2].y);
	glTexCoord2f(_coord2f[4], _coord2f[5]); glVertex2f(vertexes[1].x, vertexes[1].y);
	glTexCoord2f(_coord2f[6], _coord2f[7]); glVertex2f(vertexes[0].x, vertexes[0].y);
	}
	else if (_is_flipx == true && _is_flipy == true)
	{
	glTexCoord2f(_coord2f[0], _coord2f[1]); glVertex2f(vertexes[2].x, vertexes[2].y);
	glTexCoord2f(_coord2f[2], _coord2f[3]); glVertex2f(vertexes[3].x, vertexes[3].y);
	glTexCoord2f(_coord2f[4], _coord2f[5]); glVertex2f(vertexes[0].x, vertexes[0].y);
	glTexCoord2f(_coord2f[6], _coord2f[7]); glVertex2f(vertexes[1].x, vertexes[1].y);
	}



	*/



	Node::draw();

}