资源简介
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内置Shader源码与详解解释文档
- Unity3D《最后一战》全套完整源代码
-
unity3d读取xm
l插件Mono.xm l - Unity3d背包物品拖拽
- 无限滚动TableView
- Unity3D使用socket通讯源码
- 塔防游戏源码
- Unity3D插件-- LitJson.dll
- 2018unity3d 特效资源包大合集
- Unity3D读取Excel工具
- unity3d RPG游戏《外星人》完整
- unity3d实现的弹幕功能
- Unity3D中Blendshapes之间的过渡方式
- unity3D手机游戏开发光盘链接
- Unity3d SGIzmo
- unity3d 云特效
- Unity3D 温度图、热点图
- BloodSlider
- Unity下调用摄像头识别二维码
- Unity路径插件
- UGUI画图脚本RadarChart.unitypackage
- SplineBend物体弯曲调节工具
- Unity3d适配
- 2017unity3d 特效资源包大合集
- 网易TA笔试题整理不全 (1).txt
- 由unity3d开发的《最后一战》手游全套
- unity3D5.x 游戏开发技术详解与典型案例
- unity3d要求的ndkr19 19.0.19.0.5232133
- unity3D卡通女战士精细人物角色模型带
- Unity3D5.x入门到精通资源.txt
评论
共有 条评论