Godot: how to send texture through RPC call? - rpc

I have the following code
var texture = ImageTexture.new()
texture=_viewport.get_texture()
now I want to send the texture value to other player ,so i can use it there as a texture for TextureRect node , as the following
rpc("set_texture",texture)
but it's not working !
if using rpc not possible please enlighten me .

Related

ArcGIS - How to move a graphic or symbol on the map

I'm trying to create an overlay in ArcGIS that has moving graphics/symbols which are updated by coordinates received from roving devices. I'm able to display a simple symbol initially but cannot get it to move on the map. My test code is
GraphicsOverlay machineOverlay = new GraphicsOverlay();
MainMapView.GraphicsOverlays.Add(machineOverlay);
MapPointBuilder rdLocation = new MapPointBuilder(150.864119200149, -32.3478640837185, SpatialReferences.Wgs84);
SimpleMarkerSymbol sRD1234 = new SimpleMarkerSymbol()
{
Color = System.Drawing.Color.Red,
Size = 10,
Style = SimpleMarkerSymbolStyle.Circle
};
Graphic graphicWithSymbol = new Graphic(rdLocation.ToGeometry(), sRD1234);
machineOverlay.Graphics.Add(graphicWithSymbol);
// here the red circle is displayed correctly on the map
rdLocation.SetXY(150.887115, -32.357600);
rdLocation.ReplaceGeometry(rdLocation.ToGeometry());
// here I expect the red circle to move but it doesn't
Do I need to trigger an event to "re-render" or refresh the overlay, or what do I need to do to get the graphic to move on my map?
There was a similar question here and the answer was "just update the geometry" which is what I'm attempting to do, but with no success.
If there is an entirely different or better approach to moving markers on a map please suggest, I'm just getting started in the ArcGIS runtime.
Thanks
After a lot of searching I replaced one line of code and its now working
//rdLocation.ReplaceGeometry(rdLocation.ToGeometry());
graphicWithSymbol.Geometry = rdLocation.ToGeometry();
It seems I misunderstood the function of ReplaceGeometry(). Any clarification on this would be helpful.

Want to make Node Red on Raspberry Pi detected Data from Arduino and React to it but unsure how to do so?

I recently made a sensor that can correctly display the distances on the Serial Monitor on the Arduino, it would continuously display the distance as I would move my hand up/down the sensor. Thing is though, I intended on connecting this to a Pi (mine being Pi 3B+), use Node Red and basically have it detect that whenever the distance was "20cm" for example, then it would go straight to a YouTube video and play it. I tried researching all over the net to see if such had been done before, but to no avail as I found content much different than what I tried to pull off with Node Red and my Arduino.
I did try on my end to set up a function on Node Red to my Arduino, using a conditional statement to detect something and print something else out.
Overview of what I tried to do on Node Red
As you can see, there was not much to add as I was initially trying to test the conditional statement I made, making it output something on the debug screen using the code below:
Contents of the function created
var newMsg = {payload:msg.payload.toString()}:
if (newMsg == 'Distance: 20cm') {
newMsg = 'Distance is 20, nice'
return newMsg;
}
return newMsg;
Even with the little test I created to return a message to the debug did not work, so I'm not sure what I'm missing here.
First, you should not be creating new message objects as a rule, this breaks flows that use things like http-in/http-response nodes that require the original message to pass from start to end.
Second, you can't compare an Object to a String and get anything meaningful. The function node probably should looks something like the following:
if (msg.payload === "Distance: 20") {
msg.payload = "Distance is 20cm, nice"
return msg;
}
Third, the input message appears to be terminated with a new line character so the test should probably be:
if (msg.payload === "Distance: 20\n") {

How to Pinjoint2D darts(Kinematicbody2D) on moving wall(StaticBody2D) via gdscript

I have a shooting darts (KinematicBody2D) that will need to stick on a moving wall (staticbody2D).
I wants to let the dart stick on the wall, and change position according to how the wall move (currently my wall is moved by updating its position).
However, the dart does not follow fully the moving path of the wall.
I end up adding pinJoint2D, but setting the node via gdscript only give me an error
Invalid set index 'node_b' (on base: 'PinJoint2D') with value of type 'StaticBody2D (StaticBody2DWall.gd)'.
My code in dart node for setting up pinjoint2d goes as below:
var slide_count = get_slide_count()
if slide_count:
var collision = get_slide_collision(slide_count - 1)
var collider = collision.collider
lif collider.is_in_group("wall"):
$PinJoint2D.node_b = collider
Anyone please help. Please let me know if there's a better practice.
The node_b member is a node path, not a node. Try the following:
$PinJoint2D.node_b = collider.get_path()

how to generate an image for each user in node.js

I am making a guess the number game over socket.io in node.js Lets say I ask the person to guess the a number 124 which is obviously shown to the user as 12_ ,I want to tell the person complete 12_, if they guessed 4 as the last digit, that would be right answer, how do I send an image containing the text 12_ for each person over socket.io. I need a way to generate images. I believe storing images for a large number of people would be a bad idea. or could I simply have 7 or 8 plain backgrounds and dynamically overlay text that I want on these backgrounds and send it to the user.
What have I tried
I cannot use node-canvas as it needs a native dependency on Heroku
I cannot use GraphicsMagick as Heroku s free plan doesnt support it
Any suggestions
you have to read the image and convert into base64 on the server side
socket.emit('image', { image: true, buffer: buf.toString('base64') });
where as on the client side you can use websocket to receive image
var ctx = document.getElementById('canvas').getContext('2d');
socket.on("image", function(info) {
if (info.image) {
var img = new Image();
img.src = 'data:image/jpeg;base64,' + info.buffer;
ctx.drawImage(img, 0, 0);
}
});
I know it's a really old question, but maybe it helps someone (as there's very little info about this).
I just wanted to say that you can use GraphicsMagick and ImageMagick in Heroku. You just need to add a buildpack for it to work (it works even on free instances).
Here's a blogpost I made saying how I used GraphicsMagick in Node.js. You can check the code on Github (fair warning, the code sucks, but hey, it works).

THREE.js in node.js environment

Due to making some simple multiplayer game, I have chosen THREE.js for implementing graphics at browser side. At the browser everything works fine.
Then I thought:
Server have to check out most of user actions. So I WILL need to have world copy on a server, interact it with users and then give it's state back to users.
So, As the good piece of code had been written for client side - I just made it node.js compatible and moved on. (Good collision detection, which could use object.geometry - is what I wanted so bad)
As a result, collision detection code stopped working. On the server side Raycaster exits on
the string
} else if ( object instanceof THREE.Mesh ) {
var geometry = object.geometry;
// Checking boundingSphere distance to ray
if ( geometry.boundingSphere === null ) geometry.computeBoundingSphere();
sphere.copy( geometry.boundingSphere );
sphere.applyMatrix4( object.matrixWorld );
if ( raycaster.ray.isIntersectionSphere( sphere ) === false ) {
return intersects; // _HERE_
}
And that happens, because object.matrixWorld Is Identity matrix.
But object initialization is made. mesh.position and mesh.rotation are identical on server and client( in browser, raycaster works as a charm);
I thinking, that, object.matrixWorld would update somewhere in renderer.render(self.three_scene, self.camera);. But of course, that's not what I want to do at server side.
So the question is: How to make object.matrixWorld update in each simulation tick on the server-side?
Or, maybe advice, if there's some other way to get something simular to what I want.
Okey.
That was simple.
renderer.render updates matrices of the whole scene recursively. The entrance of the recursion is updateMatrixWorld() function of Object3D instance.
So, before we use Raycaster on the server-side we should call this method for each mesh in collidable meshes list.

Resources