Ejemplo n.º 1
0
 static PointObject * create(Vec2 ratio, Vec2 offset)
 {
     PointObject *ret = new (std::nothrow) PointObject();
     ret->initWithPoint(ratio, offset);
     ret->autorelease();
     return ret;
 }
Ejemplo n.º 2
0
 static PointObject * create(const Vec2& ratio, const Vec2& offset, const Vec2& autoscroll)
 {
     PointObject *ret = new PointObject();
     ret->initWithPoint(ratio, offset, autoscroll);
     ret->autorelease();
     return ret;
 }
	static PointObject * create(Point ratio, Point offset)
	{
		PointObject *ret = new PointObject();
		ret->initWithPoint(ratio, offset);
		ret->autorelease();
		return ret;
	}
Ejemplo n.º 4
0
void Voxelify::DoRecursion(BaseObject *op, BaseObject *child, GeDynamicArray<Vector> &points, Matrix ml) {
	BaseObject *tp;
	if (child){
		tp = child->GetDeformCache();
		ml = ml * child->GetMl();
		if (tp){
			DoRecursion(op,tp,points,ml);
		}
		else{
			tp = child->GetCache(NULL);
			if (tp){
				DoRecursion(op,tp,points,ml);
			}
			else{
				if (!child->GetBit(BIT_CONTROLOBJECT)){
					if (child->IsInstanceOf(Opoint)){
						PointObject * pChild = ToPoint(child);
						LONG pcnt = pChild->GetPointCount();
						const Vector *childVerts = pChild->GetPointR();
						for(LONG i=0; i < pcnt; i++){
							points.Push(childVerts[i] * ml * parentMatrix);
						}
					}
				}
			}
		}
		for (tp = child->GetDown(); tp; tp=tp->GetNext()){
			DoRecursion(op,tp,points,ml);
		}
	}
}
Ejemplo n.º 5
0
void ParallaxContainer::addChild(Node *child, int z, const Vec2& ratio, const Vec2& offset, const Vec2& autoScroll)
{
    CCASSERT( child != nullptr, "Argument must be non-nil");
    PointObject *obj = PointObject::create(ratio, offset, autoScroll);
    obj->setChild(child);
    ccArrayAppendObjectWithResize(_parallaxArray, (Ref*)obj);

    Node::addChild(child, z, child->getTag());
}
Ejemplo n.º 6
0
PointObject* TemplateTrack::importWaypoint(const MapCoordF& position, const QString& name)
{
	PointObject* point = new PointObject(map->getUndefinedPoint());
	point->setPosition(position);
	point->setTag(QStringLiteral("name"), name);
	map->addObject(point);
	map->addObjectToSelection(point, false);
	return point;
}
void ParallaxNodeExtras::incrementOffset(Point offset, Node* node){
	for (int i = 0; i < _parallaxArray->num; i++) {
		PointObject *point = (PointObject *)_parallaxArray->arr[i];
		Node * curNode = point->getChild();
		if (curNode==/*->isEqual*/(node)) {
			point->setOffset(point->getOffset() + offset);
			break;
		}
	}
}
Ejemplo n.º 8
0
void ParallaxContainer::removeChild(Node* child, bool cleanup)
{
    for( int i=0;i < _parallaxArray->num;i++) {
        PointObject *point = (PointObject*)_parallaxArray->arr[i];
        if (point->getChild() == child) {
            ccArrayRemoveObjectAtIndex(_parallaxArray, i, true);
            break;
        }
    }
    Node::removeChild(child, cleanup);
}
Ejemplo n.º 9
0
void ParallaxNode::addChild(Node *child, int z, const Vec2& ratio, const Vec2& offset)
{
    CCASSERT( child != nullptr, "Argument must be non-nil");
    PointObject *obj = PointObject::create(ratio, offset);
    obj->setChild(child);
    ccArrayAppendObjectWithResize(_parallaxArray, (Ref*)obj);

    Vec2 pos = this->absolutePosition();
    pos.x = -pos.x + pos.x * ratio.x + offset.x;
    pos.y = -pos.y + pos.y * ratio.y + offset.y;
    child->setPosition(pos);

    Node::addChild(child, z, child->getName());
}
Ejemplo n.º 10
0
void GraphicalRobotElement::updateHFOVRect() {
	QPolygonF poly;

	if (this->currentWIM.has_myposition() ) {
		for (int i = 0; i < currentObsm.view_limit_points_size(); i++) {
			const PointObject p = currentObsm.view_limit_points (i);
			QLineF l = this->parentScene->lineFromFCA (
			               this->currentWIM.myposition().x() * 1000,
			               this->currentWIM.myposition().y() * 1000,
			               this->currentWIM.myposition().phi() + p.bearing(),
			               p.distance() * 1000);
			poly << l.p2();
			HFOVLines->setPolygon (poly);
		}
	} else {
		HFOVLines->setPolygon (QPolygon() );
	}
}
Ejemplo n.º 11
0
/*
The positions are updated at visit because:
- using a timer is not guaranteed that it will called after all the positions were updated
- overriding "draw" will only precise if the children have a z > 0
*/
void ParallaxNode::visit(Renderer *renderer, const Mat4 &parentTransform, uint32_t parentFlags)
{
    //    Vec2 pos = position_;
    //    Vec2    pos = [self convertToWorldSpace:Vec2::ZERO];
    Vec2 pos = this->absolutePosition();
    if( ! pos.equals(_lastPosition) )
    {
        for( int i=0; i < _parallaxArray->num; i++ ) 
        {
            PointObject *point = (PointObject*)_parallaxArray->arr[i];
            float x = -pos.x + pos.x * point->getRatio().x + point->getOffset().x;
            float y = -pos.y + pos.y * point->getRatio().y + point->getOffset().y;            
            point->getChild()->setPosition(x,y);
        }
        _lastPosition = pos;
    }
    Node::visit(renderer, parentTransform, parentFlags);
}
Ejemplo n.º 12
0
void ParallaxContainer::visit(cocos2d::Renderer *renderer, const cocos2d::Mat4& parentTransform, uint32_t parentFlags)
{
    Vec2 pos = parallaxPosition;

    //if (!pos.equals(_lastPosition)) {
        for( int i=0; i < _parallaxArray->num; i++ ) {
            PointObject *point = (PointObject*)_parallaxArray->arr[i];

            // auto scrolling
            auto offset = point->getOffset();
            offset.x += point->getAutoscroll().x;
            offset.y += point->getAutoscroll().y;
            point->setOffset(offset);

            float x = pos.x * point->getRatio().x + point->getOffset().x;
            float y = pos.y * point->getRatio().y + point->getOffset().y;
            point->getChild()->setPosition({x, y});
        }
        _lastPosition = pos;
    //}
    Node::visit(renderer, parentTransform, parentFlags);
}
Ejemplo n.º 13
0
/*===========================================================================*/
void PointObject::deepCopy( const PointObject& other )
{
    BaseClass::deepCopy( other );
    m_sizes = other.sizes().clone();
}
Ejemplo n.º 14
0
/*===========================================================================*/
void PointObject::add( const PointObject& other )
{
    if ( this->coords().size() == 0 )
    {
        // Copy the object.
        BaseClass::setCoords( other.coords() );
        BaseClass::setNormals( other.normals() );
        BaseClass::setColors( other.colors() );
        this->setSizes( other.sizes() );

        BaseClass::setMinMaxObjectCoords(
            other.minObjectCoord(),
            other.maxObjectCoord() );
        BaseClass::setMinMaxExternalCoords(
            other.minExternalCoord(),
            other.maxExternalCoord() );
    }
    else
    {
        if ( !BaseClass::hasMinMaxObjectCoords() )
        {
            BaseClass::updateMinMaxCoords();
        }

        kvs::Vec3 min_object_coord( BaseClass::minObjectCoord() );
        kvs::Vec3 max_object_coord( BaseClass::maxObjectCoord() );

        min_object_coord.x() = kvs::Math::Min( min_object_coord.x(), other.minObjectCoord().x() );
        min_object_coord.y() = kvs::Math::Min( min_object_coord.y(), other.minObjectCoord().y() );
        min_object_coord.z() = kvs::Math::Min( min_object_coord.z(), other.minObjectCoord().z() );

        max_object_coord.x() = kvs::Math::Max( max_object_coord.x(), other.maxObjectCoord().x() );
        max_object_coord.y() = kvs::Math::Max( max_object_coord.y(), other.maxObjectCoord().y() );
        max_object_coord.z() = kvs::Math::Max( max_object_coord.z(), other.maxObjectCoord().z() );

        BaseClass::setMinMaxObjectCoords( min_object_coord, max_object_coord );
        BaseClass::setMinMaxExternalCoords( min_object_coord, max_object_coord );

        // Integrate the coordinate values.
        kvs::ValueArray<kvs::Real32> coords;
        const size_t ncoords = this->coords().size() + other.coords().size();
        coords.allocate( ncoords );
        kvs::Real32* pcoords = coords.data();

        // x,y,z, ... + x,y,z, ... = x,y,z, ... ,x,y,z, ...
        memcpy( pcoords, this->coords().data(), this->coords().byteSize() );
        memcpy( pcoords + this->coords().size(), other.coords().data(), other.coords().byteSize() );
        BaseClass::setCoords( coords );

        // Integrate the normal vectors.
        kvs::ValueArray<kvs::Real32> normals;
        if ( this->normals().size() > 0 )
        {
            if ( other.normals().size() > 0 )
            {
                // nx,ny,nz, ... + nx,ny,nz, ... = nx,ny,nz, ... ,nx,ny,nz, ...
                const size_t nnormals = this->normals().size() + other.normals().size();
                normals.allocate( nnormals );
                kvs::Real32* pnormals = normals.data();
                memcpy( pnormals, this->normals().data(), this->normals().byteSize() );
                memcpy( pnormals + this->normals().size(), other.normals().data(), other.normals().byteSize() );
            }
            else
            {
                // nx,ny,nz, ... + (none) = nx,ny,nz, ... ,0,0,0, ...
                const size_t nnormals = this->normals().size() + other.coords().size();
                normals.allocate( nnormals );
                kvs::Real32* pnormals = normals.data();
                memcpy( pnormals, this->normals().data(), this->normals().byteSize() );
                memset( pnormals + this->normals().size(), 0, other.coords().byteSize() );
            }
        }
        else
        {
            if ( other.normals().size() > 0 )
            {
                const size_t nnormals = this->coords().size() + other.normals().size();
                normals.allocate( nnormals );
                kvs::Real32* pnormals = normals.data();
                // (none) + nx,ny,nz, ... = 0,0,0, ... ,nz,ny,nz, ...
                memset( pnormals, 0, this->coords().byteSize() );
                memcpy( pnormals + this->coords().size(), other.normals().data(), other.normals().byteSize() );
            }
        }
        BaseClass::setNormals( normals );

        // Integrate the color values.
        kvs::ValueArray<kvs::UInt8> colors;
        if ( this->colors().size() > 1 )
        {
            if ( other.colors().size() > 1 )
            {
                // r,g,b, ... + r,g,b, ... = r,g,b, ... ,r,g,b, ...
                const size_t ncolors = this->colors().size() + other.colors().size();
                colors.allocate( ncolors );
                kvs::UInt8* pcolors = colors.data();
                memcpy( pcolors, this->colors().data(), this->colors().byteSize() );
                memcpy( pcolors + this->colors().size(), other.colors().data(), other.colors().byteSize() );
            }
            else
            {
                // r,g,b, ... + R,G,B = r,g,b, ... ,R,G,B, ... ,R,G,B
                const size_t ncolors = this->colors().size() + other.coords().size();
                colors.allocate( ncolors );
                kvs::UInt8* pcolors = colors.data();
                memcpy( pcolors, this->colors().data(), this->colors().byteSize() );
                pcolors += this->colors().size();
                const kvs::RGBColor color = other.color();
                for ( size_t i = 0; i < other.coords().size(); i += 3 )
                {
                    *(pcolors++) = color.r();
                    *(pcolors++) = color.g();
                    *(pcolors++) = color.b();
                }
            }
        }
        else
        {
            if ( other.colors().size() > 1 )
            {
                // R,G,B + r,g,b, ... = R,G,B, ... ,R,G,B, r,g,b, ...
                const size_t ncolors = this->coords().size() + other.colors().size();
                colors.allocate( ncolors );
                kvs::UInt8* pcolors = colors.data();
                const kvs::RGBColor color = this->color();
                for ( size_t i = 0; i < this->coords().size(); i += 3 )
                {
                    *(pcolors++) = color.r();
                    *(pcolors++) = color.g();
                    *(pcolors++) = color.b();
                }
                memcpy( pcolors, other.colors().data(), other.colors().byteSize() );
            }
            else
            {
                const kvs::RGBColor color1 = this->color();
                const kvs::RGBColor color2 = other.color();
                if ( color1 == color2 )
                {
                    // R,G,B + R,G,B = R,G,B
                    const size_t ncolors = 3;
                    colors.allocate( ncolors );
                    kvs::UInt8* pcolors = colors.data();
                    *(pcolors++) = color1.r();
                    *(pcolors++) = color1.g();
                    *(pcolors++) = color1.b();
                }
                else
                {
                    // R,G,B + R,G,B = R,G,B, ... ,R,G,B, ...
                    const size_t ncolors = this->coords().size() + other.coords().size();
                    colors.allocate( ncolors );
                    kvs::UInt8* pcolors = colors.data();
                    for ( size_t i = 0; i < this->coords().size(); i += 3 )
                    {
                        *(pcolors++) = color1.r();
                        *(pcolors++) = color1.g();
                        *(pcolors++) = color1.b();
                    }
                    for ( size_t i = 0; i < other.coords().size(); i += 3 )
                    {
                        *(pcolors++) = color2.r();
                        *(pcolors++) = color2.g();
                        *(pcolors++) = color2.b();
                    }
                }
            }
        }
        BaseClass::setColors( colors );

        // Integrate the size values.
        kvs::ValueArray<kvs::Real32> sizes;
        if ( this->sizes().size() > 1 )
        {
            if ( other.sizes().size() > 1 )
            {
                // s, ... + s, ... = s, ... ,s, ...
                const size_t nsizes = this->sizes().size() + other.sizes().size();
                sizes.allocate( nsizes );
                kvs::Real32* psizes = sizes.data();
                memcpy( psizes, this->sizes().data(), this->sizes().byteSize() );
                memcpy( psizes + this->sizes().size(), other.sizes().data(), other.sizes().byteSize() );
            }
            else
            {
                // s, ... + S = s, ... ,S, ... ,S
                const size_t nsizes = this->sizes().size() + other.coords().size();
                sizes.allocate( nsizes );
                kvs::Real32* psizes = sizes.data();
                memcpy( psizes, this->sizes().data(), this->sizes().byteSize() );
                psizes += this->colors().size();
                const kvs::Real32 size = other.size();
                for ( size_t i = 0; i < other.coords().size(); i++ )
                {
                    *(psizes++) = size;
                }
            }
        }
        else
        {
            if ( other.sizes().size() > 1 )
            {
                // S + s, ... = S, ... ,S, s, ...
                const size_t nsizes = this->coords().size() + other.sizes().size();
                sizes.allocate( nsizes );
                kvs::Real32* psizes = sizes.data();
                const kvs::Real32 size = this->size();
                for ( size_t i = 0; i < this->coords().size(); i++ )
                {
                    *(psizes++) = size;
                }
                memcpy( psizes, other.sizes().data(), other.sizes().byteSize() );
            }
            else
            {
                const kvs::Real32 size1 = this->size();
                const kvs::Real32 size2 = other.size();
                if ( size1 == size2 )
                {
                    // S + S = S
                    const size_t nsizes = 1;
                    sizes.allocate( nsizes );
                    kvs::Real32* psizes = sizes.data();
                    *(psizes++) = size1;
                }
                else
                {
                    // S + S = S, ... , S, ...
                    const size_t nsizes = this->coords().size() + other.coords().size();
                    sizes.allocate( nsizes );
                    kvs::Real32* psizes = sizes.data();
                    for ( size_t i = 0; i < this->coords().size(); i++ )
                    {
                        *(psizes++) = size1;
                    }
                    for ( size_t i = 0; i < other.coords().size(); i++ )
                    {
                        *(psizes++) = size2;
                    }
                }
            }
        }
        this->setSizes( sizes );
    }
}
Ejemplo n.º 15
0
void DeselectAllTool::perform_virtual(Object *o)
{
    PointObject* p = (PointObject*) o;
    p->deselectAllPoints();
}
Ejemplo n.º 16
0
void SelectionTool::perform_virtual(Object *o)
{
    PointObject* pointObject = (PointObject*) o;
    Point* p = pointObject->pointAt(interaction(o).point());

    if (p && interaction().click() == Interaction::DoubleClick) {
        PointEditDialog::exec_static(p,
                                     pointObject->inherits(CLASSNAME(Spline)) && ((Spline*) pointObject)->type() == Spline::Bezier,
                                     parentWidget());
    }

    if (interaction().type() == Interaction::Press) {
        if (p && !p->isSelected()) {
            _justSelectedOrRemoved = true;
        }
        if (interaction().modifiers() != Qt::SHIFT)
            pointObject->deselectAllPoints();
        if (p) {
            pointObject->selectPoint(p);
        }
    } else if (interaction().type() == Interaction::Release) {
        if (interaction().modifiers() != Qt::SHIFT) {
            pointObject->deselectAllPoints();
        }
        if (p && !p->isSelected()) {
            pointObject->selectPoint(p);
        }
        if (p && p->isSelected() && !_justSelectedOrRemoved) {
            pointObject->deselectPoint(p);
        }
        _justSelectedOrRemoved = false;
    } else if (interaction().type() == Interaction::Move) {
        for (Point* point : pointObject->selection()) {
            point->move(interaction(o).point());
        }
        if (!pointObject->selection().isEmpty()) {
            pointObject->emitChanged();
            _justSelectedOrRemoved = true;
        }
    }
}
Ejemplo n.º 17
0
glm::vec3 FragShaderIterCompute(PointObject &p,Triangle &t){
    return p.getAttachVec3("color");
}
Ejemplo n.º 18
0
/*===========================================================================*/
void PointObject::shallowCopy( const PointObject& other )
{
    BaseClass::shallowCopy( other );
    m_sizes = other.sizes();
}
Ejemplo n.º 19
0
MapCoord SnappingToolHelper::snapToObject(MapCoordF position, MapWidget* widget, SnappingToolHelperSnapInfo* info, Object* exclude_object, float snap_distance)
{
	if (snap_distance < 0)
		snap_distance = 0.001f * widget->getMapView()->pixelToLength(Settings::getInstance().getMapEditorSnapDistancePx());
	float closest_distance_sq = snap_distance * snap_distance;
	auto result_position = MapCoord { position };
	SnappingToolHelperSnapInfo result_info;
	result_info.type = NoSnapping;
	result_info.object = NULL;
	result_info.coord_index = -1;
	result_info.path_coord.pos = MapCoordF(0, 0);
	result_info.path_coord.index = -1;
	result_info.path_coord.clen = -1;
	result_info.path_coord.param = -1;
	
	if (filter & (ObjectCorners | ObjectPaths))
	{
		// Find map objects at the given position
		SelectionInfoVector objects;
		map->findAllObjectsAt(position, snap_distance, true, false, false, true, objects);
		
		// Find closest snap spot from map objects
		for (SelectionInfoVector::const_iterator it = objects.begin(), end = objects.end(); it != end; ++it)
		{
			Object* object = it->second;
			if (object == exclude_object)
				continue;
			
			float distance_sq;
			if (object->getType() == Object::Point && filter & ObjectCorners)
			{
				PointObject* point = object->asPoint();
				distance_sq = point->getCoordF().distanceSquaredTo(position);
				if (distance_sq < closest_distance_sq)
				{
					closest_distance_sq = distance_sq;
					result_position = point->getCoord();
					result_info.type = ObjectCorners;
					result_info.object = object;
					result_info.coord_index = 0;
				}
			}
			else if (object->getType() == Object::Path)
			{
				PathObject* path = object->asPath();
				if (filter & ObjectPaths)
				{
					PathCoord path_coord;
					path->calcClosestPointOnPath(position, distance_sq, path_coord);
					if (distance_sq < closest_distance_sq)
					{
						closest_distance_sq = distance_sq;
						result_position = MapCoord(path_coord.pos);
						result_info.object = object;
						if (path_coord.param == 0.0)
						{
							result_info.type = ObjectCorners;
							result_info.coord_index = path_coord.index;
						}
						else
						{
							result_info.type = ObjectPaths;
							result_info.coord_index = -1;
							result_info.path_coord = path_coord;
						}
					}
				}
				else
				{
					MapCoordVector::size_type index;
					path->calcClosestCoordinate(position, distance_sq, index);
					if (distance_sq < closest_distance_sq)
					{
						closest_distance_sq = distance_sq;
						result_position = path->getCoordinate(index);
						result_info.type = ObjectCorners;
						result_info.object = object;
						result_info.coord_index = index;
					}
				}
			}
			else if (object->getType() == Object::Text)
			{
				// No snapping to texts
				continue;
			}
		}
	}
	
	// Find closest grid snap position
	if ((filter & GridCorners) && widget->getMapView()->isGridVisible() &&
		map->getGrid().isSnappingEnabled() && map->getGrid().getDisplayMode() == MapGrid::AllLines)
	{
		MapCoordF closest_grid_point = map->getGrid().getClosestPointOnGrid(position, map);
		float distance_sq = closest_grid_point.distanceSquaredTo(position);
		if (distance_sq < closest_distance_sq)
		{
			closest_distance_sq = distance_sq;
			result_position = MapCoord(closest_grid_point);
			result_info.type = GridCorners;
			result_info.object = NULL;
			result_info.coord_index = -1;
		}
	}
	
	// Return
	if (snap_mark != result_position || snapped_type != result_info.type)
	{
		snap_mark = result_position;
		snapped_type = result_info.type;
		emit displayChanged();
	}
	
	if (info != NULL)
		*info = result_info;
	return result_position;
}