How is soft selection in 3D DCC such as maya implemented? - graphics

In DCC, we can soft select things with proper falloff in volume/viewport. I think I can do the soft selection with viewport falloff. But how is volume falloff implemented especially with lasso/poly selection mode?
In lasso/poly selection mode, the 2D selection area in viewport is irregular polygon. Then selected objects will also in an irregular 3D space. How to do volume falloff based on this irregular 3D space to achieve soft selection?

As already mentioned, this can only be answered by the developers. But a quite easy method would be to use a kdtree and for every selected point simply add a falloff value to every point in the required distance.

Related

AnyLogic - Move presentation frame dynamicaly

I've got a model with cars moving over the road. To make roads length similar to real-life sizes I had to change the scale so the cars turned into points (4px*2px).
Are there any facilities in AnyLogic 7 PLE to, for ex, zoom one of the cars and track it?
Yes, it is possible. If you want to zoom in one car and follow it in 3D (like if the car has GoPro at top), use Camera object with dynamic coordinates. Railway Station example model and its cameraOnTrain object illustrates the concept.
In case if you want to do similar thing in 2D space (GTA2 view mode), you may drag & drop empty Group element. In its On Draw action use the code:
getPresentation().getPanel().setOffsets( 300-agent.getX(), 300-agent.getY());
The code will constantly move frame, so car always will appear with in the bottom right corner of the 300x300 square, drawn from top left corner. Zoom can be adjusted with mouse wheel, or with code as well:
getPresentation().getPanel().setZoom( double value);

Detecting objects near cursor to snap to - any alternatives to picking ray?

In the problem of detecting objects near the mouse cursor to snap to (in a 3d view), we are using the picking ray method (which basically forms a 3d region of the cursor's immediate neighborhood and then detects objects present in the region).
I wonder if it is the only way to solve the task. Can I use, for example, the view matrix to get the 2D coordinates of the object in view space, then search for any objects in the cursor's vicinity?
I am not happy with the picking ray method because it is relatively expensive, so the question is essentially about whether any space transformation-based method will generally be faster. I am new to 3D programming so please give me a direction to dig into.
You can probably speedup the ray picking process by forming a hierarchy of nested bounding boxes around the objects, and checking for intersection of the rays with the bounding boxes. This way, you can spare a lot of intersection tests.
There is an alternative, exploiting the available rendering engine: instead of rendering to screen with the normal rendering attributes, you can render the same view in an off-screen plane, using flat shading and setting a different color for every object. You will obtain an object map that instantaneously tells you the object id for any pixel.

Creating free empty space between two planes in Solidworks

I have rotary encoder with RGB LED illuminated Shaft (Bourns PEL12T-4226F-S1024) and I am designing volume knob using Solidworks 2013, that will be used with this encoder. Now, I've managed to design basic shape and made extrusions, then add a hole for potentiometer shaft, that is all ok. But, between potentiometer hole upper plate and global upper plate I need empty space, so the knob will transfer illuminated colors. How do I add empty space between two planes using Solidworks? And how do I "cut" slots from chamfered surface, so the illumination can be visible?
This is very easy to do.
Click on the Cut Extrude symbol and then click on the top face on the model and select the top view and now u can see the center of the knob hole click circle and click on that and draw the circle define it and extrude it all the way.

Can I remap mouse co-ordinates when using Gdiplus::SetPageScale using a GDI Function?

I want to add zoom capability to an app, which at its core is a spf graph app. Now I currently have no zoom, but the ability to select/move, multi-select objects on the graph in the graph window. I started to write my own code to do scaling of the objects and then work out mouse co-ordinates to map clicks and redraws correctly. I didnt complete this as I found the Gdiplus::SetPageScale function, which scales the window fine but I cannot see any GDI function I can use to map the mouse click co-ordinates from the world co-ord's to the page co-ords. I tried TransformPoints(Gdiplus::CoordinateSpaceWorld, ::Gdiplus::CoordinateSpacePage, points, 2) but this does not convert the points and the returned points are (0,0).
So is this even possible with Gdiplus or do I need to write this mapping myself? Any advice appreciated!
You don't want to use Graphics::SetPageScale() in this case. The much more general way is to use the Matrix class instead. Its Scale, Translate and Rotate methods are handy to get the matrix you need. You'll want to use the Scale() method here, possibly Translate() to change the origin.
Before you start drawing, activate the matrix with the Graphics::SetTransform() method. Anything you draw will now automatically be scaled according to the arguments you passed to the Matrix::Scale() method. Mapping a mouse position is now exceedingly simple with Matrix::TransformPoints() method, the exact same transform that was used while drawing is now applied to the mouse coordinates. Even going back from graph coordinates to mouse coordinates is simple, use the Matrix::Invert() method to obtain the inverse transform.
When GDI+ draws, it applies a world transform (which is controlled by Graphics::SetTransform, ScaleTransform, etc.) followed by the page transform (which is controlled by Graphics::SetPageScale and Graphics::SetPageUnit) to transform the points to device coordinates.
So it normally goes like this: World coordinates --[World transform]--> Page coordinates --[Page transform]--> Device coordinates
You can use Graphics::TransformPoints the way you wanted, to map mouse coordinates to world coordinates, but you have to specify Device coordinates as the source space and World coordinates as the destination space.
However, there are good reasons to do it as Hans describes with a Matrix you store separately, most notably that you shouldn't be holding on to your Graphics object for long enough to process mouse input (nor should there be a need to create one then).

How to construct ground surface of infinite size in a 3D CAD application?

I am trying to create an application similar in UI to Sketchup. As a first step, I need to display the ground surface stretching out in all directions. What is the best way to do this?
Options:
Create a sufficiently large regular polygon stretching out in all directions from the origin. Here there is a possibility of the user hitting the edges and falling off the surface of the earth.
Model the surface of the earth as a sphere/spheroid. Here I will be limiting my vertex co-ordinates to very large values prone to rounding off errors. (Radius of earth is 6371000000 millimeter).
Same as 1 but dynamically extend the ends of the earth as the user gets close to them.
What is the usual practice?
I guess you would do neither of these, but instead use a virtual ground.
So you just find out, what portion of the ground is visible in the viewport and then create a plane large enough to fill that. With some reasonable maxiumum, which simulates the end of the line of sight aka horizon as we know it.

Resources