Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function TFL3dCobject.Init:Boolean;
- var
- P : PByte;
- S : Integer;
- F : Integer;
- I : Integer;
- J : Integer;
- L : Integer;
- V : Integer;
- M : Integer;
- N : Integer;
- W : Integer;
- Vms : PVms;
- Ref : PFLVMeshPartRef;
- All : UINT;
- Grow : UINT;
- Final : T3d;
- Found : P3d;
- Local : UINT;
- Verts : array of array [0..7] of Single;
- Vertex : UINT;
- Varray : array of record
- Mat : UINT;
- Mesh : UINT;
- Index : UINT;
- Build : Boolean;
- end;
- Search : UINT;
- begin
- Result := False;
- L := 0;
- for I := 0 to High(F3dbs) do
- with F3dbs[I] do
- if Length(Levels) > L then
- L := Length(Levels);
- if L = 0 then Exit;
- All := 0;
- I := 0;
- while I <= L do
- begin
- for J := 0 to High(F3dbs) do
- with F3dbs[J] do
- if UINT(I) <= UINT(High(Levels)) then
- with Levels[I] do
- begin
- Ref := @Data;
- Vms := Lib.Data;
- if (Ref.MeshCount > 0) and
- (Ref.IndexStart < Vms.Data.IndexCount) and
- (Ref.VertexStart < Vms.Data.VertexCount) and
- (UINT(Ref.MeshStart) + UINT(Ref.MeshCount) <= UINT(Vms.Data.MeshesCount)) then
- begin
- Grow := 0;
- SetLength(Varray, Ref.MeshCount);
- for M := 0 to Ref.MeshCount-1 do
- with Vms.Meshes[Ref.MeshStart + M], Varray[M] do
- begin
- Mat := MaterialID;
- Mesh := Ref.MeshStart + M;
- Index := Ref.IndexStart + Grow;
- Build := True;
- Inc(Grow, VNum);
- end;
- Final.VStart := All;
- Inc(All,Grow);
- Final.VCount := All;
- if Grow > 0 then
- begin
- Local := Final.VStart;
- SetLength(Verts, All);
- P := @Verts[Final.VStart];
- for N := 0 to High(Varray) do
- begin
- if Varray[N].Build then
- begin
- Search := Varray[N].Mat;
- repeat
- F := -1;
- for S := 0 to High(Varray) do
- if Varray[S].Build and (Varray[S].Mat = Search) then
- begin
- F := S;
- Break;
- end;
- if F >= 0 then
- with Varray[F] do
- begin
- Build := False;
- Found := nil;
- for W := 0 to High(Items) do
- if Items[W].Material = Search then
- begin
- Found := @Items[W];
- Break;
- end;
- if Found = nil then
- begin
- SetLength(Items, Length(Items)+1);
- Found := @Items[High(Items)];
- Found.VStart := Local;
- Found.Material := Search;
- end;
- with Vms.Meshes[Mesh] do
- begin
- //Found.VStart := Final.VStart + Index - Ref.IndexStart;
- Inc(Local, VNum);
- Inc(Found.VCount, VNum);
- for V := 0 to VNum-1 do
- begin
- Vertex := Index + V;
- if Vertex > Vms.Data.IndexCount then
- begin
- Inc(P,VVERTEX_STRIDE);
- Continue;
- end;
- Vertex := Vms.Indices[Vertex];
- if Vertex > Vms.Data.VertexCount then
- begin
- Inc(P,VVERTEX_STRIDE);
- Continue;
- end;
- Vertex := Vertex + Ref.VertexStart + VStart;
- if Vertex > Vms.Data.VertexCount then
- begin
- Inc(P,VVERTEX_STRIDE);
- Continue;
- end;
- with Vms.Vertices[Vertex] do
- begin
- PD3DXVector3(P)^ := PD3DXVector3(@x)^;
- Inc(P,12);
- PD3DXVector2(P)^ := PD3DXVector2(@u)^;
- Inc(P,8);
- PD3DXVector3(P)^ := PD3DXVector3(@nx)^;
- Inc(P,12);
- end;
- end;
- end;
- end;
- until F < 0;
- Varray[N].Build := False;
- end;
- end;
- end;
- end;
- end;
- Inc(I);
- end;
- FBuffer := D3DX11CreateBuffer;
- FBuffer.Init(FL.Device);
- if Verts = nil then
- P := nil else
- P := @Verts[0];
- FBuffer.CreateVB(VVERTEX,D3D11_USAGE_IMMUTABLE,0,P,Length(Verts),Length(Verts),VVERTEX_STRIDE);
- Result := True;
- end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement