Mineflayer bot.look at a direction - mineflayer

Ok so im making a minecraft bot app and im using mineflayer but I cant seem to figure out on how do I make the bot look at a direction such a north or south I tried doing bot.lookAt(north) but that didnt work I searched the api documentation but couldnt find any answers . Any help related would be appreciated

bot.lookAt needs a vec3 direction as input.
So you cant just say north.
You can give it sth like (0,1,0)
https://github.com/PrismarineJS/mineflayer/blob/master/docs/api.md#botlookatpoint-force
If you code with JavaScript like this
var Vec3 = require('vec3').Vec3;
var v1 = new Vec3(1, 2, 3);
bot.lookAt(v1)

Related

Qt3D Billboards: how to make plane always face to camera

I try to use camera's viewVector to make plane face to camera, but it will turn Clockwise or Counterclockwise when Camera rotate to left or right.
Can I make the plane always face to camera without turning Clockwise or Counterclockwise?
I think camera->upVector() can help me maybe, but I don't how to use.
My code :
class planeTransformClass : public Qt3DCore::QTransform {
public:
planeTransformClass( Qt3DCore::QNode *entity = nullptr ) :Qt3DCore::QTransform(entity) {}
signals:
void faceTo( QVector3D v ) {
setRotation(QQuaternion::rotationTo(QVector3D(0,1,0), -v));
} ;
};
// Background
Qt3DCore::QEntity *planeEntity = new Qt3DCore::QEntity(rootEntity);
Qt3DExtras::QPlaneMesh *planeMesh = new Qt3DExtras::QPlaneMesh(planeEntity);
planeMesh->setHeight(2);
planeMesh->setWidth(2);
Qt3DExtras::QTextureMaterial planeMaterial = new Qt3DExtras::QTextureMaterial(planeEntity);
Qt3DRender::QTexture2D *planeTexture = new Qt3DRender::QTexture2D(planeMaterial);
FlippedTextureImage *planeTextureImage = new FlippedTextureImage(planeTexture);
planeTextureImage->setSize(QSize(3000, 3000));
planeTexture->addTextureImage(planeTextureImage);
planeMaterial->setTexture(planeTexture);
planeMaterial->setAlphaBlendingEnabled(true);
// Transform
planeTransformClass planeTransform = new planeTransformClass(planeEntity);
planeTransform->setRotationX(90);
planeTransform->setTranslation(QVector3D(2, 0, 0));
planeEntity->addComponent(planeMesh);
planeEntity->addComponent(planeMaterial);
planeEntity->addComponent(planeTransform);
// connect camera's viewVectorChanged
camera->connect( camera, &Qt3DRender::QCamera::viewVectorChanged,
planeTransform, &planeTransformClass::faceTo);
Solution using geometry shader
There is already a C++ translation this QML code that I tried to translate (using geometry shader):
https://github.com/ismailsunni/qt3d-custom-shader
My own translation can be found here. It works now after solving the issues mentioned in this question.
Solution without geometry shader
I got a different version running based on this bug report. You can find my implementation on GitHub. The billboards don't change their size when the camera moves, i.e. become smaller and larger on screen like every other object, but I hope you can work with that.
On the master branch the images also move for some reason as can be seen in this image:
The no_instanced_rendering branch doesn't use instanced rendering and displays everything correctly.
Edit
I'm sorry I'm not using your example but I don't have time anymore to adjust it. Check out the patch related to the bug report I mentioned. The person implemented a material with this effect, you should be able to extract it and make it run.

BABYLONJS : How to move the camera in front of a mesh

It's my first post in StackOverFlow.
I'm asking for how can I put the camera in front of a mesh.
Context :
my projects is a museum, and when i click in to picture " mesh" , i need the camera get in front of the mesh , so that i can watch the picture.
I tried :
camera.postion = Mesh.position;
Problem :
the camera take the position of the mesh so i cannot see the picture , but i'm in the picture !
Thank you for your help !
You can try to move the camera a bit away from the mesh position.
Something like that:
camera.position = mesh.position.add(new BABYLON.Vector3(0, 0, 5));
camera.target = mesh.position
I found the right solution !
Thank you for your answer ! i did tried before, but it doesn't worked properly !
Solution !
Picture.metadata={};
Picture.metadata.visitorPosition = new BABYLON.Vector3(x,y,z);
if (pickResult.hit){
if(!pickResult.pickedMesh.metadata){return;}
camera.position = pickResult.pickedMesh.metadata.visitorPosition;
camera.setTarget(pickResult.pickedMesh.position);}

Xbox One Right Trigger Not Working

I have an Xbox One controller setup with Unity3d, and when I try to use the RT button nothing happens.
With the following setup, the RB button works fine:
I have looked at this but setting that up doesn't make sense to me. I have tried 3rd Axis 0_10th and I have tried 3rd Axis 0_1 but those are not valid. What is the proper settings for this to work?
To the get the result I was looking for, I needed to set it up the following way:
Then to get the button to work we need to use:
if(Mathf.Round(Input.GetAxisRaw("Fire1")) < 0){
// Firing code here
}
instead of:
if(Input.GetButton("Fire1")){
// Firing code here
}
Yes, thanks for posting. I was having the same problem using a 360 wired controller in Unity3d. It looks like the Left and Right triggers now both use the 3rd axis (Joystick) with the Left generating positive (0 to +1) values and the Right trigger generating negative (0 to -1) values. This differs from all the documentation I was finding.

What is the field of view(FOV) of the color camera in Kinect for Windows V2?

Can't find it anywhere. The kinectforwindows site has the FOV for depth camera. I can't find it in the box either.
#user1809923 is correct. I contacted the developer of the link:
http://smeenk.com/kinect-field-of-view-comparison/
And he responded with this information:
If I remember correctly these FOV values are part of the
framedescriptions that you can retrieve with help of the Kinect SDK.
Since other people asked for the same info I will update the my blog.
I confirmed his findings by calling the frame's framedescription in the Kinect SDK code and printing the values to the screen.
According to this post
http://smeenk.com/kinect-field-of-view-comparison/
the FOV of the color camera is 84.1 x 53.8. I am not sure, where the author found this information though.
I just wanted to add some more information to this, because the official Kinect Fusion documentation is really bad and because the answer here is correct but the numbers are rounded:
assuming, you already have a initialized IColorFrameSource* (e.g. with the name pColorFrameSource) you should retrieve the information after you opened the reader: pColorFrameSource->OpenReader(&m_pColorFrameReader); with m_pColorFrameReader beeing IColorFrameReader*
the code to retrieve the FOV then looks like this:
IFrameDescription *f=nullptr;
float fovDiago = 0;
float fovHori = 0;
float fovVerti = 0;
HRESULT hh=pColorFrameSource
->CreateFrameDescription(ColorImageFormat::ColorImageFormat_Rgba,&f);
if (hh == S_OK) {
f->get_DiagonalFieldOfView(&fovDiago);
f->get_HorizontalFieldOfView(&fovHoront);
f->get_VerticalFieldOfView(&fovVerti);
}
The FOV values not rounded are:
fovDiago =91.9000015
fovHori =84.0999985
fovVerti =53.7999992

What is the functioning of fireevent() in HP QTP / UFT?

I am learning HP UFT.
Recently I came across fireevent and I tried to implement it on the website of Flipkart. I was trying to use firevent("onmouseover") for the link Men on the homepage of the website.
I used ChildObjects to find out the Link and WebElement (in two different tests), first Highlighted it and then used object.fireevent("onmouseover") as well as object.fireevent("OnClick"). The OnClick is working and it is showing the link as selected (i.e. the dotted box covering the link when we press tab), but it is not showing the Menu Under Men Section.
I had googled and bingged a lot. But was unable to find the exact working of FireEvent in QTP/UFT.
Please Help me solving the above problem as well as some tutorials on FireEvent.
EDIT: I am using IE 11 for testing.
Motti has already answered the technical definition, but I shall attempt to give you a solution to your functional issue.
In my experience .FireEvent often doesn't work as you would expect. An alternative for something like onmouseover is to simulate user behaviour a bit more closely by actually moving the mouse to the desired location. In our framework we have a little extension function to do just that, a pared-down version of which is shown here:
Sub My_MouseOver(objSender)
Dim absX : absX = objSender.GetROProperty("abs_x")
Dim absY : absY = objSender.GetROProperty("abs_y")
Dim width : width = objSender.GetROProperty("width")
Dim height : height = objSender.GetROProperty("height")
Dim x : x = (absX + (width / 2))
Dim y : y = (absY + (height / 2))
Dim deviceReplay : Set deviceReplay = CreateObject("Mercury.DeviceReplay")
deviceReplay.MouseMove x, y
Reporter.ReportEvent micDone, "A step name", "A useful step description"
End Sub
RegisterUserFunc "Link", "MouseOver", "My_MouseOver"
RegisterUserFunc "WebButton", "MouseOver", "My_MouseOver"
RegisterUserFunc "WebElement", "MouseOver", "My_MouseOver"
As an example you can then do as follows to bring up the "ELECTRONICS" menu overlay on flipkart.com (obviously substitute your own Browser and Page definitions):
Browser("Flipkart").Page("Main Nav").Link("xpath:=//a[#data-tracking-id='electronics']").MouseOver
In the original version there's various extra bits of error handling and custom reporting so it tells you what you clicked on, but the essence is the same. It locates the object on screen, calculates the centre and moves the mouse there. You might want to wait a small amount of time for the menu overlay to appear after doing so before calling .Click on one of the newly-displayed sub-elements.
I found a solution to my problem and it is working perfectly.
Setting.WebPackage("ReplayType") = 2
object.FireEvent "onmouseover"
Setting.WebPackage("ReplayType") = 1
In this case, the object will be:
Browser("name:=Online Shopping.*").Page("name:=Online Shopping.*").Link("innertext:=Men")
I have tried this and it is working fine. I guess, we do not need any alternatives. But I really don't know is, Ctrl+Space is not working for this in UFT. Don't know the reason.
This actually depends on what browser you're using.
Warning: There are exceptions to the information presented in this answer and it also may change in the future. The answer is meant to give a basic understanding but don't depend on it to be true without checking the behaviour for your specific version/use-case.
Originally QTP's FireEvent was supposed to call IE's non-standard fireEvent method.
On Firefox and Chrome this is implemented using the standard dispatchEvent. You should check which events the web site expects to get.
Things get complicated if you mix the event models (the standard DOM level 2 and Microsofts) as explained in this blog post.