logo
down
shadow

How to implement camera pan like in 3dsMax?


How to implement camera pan like in 3dsMax?

By : Cường Đình Bùi
Date : November 20 2020, 04:01 AM
this will help
[...] but there's still one case where his algorithm won't work properly. It doesn't handle properly the case where you panning is started from empty space [...]
code :
pt_drag = glm.vec3(0, 0, 0)
box_min = ... # glm.vec3
box_max = ... # glm.vec3

pt_drag = (box_min + box_max) / 2
o_clip = self.proj * self.view * glm.vec4(pt_drag, 1)
o_ndc  = glm.vec3(o_clip) / o_clip.w
def glut_mouse(self, button, state, x, y):
    self.drag = state == GLUT_DOWN
    self.last_mouse_pos = glm.vec2(x, self.height-y)
    self.mouse_down_pos = glm.vec2(x, self.height-y)

    if self.drag:
        depth_buffer = glReadPixels(x, self.height-y, 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT)
        self.last_depth = depth_buffer[0][0]
        if self.last_depth == 1:
            pt_drag = glm.vec3(0, 0, 0)
            o_clip  = self.proj * self.view * glm.vec4(pt_drag, 1)
            o_ndc   = glm.vec3(o_clip) / o_clip.w
            if o_ndc.z > -1 and o_ndc.z < 1:
                self.last_depth = o_ndc.z * 0.5 + 0.5
depth_buffer = glReadPixels(x, self.height-y, 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT)    
self.last_depth = depth_buffer[0][0]
d_buf = glReadPixels(0, 0, self.width, self.height, GL_DEPTH_COMPONENT, GL_FLOAT)
d_vals = [float(d_buf[i][j]) for i in range(self.width) for j in range(self.height) if d_buf[i][j] != 1]
if len(d_vals) > 0:
    self.last_depth = (min(d_vals) + max(d_vals)) / 2 
pt_drag = glm.vec3(0, 0, 0)
o_clip  = self.proj * self.view * glm.vec4(pt_drag, 1)
o_ndc   = glm.vec3(o_clip) / o_clip.w
if o_ndc.z > -1 and o_ndc.z < 1:
    self.last_depth = o_ndc.z * 0.5 + 0.5 


Share : facebook icon twitter icon
How to correctly implement ChannelsChanged and ChannelsUsed when creating a modifier plugin for 3dsmax in C#?

How to correctly implement ChannelsChanged and ChannelsUsed when creating a modifier plugin for 3dsmax in C#?


By : bennani lamiaa
Date : March 29 2020, 07:55 AM
I hope this helps . The fact that the methods expects a uint as a return value, hints that Autodesk have failed to implement a strong enumeration for Object Channel PartIDs.
You can define your own enumeration to handle it, based on the values defined in the c++ SDK.
code :
[Flags]
enum ChannelPartID : uint
{
    // The topology channel - the face or polygon structures. 
    TOPO_CHANNEL = 1 << 0,
    // The vertices of the object. 
    GEOM_CHANNEL = 1 << 1,
    // The texture vertices and procedural mappings. 
    TEXMAP_CHANNEL = 1 << 2,
    // This is no longer used. 
    MTL_CHANNEL = 1 << 3,
    // The sub-object selection channel. 
    SELECT_CHANNEL = 1 << 4,        
    // The current level of selection. 
    SUBSEL_TYPE_CHANNEL = 1 << 5,
    // The miscellaneous bits controlling the item's display. 
    DISP_ATTRIB_CHANNEL = 1 << 6,
    // The color per vertex channel. 
    VERTCOLOR_CHANNEL = 1 << 7
    // The used internally by 3ds Max for stripping. 
    GFX_DATA_CHANNEL = 1 << 8,
    // Displacement approximation. 
    DISP_APPROX_CHANNEL = 1 << 9,
    // The channel used by extension channel objects. 
    EXTENSION_CHANNEL = 1 << 13,
    // The ObjectState Transform that flows down the pipeline. 
    TM_CHANNEL = 1 << 10,
    // For internal use. 
    EDGEVISIBILITY_CHANNEL = 1 << 11,
    // For internal use. 
    DONT_RECREATE_TRISTRIP_CHANNEL = 1 << 12,
    // This is no longer used. 
    GLOBMTL_CHANNEL = 1 << 31,
    OBJ_CHANNELS = TOPO_CHANNEL | GEOM_CHANNEL | SELECT_CHANNEL | TEXMAP_CHANNEL | MTL_CHANNEL | SUBSEL_TYPE_CHANNEL | DISP_ATTRIB_CHANNEL | VERTCOLOR_CHANNEL | GFX_DATA_CHANNEL | DISP_APPROX_CHANNEL | EXTENSION_CHANNEL,
    ALL_CHANNELS = OBJ_CHANNELS | TM_CHANNEL | GLOBMTL_CHANNEL 
}
public override uint ChannelsChanged 
{
  get { return (uint)(ChannelPartID.PART_GEOM | ChannelPartID.TEXMAP_CHANNEL | ChannelPartID.VERTCOLOR_CHANNEL); }
} 
3dsmax: How to use cmd to simulate Drag and Drop mxs from explorer to 3dsMax?

3dsmax: How to use cmd to simulate Drag and Drop mxs from explorer to 3dsMax?


By : Sumit
Date : March 29 2020, 07:55 AM
Does that help You can use OLE Automation for that. First, you need to expose fileIn function. Put this script inside the startup folder:
code :
registerOLEInterface #(fileIn)
import win32com.client
import sys

conn = win32com.client.Dispatch("MAX.Application")
conn._FlagAsMethod("fileIn")
conn.fileIn(sys.argv[1])
python maxOLE.py "C:/Scripts/script.ms"
How do I implement camera changing from front to back camera

How do I implement camera changing from front to back camera


By : Nicholas Puglia
Date : March 29 2020, 07:55 AM
it should still fix some issue Your problem is that you are not checking if you can add input and/or output before adding them to your capture session. Btw you don't need to setup the preview layer again when switching your camera and you need only one captureDevice:
code :
if captureSession.canAddInput(captureDeviceInput) {
    captureSession.addInput(captureDeviceInput)
} 
if captureSession.canAddOutput(photoOutPut) {
    captureSession.addOutput(photoOutPut)
}
class MainCameraCollectionViewCell: UICollectionViewCell, AVCapturePhotoCaptureDelegate {
    private var captureSession = AVCaptureSession()
    private var sessionQueue: DispatchQueue!
    private var captureDevice: AVCaptureDevice!
    private  var photoOutPut: AVCapturePhotoOutput!
    private var cameraPreviewLayer: AVCaptureVideoPreviewLayer!
    var image: UIImage?
    var usingFrontCamera = false
    override func awakeFromNib() {
        super.awakeFromNib()
        setupCaptureSession()
        setupDevice()
        setupInput()
        setupPreviewLayer()
        startRunningCaptureSession()
    }
    func setupCaptureSession(){
        captureSession.sessionPreset = .photo
        sessionQueue = DispatchQueue(label: "session queue")
    }
    func setupDevice(usingFrontCamera: Bool = false){
        sessionQueue.async {
            let deviceDiscoverySession = AVCaptureDevice.DiscoverySession(deviceTypes: [.builtInWideAngleCamera], mediaType: .video, position: .unspecified)
            let devices = deviceDiscoverySession.devices
            for device in devices {
                if usingFrontCamera && device.position == .front {
                    self.captureDevice = device
                } else if device.position == .back {
                    self.captureDevice = device
                }
            }
        }
    }
    func setupInput() {
        sessionQueue.async {
            do {
                let captureDeviceInput = try AVCaptureDeviceInput(device: self.captureDevice)
                if self.captureSession.canAddInput(captureDeviceInput) {
                    self.captureSession.addInput(captureDeviceInput)
                }
                self.photoOutPut = AVCapturePhotoOutput()
                self.photoOutPut.setPreparedPhotoSettingsArray([AVCapturePhotoSettings(format:[AVVideoCodecKey: AVVideoCodecType.jpeg])], completionHandler: nil)
                if self.captureSession.canAddOutput(self.photoOutPut) {
                    self.captureSession.addOutput(self.photoOutPut)
                }
            } catch {
                print(error)
            }
        }
    }
    func setupPreviewLayer() {
        cameraPreviewLayer = AVCaptureVideoPreviewLayer(session: captureSession)
        cameraPreviewLayer.videoGravity = .resizeAspectFill
        cameraPreviewLayer.connection?.videoOrientation = .portrait
        cameraPreviewLayer.frame = UIScreen.main.bounds
        layer.insertSublayer(cameraPreviewLayer, at: 0)
    }
    func startRunningCaptureSession() {
        captureSession.startRunning()
    }
    @IBAction func cameraButton_TouchUpInside(_ sender: Any) {
        let settings = AVCapturePhotoSettings()
        photoOutPut.capturePhoto(with: settings, delegate: self)
    }
    //Flip to front and back camera
    @IBAction func FlipThe_camera(_ sender: UIButton) {
        captureSession.beginConfiguration()
        if let inputs = captureSession.inputs as? [AVCaptureDeviceInput] {
            for input in inputs {
                captureSession.removeInput(input)
            }
        }
        usingFrontCamera = !usingFrontCamera
        setupCaptureSession()
        setupDevice(usingFrontCamera: usingFrontCamera)
        setupInput()
        captureSession.commitConfiguration()
        startRunningCaptureSession()
    }
}
Unity Camera component error when tried to implement player following camera

Unity Camera component error when tried to implement player following camera


By : TrueZion
Date : March 29 2020, 07:55 AM
will help you What I am trying to do: have the camera follow the character like Mario , Just type
code :
transform.position 
 gameobject.transform.postion
GameObject.Transform.Position
How to implement zoom towards mouse like in 3dsMax?

How to implement zoom towards mouse like in 3dsMax?


By : user2260655
Date : March 29 2020, 07:55 AM
will be helpful for those in need A possible solution is to move the camera along a ray, from the camera position through the cursor (mouse) position and to move the target position in parallel.
code :
self.eye    = self.eye    + ray_cursor * delta
self.target = self.target + ray_cursor * delta
pt_wnd   = vec3(x, height - y, 1.0)
pt_world = unProject(pt_wnd, self.view, self.projection, viewport)
ray_cursor = normalize(pt_world - self.eye)
v = glGetIntegerv(GL_VIEWPORT)
viewport = vec4(float(v[0]), float(v[1]), float(v[2]), float(v[3]))
width  = viewport.z
height = viewport.w
def zoom_towards_cursor(self, *args):
    x = args[2]
    y = args[3]
    v = glGetIntegerv(GL_VIEWPORT)
    viewport = vec4(float(v[0]), float(v[1]), float(v[2]), float(v[3]))
    width  = viewport.z
    height = viewport.w

    pt_wnd     = vec3(x, height - y, 1.0)
    pt_world   = unProject(pt_wnd, self.view, self.projection, viewport)
    ray_cursor = normalize(pt_world - self.eye)

    delta = -args[1]
    self.eye    = self.eye    + ray_cursor * delta
    self.target = self.target + ray_cursor * delta 
Related Posts Related Posts :
  • Creating a Dataframe of Proportions
  • Scrapy with dynamic captcha
  • In python, how do I get urllib to recognize multiple lines in a string as separate URLs?
  • Add prefix and suffix to each element of a nested list
  • Generate string set from csv file in Python
  • Custom usage message for many-valued argument
  • Python Class, how to skip a wrong entry and proceed to next entry
  • Numpy efficient way to parse array of string
  • Kivy , Python: Update Label on_file_drop
  • What does it mean if a deeper conv layer converges first?
  • Selecting User in client.send_message() from arg list
  • python slicing multi levels list of dict using list comprehension
  • Value Error problem with multicell Dimensions must be equal, but are 20 and 13
  • How to print a board with coordinates?
  • Keras LSTM shape doesn't contain length of sequence
  • Boxplot with Pandas in Python
  • How can I rename a PySpark dataframe column by index? (handle duplicated column names)
  • How to calculate hash of a python class object
  • Using ideas from HashEmbeddings with sklearn's HashingVectorizer
  • keycloak.exceptions.KeycloakGetError: 404: b'' using Python 3.7
  • How to modify a column in a SQLite3?
  • VS Integration Services: flat file source to OLE DB destination - detect new data columns in file, add columns to table,
  • Customize xticks in matplotlib plot
  • How can I show the image in a labelframe which is inserted through askopenfilename?
  • Boxplot with distibution size histogram on top (and median regression)
  • Fit differential equation with scipy
  • ModuleNotFoundError: Correct setup
  • How to pass rendered plot to a html file through render_template?
  • Create flat ndarray from DataFrame column containing arrays
  • Bring radial axes labels in front of lines of polar plot matplotlib
  • Python3: Unable to split word from parsed data
  • Using Python to login to a website and web scrape
  • Customise shift in matplotlib offset
  • Combining and Reshaping rows and columns of 2 dataframes in R or Python
  • Regex condition after and before a known phrase
  • subplots based on records of two different pandas DataFrames ( with same structure) using Seaborn or Matplotlib
  • find numpy array in other numpy array
  • Print Triangle Pyramid pattern using for loop python
  • Python Script Running through Command Line Not Creating CSV
  • Questions about Subclassing
  • Creating list with dictionary instead of multiple dictionaries in python
  • Sorting queryset results in a template
  • Django Rest Framework allow not authenticated access to a view in certain cases
  • How do I efficiently map integers to URIs in a multidemnsional array?
  • Installing Python packages for Visual Studio Code
  • How to merge two columns into one in pandas dataframe
  • Decompose string of different symbols in python
  • pandas merge and group concat
  • How to traverse tree for making binary code from a HuffmanTree?
  • Check if IP is in network on Python3
  • non equally spaced points along x-axis in a plot
  • Concatenation of text files consisting list of lists?
  • Use regex to parse characters on a line of text
  • pandas df.fillna - filling NaNs after outer join with correct values
  • How can I undo a time series conversion of a pandas dataframe?
  • Virtual environment is not working in Django
  • FileNotFoundError in Python during Arabic text analysis
  • How to read email using python and smtplib
  • How to write a function which takes a string and turns into a single digit?
  • Linear Regression without Least Squares in sklearn
  • shadow
    Privacy Policy - Terms - Contact Us © bighow.org