sync
This commit is contained in:
parent
7758a50ed5
commit
92cea44839
Binary file not shown.
|
Before Width: | Height: | Size: 1.9 KiB After Width: | Height: | Size: 3.1 KiB |
@ -22,24 +22,24 @@ struct UniformParams {
|
|||||||
|
|
||||||
struct VertexOutput {
|
struct VertexOutput {
|
||||||
@builtin(position) position: vec4f,
|
@builtin(position) position: vec4f,
|
||||||
@location(0) r_range: vec2f,
|
@location(0) r_range: vec4f,
|
||||||
@location(1) idx: u32
|
@location(1) idx: u32
|
||||||
}
|
}
|
||||||
|
|
||||||
@vertex
|
@vertex
|
||||||
fn vertex(
|
fn vertex(
|
||||||
@location(0) position: vec3f,
|
@location(0) position: vec4f,
|
||||||
@location(1) r_range: vec2f,
|
@location(1) r_range: vec4f,
|
||||||
@location(2) idx: u32
|
// @location(2) idx: u32
|
||||||
) -> VertexOutput {
|
) -> VertexOutput {
|
||||||
|
|
||||||
var out: VertexOutput;
|
var out: VertexOutput;
|
||||||
|
|
||||||
// Transform position
|
// Transform position
|
||||||
// out.position = common_tools.proj_matrix * common_tools.view_matrix * common_tools.model_matrix * vec4f(position, 1.0);
|
// out.position = common_tools.proj_matrix * common_tools.view_matrix * common_tools.model_matrix * vec4f(position, 1.0);
|
||||||
out.position = vec4(position, 1.0);
|
out.position = vec4(position.xyz, 1.0);
|
||||||
out.r_range = r_range;
|
out.r_range = r_range;
|
||||||
out.idx = idx;
|
out.idx = 0u;
|
||||||
|
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
@ -68,6 +68,6 @@ fn fragment(input: VertexOutput) -> @location(0) vec4f {
|
|||||||
// let is_outside = outside_lower_bound + outside_upper_bound;
|
// let is_outside = outside_lower_bound + outside_upper_bound;
|
||||||
// color.a *= 1.0 - is_outside;
|
// color.a *= 1.0 - is_outside;
|
||||||
|
|
||||||
return color;
|
return vec4(r,r,r,r);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -46,7 +46,10 @@ impl App {
|
|||||||
|
|
||||||
// Request a device and a queue from the adapter. The device is the handle to the GPU, and the queue is used to submit commands to the GPU.
|
// Request a device and a queue from the adapter. The device is the handle to the GPU, and the queue is used to submit commands to the GPU.
|
||||||
let (device, queue) = adapter
|
let (device, queue) = adapter
|
||||||
.request_device(&Default::default(), None)
|
.request_device(&wgpu::DeviceDescriptor{
|
||||||
|
required_features: wgpu::Features::POLYGON_MODE_LINE,
|
||||||
|
..Default::default()
|
||||||
|
}, None)
|
||||||
.await
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
@ -404,11 +407,14 @@ mod test {
|
|||||||
use super::*;
|
use super::*;
|
||||||
#[test]
|
#[test]
|
||||||
fn test_app() {
|
fn test_app() {
|
||||||
let plugin_manager = PluginManager::new(r#"/Users/tsuki/projects/mp/loaders"#).unwrap();
|
let plugin_manager = PluginManager::new(
|
||||||
|
// r#"/Users/tsuki/projects/mp/loaders"#
|
||||||
|
r#"C:\Users\qwin7\projects\radarmp\loaders"#
|
||||||
|
).unwrap();
|
||||||
|
|
||||||
let data = plugin_manager.try_load_data(
|
let data = plugin_manager.try_load_data(
|
||||||
"/Users/tsuki/Desktop/Z_RADR_I_X5775_20230726180000_O_DOR-XPD-CAP-FMT.BIN.zip",
|
// "/Users/tsuki/Desktop/Z_RADR_I_X5775_20230726180000_O_DOR-XPD-CAP-FMT.BIN.zip",
|
||||||
// r#"C:\Users\qwin7\Downloads\ZJSXAA_20230113070200_R.dat.gz"#,
|
r#"C:\Users\qwin7\Downloads\ZJSXAA_20230113070200_R.dat.gz"#,
|
||||||
);
|
);
|
||||||
|
|
||||||
pollster::block_on(async {
|
pollster::block_on(async {
|
||||||
|
|||||||
@ -29,9 +29,9 @@ pub struct PPIUniform {
|
|||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
#[derive(Debug, Copy, Clone, bytemuck::Pod, bytemuck::Zeroable)]
|
#[derive(Debug, Copy, Clone, bytemuck::Pod, bytemuck::Zeroable)]
|
||||||
pub struct PPIVertex {
|
pub struct PPIVertex {
|
||||||
position: Vec3,
|
position: Vec4,
|
||||||
r_ranges: [f32; 2],
|
r_ranges: [f32; 4],
|
||||||
idx: u32,
|
// idx: u32,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl PPIVertex {
|
impl PPIVertex {
|
||||||
@ -43,18 +43,18 @@ impl PPIVertex {
|
|||||||
wgpu::VertexAttribute {
|
wgpu::VertexAttribute {
|
||||||
offset: 0,
|
offset: 0,
|
||||||
shader_location: 0,
|
shader_location: 0,
|
||||||
format: wgpu::VertexFormat::Float32x3,
|
format: wgpu::VertexFormat::Float32x4,
|
||||||
},
|
},
|
||||||
wgpu::VertexAttribute {
|
wgpu::VertexAttribute {
|
||||||
offset: std::mem::size_of::<Vec3>() as wgpu::BufferAddress,
|
offset: std::mem::size_of::<Vec4>() as wgpu::BufferAddress,
|
||||||
shader_location: 1,
|
shader_location: 1,
|
||||||
format: wgpu::VertexFormat::Float32x2,
|
format: wgpu::VertexFormat::Float32x4,
|
||||||
},
|
|
||||||
wgpu::VertexAttribute {
|
|
||||||
offset: std::mem::size_of::<[f32; 2]>() as wgpu::BufferAddress,
|
|
||||||
shader_location: 2,
|
|
||||||
format: wgpu::VertexFormat::Uint32,
|
|
||||||
},
|
},
|
||||||
|
// wgpu::VertexAttribute {
|
||||||
|
// offset: std::mem::size_of::<[f32; 2]>() as wgpu::BufferAddress,
|
||||||
|
// shader_location: 2,
|
||||||
|
// format: wgpu::VertexFormat::Uint32,
|
||||||
|
// },
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -135,7 +135,7 @@ impl Element for PPI {
|
|||||||
strip_index_format: None,
|
strip_index_format: None,
|
||||||
front_face: wgpu::FrontFace::Ccw,
|
front_face: wgpu::FrontFace::Ccw,
|
||||||
cull_mode: None,
|
cull_mode: None,
|
||||||
polygon_mode: wgpu::PolygonMode::Fill,
|
polygon_mode: wgpu::PolygonMode::Line,
|
||||||
unclipped_depth: false,
|
unclipped_depth: false,
|
||||||
conservative: false,
|
conservative: false,
|
||||||
},
|
},
|
||||||
@ -166,7 +166,7 @@ impl Element for PPI {
|
|||||||
} = coord_typ
|
} = coord_typ
|
||||||
{
|
{
|
||||||
let e = elevation.map(|v| *v.first().unwrap_or(&0.0)).unwrap_or(0.0);
|
let e = elevation.map(|v| *v.first().unwrap_or(&0.0)).unwrap_or(0.0);
|
||||||
let (vertices, indices) = Self::bake_vi(e, azimuth, &range);
|
let (vertices, indices) = Self::bake_vi(e as f32, azimuth, &range);
|
||||||
|
|
||||||
(vertices, Some(indices))
|
(vertices, Some(indices))
|
||||||
} else {
|
} else {
|
||||||
@ -189,6 +189,7 @@ impl Element for PPI {
|
|||||||
buffer_pool: &mut DataBufferPool,
|
buffer_pool: &mut DataBufferPool,
|
||||||
) -> ElementAttach {
|
) -> ElementAttach {
|
||||||
let (vertex, index) = self.bake(data);
|
let (vertex, index) = self.bake(data);
|
||||||
|
println!("index: {:?}", &(index.as_ref()).unwrap()[0..24]);
|
||||||
let device = &ctx.device;
|
let device = &ctx.device;
|
||||||
|
|
||||||
let uniform_buffer = device.create_buffer_init(&wgpu::util::BufferInitDescriptor {
|
let uniform_buffer = device.create_buffer_init(&wgpu::util::BufferInitDescriptor {
|
||||||
@ -257,7 +258,8 @@ impl Element for PPI {
|
|||||||
|
|
||||||
impl PPI {
|
impl PPI {
|
||||||
fn init_shader(device: &wgpu::Device) -> wgpu::ShaderModule {
|
fn init_shader(device: &wgpu::Device) -> wgpu::ShaderModule {
|
||||||
let shader_str = merge_shader(r#"/Users/tsuki/projects/mp/mp_elements/shaders/ppi.wgsl"#);
|
// let shader_str = merge_shader(r#"/Users/tsuki/projects/mp/mp_elements/shaders/ppi.wgsl"#);
|
||||||
|
let shader_str = merge_shader(r#"C:\Users\qwin7\projects\radarmp\mp_elements\shaders\ppi.wgsl"#);
|
||||||
let shader = device.create_shader_module(wgpu::ShaderModuleDescriptor {
|
let shader = device.create_shader_module(wgpu::ShaderModuleDescriptor {
|
||||||
label: Some("PPI Shader Module"),
|
label: Some("PPI Shader Module"),
|
||||||
source: wgpu::ShaderSource::Wgsl(shader_str.into()),
|
source: wgpu::ShaderSource::Wgsl(shader_str.into()),
|
||||||
@ -274,7 +276,7 @@ impl PPI {
|
|||||||
BufferKey::new(key_name)
|
BufferKey::new(key_name)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn bake_vi(e: f64, a: &Vec<f64>, r: &Vec<f64>) -> (Vec<PPIVertex>, Vec<u32>) {
|
fn bake_vi(e: f32, a: &Vec<f64>, r: &Vec<f64>) -> (Vec<PPIVertex>, Vec<u32>) {
|
||||||
// Sort azimuth
|
// Sort azimuth
|
||||||
let mut sorted_azimuth = a.clone();
|
let mut sorted_azimuth = a.clone();
|
||||||
sorted_azimuth.sort_by(|a, b| a.partial_cmp(b).unwrap_or(std::cmp::Ordering::Greater));
|
sorted_azimuth.sort_by(|a, b| a.partial_cmp(b).unwrap_or(std::cmp::Ordering::Greater));
|
||||||
@ -283,40 +285,43 @@ impl PPI {
|
|||||||
let azi_step = max_step(&sorted_azimuth, f64::MIN) / 2.0;
|
let azi_step = max_step(&sorted_azimuth, f64::MIN) / 2.0;
|
||||||
let r_step = min_step(&r, f64::MAX) / (r[r.len() - 1]) / 2.0;
|
let r_step = min_step(&r, f64::MAX) / (r[r.len() - 1]) / 2.0;
|
||||||
let r_step_f32 = r_step as f32;
|
let r_step_f32 = r_step as f32;
|
||||||
|
let r_max = r[r.len() - 1] as f32;
|
||||||
|
|
||||||
// One cell has 4 vertices
|
// One cell has 4 vertices
|
||||||
let mut vertexs = Vec::with_capacity(a.len() * r.len() * 4);
|
let mut vertexs = Vec::with_capacity(a.len() * r.len() * 4);
|
||||||
for (a_idx, _a) in sorted_azimuth.into_iter().enumerate() {
|
for (a_idx, _a) in sorted_azimuth.into_iter().enumerate() {
|
||||||
for (r_idx, _r) in r.iter().enumerate() {
|
for (r_idx, _r) in r.iter().enumerate() {
|
||||||
let r_ranges = [*_r as f32 - r_step_f32, *_r as f32 + r_step_f32];
|
|
||||||
|
let cr = *_r as f32 / r_max;
|
||||||
|
let r_ranges = [cr - r_step_f32, cr + r_step_f32, 0.0, 0.0];
|
||||||
let idx = (a_idx * r.len() + r_idx) as u32;
|
let idx = (a_idx * r.len() + r_idx) as u32;
|
||||||
// Left Top
|
// Left Top
|
||||||
let lt = polar_to_cartesian(*_r + r_step, _a - azi_step, e);
|
let lt = polar_to_cartesian(cr + r_step_f32, (_a - azi_step) as f32, e);
|
||||||
vertexs.push(PPIVertex {
|
vertexs.push(PPIVertex {
|
||||||
position: Vec3::new(lt.0, lt.1, lt.2),
|
position: Vec4::new(lt.0, lt.1, lt.2,0.0),
|
||||||
r_ranges,
|
r_ranges,
|
||||||
idx,
|
// idx,
|
||||||
});
|
});
|
||||||
// Left Bot
|
// Left Bot
|
||||||
let lb = polar_to_cartesian(*_r - r_step, _a - azi_step, e);
|
let lb = polar_to_cartesian(cr - r_step_f32, (_a - azi_step) as f32, e);
|
||||||
vertexs.push(PPIVertex {
|
vertexs.push(PPIVertex {
|
||||||
position: Vec3::new(lb.0, lb.1, lb.2),
|
position: Vec4::new(lb.0, lb.1, lb.2,0.0),
|
||||||
r_ranges,
|
r_ranges,
|
||||||
idx,
|
// idx,
|
||||||
});
|
});
|
||||||
// Right Top
|
// Right Top
|
||||||
let rt = polar_to_cartesian(*_r + r_step, _a + azi_step, e);
|
let rt = polar_to_cartesian(cr + r_step_f32, (_a + azi_step) as f32, e);
|
||||||
vertexs.push(PPIVertex {
|
vertexs.push(PPIVertex {
|
||||||
position: Vec3::new(rt.0, rt.1, rt.2),
|
position: Vec4::new(rt.0, rt.1, rt.2,0.0),
|
||||||
r_ranges,
|
r_ranges,
|
||||||
idx,
|
// idx,
|
||||||
});
|
});
|
||||||
// Right Bot
|
// Right Bot
|
||||||
let rb = polar_to_cartesian(*_r - r_step, _a + azi_step, e);
|
let rb = polar_to_cartesian(cr - r_step_f32, (_a + azi_step) as f32, e);
|
||||||
vertexs.push(PPIVertex {
|
vertexs.push(PPIVertex {
|
||||||
position: Vec3::new(rb.0, rb.1, rb.2),
|
position: Vec4::new(rb.0, rb.1, rb.2,0.0),
|
||||||
r_ranges,
|
r_ranges,
|
||||||
idx,
|
// idx,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -325,13 +330,14 @@ impl PPI {
|
|||||||
let mut indice_buffer = Vec::with_capacity(a.len() * r.len() * 6);
|
let mut indice_buffer = Vec::with_capacity(a.len() * r.len() * 6);
|
||||||
|
|
||||||
for i in 0..a.len() * r.len() {
|
for i in 0..a.len() * r.len() {
|
||||||
indice_buffer.push(i as u32 * 4);
|
let start = (i * 2) as u32;
|
||||||
indice_buffer.push(i as u32 * 4 + 1);
|
indice_buffer.push(start);
|
||||||
indice_buffer.push(i as u32 * 4 + 2);
|
indice_buffer.push(start + 1);
|
||||||
|
indice_buffer.push(start + 2);
|
||||||
|
|
||||||
indice_buffer.push(i as u32 * 4 + 1);
|
indice_buffer.push(start + 2);
|
||||||
indice_buffer.push(i as u32 * 4 + 3);
|
indice_buffer.push(start + 1);
|
||||||
indice_buffer.push(i as u32 * 4 + 2);
|
indice_buffer.push(start + 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (vertexs, indice_buffer);
|
return (vertexs, indice_buffer);
|
||||||
@ -372,9 +378,9 @@ where
|
|||||||
return max_gap;
|
return max_gap;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn polar_to_cartesian(r: f64, azimuth: f64, elevation: f64) -> (f32, f32, f32) {
|
fn polar_to_cartesian(r: f32, azimuth: f32, elevation: f32) -> (f32, f32, f32) {
|
||||||
let x = r * azimuth.cos() * elevation.cos();
|
let x = r * azimuth.cos() * elevation.cos();
|
||||||
let y = r * azimuth.sin() * elevation.cos();
|
let y = r * azimuth.sin() * elevation.cos();
|
||||||
let z = r * elevation.sin();
|
let z = r * elevation.sin();
|
||||||
(x as f32, y as f32, z as f32)
|
(x, y, z )
|
||||||
}
|
}
|
||||||
|
|||||||
@ -33,7 +33,8 @@ struct UniformCommonTools {
|
|||||||
Ok(path) => path.parent().unwrap().to_owned(),
|
Ok(path) => path.parent().unwrap().to_owned(),
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
// panic!("Failed to canonicalize path: {}", e);
|
// panic!("Failed to canonicalize path: {}", e);
|
||||||
PathBuf::from(r#"/Users/tsuki/projects/mp/mp_elements/shaders"#)
|
// PathBuf::from(r#"/Users/tsuki/projects/mp/mp_elements/shaders"#)
|
||||||
|
PathBuf::from(r#"C:\Users\qwin7\projects\radarmp\mp_elements\shaders"#)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user