En esta página

Qt3DRender::QRayCaster Class

class Qt3DRender::QRayCaster

Qt3DRender::QRayCaster se utiliza para realizar pruebas de fundición de rayos en coordenadas de mundo 3d. Más...

Cabecera: #include <QRayCaster>
CMake: find_package(Qt6 REQUIRED COMPONENTS 3drender)
target_link_libraries(mytarget PRIVATE Qt6::3drender)
qmake: QT += 3drender
En QML: RayCaster
Hereda: Qt3DRender::QAbstractRayCaster
Status: Obsoleto

Propiedades

Funciones públicas

QVector3D direction() const
float length() const
QVector3D origin() const

Ranuras públicas

void setDirection(const QVector3D &direction)
void setLength(float length)
void setOrigin(const QVector3D &origin)
void trigger()
void trigger(const QVector3D &origin, const QVector3D &direction, float length)

Señales

void directionChanged(const QVector3D &direction)
void lengthChanged(float length)
void originChanged(const QVector3D &origin)

Descripción detallada

El rayo 3d está definido por su origen, dirección y longitud. Se verá afectado por las transformaciones aplicadas a la entidad a la que pertenece.

Las pruebas de proyección de rayos se realizarán en cada fotograma mientras el componente esté activado. La propiedad hits se actualizará con la lista de intersecciones.

Ver también QAbstractRayCaster, QScreenRayCaster, y QNoPicking.

Documentación de propiedades

direction : QVector3D

Mantiene la dirección del rayo 3D. Debe ser un vector unitario.

Funciones de acceso:

QVector3D direction() const
void setDirection(const QVector3D &direction)

Señal notificadora:

void directionChanged(const QVector3D &direction)

length : float

Mantiene la longitud del rayo 3D.

Funciones de acceso:

float length() const
void setLength(float length)

Señal notificadora:

void lengthChanged(float length)

origin : QVector3D

Mantiene el origen del rayo 3D en coordenadas locales.

Funciones de acceso:

QVector3D origin() const
void setOrigin(const QVector3D &origin)

Señal notificadora:

void originChanged(const QVector3D &origin)

Documentación de la función miembro

[slot] void QRayCaster::setLength(float length)

Establece la longitud del rayo en length.

Si el valor es menor o igual que cero, el rayo se considera infinito.

Nota: Función Setter para la propiedad length.

Ver también length().

[slot] void QRayCaster::trigger()

Método práctico para activar el componente y lanzar pruebas utilizando el rayo actual.

Nota: Esta ranura está sobrecargada. Para conectarse a esta ranura:

// Connect using qOverload:
connect(sender, &SenderClass::signal,
        rayCaster, qOverload<>(&QRayCaster::trigger));

// Or using a lambda as wrapper:
connect(sender, &SenderClass::signal,
        rayCaster, [receiver = rayCaster]() { receiver->trigger(); });
Para ver más ejemplos y enfoques, consulte conectarse a ranuras sobrecargadas.

[slot] void QRayCaster::trigger(const QVector3D &origin, const QVector3D &direction, float length)

Método práctico para establecer los detalles de rayo origin, direction, y length, y permitir que el componente active pruebas.

Nota: Esta ranura está sobrecargada. Para conectarse a esta ranura:

// Connect using qOverload:
connect(sender, &SenderClass::signal,
        rayCaster, qOverload(&QRayCaster::trigger));

// Or using a lambda as wrapper:
connect(sender, &SenderClass::signal,
        rayCaster, [receiver = rayCaster](const QVector3D &origin, const QVector3D &direction, float length) { receiver->trigger(origin, direction, length); });
Para ver más ejemplos y enfoques, consulte la conexión a ranuras sobrecargadas.

© 2026 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.