Jump to content
Developer Wiki and Function Reference Links ×

Function to create Hduplicate3D


Assembly

Recommended Posts

I'm trying to make a function that works like Hduplicate but for 3D.

This is how I think it will work.

FUNCTION hDuplicate3D(copyhandle:handle;xoffset,yoffset,zoffset:real):Handle;

BEGIN;

Copyhandle:=HDuplicate(copyhandle,0,0);

Move3DObj(copyhandle,xoffset,yoffset,zoffset);

END;

How do I get the function to return the handle of the new object?.

I want to be able to use in a repeat statement IE

REPEAT

n:=n+1;

Myobjecthandle:=hDuplicate3D(myobjecthandle,0,0,Zspace);

UNTIL (N=10)

Link to comment

Try putting this as the last line of the function declaration, before 'END'

hDuplicate3D := CopyHandle;

Not obvious at first, but makes sense if you think about it. You want the compiler to see hDuplicate3D as the return value of your function, which in this case is copyhandle. A function is kinda like a self-assigning variable.

It is because of this characteristic that you can use a function directly without assigning it's return value to another variable, should you so desire.

Link to comment

Hi Justin,

???If you are going to create multiple copies and want to get at their handles after your repeat loop executes, you'll probably want to save them as you create them. Try something like this:

VAR

???HArray = DynArray [ ] of Handle;

...

Cnt := 10;

Allocate HArray[0..Cnt];

n := 0;

HArray[n] := MyObjectHandle;???{ element 0 holds handle to original }

REPEAT

???n := n + 1;

???HArray[n] := hDuplicate3D(HArray[n-1], 0, 0, Zspace);

UNTIL (n = Cnt);

Raymond

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...