public void CalcCoordinates(int index, CharacterCoord[] data) { SplineData spline = new SplineData(); for (int i = 0; i < data.Length; ++i) { int p = index - PLOT_NUM - i + 1; if (p < m_plotIndex) { m_culling.Add(data[i]); } } // 최신 좌표를 설정. m_plotIndex = index; // 스플라인 곡선을 구해서 보간합니다. spline.CalcSpline(m_culling, CULLING_NUM); // 구한 스플라인 보간을 좌표 정보로서 저장합니다. CharacterCoord plot = new CharacterCoord(); for (int i = 0; i < spline.GetPlotNum(); ++i) { spline.GetPoint(i, out plot); m_plots.Add(plot); } // 가장 오래된 좌표를 삭제. if (m_culling.Count > PLOT_NUM) { m_culling.RemoveAt(0); } }
// Find the closest spline vertex id and position void FindNearestVertex(SplineData spline, int vertex_id, out float vertex_position, out float vertex_distance) { // If we don't have a spline, skip this vertex_position = 0.0f; vertex_distance = 0.0f; if (spline == null) return; // Get the vertex end-points Vector3 v0 = spline.transform.TransformPoint (spline.vertexes[vertex_id]); Vector3 v1 = spline.transform.TransformPoint (spline.vertexes[vertex_id+1]); // Find the closest point to the vertex segement // // TODO: Make this actually calculate closest point on the spline! // Is it possible? float seg_len_sq = (v1 - v0).sqrMagnitude; vertex_position = Vector3.Dot (transform.position - v0, v1 - v0) / seg_len_sq; // Get the distance to the vertex if (vertex_position < 0.0f) { vertex_distance = Vector3.Distance(transform.position, v0); } else if (vertex_position > 1.0f) { vertex_distance = Vector3.Distance(transform.position, v1); } else { vertex_distance = Vector3.Distance(transform.position, v0 + (v1 - v0) * vertex_position); } }
// ================================================================ // public void ReceivePointFromNet(Vector3 point) { CharacterCoord coord; coord.x = point.x; coord.z = point.z; m_culling.Add(coord); SplineData spline = new SplineData(); spline.CalcSpline(m_culling, 4); m_plots.Clear(); if (spline.GetPlotNum() > 0) { for (int i = 0; i < spline.GetPlotNum(); i++) { CharacterCoord plot; spline.GetPoint(i, out plot); m_plots.Add(plot); } } }
public void CalcCoordinates(int index, CharacterCoord[] data) { // 수신한 좌표를 보존. do { // 데이터가 텅빔(만일을 위해). if (data.Length <= 0) { break; } // 새로운 데이터가 없다. if (index <= m_plotIndex) { break; } // m_plotIndex ... m_culling[]의 마지막 정점 인덱스. // index ... data[]의 마지막 정점의 인덱스. // // index - m_plotIndex ... 이번에 새로 추가된 정점의 수. // int s = data.Length - (index - m_plotIndex); if (s < 0) { break; } for (int i = s; i < data.Length; i++) { m_culling.Add(data[i]); } // m_culling[]의 마지막 정점 인덱스. m_plotIndex = index; // 스플라인 곡선을 구해서 보간한다. SplineData spline = new SplineData(); spline.CalcSpline(m_culling); // 구한 스플라인 보간을 좌표 정보로서 보존한다. CharacterCoord plot = new CharacterCoord(); for (int i = 0; i < spline.GetPlotNum(); ++i) { spline.GetPoint(i, out plot); m_plots.Add(plot); } // 가장 오래된 좌표를 삭제. if (m_culling.Count > PLOT_NUM) { m_culling.RemoveRange(0, m_culling.Count - PLOT_NUM); } } while(false); }
public void CalcCoordinates(int index, CharacterCoord[] data) { // ?섏떊??醫뚰몴瑜?蹂댁〈. do { // ?곗씠?곌? ?낅퉼(留뚯씪???꾪빐). if (data.Length <= 0) { break; } // ?덈줈???곗씠?곌? ?녿떎. if (index <= m_plotIndex) { break; } // m_plotIndex ... m_culling[]??留덉?留??뺤젏 ?몃뜳?? // index ... data[]??留덉?留??뺤젏???몃뜳?? // // index - m_plotIndex ... ?대쾲???덈줈 異붽????뺤젏???? // int s = data.Length - (index - m_plotIndex); if (s < 0) { break; } for (int i = s; i < data.Length; i++) { m_culling.Add(data[i]); } // m_culling[]??留덉?留??뺤젏 ?몃뜳?? m_plotIndex = index; // ?ㅽ뵆?쇱씤 怨≪꽑??援ы빐??蹂닿컙?쒕떎. SplineData spline = new SplineData(); spline.CalcSpline(m_culling); // 援ы븳 ?ㅽ뵆?쇱씤 蹂닿컙??醫뚰몴 ?뺣낫濡쒖꽌 蹂댁〈?쒕떎. CharacterCoord plot = new CharacterCoord(); for (int i = 0; i < spline.GetPlotNum(); ++i) { spline.GetPoint(i, out plot); m_plots.Add(plot); } // 媛???ㅻ옒??醫뚰몴瑜???젣. if (m_culling.Count > PLOT_NUM) { m_culling.RemoveRange(0, m_culling.Count - PLOT_NUM); } } while(false); }
public SplineData GetData(float d) { float alpha = d / curveLength; SplineData data = new SplineData(); data.Position = GetPoint(alpha); data.Tangent = GetTangent(alpha); data.Normal = GetNormal(alpha, Vector3.up); return(data); }
public CreatureStateBody(string typeName, UnityEngine.GameObject parent) { creatureStateBodyPhysics = new CreatureStateBodyPhysics(); creatureStateBodyVisual = new CreatureStateBodyVisual(); var jsonNode = Bootstrap.GetDataStore().staticData.GetNode("creatures")[typeName]; //creatures if (null == jsonNode) { Bootstrap.Warn("creature not found:" + typeName, parent); return; } height = jsonNode["height"].AsFloat; //height = 0.5f; { var jsonBodyDataArray = jsonNode["body_data_array"]; if ((null != jsonBodyDataArray) && (true == jsonBodyDataArray.IsArray)) { for (int index = 0; index < jsonBodyDataArray.Count; ++index) { var bodyData = BodyData.Factory(jsonBodyDataArray[index]); bodyDataArray.Add(bodyData); _mapBodyRadius[bodyData.m_name] = bodyData.m_radius * 0.5f; } } } { var jsonSplineDataArray = jsonNode["spline_data_array"]; if ((null != jsonSplineDataArray) && (true == jsonSplineDataArray.IsArray)) { for (int index = 0; index < jsonSplineDataArray.Count; ++index) { splineDataArray.Add(SplineData.Factory(jsonSplineDataArray[index])); } } } { var jsonSphereDataArray = jsonNode["sphere_data_array"]; if ((null != jsonSphereDataArray) && (true == jsonSphereDataArray.IsArray)) { for (int index = 0; index < jsonSphereDataArray.Count; ++index) { sphereDataArray.Add(SphereData.Factory(jsonSphereDataArray[index])); } } } faceData = FaceData.Factory(jsonNode); }
// 좌표 보간 함수 public void CalcCoordinates(int index, CharacterCoord[] data) { // 중복계산 방지 do { // 데이터가 비는 경우나 if (data.Length <= 0) { break; } // 계산할 새로운 데이터가 없으면 루프를 탈출 if (index <= m_plotIndex) { break; } // m_plotIndex m_culling[]의 마지막 점의 인덱스. // index data[]의 마지막 점의 인덱스. // 보간할 좌표만 저장한다 for (int i = 0; i < data.Length; i++) { if (index - i - (PLOT_NUM - 1) < m_plotIndex) { m_culling.Add(data[i]); } } // 최신 좌표 설정 m_plotIndex = index; // 스플라인 곡선을 구해서 보간 SplineData spline = new SplineData(); spline.CalcSpline(m_culling); // 구한 스플라인 곡선을 좌표 정보로 보존 CharacterCoord plot = new CharacterCoord(); for (int i = 0; i < spline.GetPlotNum(); i++) { spline.GetPoint(i, out plot); m_plots.Add(plot); } // 가장 오래된 좌표를 삭제한다. if (m_culling.Count > PLOT_NUM) { m_culling.RemoveRange(0, m_culling.Count - PLOT_NUM); } } while (false); }
// Constrain the position to the vertex, and limit the velocity to the direction of the path void ApplyConstraint() { // Make sure we have a spline if (spline == null) return; // Update the vertex we should be on FindNearestVertex(spline, vertex_id, out vertex_position, out vertex_distance); // If we've gone off one of the ends, try to jump to the next vertex SplineData next_spline = spline; int next_vertex_id = vertex_id; if (vertex_position < 0.0f) { if (vertex_id > 0) { next_vertex_id = vertex_id - 1; } else if (spline.in_connections.Count > 0) { next_spline = spline.in_connections[0]; next_vertex_id = spline.in_connections[0].vertexes.Count - 2; } else { spline = null; return; } } else if (vertex_position > 1.0f) { if (vertex_id < spline.vertexes.Count - 2) { next_vertex_id = vertex_id + 1; } else if (spline.out_connections.Count > 0) { next_spline = spline.out_connections[0]; next_vertex_id = 0; } else { spline = null; return; } } // If we're supposed to try jumping, then f****n' do it if (next_vertex_id != vertex_id || next_spline != spline) { float next_vertex_position; float next_vertex_distance; FindNearestVertex(next_spline, next_vertex_id, out next_vertex_position, out next_vertex_distance); if (next_vertex_distance < vertex_distance) { spline = next_spline; vertex_id = next_vertex_id; vertex_position = next_vertex_position; vertex_distance = next_vertex_distance; } } // Update the joint axis joint.connectedAnchor = spline.transform.TransformPoint(spline.Interpolate(vertex_id, vertex_position)); joint.axis = spline.transform.TransformDirection(spline.InterpolateNormal(vertex_id, vertex_position)); }
void Update() { distanceTraveled += Time.deltaTime * Speed; SplineData data = Spline.NextDataPoint(distanceTraveled); transform.position = data.Position; if (OrientToPath) { // For some reason calling SetLookRotation directly on transform.localRotation doesn't update anything Quaternion rot = Quaternion.LookRotation(data.Tangent, data.Normal); transform.localRotation = rot; } }
// 좌표 보간 함수 public void CalcCoordinates(int index, CharacterCoord[] data) { // 중복계산 방지 do { // 데이터가 비는 경우나 if(data.Length <= 0) { break; } // 계산할 새로운 데이터가 없으면 루프를 탈출 if (index <= m_plotIndex) { break; } // m_plotIndex m_culling[]의 마지막 점의 인덱스. // index data[]의 마지막 점의 인덱스. // 보간할 좌표만 저장한다 for(int i = 0; i < data.Length; i++) { if (index - i - (PLOT_NUM - 1) < m_plotIndex) { m_culling.Add(data[i]); } } // 최신 좌표 설정 m_plotIndex = index; // 스플라인 곡선을 구해서 보간 SplineData spline = new SplineData(); spline.CalcSpline(m_culling); // 구한 스플라인 곡선을 좌표 정보로 보존 CharacterCoord plot = new CharacterCoord(); for (int i = 0; i < spline.GetPlotNum(); i++) { spline.GetPoint(i, out plot); m_plots.Add(plot); } // 가장 오래된 좌표를 삭제한다. if (m_culling.Count > PLOT_NUM) { m_culling.RemoveRange(0, m_culling.Count - PLOT_NUM); } } while (false); }
// Find the closest spline vertex id and position void FindNearestVertex(SplineData spline, int vertex_id, out float vertex_position, out float vertex_distance) { // If we don't have a spline, skip this vertex_position = 0.0f; vertex_distance = 0.0f; if (spline == null) { return; } // Get the vertex end-points Vector3 v0 = spline.transform.TransformPoint(spline.vertexes[vertex_id]); Vector3 v1 = spline.transform.TransformPoint(spline.vertexes[vertex_id + 1]); // Find the closest point to the vertex segement // // TODO: Make this actually calculate closest point on the spline! // Is it possible? float seg_len_sq = (v1 - v0).sqrMagnitude; vertex_position = Vector3.Dot(transform.position - v0, v1 - v0) / seg_len_sq; // Get the distance to the vertex if (vertex_position < 0.0f) { vertex_distance = Vector3.Distance(transform.position, v0); } else if (vertex_position > 1.0f) { vertex_distance = Vector3.Distance(transform.position, v1); } else { vertex_distance = Vector3.Distance(transform.position, v0 + (v1 - v0) * vertex_position); } }
public override void Write() { _worldPacket.WritePackedGuid(MoverGUID); _worldPacket.WriteVector3(Pos); SplineData.Write(_worldPacket); }
// ================================================================ // public void ReceivePointFromNet(Vector3 point) { CharacterCoord coord; coord.x = point.x; coord.z = point.z; m_culling.Add(coord); SplineData spline = new SplineData(); spline.CalcSpline(m_culling, 4); m_plots.Clear(); if(spline.GetPlotNum() > 0) { for(int i = 0;i < spline.GetPlotNum();i++) { CharacterCoord plot; spline.GetPoint(i, out plot); m_plots.Add(plot); } } }
// Constrain the position to the vertex, and limit the velocity to the direction of the path void ApplyConstraint() { // Make sure we have a spline if (spline == null) { return; } // Update the vertex we should be on FindNearestVertex(spline, vertex_id, out vertex_position, out vertex_distance); // If we've gone off one of the ends, try to jump to the next vertex SplineData next_spline = spline; int next_vertex_id = vertex_id; if (vertex_position < 0.0f) { if (vertex_id > 0) { next_vertex_id = vertex_id - 1; } else if (spline.in_connections.Count > 0) { next_spline = spline.in_connections[0]; next_vertex_id = spline.in_connections[0].vertexes.Count - 2; } else { spline = null; return; } } else if (vertex_position > 1.0f) { if (vertex_id < spline.vertexes.Count - 2) { next_vertex_id = vertex_id + 1; } else if (spline.out_connections.Count > 0) { next_spline = spline.out_connections[0]; next_vertex_id = 0; } else { spline = null; return; } } // If we're supposed to try jumping, then f****n' do it if (next_vertex_id != vertex_id || next_spline != spline) { float next_vertex_position; float next_vertex_distance; FindNearestVertex(next_spline, next_vertex_id, out next_vertex_position, out next_vertex_distance); if (next_vertex_distance < vertex_distance) { spline = next_spline; vertex_id = next_vertex_id; vertex_position = next_vertex_position; vertex_distance = next_vertex_distance; } } // Update the joint axis joint.connectedAnchor = spline.transform.TransformPoint(spline.Interpolate(vertex_id, vertex_position)); joint.axis = spline.transform.TransformDirection(spline.InterpolateNormal(vertex_id, vertex_position)); }
public void CalcCoordinates(int index, CharacterCoord[] data) { // ?섏떊??醫뚰몴瑜?蹂댁〈. do { // ?곗씠?곌? ?낅퉼(留뚯씪???꾪빐). if(data.Length <= 0) { break; } // ?덈줈???곗씠?곌? ?녿떎. if(index <= m_plotIndex) { break; } // m_plotIndex ... m_culling[]??留덉?留??뺤젏 ?몃뜳?? // index ... data[]??留덉?留??뺤젏???몃뜳?? // // index - m_plotIndex ... ?대쾲???덈줈 異붽????뺤젏???? // int s = data.Length - (index - m_plotIndex); if(s < 0) { break; } for(int i = s;i < data.Length;i++) { m_culling.Add(data[i]); } // m_culling[]??留덉?留??뺤젏 ?몃뜳?? m_plotIndex = index; // ?ㅽ뵆?쇱씤 怨≪꽑??援ы빐??蹂닿컙?쒕떎. SplineData spline = new SplineData(); spline.CalcSpline(m_culling); // 援ы븳 ?ㅽ뵆?쇱씤 蹂닿컙??醫뚰몴 ?뺣낫濡쒖꽌 蹂댁〈?쒕떎. CharacterCoord plot = new CharacterCoord(); for (int i = 0; i < spline.GetPlotNum(); ++i) { spline.GetPoint(i, out plot); m_plots.Add(plot); } // 媛???ㅻ옒??醫뚰몴瑜???젣. if (m_culling.Count > PLOT_NUM) { m_culling.RemoveRange(0, m_culling.Count - PLOT_NUM); } } while(false); }
// ================================================================ // // // 게스트 단말에서의 보스의 이동. // public void CalcCoordinates(int index, CharacterCoord[] data) { // 수신한 좌표를 보존. do { // 데이터가 빔(만일을 위해). if(data.Length <= 0) { break; } // 새로운 데이터가 없다. if(index <= m_plotIndex) { break; } // m_plotIndex ... m_culling[]의 마지막 정점의 인덱스. // index ... data[]의 마지막 정점의 인덱스. // // index - m_plotIndex ... 이번에 새로 추가된 정점 수. // int s = data.Length - 1 - (index - m_plotIndex); if(s < 0) { break; } for(int i = s;i < data.Length;i++) { m_culling.Add(data[i]); } // m_culling[]의 마지막 정점의 인덱스. m_plotIndex = index; // 스플라인 곡선을 구해서 보간한다. SplineData spline = new SplineData(); spline.CalcSpline(m_culling); // 구한 스플라인 곡선을 좌표 정보로 저장한다. CharacterCoord plot = new CharacterCoord(); for (int i = 0; i < spline.GetPlotNum(); ++i) { spline.GetPoint(i, out plot); m_plots.Add(plot); } // 가장 오래된 좌표를 삭제한다. if (m_culling.Count > PLOT_NUM) { m_culling.RemoveRange(0, m_culling.Count - PLOT_NUM); } } while(false); // 수신한 좌표를 저장한다. for (int i = 0; i < data.Length; ++i) { int p = index - PLOT_NUM - i + 1; if (p < m_plotIndex) { m_culling.Add(data[i]); } } }
public LineChartViewModel() { this.Data = new List <LineModel>(); Data.Add(new LineModel() { XValue = "Sun", YValue = 26 }); Data.Add(new LineModel() { XValue = "Mon", YValue = 21 }); Data.Add(new LineModel() { XValue = "Tue", YValue = 30 }); Data.Add(new LineModel() { XValue = "Wed", YValue = 28 }); Data.Add(new LineModel() { XValue = "Thu", YValue = 29 }); Data.Add(new LineModel() { XValue = "Fri", YValue = 24 }); Data.Add(new LineModel() { XValue = "Sat", YValue = 30 }); this.SplineData = new List <LineModel>(); SplineData.Add(new LineModel() { XValue = "1995", YValue = 103 }); SplineData.Add(new LineModel() { XValue = "1997", YValue = 221 }); SplineData.Add(new LineModel() { XValue = "1999", YValue = 80 }); SplineData.Add(new LineModel() { XValue = "2001", YValue = 110 }); SplineData.Add(new LineModel() { XValue = "2003", YValue = 80 }); SplineData.Add(new LineModel() { XValue = "2005", YValue = 160 }); SplineData.Add(new LineModel() { XValue = "2007", YValue = 200 }); }
private void Selection_SelectionChanged(EditorItemSelection sender) { if (suppressSelectionEvents) { return; } // match our tree to our editor selection List <TreeNode> selectedNodes = new List <TreeNode>(); foreach (Item item in sender.Items) { if (item is LevelItem) { LevelItem levelItem = (LevelItem)item; // find the index of the level item int index = LevelData.GetIndexOfItem(levelItem); selectedNodes.Add(levelItemNode.Nodes[index]); } else if (item is LevelAnim) { LevelAnim levelAnim = (LevelAnim)item; // find the index of the level animation int index = LevelData.GetIndexOfItem(levelAnim); selectedNodes.Add(levelAnimNode.Nodes[index]); } else if (item is DeathZoneItem) { DeathZoneItem deathZoneItem = (DeathZoneItem)item; int index = LevelData.DeathZones.IndexOf(deathZoneItem); selectedNodes.Add(deathZoneNode.Nodes[index]); } else if (item is MissionSETItem) { MissionSETItem miSetItem = (MissionSETItem)item; int index = LevelData.MissionSETItems[LevelData.Character].IndexOf(miSetItem); selectedNodes.Add(missionSETNode.Nodes[index]); } else if (item is SETItem) { SETItem setItem = (SETItem)item; int index = LevelData.GetIndexOfSETItem(LevelData.Character, setItem); //LevelData.SETItems[LevelData.Character].IndexOf(setItem); selectedNodes.Add(setNode.Nodes[index]); } else if (item is CAMItem) { CAMItem camItem = (CAMItem)item; int index = LevelData.CAMItems[LevelData.Character].IndexOf(camItem); selectedNodes.Add(camNode.Nodes[index]); } else if (item is SplineData) { SplineData spline = (SplineData)item; int index = LevelData.LevelSplines.IndexOf(spline); selectedNodes.Add(splineNode.Nodes[index]); } } sceneTreeView.SelectedNodes = selectedNodes; }