[Solved]Copy an entity with the the attributes of the model.
Posted: Thu Aug 13, 2015 9:32 pm
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.Thank you for your help.
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