feat(render): 使用Color类替换Vector3f表示光源颜色

- 在LightSource类中引入java.awt.Color类型
- 添加colorToVector3f和vector3fToColor静态转换方法- 修改构造函数以接受Color参数并自动转换
- 更新LightSourceData反序列化逻辑以使用新颜色格式
- 在测试类中使用标准Color常量设置光源
- 移除旧的直接Vector3f颜色构造方式
This commit is contained in:
tzdwindows 7
2025-10-11 20:39:25 +08:00
parent 9cde0192fd
commit 16af846e48
3 changed files with 37 additions and 9 deletions

View File

@@ -14,6 +14,7 @@ import org.lwjgl.glfw.GLFWVidMode;
import org.lwjgl.opengl.GL;
import org.lwjgl.system.MemoryUtil;
import java.awt.*;
import java.nio.ByteBuffer;
import java.util.Random;
@@ -135,15 +136,15 @@ public class ModelRenderLightingTest {
body.addChild(rightLeg);
LightSource ambientLight = new LightSource(
new Vector3f(0.5f, 0.5f, 0.5f), // 灰色
Color.GRAY,
0.3f
);
ambientLight.setAmbient(true);
model.addLight(ambientLight);
// 添加光源
model.addLight(new LightSource(new Vector2f(-100, -100), new Vector3f(1f, 0f, 0f), 20f));
model.addLight(new LightSource(new Vector2f(150, 150), new Vector3f(0f, 0f, 1f), 20f));
model.addLight(new LightSource(new Vector2f(-100, -100), Color.ORANGE, 100f));
//model.addLight(new LightSource(new Vector2f(150, 150), new Color(1f, 1f, 1f), 200f));
}
private Texture createSolidTexture(int w, int h, int rgba) {