PDA

View Full Version : Glscene & TreeView



programmer
27-06-2008, 09:00 PM
Hi ..

How can I copy all the objects names in the Glscene to the Treeview Component at the same order

Tank you very much

Brainer
28-06-2008, 04:30 AM
Here's the code I used (you'll probably have to add GLCrossPlatform to the uses):

procedure TForm1.FormCreate(Sender: TObject);

{ .: AddNodes :. }
function AddNodes(ANode: TTreeNode; AObject: TGLBaseSceneObject): TTreeNode;
var
I: Integer;
CurrentNode: TTreeNode;
begin
if IsSubComponent(AObject) then
begin
Result := TreeView1.Selected;
exit;
end else
begin
Result := TreeView1.Items.AddChildObject(ANode, AObject.Name, AObject);
CurrentNode := Result;
for I := 0 to AObject.Count -1 do
Result := AddNodes(CurrentNode, AObject[I]);
end;
end;

var
I: Integer;
CameraNode, ObjectNode: TTreeNode;
begin
// -- add two root nodes --
ObjectNode := TreeView1.Items.AddFirst(nil, 'Scene objects');
CameraNode := TreeView1.Items.AddFirst(nil, 'Cameras');

// -- get the object's tree --
TreeView1.Items.BeginUpdate();
with GLScene1 do
begin
// -- cameras --
if Assigned(Cameras) then
begin
CameraNode.Data := Cameras;
for I := 0 to Cameras.Count -1 do
AddNodes(CameraNode, Cameras[I]);
CameraNode.Expand(True);
end;

// -- objects (with children too) --
if Assigned(Objects) then
begin
ObjectNode.Data := Objects;
with Objects do
for I := 0 to Count -1 do
AddNodes(ObjectNode, Children[I]);
ObjectNode.Expand(True);
end;
end;
TreeView1.Items.EndUpdate();
end;

programmer
28-06-2008, 01:56 PM
Thank you .. :o

But it gave me wrong on " IsSubComponent(AObject) " what can I do

Brainer
28-06-2008, 04:06 PM
Just like I said here :D :

Here's the code I used (you'll probably have to add GLCrossPlatform to the uses):

programmer
29-06-2008, 08:02 AM
I added GLCrossPlatform to the uses but it didn't work ( the same error) :(

Brainer
29-06-2008, 05:53 PM
Then search for that one inside your source files, I guess it could have been moved in the latest versions, or download the latest version from the CVS.

programmer
30-06-2008, 06:43 PM
Finally it work , Thank you very much :D :D :D