LibGDX를 사용하고 있는데 두 Vector3s 사이를 lerp하려고합니다. 그러나 이렇게하면 선형이 아니며 기하 급수적으로 쉽게 줄 수 있습니다. 나는 이것을 원하지 않는다, 나는 그것을 순수하게 선형으로 원한다!LibGDX Vector3 Lerp 문제
내 모델이 경로를 따르는 것처럼 Vector3s를 따라갈 수 있습니다.
내 업데이트 방법의 코드는 여기에 있습니다 :
public void update(float delta) {
if (!this.pathQueue.isEmpty() && this.currentDestination == null) {
this.currentDestination = this.pathQueue.poll();
this.alpha = 0;
}
Vector3 position = new Vector3();
position = this.model.transform.getTranslation(position);
if (this.currentDestination != null) {
this.alpha += this.speed * delta;
if (this.alpha >= 1) {
this.currentDestination = this.pathQueue.poll();
this.alpha = 0;
}
System.out.println(alpha);
//position.interpolate(this.currentDestination.getPosition(), this.alpha, Interpolation.linear);
position.lerp(this.currentDestination.getPosition(), this.alpha);
//I have tried interpolate and lerp, same effect.
this.model.transform.setTranslation(position.x, 0, position.z);
}
}
감사합니다!
는편집 :
내가 더 간단한 문제가 내 코드를 변경하고, 고정 새로운 Vector3 (5,0,5) 벡터를 사용했습니다는 :
public void update(float delta) {
if (!this.pathQueue.isEmpty() && this.currentDestination == null) {
this.currentDestination = this.pathQueue.poll();
this.alpha = 0;
}
if (this.currentDestination != null) {
this.alpha += this.speed * delta;
this.currentPosition.lerp(new Vector3(5,0,5), this.alpha);
this.model.transform.setTranslation(this.currentPosition.x, 0, this.currentPosition.z);
}
}
아직 문제가 발생합니다. 같은 일이 일어난다! 나는 너무 비웃었다.
네가 옳다. 나는 또한 이것과 비슷한 것으로 생각한다. 그러나 내가 이렇게하더라도 : Vector3 newPosition = this.previousDestination.lerp (this.currentDestination.getPosition(), this.alpha); \t \t \t this.model.transform.setTranslation (newPosition.x, 0, newPosition.z); 작동하지 않습니다. lerp가 호출 될 때마다 this.previousDestination이 업데이트되는 것 같습니다. 정상적인 동작 일 수 있습니까? – Dolan
나는 previousDestination을 수정한다고 생각합니다. 이전 목적지를 복사하거나 복제해야 할 수도 있습니다 (아마?). println()에서 현재/이전/위치를 인쇄하여 이들 중 어느 것이 변경되고 있는지 확인하십시오. –
더 간단한 버전의 문제에 대한 제 질문을 편집했습니다. 그것의 6am 지금, 아픈이 내일과 함께 계속 – Dolan