It is currently Sat Jul 04, 2020 10:20 am

All times are UTC + 1 hour




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: [Solved]Copy an entity with the the attributes of the model.
PostPosted: Thu Aug 13, 2015 9:32 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Wed Sep 21, 2011 9:11 am
Posts: 608
Location: France
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:
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.

_________________

➽ Windows 10 - PB 5.62 & PB 5.70 LTS

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


Last edited by falsam on Fri Aug 14, 2015 9:05 am, edited 1 time in total.

Top
 Profile  
Reply with quote  
 Post subject: Re: How to copy an entity with the the attributes of the mod
PostPosted: Fri Aug 14, 2015 8:36 am 
Offline
Addict
Addict
User avatar

Joined: Sat Feb 19, 2011 10:06 am
Posts: 853
Location: Denmark
Code:
RotateEntity(Copy,
             EntityPitch(Model,#PB_Engine3D_Adjusted),
             EntityYaw(Model,#PB_Engine3D_Adjusted),
             EntityRoll(Model,#PB_Engine3D_Adjusted))

_________________
“Tell me and I forget. Teach me and I remember. Involve me and I learn.”
— Benjamin Franklin
Current configurations: Windows 10, Intel 6800K, GeForce Gtx 1060, 32 gb ram.


Top
 Profile  
Reply with quote  
 Post subject: Re: How to copy an entity with the the attributes of the mod
PostPosted: Fri Aug 14, 2015 9:04 am 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Wed Sep 21, 2011 9:11 am
Posts: 608
Location: France
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 10 - PB 5.62 & PB 5.70 LTS

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


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 6 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye