Maya 2015: fit view issue when create custom node - maya

I have a simple scene like this:
Where CTRL_set and CTRL_setsubControl are two custom nodes. When I press F for focus to selection, it gives me this:
The mesh go far far away also if I select the mesh (and not the custom node) before press F. This issue also occurs when I press A.
How can I solve it maintaining the same structure of nodes?

The problem is that CTRL_set node has huge bounding box.
I solve it turning off the CTRL_set visibility: now the bbox has finite size and the node still works fine. Finally, when I press A (or F with CTRL_set selected) the view fit the scene as usual.
(This problem occurs in Maya 2015 SP6 Extension 1, not in SP2)

Related

React Three Fiber: How to switch between TrackballControls and OrbitControls?

I'm trying to create a viewer in react-three-fiber with react-three/drei where I can switch between OrbitControls and TrackballControls.
The problem is that when switching from TrackballControls to OrbitControls, the axis that the camera rotates around changes as of course the TrackballControls change the up-vector when moving around.
I created a couple of minimal examples in codesandbox to explain my approach to solve this and to show where I'm stuck.
Base Case
This shows the initial attempt to switch between the different control types:
https://codesandbox.io/s/r3f-camera-controllers-base-neu07
Attempt #1
Obviously, this does not work as it is, so I tried resetting the up-vector to (0, 1, 0) and calling lookAt(). This seems to work initially as the camera reorients itself correctly (this is how it should look like). However, it does not rotate around the correct axis and instead moves in strange arcs. See here:
https://codesandbox.io/s/r3f-camera-controllers-set-up-vector-yps4k
Attempt #2
For this question it was suggested to create a new camera which I also tried but ultimately it lead to the same result. This here is my attempt at creating a new camera and copying some values to the new camera:
https://codesandbox.io/s/r3f-camera-controllers-reset-camera-3cih0
Any help appreciated. Thanks!
After a couple of days, I finally figured out a way to achieve what I want.
Instead of trying to remove the different controls, I just enable and disable them separately. I can then call the reset() functions on both Controls via a ref if the control prop changes. To retain the camera position, I can just temporarily store it before resetting the controls.
You can find an example here.

SceneKit DAE animation not appearing in attributes

I'm trying to carefully word this question because the problem doesn't appear to be that the animation isn't being imported. I can see the animation as <untitled animation> in the scene graph, and I can play the animation in Xcode; the issue is then locating the animation as an attribute to any of the objects. This is what I can see in the scene graph:
But, when I try and locate the animation here:
... nothing appears. So, it seems that it isn't importing the animation as a CAAnimation object with a key.
I have tried to programmatically enumerate through the child nodes to find any CAAnimation objects, but it doesn't see any. Other scenes work perfectly however.
What do I need to add to the DAE file to get it to build the CAAnimation object properly?
Worth pointing out that the 3D model and animation was exported from 3DS Max using OpenCollada. I don't know what the best practices are for exporting collada to SceneKit, and if anyone has any useful information that would be great. Apple don't seem to have anything.
The SceneKit editor in Xcode does not display the root node in the scene graph view, and it might be the one that holds the animation.
You should be able to retrieve the root node's animation programmatically.

In SceneKit, how do you make camera look at a specific face of a node's geometry?

In SceneKit, you can add a lookAtConstraint constraint to your SceneView's Point Of View, to make Camera look at a certain node.
Is there a standard way of doing the same but for a specific face of a geometry?
So that, if I touch a specific face of a cube, camera would move so that the Z axis of the camera node gets in line with the normal of the touched face? So that the cube would look like a plane form the new perspective.
No.
That would require movement of the camera, in addition to re-aiming it.
Imagine I'm in front of my house. I have a great view of the front and can just barely see the side to my left. In my Scene I tap the side of the house. A LookAt constraint would merely change the angle of the camera. It would not be aligned with the normal of that barely visible side.
To align with the normal, I'd have to walk around the house until I can stare at the house and be perpendicular to the side I tapped. At what radius? What path? You have to figure that out yourself.
Depending on what effect you're trying for, you might want to rotate the model instead of moving the camera. Rotate the tapped node locally (or as a child of an invisible parent) so that its minus-Z axis points out the tapped face, and keep a lookAtConstraint on the node, not the camera. This approach will change the look of the object, though: you will see it rotating, and the shading changing appropriately.
So that, if I touch a specific face of a cube, camera would move so that the Z axis of the camera node gets in line with the normal of the touched face?
Supposing you are using hit-testing to determine what object got touched, a SCNHitTestResult will give you both localCoordinates and localNormal from which it should be fairly easy to derive a camera transform.
One easy way would be to have the camera as a child node of the box, compute a position that would look like localCoordinates + distance * localNormal and finally a transform using GLKMatrix4MakeLookAt and SCNMatrix4FromGLKMatrix4.
Note that you can also use worldCoordinates, worldNormal, as well as conversion utilities such as SCNNode.convertTransform(_:from:).
mutating on mnuages answer, use a hit test or ray trace to find where the user tapped on the mesh, then add a node at that location, and constrain the camera to lookAt that node.

How does QTP click if no coordinates are specified?

I am working on a WPF & .Net application that has many WPFbuttons that I must click. When I attempt to click the button objects, sometimes it works right away, more often it waits several seconds then proceeds, and sometimes it waits up to 3 minutes before my application proceeds.
There is a workaround (or rather, a kludge) by specifying object.Click 5,5 thereby setting QTP to click 5 pixel in from the top-left corner. This works, but why doesn't a regular click work on the program?
Further investigating, QTP says that by default micNoCoordinate is used when no coordinates are specified (this is supposed to click the center of the object).
I have tried micNoCoordinate as well as 5,5 and even 0,0 and while micNoCoordinate is a bit slower than specifying a real coordinate, all of these methods work much, much faster than not specifying a coordinate at all.
What is really going on when QTP "clicks" an object? I don't see a cursor on the button during a plain click event. Why is a plain .Click event so different than specifying a coordinate or even just using micNoCoordinate??
EDIT: Specifically, I'm quite interested in how the click events themselves differ when using coordinates vs. when not using coordinates. What type of click event is being simulated in each scenario?
By default, if no X/Y coordinates are provided, the object's .Click method will click directly in the center of the object. This is the same as specifying "micNoCoordinate" for both coordinates. You have correctly identified the functionality.
Make sure you have all of the latest patches relating to .NET and WPF (QTPNET_00062 and possibly others).

Converting mouse position to world position OpenGL

Hey, I'm working on a map editor for my game, and I'm trying to convert the mouse position to a position in the game world, the view is set up using gluPerspective
A good place to start would be the function gluUnProject, which takes mouse coordinates and calculates object space coordinates. Take a look at http://nehe.gamedev.net/data/articles/article.asp?article=13 for a basic tutorial.
UPDATE:
You must enable depth buffering for the code in that article to work. The Z value for mouse coordinates is determined based on the value in the depth buffer at that point.
In your initialization code, make sure you do the following:
glEnable(GL_DEPTH);
A point on the screen represents an entire line (an infinite set of points) in 3D space.
Most people with questions similar to yours are really trying to select an object by clicking on it. If that's what you're after, OpenGL offers a selection mode that's generally more effective than trying to convert the screen coordinate into real-world coordinates.
Using selection mode is (usually) pretty simple: you start with gluPickMatrix, which you use to specify a small box around the click point. You then draw your scene in selection mode. When you're done, instead of actually drawing anything, it gives you back records of what would have been drawn in the box you specified. If memory serves, those are arranged in Z order, so the first one in the list is what would have displayed front-most (i.e., the one you usually want).

Resources