- Edited
using Godot;
using NuGet.Configuration;
using System;
public partial class SquareFloor : Node3D
{
Camera3D Cam;
Vector3 PlaneNormal;
//float PlaneDistance;
Godot.Collections.Array<Plane> Vectorfrust;
ImmediateMesh DrawMesh;
MeshInstance3D MeshSet;
Vector3? IntersectionPoint;
// Called when the node enters the scene tree for the first time.
public override void _Ready()
{
Cam = GetNode<Camera3D>("Camera3D");
MeshSet = new MeshInstance3D();
AddChild(MeshSet);
DrawMesh = new ImmediateMesh();
//MeshSet.Mesh = DrawMesh;
}
// Called every frame. 'delta' is the elapsed time since the previous frame.
public override void _Process(double delta)
{
if (DrawMesh.GetSurfaceCount() < 250)
{
DrawPlane ();
}
}
private void DrawPlane ()
{
Vectorfrust = Cam.GetFrustum();
//DrawMesh.ClearSurfaces();
DrawMesh.SurfaceBegin(Mesh.PrimitiveType.Lines);
foreach (Plane plane in Vectorfrust)
{
PlaneNormal = plane.Normal;
//PlaneDistance = plane.D;
//IntersectionPoint = plane.IntersectsSegment(Vector3.Zero, PlaneNormal);
IntersectionPointControl(plane, Vector3.Zero, PlaneNormal);
IntersectionPointControl(plane, Vector3.Right, PlaneNormal);
}
DrawMesh.SurfaceSetColor(Color.FromHtml("#d4191e"));
DrawMesh.SurfaceEnd();
MeshSet.Mesh = DrawMesh;
}
private void IntersectionPointControl (Plane plane, Vector3 vec3, Vector3 plnrml)
{
IntersectionPoint = plane.IntersectsSegment(vec3, plnrml);
if (IntersectionPoint != null)
{
DrawMesh.SurfaceAddVertex((Vector3) IntersectionPoint);
}
}
}
why drawings do not appear on the screen where is my fault?