Setting the orientation of gameobjects works? - azerothcore

I'm trying to change the orientation of a gameobject by updating the table gameobject with the columns rotation0, rotation1, rotation2, rotation3.
So far the only thing that I got was the despawning of the item if the value was greater than 1. Changing it seems to not have an effect, and I don't know if the implementation works or if I'm missing something.
On the wiki there is not a single explanation as which rotation modifies X Y or Z axis too.

Related

Is there a formula to find affected square by sized-brush on a grid?

I am not sure how to put this problem in a single sentence, sorry if the title is misleading.
I am currently developing a simple terrain editor with a circle-shaped brush size. The image below shows a few cases that represent my problem.
additional info: the square size is fixed and uniform and in the current version, my concern is only to find which one is hit and which one is not (the amount of region covered is important for weighting the hit, but probably not right now)
My current solution (which is not even correct for a certain condition) is: given a hit in a position (x, y) with radius r, loop through all square from (x-radius, y-radius) to (x+radius, y+radius) and apply 2-D box to circle collision detection. But I don't think this is optimal (or even correct IMO).
Can anyone help me with this one? Thank you
Since i can't add a simple comment due to bureaucracy on this website i have to type it out here.
Anyway you're in luck since i was trying to do this recently as well! The way i did it is i iterated through the vertex array and check if the current vertex falls inside the radius of the circle. But perhaps what you want is to check it against each quad center and if that center falls inside the radius then add the whole quad as it's being collided.
Of course depending on the size of your grid the performance will vary so it's good to try to iterate through as few quads as needed. Though accessing these quads from the array is something you have to figure out yourself.

proper way of calculating mouse 'z' position (Unity 3d)

Whenever I develop games that use mouse input, I will get confused of calculating the mouse position. Especially the z position.
The ways I saw many using.
mouse position z = mouse position y.
z = distance between camera and object.
z = difference b/w object z and camera z. (I am using. Doesn't work when camera and object is rotated).
z = some arbitrary value. (many use 0 and some other values).
others.
Which method is correct? Is there any other method which is correct?
Please let me know.
The same answer as in your second mouse based question applies here too: Mouse based aiming Unity3d
TL;DR: use a raycast from camera to intersect the plane that the action is on.
Vector3 pz = Camera.main.ScreenToWorldPoint(Input.mousePosition);
pz.z should be what you are asking for if I'm understanding right. Tell me if it works
The mouse position is in theory external to the game world itself. Therefore, the mouse position relates simply to X and Y co-ordinates of the screen space in which you are interacting with your game (IE width:height of your game).
What you're asking seems to be more of "How do I model the mouse position in my game world?"
As noted by Mario, Camera.main.ScreenToWorldPoint(Input.mousePosition) will convert your mouse position to world co-ordinates. However, this assumes that your main camera is where you want to convert to. In reality, you want to call the ScreenToWorldPoint method on the Camera that is rendering whatever space it is you are wanting to interact with. For example, you may have your main game world at (0, 0, 0) but you may be rendering your GUI on top using a separate camera that renders objects at (-5000, 0, 0).
To answer your question, to model the mouse z position it should simply be the same z value as your Camera. You can then perform calculations on that value to suit your particular needs.
IE:
1) mouse.position.z = mouse.position.y - These are entirely different. Now you're just using an arbitrary value
2) Distance between camera and object - That's a calculation made from your original object.position.z and original mouse.position.z. Not your actual z value.
3) See 2.
4) See 1.

How to specify symbol position on the marker?

I am using Qwt library. I have added vertical QwtPlotMarker on the plot. I want to add QwtSymbol to my marker and I want the symbol to be in the bottom of the marker. When I use setSymbol() it places symbol in the middle of the marker. There are setLabelAlignment() function to specify where the label is drawn. Unfortunately, I did not found anything like that for symbol. I have read Qwt User's Guide where I found: The setSymbol() member assigns a symbol to the marker. The symbol is drawn at the specified point. So, how to specify that point?
It is a very old question, but I found solution and I want to share with you.
There is way to specify this point. Method setValue(double x, double y) do this, but this method not describes in the documentation (it's very strange for me), but this method works!
I wrote small but useful snippet. If I understand you correctly, this code do exactly what you need
QwtSymbol *sym=new QwtSymbol(QwtSymbol::Diamond,QBrush(Qt::red),QPen(Qt::red),QSize(5,5));
//create the symbol
QwtPlotMarker *mark=new QwtPlotMarker;
mark->setSymbol(sym);
mark->setLineStyle(QwtPlotMarker::VLine);
//set vertical line
mark->setValue(5,ui->qwtPlot->axisInterval(QwtPlot::yLeft).minValue());
//here you have to set the coordinate axis i.e. where the axis are meeting.
//as you can see I set coordinate 5 and the lowest coordinate of Y axis
//you can set here needed coordinates
mark->attach(ui->qwtPlot);
I hope, it helps.

How to get the negative position value in Group?

The dashed rectangle is the parent group and inside, there is a label. Its x is negative.
Now, what I want to do is relocation the outside group to the contents' top-left point and meanwhile the contents' move back to the outside group's (0,0) point. The result looks like everything keeps the same position as before.but in fact, both inside content and outside group is moved.
It is easy to realize in flash, however, in flex i got trouble.
The function "getRect" returns wrong values.it's never return the correct position the inside content is.(like the thumb shows,the position should be like [-70,50])
(Feel free to correct me because I'm not sure what you want to accomplish here)
If your Label (let's say it is called myLabel) is correctly located directly inside of your Group, simply calling myLabel.x will return the X-coordinate of the label compared to its parent (which is your Group here, so you should get -70).
Then if you want to move the label so it fits into your Group viewport, you have two solutions:
Either you manually set myLabel.x = 0 and myLabel.y = 0. In this case the label will actually be moved at the Group origin.
Either you retrieve the matrix of your label component to call its .translate(dx, dy) function. Using the matrix functions will modify the way your Label is displayed, but its position will remain unchanged (More information about that on this page).
Short answer: If you don't care about keeping the original position of your label, just set myLabel.x = 0 and myLabel.y = 0 and it should be moved correctly.

Finding component's x,y location

I have a component that changes its location based on other elements. I'm trying to find its x and y position at different intervals, so I tried compname.x and compname.y.
The x position seems to be working, but the y position is always 0. I'm guessing I need to play with localToGlobal or contentToGlobal or one of those conversions. Is that the problem?
A component's x and y values are relative to it's parent. Flex calls this the content coordinate system; and the contentToGlobal should give you the answers you need.
Read up on positioning components, which explains the content, local, and viewable coordinates:
http://livedocs.adobe.com/flex/3/html/help.html?content=size_position_2.html
And read up on the Flex coordinate system:
http://livedocs.adobe.com/flex/3/html/help.html?content=containers_intro_5.html#254752
If you had a working example it may be easier to give a specific answer.
...also, have a look at getBounds() - this method returns you the position relative to other display objects.
simon

Resources