在这里使用我自己的 DAE 模型和纹理文件在 XE2 上进行了上下文测试,并且似乎运行良好。
procedure TForm2.createMap(r:integer;c:integer);
var
player : tmodel3d;
begin
// NEVER create a 3D object as a sub-component of anything other than a 3D viewport!
player := TModel3d.Create(viewport3d1);
{
Ensure that the Parent is always set before operating on the control.
Some operations (such as texturing) will force the object to be re-rendered
so if your parent isn't specified (or isn't ready for rendering) it will cause
some nasty bugs.
}
player.Parent := viewport3d1;
player.Visible := true;
Player.Position.X := 0;
player.Position.Y := 0;
player.position.Z := 2;
player.LoadFromFile(gamedir+'\pics\player.dae');
player.MeshCollection[0].Material.texture.loadfromfile(gamedir+'\pics\playertexture.bmp');
从游戏架构的角度来看,您应该真正创建一个类似于 的自定义类TPlayer
,并将模型作为该对象的成员。这样,所有玩家控件都可以与 关联TPlayer
,并且它成为一个描述的实体,而不仅仅是一个您必须在游戏逻辑中从更高层手动操作的模型。
此外,您要确保模型的位置和相机的位置在相机的透视框架内。