'전체 글'에 해당되는 글 1803건

  1. 2023.12.22 blender 2.8 fbx import error
  2. 2023.12.22 탁구채로 탁구공 튕기기
  3. 2023.12.22 활시위 당기는 법
  4. 2023.12.20 HandGun 장전
  5. 2023.12.20 OneGrabPhysicsJointTransformer
  6. 2023.12.19 Grabbable (Two Grab Transformers)

blender 2.8 fbx import error

VR 2023. 12. 22. 23:20
반응형

 

 

blender 2.8 fbx import error unicode decode error utf-8

반응형

'VR' 카테고리의 다른 글

오큘러스 퀘스트 3 컨트롤러 모델  (0) 2024.02.24
Use Custom Hand Model  (0) 2023.12.22
HandGun 장전  (0) 2023.12.20
Unity VR Create Snap Interactions  (0) 2023.12.13
:

탁구채로 탁구공 튕기기

VR/Oculus Integration 2023. 12. 22. 18:21
반응형

 https://youtube.com/playlist?list=PLTFRwWXfOIYB9hru6EjeVS0E-4jNiOuQQ&si=zoJ3NoYX6YrGnpg1


 
 
Racket구조 

 
 

Racket

 

Visuals

 
 

Mesh

 

Handle

 

Handle

 

Hand Grab Interactable

 
 

Hand Grab Pose

 
 
 
 
 


 
Ball 구조 

 
 

Visuals
Mesh (Ball)
Ball

 
 
 

Mesh/Sphere

 
 

물리 메터리얼

 

물리 메터리얼
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Ball : MonoBehaviour
{
    public float gravity = -9.8f;
    void Start()
    {
        // 중력 크기 조절 예시 (Y축 방향의 중력)
        Vector3 customGravity = new Vector3(0f, gravity, 0f); // 중력 크기 및 방향 설정
        Physics.gravity = customGravity; // 중력 크기 적용

    }

}

 

Hand Grab Interactable

 
 
 


 
터널링 방지를 위한 물리 콜라이더 

 
 
물리 메터리얼 

using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PhysicsCollider : MonoBehaviour
{
    private Rigidbody rBody;
    [SerializeField] private Transform target;

    private Vector3 previousPosition;
    private Quaternion previousRotation;

    void Start()
    {
        this.rBody = this.GetComponent<Rigidbody>();
        previousPosition = target.position;
        previousRotation = target.rotation;
    }

    private void FixedUpdate()
    {
        if (target != null)
        {
            // 현재 위치 및 회전을 저장합니다.
            Vector3 currentPosition = target.position;
            Quaternion currentRotation = target.rotation;

            // 이전 위치 및 회전과 현재 위치 및 회전 간의 차이를 계산합니다.
            Vector3 positionDelta = currentPosition - previousPosition;
            Quaternion rotationDelta = currentRotation * Quaternion.Inverse(previousRotation);

            // 이전 위치와 현재 위치 간의 거리를 계산합니다.
            float distance = Vector3.Distance(previousPosition, currentPosition);

            // 거리가 일정 값 이상인 경우에만 보간을 적용합니다.
            if (distance > 0.001f)
            {
                float t = Time.fixedDeltaTime * 100f; // 조절 가능한 보간 계수
                this.rBody.MovePosition(Vector3.Lerp(this.rBody.position, currentPosition, t));
                this.rBody.MoveRotation(Quaternion.Slerp(this.rBody.rotation, currentRotation, t));
            }
            else
            {
                // Rigidbody에 이동과 회전을 적용합니다.
                this.rBody.MovePosition(this.rBody.position + positionDelta);
                this.rBody.MoveRotation(this.rBody.rotation * rotationDelta);
            }

            // 현재 위치 및 회전을 이전 값으로 업데이트합니다.
            previousPosition = currentPosition;
            previousRotation = currentRotation;
        }
    }
}
반응형

'VR > Oculus Integration' 카테고리의 다른 글

Oculus Integration SDK Hand & Materials  (0) 2024.01.03
활시위 당기는 법  (0) 2023.12.22
OneGrabPhysicsJointTransformer  (0) 2023.12.20
Grabbable (Two Grab Transformers)  (0) 2023.12.19
Grabbable  (0) 2023.12.18
:

활시위 당기는 법

VR/Oculus Integration 2023. 12. 22. 13:43
반응형

 https://youtube.com/playlist?list=PLTFRwWXfOIYB9hru6EjeVS0E-4jNiOuQQ&si=zoJ3NoYX6YrGnpg1






 
 
잡기 기본형을 만들어 줍니다

 
 
빈 오브젝트 Bow를 만들어 주고 자식으로 빈오브젝트 Body를 만들어 줍니다.

 
Bow의 위치와 크기를 설정 합니다.

 
 
Body를 선택하고 Rigidbody, Grabbable, One Grab Free Transformer 컴포넌트를 추가 합니다.

 
 
 
Body를 선택하고 빈 오브젝트 Visuals, BowString, Handle를 생성 하고 
HandGrabInteractable 프리팹을 가져옵니다.

 
 
Visuals를 선택하고 Mesh, Collider빈오브젝트를 생성 합니다.

 
Mesh오브젝트를 선택하고 Mesh Filter, Mesh Renderer를 부착 후 Mesh와 Material을 넣어 줍니다.

 
Collider 오브젝트를 선택하고 캡슐 콜라이더를 부착 합니다.

 
 
 
BowString 오브젝트를 선택하고 BowString 스크립트를 만들어 부착 합니다.

 
BowString스크립트는 다음과 같습니다.

using System;
using System.Collections.Generic;
using UnityEngine;
using Oculus.Interaction;

public class BowString : MonoBehaviour
{
    [SerializeField] private LineRenderer lineRenderer;
    [SerializeField] private Transform point1, point2;
    [SerializeField] private Transform midPoint;
    [SerializeField] private ConfigurableJoint joint;
    public InteractableUnityEventWrapper eventWrapper;
    private List<Vector3> linePoints = new List<Vector3>();
    

    private void Start()
    {
        this.eventWrapper.WhenSelect.AddListener(() =>
        {
            Debug.Log("<color=yellow>Selected</color> Handle");
            JointDrive drive = joint.xDrive;
            drive.positionSpring = 0;
            drive.positionDamper = 0;
            joint.xDrive = drive; // xDrive를 수정한 후 다시 할당합니다.
        });

        this.eventWrapper.WhenUnselect.AddListener(() =>
        {
            Debug.Log("<color=yellow>UnSelected</color> Handle");
            JointDrive drive = joint.xDrive;
            drive.positionSpring = 2000;
            drive.positionDamper = 200;
            joint.xDrive = drive; // xDrive를 수정한 후 다시 할당합니다.
        });
    }

    private void FixedUpdate()
    {
        linePoints.Clear();
        linePoints.Add(point1.localPosition);
        var midLocalPosition = transform.InverseTransformPoint(midPoint.position);
        linePoints.Add(midLocalPosition);
        linePoints.Add(point2.localPosition);

        lineRenderer.positionCount = linePoints.Count;
        lineRenderer.SetPositions(linePoints.ToArray());
    }
}

 
 
BowString오브젝트를 선택 하고 
Visuals, Point1, Point2 빈오브젝트를 생성 합니다.
 

 
 
Visuals 오브젝트를 선택하고 LineRenderer 빈 오브젝트를 생성 합니다.

 
LineRenderer를 선택하고 LineRenderer 컴포넌트를 부착 합니다.

 
 
Point1오브젝트를 선택하고 위치를 잡아줍니다.

 

 
 
Point2를 선택하고 위치를 잡아 줍니다.

 
 
 
Handle오브젝트를 선택하고 

 
Rigidbody, Grabbable, ConfigurableJoint, OneGrabTranslateTransformer컴포넌트를 부착 합니다.

 
 
 
Handle오브젝트 자식으로 Sphere를 생성 하고 HandGrabInteractable프리팹을 가져옵니다.

 
 
Sphere 오브젝트를 선택하고 

 
Mesh를 비활성화 합니다.

 
 
HandGrabInteractable오브젝트를 선택하고 

 
Interactable Unity Event Wrapper컴포넌트를 부착 합니다.

 

Bow.fbx
0.08MB
반응형

'VR > Oculus Integration' 카테고리의 다른 글

Oculus Integration SDK Hand & Materials  (0) 2024.01.03
탁구채로 탁구공 튕기기  (0) 2023.12.22
OneGrabPhysicsJointTransformer  (0) 2023.12.20
Grabbable (Two Grab Transformers)  (0) 2023.12.19
Grabbable  (0) 2023.12.18
:

HandGun 장전

VR 2023. 12. 20. 18:27
반응형

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

반응형

'VR' 카테고리의 다른 글

오큘러스 퀘스트 3 컨트롤러 모델  (0) 2024.02.24
Use Custom Hand Model  (0) 2023.12.22
blender 2.8 fbx import error  (0) 2023.12.22
Unity VR Create Snap Interactions  (0) 2023.12.13
:

OneGrabPhysicsJointTransformer

VR/Oculus Integration 2023. 12. 20. 18:02
반응형

https://youtube.com/playlist?list=PLTFRwWXfOIYB9hru6EjeVS0E-4jNiOuQQ&si=zoJ3NoYX6YrGnpg1

Unity VR with Oculus Integration 57.0

Unity VR with Oculus Integration

www.youtube.com



Unity Physics Joints를 통해 Grabbable을 연결합니다. 기본적으로 이는 고정 조인트(FixedJoint)를 사용하지만 사용자 정의 ConfigurableJoint를 사용하도록 설정할 수 있습니다. 이 변환기는 Grabbable이 변형 중에 환경과 계속 충돌(비운동학적)해야 하는 물리적 엔터티이거나 Grabbable 물리 도어의 경우에서 흔히 발생하는 것처럼 물리 조인트를 통해 환경에 연결될 때 유용합니다. 또는 레버. 옵션인 ConfigurableJoint를 사용하면 관련 없는 모션을 Free로 설정하고 사전 처리와 같은 다른 기능을 사용할 수 있습니다. 이는 사용자 정의 동작을 생성하는 데 도움이 되고 가끔 발생하는 물리적 결함을 제거할 수 있습니다. 이 선택적 ConfigurableJoint는 런타임 중에 복사되므로 비활성화된 GameObject에 배치해야 합니다.
 
 

 
One Grab Free일경우 

 
잡은 물체가 바닥을 뚫어 버림 

 
 
 
 
OneGrabPhysicsJointTransformer를 사용해보자 

 
 
막혀서 안내려옴 
 

 

반응형

'VR > Oculus Integration' 카테고리의 다른 글

탁구채로 탁구공 튕기기  (0) 2023.12.22
활시위 당기는 법  (0) 2023.12.22
Grabbable (Two Grab Transformers)  (0) 2023.12.19
Grabbable  (0) 2023.12.18
FingerFeatureStateThresholds  (0) 2023.12.14
:

Grabbable (Two Grab Transformers)

VR/Oculus Integration 2023. 12. 19. 11:21
반응형

 

https://developer.oculus.com/documentation/unity/unity-isdk-grabbable/

 
https://youtube.com/playlist?list=PLTFRwWXfOIYB9hru6EjeVS0E-4jNiOuQQ&si=zoJ3NoYX6YrGnpg1

Unity VR with Oculus Integration 57.0

Unity VR with Oculus Integration

www.youtube.com



 
Grabbable 구성 요소의 Two Grab Transformer 속성에 Two Grab Transformer 구성 요소를 할당해야 합니다.
Two Grab Transformer 구성 요소를 추가하는 경우 One Grab Transformer 속성도 더 이상 자동 생성되지 않으므로 설정해야 합니다.
 
 
 
잡기 기본형을 만들고 다음 3가지 Transformer를 테스트 합니다 
 
기본 잡기가 완성 되었습니다.
 

 
 
 
물리 던지기 까지 설정 해주자 
 

 

 

TwoGrabFreeTransformer

포인팅 가능한 두 대상의 위치 및 회전 변경을 고려하여 Grabbable의 위치, 회전 및 크기를 업데이트합니다(크기에 대한 선택적 제약 조건 포함).
 
먼저 양속 잡기를 설정 하기 위해서는 다음 두개의 프로퍼티에 각각 넣어줘야 한다 

 
 
 
다음과 같이 One Grab Free Transformer컴포넌트와 Two Grab Free Transformer컴포넌트를 부착 하고  

 
 
넣어준다 

 
 
실행후 결과를 확인 한다 

 
 
 
크기를 제약 하고 싶다면 Min Scale과 Max Scale값을 수정하면 된다 

true인 경우 제약 조건은 객체의 초기 크기를 기준으로 합니다.&nbsp;false인 경우 제약 조건은 개체의 x축 배율에 대해 절대적입니다.

 

 


 

TwoGrabRotateTransformer

피벗에 대한 두 개의 포인팅 가능한 대상의 회전 변경을 고려하여 Grabbable의 회전을 업데이트합니다(최소/최대 회전에 대한 선택적 제약 조건 포함).
 
Two Grab Free Transformer 컴포넌트를 제거 하고 Two Grab Rotate Transformer컴포넌트를 부착 한다 

 
Grabbable의 Two Grab Transformer 프로퍼티에 넣어주자 

 
 
Two Grab Rotate Transformer의 Rotation Axis 프로퍼티를 변경해 축을 바꿀수도 있고 Min/Max Angle을 이용해 각을 조절 할수도 있다
 
 

 
 


TwoGrabPlaneTransformer

주어진 평면에 대한 Grabbable의 위치와 배율뿐만 아니라 주어진 축에 대한 회전도 업데이트합니다(위치와 배율에 대한 선택적 제약 조건 포함).
 
이번에는 Two Grab Plane Transformer를 부착 해보고 테스트 해보자 

 
 
위치와 배율
주어진 축에 대한 회전 
에 대한 인터렉션이 되는지 확인 해야 한다 
 
 

 
 
코드를 까보면 다음과 같이 Y 위치를 제약 한다 

 Vector3 targetPosition = _capturePosition;
            // Y axis constraints
            if(_constraints.MinY.Constrain)
            {
                targetPosition.y = Mathf.Max(_constraints.MinY.Value, targetPosition.y);
            }
            if(_constraints.MaxY.Constrain)
            {
                targetPosition.y = Mathf.Min(_constraints.MaxY.Value, targetPosition.y);
            }
            targetTransform.position = targetPosition;

 
 

양손 그랩 Y축 제약

 
 
옵션의 plane transform은 회전의 up 방향이다 

 

 

 

 


 
 
 
참고 
https://developer.oculus.com/documentation/unity/unity-isdk-grabbable/ovrsource-legacy/Doc/mdsourcedc/documentation/unity/unity-isdk-create-hand-grab-interactions/
https://developer.oculus.com/documentation/unity/unity-isdk-grabbable/
 
리소스 링크 
https://skfb.ly/oF7Nu

반응형

'VR > Oculus Integration' 카테고리의 다른 글

활시위 당기는 법  (0) 2023.12.22
OneGrabPhysicsJointTransformer  (0) 2023.12.20
Grabbable  (0) 2023.12.18
FingerFeatureStateThresholds  (0) 2023.12.14
Unity VR Build a Custom Hand Pose (Oculus Integration SDK)  (0) 2023.12.14
: