Should 'Attach' like commands move the attached object?

Everything related to 3D programming
User avatar
Psychophanta
Always Here
Always Here
Posts: 5153
Joined: Wed Jun 11, 2003 9:33 pm
Location: Anare
Contact:

Should 'Attach' like commands move the attached object?

Post by Psychophanta »

Code: Select all

InitEngine3D(#PB_Engine3D_NoLog,#PB_Compiler_Home+"Compilers\Engine3d.dll")
InitSprite():InitKeyboard():InitMouse()
OpenWindow(0,0,0,800,600,"tip",#PB_Window_BorderLess|#PB_Window_ScreenCentered)
OpenWindowedScreen(WindowID(0),0,0,800,600,0,0,0,#PB_Screen_WaitSynchronization)
Add3DArchive(#PB_Compiler_Home + "examples/3d/Data/Textures", #PB_3DArchive_FileSystem)
CreateLight(0,$EEEEEE,4,4,2,#PB_Light_Point)
CreateCamera(0,0,0,100,100):CameraProjectionMode(0,#PB_Camera_Perspective)
MoveCamera(0,0,0,3,#PB_Absolute)
CreateMaterial(0,LoadTexture(0,"soil_wall.jpg"))

CreateCube(0,0.3)
CreateEntity(0,MeshID(0),MaterialID(0),-0.5,0,0)
CreateSphere(1,0.2,5,5)
CreateEntity(1,MeshID(1),MaterialID(0),0.5,0,0)
CreateNode(0,-0.5,0,0)
Repeat
  While WindowEvent():Wend
  ExamineKeyboard()
  If KeyboardReleased(#PB_Key_1)
    If AttachedtoNode.b
      DetachNodeObject(0,EntityID(1))
      AttachedtoNode.b=0
    Else
      AttachNodeObject(0,EntityID(1)); <- should this command move the entity number 1 ???
      AttachedtoNode.b=1
    EndIf
  ElseIf KeyboardReleased(#PB_Key_2)
    If AttachedtoObject.b
      DetachEntityObject(0,EntityID(1))
      AttachedtoObject.b=0
    Else
      AttachEntityObject(0,"",EntityID(1)); <- should this command move the entity number 1 ???
      AttachedtoObject.b=1
    EndIf
  EndIf
  RenderWorld()
  FlipBuffers() 
Until KeyboardPushed(#PB_Key_Escape)
http://www.zeitgeistmovie.com

while (world==business) world+=mafia;
User avatar
minimy
Enthusiast
Enthusiast
Posts: 619
Joined: Mon Jul 08, 2013 8:43 pm
Location: off world

Re: Should 'Attach' like commands move the attached object?

Post by minimy »

I think that the coordinates become relative to the parent object.
That's what I've deduced after doing some testing.
(because the manual is a bit gibberish)
If translation=Error: reply="Sorry, Im Spanish": Endif
User avatar
minimy
Enthusiast
Enthusiast
Posts: 619
Joined: Mon Jul 08, 2013 8:43 pm
Location: off world

Re: Should 'Attach' like commands move the attached object?

Post by minimy »

With this you can see the two diferent coordinates based in relative and absolute. Is a start point.

If KeyboardReleased(#PB_Key_1)
If AttachedtoNode.b
DetachNodeObject(0,EntityID(1))
AttachedtoNode.b=0
Debug EntityX(1,#PB_Absolute)
Debug EntityX(1,#PB_Relative)
Else
AttachNodeObject(0,EntityID(1)); <- should this command move the entity number 1 ???
AttachedtoNode.b=1
Debug EntityX(1,#PB_Absolute)
Debug EntityX(1,#PB_Relative)
EndIf
If translation=Error: reply="Sorry, Im Spanish": Endif
User avatar
Psychophanta
Always Here
Always Here
Posts: 5153
Joined: Wed Jun 11, 2003 9:33 pm
Location: Anare
Contact:

Re: Should 'Attach' like commands move the attached object?

Post by Psychophanta »

minimy wrote: Sat Mar 16, 2024 3:46 pm I think that the coordinates become relative to the parent object.
That is a fact.
The matter is that 'Attach' commands should get the current position and inclination of the attached object, and then make it attached without changing anything from it, whatever it be the orientation and position of both objects; the attached one , and the pivot.
http://www.zeitgeistmovie.com

while (world==business) world+=mafia;
DarkDragon
Addict
Addict
Posts: 2345
Joined: Mon Jun 02, 2003 9:16 am
Location: Germany
Contact:

Re: Should 'Attach' like commands move the attached object?

Post by DarkDragon »

Often there are multiple modes to attach an object in an engine for putting it underneath some other object in the scene graph. Changing the coordinates has the same right to exist than not changing the coordinates.

E.g. putting an object into somebody's hand is changing coordinates. A person walking into a moving elevator is not changing coordinates.

It all depends on the situation.
bye,
Daniel
User avatar
Psychophanta
Always Here
Always Here
Posts: 5153
Joined: Wed Jun 11, 2003 9:33 pm
Location: Anare
Contact:

Re: Should 'Attach' like commands move the attached object?

Post by Psychophanta »

Darkdragon, that is a good answer. And that is because i posted the title with a :?:
My previous post was just my current opinion at that time, but opinions are subjects of change :D :)
http://www.zeitgeistmovie.com

while (world==business) world+=mafia;
User avatar
minimy
Enthusiast
Enthusiast
Posts: 619
Joined: Mon Jul 08, 2013 8:43 pm
Location: off world

Re: Should 'Attach' like commands move the attached object?

Post by minimy »

Hello psychophanta. The only solution I can think of (the one I use) is to use a procedure or macro to control the relative and global position of each object before and after connecting to a node
If translation=Error: reply="Sorry, Im Spanish": Endif
User avatar
Psychophanta
Always Here
Always Here
Posts: 5153
Joined: Wed Jun 11, 2003 9:33 pm
Location: Anare
Contact:

Re: Should 'Attach' like commands move the attached object?

Post by Psychophanta »

Dear minimy, don't worry, i already know many ways to deal with this from years ago.
Anyway thanks for your answer ;)
http://www.zeitgeistmovie.com

while (world==business) world+=mafia;
benubi
Enthusiast
Enthusiast
Posts: 220
Joined: Tue Mar 29, 2005 4:01 pm

Re: Should 'Attach' like commands move the attached object?

Post by benubi »

There was a bug with it in 5.22 - 5.73 when I tested and perhaps still exists.

When you attach a resized entity the scale modificators will be ignored. I tried to attach the rusty barrel to the robot in that code. When it did, the barrel shrunk in size (to the original size), but it would also remain attached as intended.
User avatar
Psychophanta
Always Here
Always Here
Posts: 5153
Joined: Wed Jun 11, 2003 9:33 pm
Location: Anare
Contact:

Re: Should 'Attach' like commands move the attached object?

Post by Psychophanta »

@benubi, please post a short example
http://www.zeitgeistmovie.com

while (world==business) world+=mafia;
Post Reply