public static Vector3[] divideWaterCollisionBox(CollisionQuad quad, Int32 divideCount) { // disable optimize if (divideCount == 0) { return(null); } float stepX = 0.0f, stepZ = 0.0f; float stepValueX = (quad.RTFCoordinates.X - quad.LBNCoordinates.X) / divideCount; float stepValueZ = (quad.RTFCoordinates.Z - quad.LBNCoordinates.Z) / divideCount; Vector3[] checkPoints = new Vector3[(2 + divideCount) * (2 + divideCount)]; for (Int32 i = 0; i < checkPoints.Length; i++, stepX += stepValueX) { /*To Do : * true - transition to next row * false - continue work with current row*/ if ((i + 1) % (divideCount + 2) == 0) { stepX = 0; stepZ += stepValueZ; } checkPoints[i] = new Vector3(quad.LBNCoordinates.X + stepX, quad.LBNCoordinates.Y, quad.LBNCoordinates.Z + stepZ); } return(checkPoints); }
public WorldFileManager(RenderManager RenderManager) { Render = RenderManager; RootNode = Render.RootNode; InitGrid(); ChunkSelectorQuad = new CollisionQuad(new Vector3(), new Vector3(), new Vector3(), new Vector3()); }
private void InitPhysics() { Quad = new CollisionQuad(-1.0f, 1.0f, 0.0f, 0.0f, -1.0f, 1.0f); Quad.LBNCoordinates = Vector3.TransformPosition(Quad.LBNCoordinates, m_modelMatrix); Quad.RTFCoordinates = Vector3.TransformPosition(Quad.RTFCoordinates, m_modelMatrix); // divide water collision box to avoid "bugs" with frustum culling m_collisionCheckPoints = FrustumCulling.divideWaterCollisionBox(Quad, m_frustumSquares); }
public void Tick(float deltaTime) { if (CQuad == null) { CQuad = new CollisionQuad(0, 0, 0, 0, 0, 0); } var lbn = Vector4.Transform(m_quadLBZ, Matrix4.CreateTranslation(m_lightSource.Position)); var rtf = Vector4.Transform(m_quadRTZ, Matrix4.CreateTranslation(m_lightSource.Position)); CQuad.synchronizeCoordinates(lbn.X, rtf.X, lbn.Y, rtf.Y, lbn.Z, lbn.Z); }
private void OnDragDrop(object sender, DragEventArgs e) { if (isManual) { Panel obj = ((Panel)e.Data.GetData(typeof(Panel))); obj.Parent = (Panel)sender; Point currPoint = obj.Parent.PointToClient(new Point(e.X, e.Y)); if (!CollisionQuad.IsBoxCollision(obj.Parent.Controls.Cast <Control>(), currPoint)) { obj.Location = currPoint; canvas.Add(obj); } else { obj.Location = prevPoint; } } }
public override void _Ready() { base._Ready(); var collisionQuadA = GetNode <Position3D>("CollisionQuad/A"); var collisionQuadB = GetNode <Position3D>("CollisionQuad/B"); var collisionQuadC = GetNode <Position3D>("CollisionQuad/C"); var collisionQuadD = GetNode <Position3D>("CollisionQuad/D"); MeshInstance = GetNode <MeshInstance>("MeshInstance"); ActiveMaterial = ResourceLoader.Load <SpatialMaterial>("res://Scenes/Materials/SegmentActiveMaterial.tres"); CutTween = GetNode <Tween>("CutTween"); CutParticlesUp = GetNode <Particles>("CutParticlesUp"); CutParticlesDown = GetNode <Particles>("CutParticlesDown"); CutSoundPlayer = GetNode <AudioStreamPlayer>("CutSoundPlayer"); CutSoundTimer = GetNode <Timer>("CutSoundTimer"); CollisionQuad = new CollisionQuad(collisionQuadA, collisionQuadB, collisionQuadC, collisionQuadD); }
public static bool isQuadIntersection(CollisionQuad quad, Matrix4 viewMatrix, Matrix4 projectionMatrix) { Matrix4 viewprojectionMatrix; Matrix4.Mult(ref viewMatrix, ref projectionMatrix, out viewprojectionMatrix); /*Transform vertices to clipped space*/ Vector4 LBZ = Vector4.Transform(new Vector4(quad.LBNCoordinates.X, quad.LBNCoordinates.Y, quad.LBNCoordinates.Z, 1.0f), viewprojectionMatrix); Vector4 RBZ = Vector4.Transform(new Vector4(quad.RTFCoordinates.X, quad.LBNCoordinates.Y, quad.LBNCoordinates.Z, 1.0f), viewprojectionMatrix); Vector4 RTZ = Vector4.Transform(new Vector4(quad.RTFCoordinates.X, quad.RTFCoordinates.Y, quad.LBNCoordinates.Z, 1.0f), viewprojectionMatrix); Vector4 LTZ = Vector4.Transform(new Vector4(quad.LBNCoordinates.X, quad.RTFCoordinates.Y, quad.LBNCoordinates.Z, 1.0f), viewprojectionMatrix); /*Transform vertices to normalized device coordinates*/ Vector4 ndcLBZ = new Vector4(new Vector3(LBZ) / LBZ.W, LBZ.W); Vector4 ndcRBZ = new Vector4(new Vector3(RBZ) / RBZ.W, RBZ.W); Vector4 ndcRTZ = new Vector4(new Vector3(RTZ) / RTZ.W, RTZ.W); Vector4 ndcLTZ = new Vector4(new Vector3(LTZ) / LTZ.W, LTZ.W); /*Check if quad doesn't lie in clipped area*/ if ((ndcLBZ.X > -1.0f && ndcLBZ.X < 1.0f) && (ndcLBZ.Y > -1.0f && ndcLBZ.Y < 1.0f) && (ndcLBZ.Z > -1.0f && ndcLBZ.Z < 1.0f)) { return(true); } if ((ndcRBZ.X > -1.0f && ndcRBZ.X < 1.0f) && (ndcRBZ.Y > -1.0f && ndcRBZ.Y < 1.0f) && (ndcRBZ.Z > -1.0f && ndcRBZ.Z < 1.0f)) { return(true); } if ((ndcRTZ.X > -1.0f && ndcRTZ.X < 1.0f) && (ndcRTZ.Y > -1.0f && ndcRTZ.Y < 1.0f) && (ndcRTZ.Z > -1.0f && ndcRTZ.Z < 1.0f)) { return(true); } if ((ndcLTZ.X > -1.0f && ndcLTZ.X < 1.0f) && (ndcLTZ.Y > -1.0f && ndcLTZ.Y < 1.0f) && (ndcLTZ.Z > -1.0f && ndcLTZ.Z < 1.0f)) { return(true); } return(false); }