public override bool Update() { Vec3f pos, fwd, right, up; m_Camera.GetBasis(out pos, out fwd, out right, out up); if (CurrentMove[0] != 0) { Vec3f dir = right; dir.Mul((float)CurrentMove[0]); m_Position.x += dir.x * CurrentSpeed; m_Position.y += dir.y * CurrentSpeed; m_Position.z += dir.z * CurrentSpeed; } if (CurrentMove[1] != 0) { Vec3f dir = new Vec3f(0.0f, 1.0f, 0.0f); //dir = up; dir.Mul((float)CurrentMove[1]); m_Position.x += dir.x * CurrentSpeed; m_Position.y += dir.y * CurrentSpeed; m_Position.z += dir.z * CurrentSpeed; } if (CurrentMove[2] != 0) { Vec3f dir = fwd; dir.Mul((float)CurrentMove[2]); m_Position.x += dir.x * CurrentSpeed; m_Position.y += dir.y * CurrentSpeed; m_Position.z += dir.z * CurrentSpeed; } if (CurrentMove[0] != 0 || CurrentMove[1] != 0 || CurrentMove[2] != 0) { Camera.SetPosition(m_Position); return(true); } return(false); }
public override void Update() { if (CurrentMove[0] != 0) { Vec3f dir = m_Camera.Right; dir.Mul((float)CurrentMove[0]); m_Position.x += dir.x * CurrentSpeed; m_Position.y += dir.y * CurrentSpeed; m_Position.z += dir.z * CurrentSpeed; m_Dirty = true; } if (CurrentMove[1] != 0) { Vec3f dir = new Vec3f(0.0f, 1.0f, 0.0f); //dir = m_Camera.GetUp(); dir.Mul((float)CurrentMove[1]); m_Position.x += dir.x * CurrentSpeed; m_Position.y += dir.y * CurrentSpeed; m_Position.z += dir.z * CurrentSpeed; m_Dirty = true; } if (CurrentMove[2] != 0) { Vec3f dir = m_Camera.Forward; dir.Mul((float)CurrentMove[2]); m_Position.x += dir.x * CurrentSpeed; m_Position.y += dir.y * CurrentSpeed; m_Position.z += dir.z * CurrentSpeed; m_Dirty = true; } }
public void InitQuads() { quadTilesRef?.Dispose(); float height = 200; MeshData mesh = new MeshData(4, 6, false, true, true, false); mesh.CustomFloats = new CustomMeshDataPartFloat(4); mesh.CustomFloats.InterleaveStride = 4; mesh.CustomFloats.InterleaveOffsets = new int[] { 0 }; mesh.CustomFloats.InterleaveSizes = new int[] { 1 }; float x, y, z; Random rnd = new Random(); float resolution = 1.5f; float spread = 1.5f; float parts = 20 * resolution; float advance = 1f / resolution; for (int i = 0; i < 15; i++) { Vec3f dir = new Vec3f((float)rnd.NextDouble() * 20 - 10, (float)rnd.NextDouble() * 5 - 3, (float)rnd.NextDouble() * 20 - 10); dir.Normalize(); dir.Mul(advance); x = spread * ((float)rnd.NextDouble() * 800 - 400); y = spread * ((float)rnd.NextDouble() * 80 - 40); z = spread * ((float)rnd.NextDouble() * 800 - 400); for (int j = 0; j < parts + 2; j++) { float lngx = (float)rnd.NextDouble() * 5 + 20; float lngy = (float)rnd.NextDouble() * 4 + 4; float lngz = (float)rnd.NextDouble() * 5 + 20; x += dir.X * lngx; y += dir.Y * lngy; z += dir.Z * lngz; int lastelement = mesh.VerticesCount; mesh.AddVertex(x, y + height, z, j % 2, 1); mesh.AddVertex(x, y, z, j % 2, 0); float f = j / (parts - 1); mesh.CustomFloats.Add(f, f); if (j > 0 && j < (parts - 1)) { mesh.AddIndex(lastelement + 1); mesh.AddIndex(lastelement + 3); mesh.AddIndex(lastelement + 2); mesh.AddIndex(lastelement + 0); mesh.AddIndex(lastelement + 1); mesh.AddIndex(lastelement + 2); } } } quadTilesRef = capi.Render.UploadMesh(mesh); }