资源简介
unity3d的2d光影插件
unity3d的2d光影插件
unity3d的2d光影插件

代码片段和文件信息
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
namespace LOS {
///
/// LOS camera.
/// Needs to be placed in a camera for the system to work.
///
[RequireComponent (typeof(Camera))]
public class LOSCamera : LOSobjectbase {
[HideInInspector]
public Vector2 halfViewboxSize;
private List _viewbox;
private Camera _camera;
public List viewbox {
get {
if (_viewbox == null) {
_viewbox = new List();
for (int i=0; i<4; i++) {
_viewbox.Add(new ViewBoxLine());
}
UpdateViewingBox();
}
return _viewbox;
}
}
public List viewboxCorners {
get {
List result = new List();
foreach (var line in viewbox) {
result.Add(line.end);
}
return result;
}
}
public void UpdateViewingBox () {
Vector2 screenSize = SHelper.GetScreenSizeInWorld(unityCamera);
halfViewboxSize = screenSize / 2 * LOSManager.instance.viewboxExtension;
Vector2 upperRight = new Vector2(halfViewboxSize.x halfViewboxSize.y) + SMath.Vec3ToVec2(_trans.position);
Vector2 upperLeft = new Vector2(-halfViewboxSize.x halfViewboxSize.y) + SMath.Vec3ToVec2(_trans.position);
Vector2 lowerLeft = new Vector2(-halfViewboxSize.x -halfViewboxSize.y) + SMath.Vec3ToVec2(_trans.position);
Vector2 lowerRight = new Vector2(halfViewboxSize.x -halfViewboxSize.y) + SMath.Vec3ToVec2(_trans.position);
viewbox[0].SetStartEnd(lowerRight upperRight); // right
viewbox[1].SetStartEnd(upperRight upperLeft); // up
viewbox[2].SetStartEnd(upperLeft lowerLeft); // left
viewbox[3].SetStartEnd(lowerLeft lowerRight); // down
}
public Camera unityCamera {
get {
if (_camera == null) {
_camera = GetComponent();
}
return _camera;
}
}
public Vector3 GetCollisionPointWithViewBox (Vector3 origin Vector3 direction) {
Vector3 point = Vector3.zero;
foreach (var line in viewbox) {
Vector2 q = line.start;
Vector2 s = line.end - line.start;
Vector2 p = SMath.Vec3ToVec2(origin);
Vector2 r = SMath.Vec3ToVec2(direction);
// The intersection is where q + u*s == p + t*r and 0 <= u <= 1 && 0 <= t
// t = (q − p) × s / (r × s)
// u = (q − p) × r / (r × s)
float crossRS = SMath.CrossProduct2D(r s);
float crossQP_S = SMath.CrossProduct2D(q - p s);
float crossQP_R = SMath.CrossProduct2D(q - p r);
if (crossRS == 0) {
// TODO: other situations
}
else {
float t = crossQP_S / crossRS;
float u = crossQP_R / crossRS;
if (0 <= u && u <= 1 && 0 <= t) {
point = q + u * s;
break;
}
}
}
return point;
}
// Works in counter-clock wise pointA is the one with smaller angle against vector (1 0)
public List GetViewboxCornersBetweenPoints (Vector3 pointA Vector3 pointB Vector3 origin bool give4CornersWhenAEqualB) {
poin
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2015-06-18 12:09 2D-Light-of-Sight-Unity-master\
文件 107 2015-06-18 12:09 2D-Light-of-Sight-Unity-master\Core.me
目录 0 2015-06-18 12:09 2D-Light-of-Sight-Unity-master\Core\
文件 107 2015-06-18 12:09 2D-Light-of-Sight-Unity-master\Core\Event.me
目录 0 2015-06-18 12:09 2D-Light-of-Sight-Unity-master\Core\Event\
文件 2571 2015-06-18 12:09 2D-Light-of-Sight-Unity-master\Core\Event\LOSEventManager.cs
文件 178 2015-06-18 12:09 2D-Light-of-Sight-Unity-master\Core\Event\LOSEventManager.cs.me
文件 3586 2015-06-18 12:09 2D-Light-of-Sight-Unity-master\Core\Event\LOSEventSource.cs
文件 178 2015-06-18 12:09 2D-Light-of-Sight-Unity-master\Core\Event\LOSEventSource.cs.me
文件 2015 2015-06-18 12:09 2D-Light-of-Sight-Unity-master\Core\Event\LOSEventTrigger.cs
文件 178 2015-06-18 12:09 2D-Light-of-Sight-Unity-master\Core\Event\LOSEventTrigger.cs.me
文件 4879 2015-06-18 12:09 2D-Light-of-Sight-Unity-master\Core\LOSCamera.cs
文件 178 2015-06-18 12:09 2D-Light-of-Sight-Unity-master\Core\LOSCamera.cs.me
文件 20743 2015-06-18 12:09 2D-Light-of-Sight-Unity-master\Core\LOSFullScreenLight.cs
文件 178 2015-06-18 12:09 2D-Light-of-Sight-Unity-master\Core\LOSFullScreenLight.cs.me
文件 11749 2015-06-18 12:09 2D-Light-of-Sight-Unity-master\Core\LOSLightba
文件 178 2015-06-18 12:09 2D-Light-of-Sight-Unity-master\Core\LOSLightba
文件 5532 2015-06-18 12:09 2D-Light-of-Sight-Unity-master\Core\LOSManager.cs
文件 178 2015-06-18 12:09 2D-Light-of-Sight-Unity-master\Core\LOSManager.cs.me
文件 882 2015-06-18 12:09 2D-Light-of-Sight-Unity-master\Core\LOSob
文件 178 2015-06-18 12:09 2D-Light-of-Sight-Unity-master\Core\LOSob
文件 1369 2015-06-18 12:09 2D-Light-of-Sight-Unity-master\Core\LOSObstacle.cs
文件 178 2015-06-18 12:09 2D-Light-of-Sight-Unity-master\Core\LOSObstacle.cs.me
文件 7345 2015-06-18 12:09 2D-Light-of-Sight-Unity-master\Core\LOSRadialLight.cs
文件 178 2015-06-18 12:09 2D-Light-of-Sight-Unity-master\Core\LOSRadialLight.cs.me
文件 107 2015-06-18 12:09 2D-Light-of-Sight-Unity-master\Editor.me
目录 0 2015-06-18 12:09 2D-Light-of-Sight-Unity-master\Editor\
文件 942 2015-06-18 12:09 2D-Light-of-Sight-Unity-master\Editor\LOSFullScreenLightEditor.cs
文件 178 2015-06-18 12:09 2D-Light-of-Sight-Unity-master\Editor\LOSFullScreenLightEditor.cs.me
文件 2011 2015-06-18 12:09 2D-Light-of-Sight-Unity-master\Editor\LOSLightba
文件 178 2015-06-18 12:09 2D-Light-of-Sight-Unity-master\Editor\LOSLightba
............此处省略103个文件信息
相关资源
- Unity3D登录界面工程
- unity3d反编译工具
-
UnityWebPla
yerFull - Unity纪念碑谷.rar
- Unity3d实现扭动挤压浏览效果
- unity案例入门坦克大战源码
- Unity3D游戏开发.pdf 宣雨松著完整高清
- Unity3D版水果忍者
- unity3d爆炸特效包
- unity3d_见缝插针源码及报告.zip
- Unity3d车库场景模型
- unity3d 警察动画模型
- unity3D 新手引导遮罩,支持圆形和矩形
- unity3d枪支武器包FPS第一人称射击游戏
- unity3d制作贪吃蛇
- unity3D暴力街区射击大战游戏源码
- Unity3D 实战视频教程 保卫萝卜 2D 游戏
- unity3d调用中央气象局城市天气数据,
- Unity 3D Paint in 3D (1.7.3)
- 2014年最新最好的Unity3d圣典之中文脚本
- Unity3D搓牌效果支持4个方向
- Unity3D课程设计 模拟火焰效果
- 贝塞尔曲线的unity3d实现
- [资源插件]Unity3D_UGUI HUD Text v1.4.1.zip
- ShaderlabVSCode 1.1.6.unitypackage
- Camera Path Animator unity3d 插件
- Unity录屏模块封装清晰的可调AVPro Mo
- FBX格式人物模型,资源齐全,带动画
- Unity3D 3D炸弹超人Demo
- unity3d坐标轴插件
评论
共有 条评论