public override void Init() { depthFBO = new FBO(0, 0, 1, true); ShadowMapping.Create(depthFBO, "lightmask.png"); Fog.CreateFog(0.005f, Fog.Color); GLSLShader.SetShader("default.shader", "FOG"); skybox = Sky.Load("sky/sky2_", "jpg"); world.Add(skybox); GLSLShader.SetShader("default.shader", "LIGHTING:PERPIXEL:FOG"); Model scene = new Model(); DotScene ds = DotScene.Load("scene1/scene1.scene", scene); world.Add(scene); camPath = Path.GetPath("Path_camera"); camPath.Attach(camera, true, true); font = BitmapFont.Load("fonts/comic12.png"); Camera.Set3D(); base.Init(); }
/// <summary> /// tarkista osuuko start->end vektori johonkin polyyn. /// palauttaa true jos osuu, muuten false. /// /// ei toimi jos modelia käännetty tai skaalattu. /// </summary> public static bool CheckIntersection(ref Vector3 start, ref Vector3 end, ref Model obj) { Vector3 position = obj.Position; Vector3 dir = end - start; float len = dir.Length + DistAdder; dir.Normalize(); Vector3[] v = new Vector3[3]; for (int e = 0; e < obj.VertexBuffer.Length; e += 3) { v[0] = obj.VertexBuffer[e].Position; v[1] = obj.VertexBuffer[e + 1].Position; v[2] = obj.VertexBuffer[e + 2].Position; v[0] += position; v[1] += position; v[2] += position; if (IntersectTriangle(ref start, ref dir, ref v[0], ref v[1], ref v[2]) == true) { if (Math.Abs(T) > len) continue; return true; } } return false; }
public void CreateBoundingVolume(Model mesh, Vector3 min, Vector3 max) { Min = min; Max = max; Vector3 dist = Max - Min; R = dist.Length; mesh.ObjCenter = Min + (dist / 2); // objektin keskikohta }
public void CreateBoundingVolume(Model mesh) { for (int q = 0; q < mesh.VertexBuffer.Length; q++) { if (mesh.VertexBuffer[q].Position.X < Min.X) Min.X = mesh.VertexBuffer[q].Position.X; if (mesh.VertexBuffer[q].Position.Y < Min.Y) Min.Y = mesh.VertexBuffer[q].Position.Y; if (mesh.VertexBuffer[q].Position.Z < Min.Z) Min.Z = mesh.VertexBuffer[q].Position.Z; if (mesh.VertexBuffer[q].Position.X > Max.X) Max.X = mesh.VertexBuffer[q].Position.X; if (mesh.VertexBuffer[q].Position.Y > Max.Y) Max.Y = mesh.VertexBuffer[q].Position.Y; if (mesh.VertexBuffer[q].Position.Z > Max.Z) Max.Z = mesh.VertexBuffer[q].Position.Z; } Vector3 dist = Max - Min; R = dist.Length; mesh.ObjCenter = Min + (dist / 2); // objektin keskikohta }
public SortedList_Model(float len, Model model) { Len = len; this.model = model; }
/// <summary> /// käydään path läpi, joka vertexin kohdalla (xz) etsitään y ja lisätään siihen yp. /// </summary> /// <param name="yp"></param> /// <param name="obj"></param> public void FixPathY(int yp, ref Model obj) { Vector3 start, end; for (int q = 0; q < path.Count; q++) { start = path[q]; end = path[q]; end.Y = -1000; // vektorin toinen pää kaukana alhaalla if (Intersection.CheckIntersection(ref start, ref end, ref obj)) { Vector3 nv = new Vector3(path[q].X, Intersection.IntersectionPoint.Y + yp, path[q].Z); path.Remove(path[q]); path.Insert(q, nv); } } }