Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Occlusion.ConvexPolygon CreatePolygonFor(VoxelDungeon.Corridor corridor, VoxelDungeon.Corridor.PositionNode pathNode)
- {
- Vector3 pos = new Vector3(pathNode.position.x, mapData.config.groundPlaneHeight, pathNode.position.y) - Vector3.one;
- float h = corridor.height+2;
- int width = corridor.width;
- int wStart = width / 2;
- int wEnd = width - wStart;
- Quaternion rot;
- if(MapData.IsHorizontalFromTop(pathNode.direction)) rot=Quaternion.LookRotation(new Vector3(1,0,0), Vector3.up);
- else rot=Quaternion.LookRotation(new Vector3(0,0,1), Vector3.up);
- var polygon = new Occlusion.ConvexPolygon();
- polygon.points.Add(rot * new Vector3(-wStart, h, 0) + pos);
- polygon.points.Add(rot * new Vector3(wEnd, h, 0) + pos);
- polygon.points.Add(rot * new Vector3(wEnd, 0, 0) + pos);
- polygon.points.Add(rot * new Vector3(-wStart, 0, 0) + pos);
- return polygon;
- }
- void Update()
- {
- if (!isGenerated) return;
- Camera cam = manager.camera.current;
- Vector3 poi = cam.transform.position;// manager.actor.player.position;
- Int3 poii = WorldToLocal(poi);
- VoxelDungeon.OwnerNode owner = null;
- for (int i = 0; i < 8 && owner == null; i++)
- {
- owner = mapData.GetOwnerAt(
- poii.x + tilesOffsets[i, 0],
- poii.y + tilesOffsets[i, 1],
- poii.z + tilesOffsets[i, 2]
- );
- }
- if (owner == null) return;
- NodeData node;
- if (!voxelMapNodeToContainer.TryGetValue(owner, out node)) return;
- node.occlusionArea.StartPropagate(cam);
- }
Advertisement
Add Comment
Please, Sign In to add comment