【问题标题】:What is the size limit of the gameobjects?游戏对象的大小限制是多少?
【发布时间】:2019-08-26 08:36:10
【问题描述】:

我正在使用 unity 和 Mapbox 构建 AR 应用程序。我有一点要代表一座建筑物。我可以通过 Mapbox 对点进行地理定位。我想到处看到这个物体。所以,我根据距离改变物体的大小。

首先,代码正在运行。但是,我看不到那个点真的很远,有 5 公里。

// Update is called once per frame
void Update()
{
    // Get user location
    // Latitude
    x = getLocation.x1.ToString();
    user_lat = Convert.ToDouble(x);
    user_lat_rad = Math.PI * user_lat / 180.0; // Radian
    // Longitude
    y = getLocation.y1.ToString();
    user_lon = Convert.ToDouble(y);
    user_lon_rad = Math.PI * user_lon / 180.0; // Radian
    // Change POIs sizes
    distances = distance(user_lat_rad, user_lon_rad);
    double s = 0.3; // size of the poi
    double d = 50f; // specific distance to point (reference distance)
    double size = (distances * s) / d;
    float size2 = Convert.ToSingle(size);
    temp = transform.localScale;
    temp.x = size2;
    temp.y = size2;
    temp.z = size2;
    transform.localScale = temp;
}
public double distance(double lat2, double lon2)
{
    // Haversine Formula
    // Lat2,Lon2 = User Location
    // Lat1,Lon1 = POI Location
    double dist1 = Sqrt((Pow(Sin((lat2 - lat1) / 2), 2)) + Cos(lat2) * Cos(lat2) * (Pow(Sin((lon2 - lon1) / 2), 2)));
    double distance = 2 * r * Asin(dist1);
    return distance;
}

为什么即使物体大小发生变化,我也看不到远处的点?这有什么限制吗?

【问题讨论】:

标签: unity3d mapbox augmented-reality


【解决方案1】:

正如 cmets 中所说,问题很可能是 Camera's farClipPlane 的值太小。

将发生绘图的相对于相机的最远点。

任何远离Camera 的对象/三角形都不会被渲染。


在 Inspector 中,它在 Camera 组件上配置 → Clipping Planes → Far

或使用代码

cameraReference.farClipPlane = XYZ;

【讨论】:

    猜你喜欢
    • 2014-12-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-09-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多