Beispiel #1
0
        // MESH & FRAMES

        public void UpdateChunk(Frame frame, RoadModulator modulator)
        {
            ClearObstacles();

            transform.position = frame.Position;
            transform.rotation = frame.Rotation;

            UpdateMesh(0, frame);
            Vector3 pos = frame.Position;

            for (int z = 1; z <= Length; z++)
            {
                frame.Advance(modulator.GetRotation(frame.Index));
                UpdateMesh(z, frame);

                frames[z - 1] = new Frame(pos, frame.Rotation, frame.Index - 1);
                pos           = frame.Position;
            }
            // Same position as next chunk's first frame.
            frames[Length] = frame.Copy();

            chunkFrame = new Frame(transform.position, Quaternion.LookRotation(
                                       frame.Position - transform.position,
                                       (frame.Up + transform.up) * 0.5f));

            mesh.vertices = vertices;
            mesh.normals  = normals;
            mesh.RecalculateBounds();
            mf.sharedMesh = mesh;
            mc.sharedMesh = mesh;
        }
Beispiel #2
0
        public void OnReset()
        {
            ClearChunks();
            ClearObstacles();

            frame     = new Frame(transform);
            modulator = new RoadModulator();

            agentFrameIndex = 0;
            AgentFrame      = frame;

            latestChunkIndex = 0;
            for (int i = 0; i < numChunks; i++)
            {
                AddChunk();
            }

            agentChunkIndex = 0;
            agentChunk      = activeChunks[0];
        }