Место общения программистов C#
-
Anonymous
Странная деформация при изменении Vector3 вершин сетки.
Сообщение
Anonymous »
У меня странная ситуация, когда я пытаюсь деформировать какую-то сетку.
У меня есть сцена с двумя объектами - нижний меньший цилиндр (деформатор) и верхний больший цилиндр ( деформируемый).
Оба объекта имеют скрипты C#:
Код: Выделить всё
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public class deformer : MonoBehaviour
{
bool clicked = false;
public float speed = 2f;
public Mesh mesh;
public Vector3[] verts;
public float maxDistance;
public GameObject explosion;
void Start ()
{
mesh = this.GetComponent ().mesh;
verts = mesh.vertices;
this.GetComponent ().mesh = mesh;
}
void OnCollisionEnter (Collision other)
{
Debug.Log ("Collided with " + other.gameObject.name);
if (other.gameObject.GetComponent () != null) {
Vector3 colPosition = transform.InverseTransformPoint (other.contacts [0].point);
movePoints (other.gameObject);
}
}
public void movePoints (GameObject other)
{
print ("entering movePoints");
Vector3[] otherVerts = other.GetComponent ().verts;
float distance;
for (int i=0; i
Подробнее здесь: [url]https://stackoverflow.com/questions/30076691/strange-deformation-when-changing-vector3-of-the-mesh-vertices[/url]
1730311919
Anonymous
У меня странная ситуация, когда я пытаюсь деформировать какую-то сетку.
У меня есть сцена с двумя объектами - нижний меньший цилиндр (деформатор) и верхний больший цилиндр ( деформируемый).
Оба объекта имеют скрипты C#:
[code]using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public class deformer : MonoBehaviour
{
bool clicked = false;
public float speed = 2f;
public Mesh mesh;
public Vector3[] verts;
public float maxDistance;
public GameObject explosion;
void Start ()
{
mesh = this.GetComponent ().mesh;
verts = mesh.vertices;
this.GetComponent ().mesh = mesh;
}
void OnCollisionEnter (Collision other)
{
Debug.Log ("Collided with " + other.gameObject.name);
if (other.gameObject.GetComponent () != null) {
Vector3 colPosition = transform.InverseTransformPoint (other.contacts [0].point);
movePoints (other.gameObject);
}
}
public void movePoints (GameObject other)
{
print ("entering movePoints");
Vector3[] otherVerts = other.GetComponent ().verts;
float distance;
for (int i=0; i
Подробнее здесь: [url]https://stackoverflow.com/questions/30076691/strange-deformation-when-changing-vector3-of-the-mesh-vertices[/url]