Table of Contents

Class DraggableModel

Namespace
PopcorningGuineaPig.Engine.Gameplay
Assembly
PopcorningGuineaPig.Engine.dll

Component that makes a 3D model draggable with smooth animations. Provides lift, follow, and drop animations for drag and drop interactions.

public class DraggableModel
Inheritance
DraggableModel
Inherited Members

Constructors

DraggableModel(Model, Vector3, Vector3, Vector3)

public DraggableModel(Model model, Vector3 position, Vector3 rotation, Vector3 scale)

Parameters

model Model
position Vector3
rotation Vector3
scale Vector3

Properties

DragFollowRate

How fast the dragged model converges on the cursor, per second. High enough that the model reads as held by the cursor (~95% in 0.075s) instead of trailing behind it — drop targeting is cursor-based, so a laggy model misleads the player about where the piece will land.

public float DragFollowRate { get; set; }

Property Value

float

IsAnimating

True while a lift, drop or return-to-origin tween is still running. Lets callers wait for the model to settle — e.g. to play a landing sound on contact rather than when the move was committed.

public bool IsAnimating { get; }

Property Value

bool

IsDragging

public bool IsDragging { get; }

Property Value

bool

IsValidDropTarget

public bool IsValidDropTarget { get; set; }

Property Value

bool

LiftHeight

public float LiftHeight { get; set; }

Property Value

float

Model

public Model Model { get; set; }

Property Value

Model

OriginalPosition

public Vector3 OriginalPosition { get; }

Property Value

Vector3

Position

public Vector3 Position { get; set; }

Property Value

Vector3

Rotation

public Vector3 Rotation { get; set; }

Property Value

Vector3

Scale

public Vector3 Scale { get; set; }

Property Value

Vector3

Tint

public Color Tint { get; set; }

Property Value

Color

Methods

CheckRayCollision(Ray)

Checks if a ray intersects with this model.

public RayCollision CheckRayCollision(Ray ray)

Parameters

ray Ray

The ray to test

Returns

RayCollision

Collision information

GetWorldBoundingBox()

Gets the world space bounding box for this model.

public BoundingBox GetWorldBoundingBox()

Returns

BoundingBox

The bounding box in world coordinates

Render()

Renders the model with current transform and any visual effects.

public void Render()

ReturnToOriginalPosition()

Returns the model to its original position with animation.

public void ReturnToOriginalPosition()

StartDrag(Vector3)

Starts dragging this model with a lift animation.

public void StartDrag(Vector3 dragOffset)

Parameters

dragOffset Vector3

Offset from model center to mouse position

StopDrag(Vector3, bool)

Stops dragging and animates the model to the target position.

public void StopDrag(Vector3 targetPosition, bool updateOriginalPosition = true)

Parameters

targetPosition Vector3

Final position for the model

updateOriginalPosition bool

Whether to update the original position

Update(double)

Updates the draggable model, handling animations and drag state.

public void Update(double deltaTime)

Parameters

deltaTime double

Time since last update in seconds

UpdateDrag(Vector3, double)

Updates the drag position to follow the mouse with smooth interpolation.

public void UpdateDrag(Vector3 mouseWorldPosition, double deltaTime = 0.016666666666666666)

Parameters

mouseWorldPosition Vector3

Current mouse position in world space

deltaTime double

Seconds since the last update. Smoothing is frame-rate independent, so the model tracks identically at 30, 60 and 144 fps.