fix(renderer): 修正注释中的中文翻译以提高可读性
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
//! Live2D 渲染器:整å<EFBFBD>ˆ Core + Model + GL + Animation
|
||||
//! Live2D 娓叉煋鍣細鏁村悎 Core + Model + GL + Animation
|
||||
|
||||
use super::animation::AnimationState;
|
||||
use super::assets::{self, Model3Json, TextureImage};
|
||||
@@ -31,12 +31,12 @@ impl Live2DRenderer {
|
||||
height: i32,
|
||||
) -> Result<Self> {
|
||||
let core = Arc::new(CubismCore::load(core_so_path)?);
|
||||
println!("[Live2D] Core 版本: {}", core.version_string());
|
||||
println!("[Live2D] Core 鐗堟湰: {}", core.version_string());
|
||||
|
||||
let paths = assets::resolve_asset_paths(live2d_base_dir, model3_json_rel)?;
|
||||
let model3 = Model3Json::from_path(&paths.model3_json)?;
|
||||
println!(
|
||||
"[Live2D] model3.json: 版本={} moc={} 纹ç<EFBFBD>†æ•?{}",
|
||||
"[Live2D] model3.json: 鐗堟湰={} moc={} 绾圭悊鏁?{}",
|
||||
model3.version,
|
||||
model3.file_references.moc,
|
||||
model3.file_references.textures.len()
|
||||
@@ -48,7 +48,7 @@ impl Live2DRenderer {
|
||||
let gl_ctx = RenderContext::new_fullscreen(width, height)?;
|
||||
|
||||
let texture_ids: Vec<u32> = textures.iter().map(|t| gl_ctx.create_texture(t)).collect();
|
||||
println!("[Live2D] 已上ä¼?{} 个纹ç<C2B9>†åˆ° GPU", texture_ids.len());
|
||||
println!("[Live2D] 宸蹭笂浼?{} 涓汗鐞嗗埌 GPU", texture_ids.len());
|
||||
|
||||
let canvas = model.canvas;
|
||||
let model_matrix = compute_model_matrix(canvas, width, height);
|
||||
@@ -114,7 +114,7 @@ impl Live2DRenderer {
|
||||
fn draw_drawable(&self, snap: &DrawableSnapshot) {
|
||||
let gl = &self.gl_ctx.gl;
|
||||
unsafe {
|
||||
// 纹ç<EFBFBD>†
|
||||
// 绾圭悊
|
||||
let tex_idx = snap.texture_index as usize;
|
||||
if tex_idx < self.texture_ids.len() {
|
||||
(gl.gl_active_texture)(gl_api::GL_TEXTURE0);
|
||||
@@ -122,14 +122,14 @@ impl Live2DRenderer {
|
||||
(gl.gl_uniform1i)(self.gl_ctx.uniform_texture, 0);
|
||||
}
|
||||
|
||||
// base color(ä¸<EFBFBD>é€<EFBFBD>明度乘åˆ?alphaï¼? (gl.gl_uniform4f)(self.gl_ctx.uniform_base_color, 1.0, 1.0, 1.0, snap.opacity);
|
||||
// base color锛堜笉閫忔槑搴︿箻鍒?alpha锛? (gl.gl_uniform4f)(self.gl_ctx.uniform_base_color, 1.0, 1.0, 1.0, snap.opacity);
|
||||
// multiply/screen color
|
||||
let mc = snap.multiply_color;
|
||||
(gl.gl_uniform4f)(self.gl_ctx.uniform_multiply_color, mc[0], mc[1], mc[2], mc[3]);
|
||||
let sc = snap.screen_color;
|
||||
(gl.gl_uniform4f)(self.gl_ctx.uniform_screen_color, sc[0], sc[1], sc[2], sc[3]);
|
||||
|
||||
// æ··å<EFBFBD>ˆæ¨¡å¼<EFBFBD>
|
||||
// 娣峰悎妯″紡
|
||||
match snap.blend_mode {
|
||||
core_ffi::blend_mode::NORMAL => {
|
||||
(gl.gl_blend_func)(gl_api::GL_SRC_ALPHA, gl_api::GL_ONE_MINUS_SRC_ALPHA);
|
||||
@@ -145,7 +145,7 @@ impl Live2DRenderer {
|
||||
}
|
||||
}
|
||||
|
||||
// 顶点数æ<EFBFBD>®ï¼šposition(xy) + texCoord(uv) 交错
|
||||
// 椤剁偣鏁版嵁锛歱osition(xy) + texCoord(uv) 浜ら敊
|
||||
let vc = snap.vertex_positions.len();
|
||||
let mut vertex_data: Vec<f32> = Vec::with_capacity(vc * 4);
|
||||
for i in 0..vc {
|
||||
@@ -218,7 +218,7 @@ impl Live2DRenderer {
|
||||
while self.running {
|
||||
let start = Instant::now();
|
||||
if let Err(e) = self.render_frame() {
|
||||
eprintln!("[Live2D] 渲染帧失� {e}");
|
||||
eprintln!("[Live2D] 娓叉煋甯уけ璐? {e}");
|
||||
break;
|
||||
}
|
||||
let elapsed = start.elapsed();
|
||||
@@ -234,8 +234,8 @@ impl Live2DRenderer {
|
||||
}
|
||||
}
|
||||
|
||||
/// 计算 model â†?NDC å<EFBFBD>˜æ<EFBFBD>¢çŸ©é˜µï¼ˆåˆ—优先 4x4ï¼?///
|
||||
/// Cubism å<EFBFBD><EFBFBD>æ ‡ï¼šåŽŸç‚¹åœ¨ canvas ä¸å¿ƒï¼ŒY è½´å<C2B4>‘上,å<C592>•ä½<C3A4>为åƒ<C3A5>ç´ ã€?/// 需è¦<C3A8>ç‰æ¯”缩放使模型完整显示在窗å<E28094>£å†…ã€?fn compute_model_matrix(
|
||||
/// 璁$畻 model 鈫?NDC 鍙樻崲鐭╅樀锛堝垪浼樺厛 4x4锛?///
|
||||
/// Cubism 鍧愭爣锛氬師鐐瑰湪 canvas 涓績锛孻 杞村悜涓婏紝鍗曚綅涓哄儚绱犮€?/// 闇€瑕佺瓑姣旂缉鏀句娇妯″瀷瀹屾暣鏄剧ず鍦ㄧ獥鍙e唴銆?fn compute_model_matrix(
|
||||
canvas: super::model::CanvasInfo,
|
||||
_width: i32,
|
||||
_height: i32,
|
||||
@@ -243,12 +243,12 @@ impl Live2DRenderer {
|
||||
let canvas_w = canvas.size[0].max(1.0);
|
||||
let canvas_h = canvas.size[1].max(1.0);
|
||||
|
||||
// è®¡ç®—ç¼©æ”¾ï¼šè®©æ¨¡åž‹ç‰æ¯”适应窗å<EFBFBD>£
|
||||
// 璁$畻缂╂斁锛氳妯″瀷绛夋瘮閫傚簲绐楀彛
|
||||
let scale_x = 2.0 / canvas_w;
|
||||
let scale_y = 2.0 / canvas_h;
|
||||
let scale = scale_x.min(scale_y);
|
||||
|
||||
// 列优先矩阵:
|
||||
// 鍒椾紭鍏堢煩闃碉細
|
||||
// [ scale 0 0 0 ]
|
||||
// [ 0 scale 0 0 ]
|
||||
// [ 0 0 1 0 ]
|
||||
|
||||
Reference in New Issue
Block a user