convertToWorldSpace - cocos2d - cocos2d-iphone

convertToWorldSpace
Hi, I'm not sure I understand how this works.
The api states that it converts local coordinate to world space.
Let' say I have three sprites. spriteA added to scene , and spriteB added to spriteA. And spriteC added to spriteB.
- Scene
- spriteA
- spriteB
- spriteC
And I want to convert spriteC origin to world
If I do: [self convertToWorldSpace:[spriteC CGPointZero]];
or this: [spriteA convertToWorldSpace:[spriteC CGPointZero]];
or this: [spriteB convertToWorldSpace:[spriteC CGPointZero]];
or even [spriteC convertToWorldSpace:[spriteC CGPointZero]];
Shouldn't they all give the same answer since they are all transformed to world coordinates? Or do I go from one node space to parent node space ...until I get to world space.
what is the correct answer to see spriteC position in world coordinates?

To find the world space origin on spriteC, you take the sprites parent, in this case spriteB and ask for the world space of its child:
[spriteB convertToWorldSpace:[spriteC CGPointZero]];

[spriteC convertToWorldSpace:CGPointZero];
As Kazuki answer but CGPointZero is a global.

[spriteC convertToWorldSpace:[spriteC CGPointZero]];
convertToWorldSpace: method converts one node space to parent node space ... until it gets to world space.

Related

Can I use vtkCellLocator to find intersected cells by line

I have mesh grid and there is a line passing through several cells. I want to get all the cells which are intersected by line.
I have start and end points of line and I have mesh vertexes coordinates.
What is the fastest way to compute this condition, is there any way, I could use vtk class ?
You can check the vtk class vtkOBBTree, and the method IntersectWithLine. This is python, but you get the idea of how it works here
from vedo import dataurl, Mesh, Line, show
m = Mesh(dataurl+'bunny.obj')
l = Line([-0.15,0.1,0], [0.1,0.1,0], c='k', lw=3)
pts_cellids = m.intersectWithLine(l, returnIds=True)
print(pts_cellids)
show(m, l, axes=1)
You should get cells ids: [3245 1364]

How can I put white spaces in Title of QGroundControl?

Is there a way that I put the white spaces in the QGroundControl? I am new to this and not sure much about QML or qmake.
I want to change title from “QGroundControl” to “Q Ground Control”.
I tried to do the change in the “qgroundcontrol.pro” at the below line, but this didn’t worked as I was expecting.
FROM: DEFINES += QGC_APPLICATION_NAME=\"\\\"QGroundControl\\\"\"
TO: DEFINES += QGC_APPLICATION_NAME=\"\\\"Q Ground Control\\\"\"
The RESULT is: Q -DGround -DControl
Required Result: Q Ground Control
OK, I think I have a solution for you:
QGC = '\\"Q Ground Control\\"'
DEFINES += QGC_APPLICATION_NAME=\"$${QGC}\"
Try it and let us know how it goes.
Fixed my issue by using the correct escape sequence:
DEFINES += QGC_APPLICATION_NAME='"\\\"Custom QGroundControl\\\""'

Adding sprite to CCParallaxNode while character moves?

Using the [CCParallaxNode node] class in cocos2d, I know how to add sprites to the parallax. But I was adding them BEFORE the character started moving with offset set to 0:
[parallaxBack addChild:ground1 z:1 parallaxRatio:CloseElementsSpeed positionOffset:L4];
[parallaxBack addChild:ground2 z:1 parallaxRatio:CloseElementsSpeed positionOffset:L5];
Now, I am trying to add a new sprite after the character has already started to move. I probably don't add the character to the right position.
How can I add a new sprite with an offset to the current position of the parallax? (I have tried to subtract its current position - it didn't work.)
//new sprite after a while - I can't see the character.
[parallaxBack addChild:man z:1 parallaxRatio:CloseElementsSpeed positionOffset:L4];

Raphael how to access element in Another drawing area or canvas

I have two drawing areas like paper = raphael(...) and paper1= raphael(...). How to access elements of canvas in another...I have a path in paper1 and i want to access its attributes from paper. Any suggestions?
Create an element that contains both papers and access them from there...there will be no magic between the 2 different papers... or add each paper in the other, so you can do this:
var myCurrentPaper = myElementInPaperOne.paper;
var myOtherPaper = myCurrentPaper.paperTwoReference;

D3 refresh axes labels

I have a graph that I show two sets of data in it. The user can hit a button to flip to another set of data. The problem is the axes aren't the same, but when I want to update the ticks I instead just layer on top another axis.
http://jsfiddle.net/scottieb/VjHd6/
The key bit is at the end:
vis.selectAll("axis").remove();
vis.append("svg:g")
.attr("class", "x axis")
.attr("transform", "translate(0, " + (h - margin ) + ")")
.call(d3.svg.axis()
.scale(x)
.tickSize(0)
.tickSubdivide(true)
.tickFormat(formatCurrency)
);
I've tried selectAll("g").remove(), but that prevents laying down the next axis. Any ideas?
Whoops, needed to redefine the scale and call a transition rather than just build a whole new axis.
http://jsfiddle.net/scottieb/JwaaV/
Your issue is that your selector is not correct. Instead of selecting "axis", you should select ".axis" since you are appending a "g" node with a class.