[Solved]Copy an entity with the the attributes of the model.

Advanced game related topics
User avatar
falsam
Enthusiast
Enthusiast
Posts: 630
Joined: Wed Sep 21, 2011 9:11 am
Location: France
Contact:

[Solved]Copy an entity with the the attributes of the model.

Post by falsam »

Hello.

I try to copy an entity.
- I create the entity model. I perform a rotation and a scale.
- I make a copy of the model that I put right.
- And finally, I copy the attributes of the model.

:?: Why my copy is not identical to the model?

■ Snippet code.

Code: Select all

Enumeration
  #Mainform
EndEnumeration

InitEngine3D() : InitKeyboard() : InitSprite() : InitMouse()

OpenWindow(#Mainform,0,0, 1024, 768, "Copy entity", #PB_Window_ScreenCentered)
OpenWindowedScreen(WindowID(#Mainform),0,0,1024,768,0, 0, 0)

;Light & Shadow
AmbientColor(RGB(127, 127, 127))
CreateLight(#PB_Any,RGB(151, 251, 151), -5, 10, 5)
WorldShadows(#PB_Shadow_Additive)

;Camera
CreateCamera(0, 0, 0,100,100)
CameraBackColor(0, RGB(145, 182, 201))
MoveCamera(0, 0, 5, 10, #PB_Absolute)  
CameraLookAt(0, 0,0,0)   

;Ground
CreateEntity(-1, MeshID(CreatePlane(-1, 20, 20, 1, 1, 10, 10)), #PB_Material_None)

;Create Model (Scale & Rotate)
Model = CreateEntity(-1,MeshID(CreateCube(-1, 1)), #PB_Material_None, -1, 2, 0)
RotateEntity(Model, 45, 45, 45)
ScaleEntity(Model, 1, 2, 1) 

;Copy model : Move right + Rotate + Scale
Copy = CopyEntity(Model, -1)

MoveEntity(Copy, 2, 2, 0)

RotateEntity(Copy, 
             EntityPitch(Model),
             EntityYaw(Model),
             EntityRoll(Model))

ScaleEntity(Copy,
            GetEntityAttribute(Model, #PB_Entity_ScaleX),
            GetEntityAttribute(Model, #PB_Entity_ScaleY),
            GetEntityAttribute(Model, #PB_Entity_ScaleZ),
            #PB_Absolute)

Repeat
  Repeat : Until WindowEvent() = 0
          
  If ExamineKeyboard()
    If KeyboardPushed (#PB_Key_Escape)
      Break
    EndIf
  EndIf
    
  RenderWorld(40)
  FlipBuffers()  
ForEver
Thank you for your help.
Last edited by falsam on Fri Aug 14, 2015 9:05 am, edited 1 time in total.

➽ Windows 11 64-bit - PB 6.0 x64 - AMD Ryzen 7 - NVIDIA GeForce GTX 1650 Ti

Sorry for my bad english and the Dunning–Kruger effect.
User avatar
DK_PETER
Addict
Addict
Posts: 898
Joined: Sat Feb 19, 2011 10:06 am
Location: Denmark
Contact:

Re: How to copy an entity with the the attributes of the mod

Post by DK_PETER »

Code: Select all

RotateEntity(Copy,
             EntityPitch(Model,#PB_Engine3D_Adjusted),
             EntityYaw(Model,#PB_Engine3D_Adjusted),
             EntityRoll(Model,#PB_Engine3D_Adjusted))
Current configurations:
Ubuntu 20.04/64 bit - Window 10 64 bit
Intel 6800K, GeForce Gtx 1060, 32 gb ram.
Amd Ryzen 9 5950X, GeForce 3070, 128 gb ram.
User avatar
falsam
Enthusiast
Enthusiast
Posts: 630
Joined: Wed Sep 21, 2011 9:11 am
Location: France
Contact:

Re: How to copy an entity with the the attributes of the mod

Post by falsam »

Thank you DK_PETER. These options do not appear in the French online documentation!.
Next time, I would look at the English help.

:arrow: http://www.purebasic.com/french/documen ... pitch.html

➽ Windows 11 64-bit - PB 6.0 x64 - AMD Ryzen 7 - NVIDIA GeForce GTX 1650 Ti

Sorry for my bad english and the Dunning–Kruger effect.
Post Reply