mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-06-13 14:22:33 -06:00
SurfaceCtrl_Demo: Added Object Tree
git-svn-id: svn://ultimatepp.org/upp/trunk@14935 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
ac8b40743b
commit
46c0313ec6
4 changed files with 150 additions and 16 deletions
|
|
@ -11,11 +11,14 @@ namespace Upp{
|
|||
class SurfaceCtrl_Demo : public WithSurfaceCtrl_DemoLayout<TopWindow> {
|
||||
private:
|
||||
|
||||
int TreeIDSelected = 0;
|
||||
|
||||
void RetrieveCameraInformation();
|
||||
void UpdatePosition();
|
||||
void UpdateRotation();
|
||||
void UpdateFocus();
|
||||
|
||||
void RetrieveObjectInformation();
|
||||
void UpdateObjectInformation();
|
||||
public:
|
||||
typedef SurfaceCtrl_Demo CLASSNAME;
|
||||
SurfaceCtrl_Demo();
|
||||
|
|
|
|||
|
|
@ -1,42 +1,60 @@
|
|||
LAYOUT(SurfaceCtrl_DemoLayout, 1266, 475)
|
||||
ITEM(SurfaceCtrl, canvas, SetFrame(ThinInsetFrame()).HSizePosZ(2, 159).VSizePosZ(56, 1))
|
||||
ITEM(SurfaceCtrl, canvas, SetFrame(ThinInsetFrame()).HSizePosZ(2, 253).VSizePosZ(56, 1))
|
||||
ITEM(Label, dv___1, SetLabel(t_("File :")).LeftPosZ(7, 28).TopPosZ(7, 18))
|
||||
ITEM(EditString, filename, LeftPosZ(33, 220).TopPosZ(7, 19))
|
||||
ITEM(Button, butOpen, SetLabel(t_("Open")).LeftPosZ(255, 44).TopPosZ(7, 19))
|
||||
ITEM(Button, Ultimate, SetLabel(t_("Ultimate++ !")).LeftPosZ(369, 68).TopPosZ(7, 19))
|
||||
ITEM(Button, OpenEarth, SetLabel(t_("Open Earth")).LeftPosZ(301, 64).TopPosZ(7, 19))
|
||||
ITEM(Switch, cameraView, SetLabel(t_("Perspective view\nParallel view")).LeftPosZ(54, 184).TopPosZ(35, 16))
|
||||
ITEM(Option, ObjShowNormal, SetLabel(t_("Show normals")).SetFont(StdFontZ(8)).RightPosZ(64, 71).BottomPosZ(81, 16))
|
||||
ITEM(Option, ObjShowLight, SetLabel(t_("Show Light")).SetFont(StdFontZ(8)).RightPosZ(4, 59).BottomPosZ(81, 16))
|
||||
ITEM(Option, ShowFocus, SetLabel(t_("Show Focus")).LeftPosZ(843, 77).TopPosZ(35, 16))
|
||||
ITEM(Option, axis, SetLabel(t_("Show axis")).LeftPosZ(364, 68).TopPosZ(35, 16))
|
||||
ITEM(Label, fov, SetLabel(t_("FOV:")).SetFont(StdFontZ(11)).LeftPosZ(246, 27).TopPosZ(33, 19))
|
||||
ITEM(EditIntSpin, fovSelector, LeftPosZ(274, 74).TopPosZ(33, 19))
|
||||
ITEM(Label, camera, SetLabel(t_("Camera:")).SetFont(StdFontZ(11)).LeftPosZ(7, 44).TopPosZ(33, 19))
|
||||
ITEM(LabelBox, dv___12, SetLabel(t_("Camera values")).SetFont(StdFont().Bold()).LeftPosZ(444, 568).TopPosZ(0, 55))
|
||||
ITEM(LabelBox, dv___14, SetLabel(t_("Object values")).SetFont(StdFont().Bold()).RightPosZ(3, 249).BottomPosZ(1, 112))
|
||||
ITEM(LabelBox, dv___15, SetLabel(t_("Camera values")).SetFont(StdFont().Bold()).LeftPosZ(444, 568).TopPosZ(0, 55))
|
||||
ITEM(Label, frontvec, SetLabel(t_("(12, 439, 10)")).LeftPosZ(765, 74).TopPosZ(38, 13))
|
||||
ITEM(Label, dv___14, SetLabel(t_("Angle (quaternion):")).LeftPosZ(450, 97).TopPosZ(35, 13))
|
||||
ITEM(Label, dv___17, SetLabel(t_("Angle (quaternion):")).RightPosZ(146, 97).BottomPosZ(37, 13))
|
||||
ITEM(EditInt64, quatZ, LeftPosZ(658, 34).TopPosZ(32, 19))
|
||||
ITEM(EditInt64, ObjScalZ, RightPosZ(52, 40).BottomPosZ(9, 19))
|
||||
ITEM(EditInt64, camPosZ, LeftPosZ(652, 40).TopPosZ(11, 19))
|
||||
ITEM(EditInt64, quatX, LeftPosZ(586, 34).TopPosZ(32, 19))
|
||||
ITEM(EditInt64, quatY, LeftPosZ(622, 34).TopPosZ(32, 19))
|
||||
ITEM(EditInt64, ObjScalY, RightPosZ(95, 40).BottomPosZ(9, 19))
|
||||
ITEM(EditInt64, camPosY, LeftPosZ(610, 40).TopPosZ(11, 19))
|
||||
ITEM(EditInt64, focusZ, LeftPosZ(974, 31).TopPosZ(11, 19))
|
||||
ITEM(EditInt64, focusY, LeftPosZ(941, 31).TopPosZ(11, 19))
|
||||
ITEM(EditInt64, focusX, LeftPosZ(908, 31).TopPosZ(11, 19))
|
||||
ITEM(Label, dv___23, SetLabel(t_("Front vector :")).SetFont(StdFontZ(10)).LeftPosZ(697, 67).TopPosZ(38, 13))
|
||||
ITEM(Label, dv___28, SetLabel(t_("Front vector :")).SetFont(StdFontZ(10)).LeftPosZ(697, 67).TopPosZ(38, 13))
|
||||
ITEM(Label, onObjectBool, SetLabel(t_("true")).SetFont(StdFontZ(10)).LeftPosZ(980, 24).TopPosZ(36, 13))
|
||||
ITEM(Label, dv___25, SetLabel(t_("Right vector :")).SetFont(StdFontZ(10)).LeftPosZ(698, 64).TopPosZ(23, 13))
|
||||
ITEM(Label, dv___26, SetLabel(t_("Focus point :")).LeftPosZ(843, 63).TopPosZ(13, 13))
|
||||
ITEM(Label, dv___30, SetLabel(t_("Right vector :")).SetFont(StdFontZ(10)).LeftPosZ(698, 64).TopPosZ(23, 13))
|
||||
ITEM(Label, dv___31, SetLabel(t_("Focus point :")).LeftPosZ(843, 63).TopPosZ(13, 13))
|
||||
ITEM(Label, rightvec, SetLabel(t_("(12, 439, 10)")).LeftPosZ(765, 74).TopPosZ(23, 13))
|
||||
ITEM(Label, upvec, SetLabel(t_("(12, 439, 10)")).LeftPosZ(765, 74).TopPosZ(8, 13))
|
||||
ITEM(Button, resetPos, SetLabel(t_("Reset")).LeftPosZ(447, 45).TopPosZ(14, 15))
|
||||
ITEM(EditInt64, quatW, LeftPosZ(550, 34).TopPosZ(32, 19))
|
||||
ITEM(TreeCtrl, dv___31, RightPosZ(3, 153).VSizePosZ(55, 1))
|
||||
ITEM(Label, dv___32, SetLabel(t_("Position (xyz):")).LeftPosZ(495, 71).TopPosZ(15, 13))
|
||||
ITEM(TreeCtrl, AllObjects, RightPosZ(3, 249).VSizePosZ(55, 117))
|
||||
ITEM(Label, dv___37, SetLabel(t_("Scale (xyz):")).RightPosZ(181, 62).BottomPosZ(11, 13))
|
||||
ITEM(Label, dv___38, SetLabel(t_("Position (xyz):")).LeftPosZ(495, 71).TopPosZ(15, 13))
|
||||
ITEM(EditInt64, ObjQuatW, RightPosZ(115, 29).BottomPosZ(34, 19))
|
||||
ITEM(EditInt64, ObjQuatX, RightPosZ(85, 29).BottomPosZ(34, 19))
|
||||
ITEM(EditInt64, ObjQuatZ, RightPosZ(25, 29).BottomPosZ(34, 19))
|
||||
ITEM(EditInt64, ObjQuatY, RightPosZ(55, 29).BottomPosZ(34, 19))
|
||||
ITEM(EditInt64, ObjScalX, RightPosZ(138, 40).BottomPosZ(9, 19))
|
||||
ITEM(EditInt64, ObjPosZ, RightPosZ(41, 40).BottomPosZ(58, 19))
|
||||
ITEM(EditInt64, ObjPosY, RightPosZ(84, 40).BottomPosZ(58, 19))
|
||||
ITEM(Label, dv___46, SetLabel(t_("Position (xyz):")).RightPosZ(172, 71).BottomPosZ(62, 13))
|
||||
ITEM(EditInt64, ObjPosX, RightPosZ(127, 40).BottomPosZ(58, 19))
|
||||
ITEM(EditInt64, camPosX, LeftPosZ(568, 40).TopPosZ(11, 19))
|
||||
ITEM(Label, dv___34, SetLabel(t_("Up vector :")).SetFont(StdFontZ(10)).LeftPosZ(699, 58).TopPosZ(8, 13))
|
||||
ITEM(Label, dv___35, SetLabel(t_("On Object :")).SetFont(StdFontZ(10)).LeftPosZ(922, 55).TopPosZ(36, 13))
|
||||
ITEM(Label, dv___36, SetLabel(t_("To Rotate around an object, \nWheel Click the object.")).SetFont(StdFontZ(10).Italic()).LeftPosZ(1125, 126).TopPosZ(29, 24))
|
||||
ITEM(Label, dv___37, SetLabel(t_("Translation: Shift + Wheel Click ")).SetFont(StdFontZ(10).Italic()).LeftPosZ(1015, 148).TopPosZ(8, 19))
|
||||
ITEM(Label, dv___38, SetLabel(t_("Rotation: Wheel Click ")).SetFont(StdFontZ(10).Italic()).LeftPosZ(1015, 105).TopPosZ(26, 19))
|
||||
ITEM(Label, dv___49, SetLabel(t_("Up vector :")).SetFont(StdFontZ(10)).LeftPosZ(699, 58).TopPosZ(8, 13))
|
||||
ITEM(Label, dv___50, SetLabel(t_("On Object :")).SetFont(StdFontZ(10)).LeftPosZ(922, 55).TopPosZ(36, 13))
|
||||
ITEM(Label, dv___51, SetLabel(t_("To Rotate around an object, \nWheel Click the object.")).SetFont(StdFontZ(10).Italic()).LeftPosZ(1125, 126).TopPosZ(29, 24))
|
||||
ITEM(Label, dv___52, SetLabel(t_("Translation: Shift + Wheel Click ")).SetFont(StdFontZ(10).Italic()).LeftPosZ(1015, 148).TopPosZ(8, 19))
|
||||
ITEM(Label, dv___53, SetLabel(t_("Rotation: Wheel Click ")).SetFont(StdFontZ(10).Italic()).LeftPosZ(1015, 105).TopPosZ(26, 19))
|
||||
ITEM(Label, dv___54, SetLabel(t_("Angle (quaternion):")).LeftPosZ(450, 97).TopPosZ(35, 13))
|
||||
ITEM(Option, ObjShowLine, SetLabel(t_("Show line")).SetFont(StdFontZ(8)).RightPosZ(137, 53).BottomPosZ(81, 16))
|
||||
ITEM(Option, ObjShowSkin, SetLabel(t_("Show Skin")).SetFont(StdFontZ(9)).RightPosZ(192, 58).BottomPosZ(81, 16))
|
||||
END_LAYOUT
|
||||
|
||||
|
|
|
|||
|
|
@ -12,5 +12,6 @@ mainconfig
|
|||
"" = "GUI",
|
||||
"" = "",
|
||||
"" = "USEMALLOC",
|
||||
"" = "USEMALLOC GUI";
|
||||
"" = "USEMALLOC GUI",
|
||||
"" = "GUI GLCTRL USEMALLOC";
|
||||
|
||||
|
|
|
|||
|
|
@ -89,6 +89,57 @@ namespace Upp{
|
|||
focusY <<= THISBACK(UpdateFocus);
|
||||
focusZ <<= THISBACK(UpdateFocus);
|
||||
|
||||
ObjPosX <<= THISBACK(UpdateObjectInformation);
|
||||
ObjPosY <<= THISBACK(UpdateObjectInformation);
|
||||
ObjPosZ <<= THISBACK(UpdateObjectInformation);
|
||||
ObjQuatW <<= THISBACK(UpdateObjectInformation);
|
||||
ObjQuatX <<= THISBACK(UpdateObjectInformation);
|
||||
ObjQuatY <<= THISBACK(UpdateObjectInformation);
|
||||
ObjQuatZ <<= THISBACK(UpdateObjectInformation);
|
||||
ObjScalX <<= THISBACK(UpdateObjectInformation);
|
||||
ObjScalY <<= THISBACK(UpdateObjectInformation);
|
||||
ObjScalZ <<= THISBACK(UpdateObjectInformation);
|
||||
|
||||
ObjShowSkin.WhenAction = [&]{
|
||||
if(TreeIDSelected > 0){
|
||||
int iterator = canvas.FindObject(TreeIDSelected);
|
||||
if( iterator != -1){
|
||||
Object3D& obj = canvas.GetObject(TreeIDSelected);
|
||||
obj.ShowMesh(ObjShowSkin.Get());
|
||||
canvas.Refresh();
|
||||
}
|
||||
}
|
||||
};
|
||||
ObjShowLine.WhenAction = [&]{
|
||||
if(TreeIDSelected > 0){
|
||||
int iterator = canvas.FindObject(TreeIDSelected);
|
||||
if( iterator != -1){
|
||||
Object3D& obj = canvas.GetObject(TreeIDSelected);
|
||||
obj.ShowMeshLine(ObjShowLine.Get());
|
||||
canvas.Refresh();
|
||||
}
|
||||
}
|
||||
};
|
||||
ObjShowNormal.WhenAction = [&]{
|
||||
if(TreeIDSelected > 0){
|
||||
int iterator = canvas.FindObject(TreeIDSelected);
|
||||
if( iterator != -1){
|
||||
Object3D& obj = canvas.GetObject(TreeIDSelected);
|
||||
obj.ShowMeshNormal(ObjShowNormal.Get());
|
||||
canvas.Refresh();
|
||||
}
|
||||
}
|
||||
};
|
||||
ObjShowLight.WhenAction = [&]{
|
||||
if(TreeIDSelected > 0){
|
||||
int iterator = canvas.FindObject(TreeIDSelected);
|
||||
if( iterator != -1){
|
||||
Object3D& obj = canvas.GetObject(TreeIDSelected);
|
||||
obj.ShowLight(ObjShowLight.Get());
|
||||
canvas.Refresh();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
resetPos.WhenAction = [&]{
|
||||
canvas.GetCamera().GetTransform().SetPosition(0,0,20);
|
||||
|
|
@ -99,7 +150,17 @@ namespace Upp{
|
|||
canvas.WhenPaint = [&] {
|
||||
canvas.DrawAllObjects();
|
||||
RetrieveCameraInformation();
|
||||
RetrieveObjectInformation();
|
||||
};
|
||||
|
||||
AllObjects.WhenLeftClick = [&]{
|
||||
if(AllObjects.GetSel().GetCount() > 0){
|
||||
int sel = atoi(AllObjects.Get(AllObjects.GetSel()[0]).ToString());
|
||||
TreeIDSelected = sel;
|
||||
RetrieveObjectInformation();
|
||||
}
|
||||
};
|
||||
|
||||
Sizeable().Zoomable();
|
||||
}
|
||||
|
||||
|
|
@ -125,7 +186,22 @@ namespace Upp{
|
|||
focusY = canvas.GetCamera().GetFocus().y;
|
||||
focusZ = canvas.GetCamera().GetFocus().z;
|
||||
onObjectBool.SetLabel( AsString(canvas.GetCamera().IsOnObject()));
|
||||
|
||||
|
||||
AllObjects.Clear();
|
||||
AllObjects.SetRoot(Image(), "Application");
|
||||
int i = AllObjects.Add(0,Image(),"All Objects");
|
||||
for(const Object3D& obj : canvas.GetAllObjects()){
|
||||
int e = AllObjects.Add(i,Image(), AsString(obj.GetID()));
|
||||
AllObjects.Add(e, Image(), "Position: " + AsString(obj.GetTransform().GetPosition().x,2) +", " + AsString(obj.GetTransform().GetPosition().y,2) +", " + AsString(obj.GetTransform().GetPosition().z,2));
|
||||
AllObjects.Add(e, Image(), "Rotation: " + AsString(obj.GetTransform().GetRotation().w,2) +", " + AsString(obj.GetTransform().GetRotation().x,2) +", " + AsString(obj.GetTransform().GetRotation().y,2)+", " + AsString(obj.GetTransform().GetRotation().z,2));
|
||||
AllObjects.Add(e, Image(), "Scale: " + AsString(obj.GetTransform().GetScale().x,2) +", " + AsString(obj.GetTransform().GetScale().y,2) +", " + AsString(obj.GetTransform().GetScale().z,2));
|
||||
AllObjects.Add(e, Image(), "Meshes count: " + AsString(obj.GetMeshes().GetCount()));
|
||||
}
|
||||
i = AllObjects.Add(0,Image(),"Selected Objects");
|
||||
for(const int& in : canvas.GetSelectedObject()){
|
||||
AllObjects.Add(i,Image(), AsString(in));
|
||||
}
|
||||
AllObjects.OpenDeep(0,true);
|
||||
}
|
||||
void SurfaceCtrl_Demo::UpdatePosition(){
|
||||
canvas.GetCamera().GetTransform().SetPosition(camPosX,camPosY,camPosZ);
|
||||
|
|
@ -136,6 +212,42 @@ namespace Upp{
|
|||
void SurfaceCtrl_Demo::UpdateFocus(){
|
||||
canvas.GetCamera().SetFocus(focusX,focusY,focusZ);
|
||||
}
|
||||
void SurfaceCtrl_Demo::RetrieveObjectInformation(){
|
||||
if(TreeIDSelected > 0){
|
||||
int iterator = canvas.FindObject(TreeIDSelected);
|
||||
if( iterator != -1){
|
||||
Object3D& obj = canvas.GetObject(TreeIDSelected);
|
||||
ObjShowSkin = obj.GetShowMesh();
|
||||
ObjShowNormal = obj.GetShowMeshNormal();
|
||||
ObjShowLine = obj.GetShowMeshLine();
|
||||
ObjShowLight = obj.GetShowLight();
|
||||
|
||||
ObjPosX = obj.GetTransform().GetPosition().x;
|
||||
ObjPosY = obj.GetTransform().GetPosition().y;
|
||||
ObjPosZ = obj.GetTransform().GetPosition().z;
|
||||
|
||||
ObjQuatW = obj.GetTransform().GetRotation().w;
|
||||
ObjQuatX = obj.GetTransform().GetRotation().x;
|
||||
ObjQuatY = obj.GetTransform().GetRotation().y;
|
||||
ObjQuatZ = obj.GetTransform().GetRotation().z;
|
||||
|
||||
ObjScalX = obj.GetTransform().GetScale().x;
|
||||
ObjScalY = obj.GetTransform().GetScale().y;
|
||||
ObjScalZ = obj.GetTransform().GetScale().z;
|
||||
}
|
||||
}
|
||||
}
|
||||
void SurfaceCtrl_Demo::UpdateObjectInformation(){
|
||||
if(TreeIDSelected > 0){
|
||||
int iterator = canvas.FindObject(TreeIDSelected);
|
||||
if( iterator != -1){
|
||||
Object3D& obj = canvas.GetObject(TreeIDSelected);
|
||||
obj.GetTransform().SetPosition(ObjPosX,ObjPosY,ObjPosZ);
|
||||
obj.GetTransform().SetRotation(glm::quat(ObjQuatW,ObjQuatX,ObjQuatY,ObjQuatZ));
|
||||
obj.GetTransform().SetScale(glm::vec3((float)ObjScalX,(float)ObjScalY,(float)ObjScalZ));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
GUI_APP_MAIN
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue