Delgine 3D Tools & Content DeleD Community Edition
Forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Patch for turn-table rotation 3d view
Goto page 1, 2  Next
 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    DeleD Community Edition Forum Index -> DeleD Development
View previous topic :: View next topic  
Author Message
paul_nicholls
DeleD PRO user


Joined: 05 Dec 2007
Posts: 356
Location: Hobart, Tasmania, Australia

PostPosted: Wed Jan 20, 2010 4:48 am    Post subject: Patch for turn-table rotation 3d view Reply with quote

Hi guys,
I have a patch for the current version of DeleD CE (version 6) which should add in y-axis rotation around the world origin or the first selected object origin.

See this item:

https://sourceforge.net/tracker/?func=detail&aid=2924593&group_id=293758&atid=1241130

This happens in 3d mode when using right mouse + ctrl + alt and dragging left or right.

First you put the object you wish to rotate around into the 3d view.

If the object isn't in the center of the world, then you can select it to rotate around that object.

Otherwise the default, no objects selected mode is to rotate around the world origin.

Anyone wish to try it to see what they think?

The patch should affect these files:

Forms/frm3dView.pas
Units/unit_Cameras.pas

Here is the patch file (inside quotes)

EDIT: updated to latest code changes.

Quote:
Index: Forms/frm3dView.pas
===================================================================
--- Forms/frm3dView.pas (revision 6)
+++ Forms/frm3dView.pas (working copy)
@@ -425,6 +425,11 @@
deltaUV: TUVCoordinate;
angle: single;
dx,dy: single;
+ prim: TBasePrimitive;
+ primX: Single;
+ primY: Single;
+ primZ: Single;
+ usePrim: Boolean;
begin
if not Active then exit;

@@ -453,13 +458,36 @@

fCamera3D.MoveRelative(0, 0, s);

+ end else if (ssCtrl in Shift) and (ssAlt in Shift) then begin //right+ctrl+alt=orbit
+ if Scene.SelectedPrimitives.Count = 0 then begin
+ usePrim := false;
+ primX := 0;
+ primY := 0;
+ primZ := 0;
+ end else begin
+ usePrim := true;
+ prim := Scene.SelectedPrimitives.First;
+
+ primX := prim.Center.x;
+ primY := prim.Center.y;
+ primZ := prim.Center.z;
+ end;
+
+ fCamera3D.Orbit(sp.X - mp.X, mp.Y - sp.Y, 0,
+ usePrim,
+ primX,
+ primY,
+ primZ,
+ editDimension = edX,
+ editDimension = edY);
+
end else if (ssCtrl in Shift) then begin // right+ctrl=navigate left/right

fCamera3D.MoveRelative(sp.X - mp.X, 0, 0);
fCamera3D.MoveRelative(0, mp.Y - sp.Y, 0);

- end else begin // right button=rotate
- fCamera3D.Rotate( mp.Y - sp.Y, mp.X - sp.X, 0);
+ end else begin
+ fCamera3D.Rotate( mp.Y - sp.Y, mp.X - sp.X, 0); // right=rotate
end;

SetCursorPos(sp.X,sp.Y);
Index: Units/unit_Cameras.pas
===================================================================
--- Units/unit_Cameras.pas (revision 6)
+++ Units/unit_Cameras.pas (working copy)
@@ -87,7 +87,11 @@
procedure Move(vector: TVertice);
procedure MoveRelative(const aVector: TVertice); overload;
procedure MoveRelative(const anX, aY, aZ: single); overload;
+ procedure Orbit(const anX, aY, aZ: Single; const aOrbitSelectedObject: Boolean;
+ const aSelectedObjectX, aSelectedObjectY, aSelectedObjectZ : Single;
+ const aConstrainToX,aConstrainToY: Boolean); overload;
procedure Rotate(const anX, anY, aZ: integer);
+ procedure RotateWithAdj(const anX, anY, aZ: Single);
procedure Reset;
property Position: TVertice read fPosition write fPosition;
property Rotation: TVertice read fRotation write fRotation; // pitch, yaw and roll
@@ -294,6 +298,21 @@
if Rotation.z < 0 then Rotation.z := 359;
end;

+procedure TCamera3d.RotateWithAdj(const anX, anY, aZ: Single);
+begin
+ Rotation.x := Rotation.x+anX;
+ if Rotation.x >= 360 then Rotation.x := Rotation.x - 360;
+ if Rotation.x < 0 then Rotation.x := 360 + Rotation.x;
+
+ Rotation.y := Rotation.y+anY;
+ if Rotation.y >= 360 then Rotation.y := Rotation.y - 360;
+ if Rotation.y < 0 then Rotation.y := 360 + Rotation.y;
+
+ Rotation.z := Rotation.z+aZ;
+ if Rotation.z >= 360 then Rotation.z := Rotation.z - 360;
+ if Rotation.z < 0 then Rotation.z := 360 + Rotation.z;
+end;
+
procedure TCamera3d.MoveRelative(const anX, aY, aZ: single);
var vector: TVertice;
begin
@@ -305,6 +324,63 @@
end;
end;

+procedure TCamera3d.Orbit(const anX, aY, aZ: Single;
+ const aOrbitSelectedObject: Boolean;
+ const aSelectedObjectX, aSelectedObjectY, aSelectedObjectZ : Single;
+ const aConstrainToX,aConstrainToY: Boolean);
+var
+ x,y,z : Single;
+ rx,ry,rz : Single;
+
+ procedure RotatePoint_YAxis(angle,x,z,ox,oz : Single; var rx,rz : Single);
+ begin
+ angle := angle * PI / 180;
+ x := x - ox;
+ z := z - oz;
+ rx := x * Cos(angle) - z * Sin(angle) + ox;
+ rz := x * Sin(angle) + z * Cos(angle) + oz;
+ end;
+
+ //todo: include this when x-axis orbit is working along with y-axis orbit
+{ procedure RotatePoint_XAxis(angle,z,y,oz,oy : Single; Var rz,ry : Single);
+ begin
+ angle := angle * PI / 180;
+ z := z - oz;
+ y := y - oy;
+ rz := z * Cos(angle) - y * Sin(angle) + oz;
+ ry := z * Sin(angle) + y * Cos(angle) + oy;
+ end;}
+begin
+ // default to world origin for orbit point
+ if aOrbitSelectedObject then begin // use selected object center as orbit point
+ x := aSelectedObjectX;
+ y := aSelectedObjectY;
+ z := aSelectedObjectZ;
+ end else begin
+ x := 0;
+ y := 0;
+ z := 0;
+ end;
+
+ //todo: include this when x-axis orbit is working along with y-axis orbit
+// if aConstrainToY or (not aConstrainToX and not aConstrainToY) then begin
+ begin
+ RotatePoint_YAxis(-anX,Position.x,Position.z,x,z,rx,rz);
+ Position.x := rx;
+ Position.z := rz;
+ RotateWithAdj(0, -anX, 0);
+ end;
+
+ //todo: include this when x-axis orbit is working along with y-axis orbit
+ {
+ if aConstrainToX or (not aConstrainToX and not aConstrainToY) then begin
+ RotatePoint_XAxis(-aY,Position.z,Position.y,z,y,rz,ry);
+ Position.z := rz;
+ Position.y := ry;
+ RotateWithAdj(-aY, 0, 0);
+ end;}
+end;
+
procedure TCamera3d.Reset;
begin
Position.x := 0;



If applying the patch is difficult, then I could supply my executable for people to try the new functionality?

cheers,
Paul
_________________
Long live DeleD!

Hi ho...hi ho...it's off 3d modeling I go...


Last edited by paul_nicholls on Wed Jan 20, 2010 10:17 am; edited 2 times in total
Back to top
View user's profile Send private message
chronozphere
DeleD PRO user


Joined: 20 Jun 2006
Posts: 1010
Location: Netherlands

PostPosted: Wed Jan 20, 2010 7:44 am    Post subject: Reply with quote

Great work paul. Very Happy Can't wait to see this feature in the new release.

I still need to deliver my first patch. I'm working on it. Razz
Back to top
View user's profile Send private message
paul_nicholls
DeleD PRO user


Joined: 05 Dec 2007
Posts: 356
Location: Hobart, Tasmania, Australia

PostPosted: Wed Jan 20, 2010 9:18 am    Post subject: Reply with quote

Hi all,
I have made some small changes to the code to neaten/shorten it a bit.

I am quite happy with the result so far, so would anyone have an issue if I try checking in my change directly to the DeleD CE codebase?

Then others can just update their code to insert my change if they want to live 'on the bleeding edge' LOL

PLEASE let me know!

cheers,
Paul
_________________
Long live DeleD!

Hi ho...hi ho...it's off 3d modeling I go...
Back to top
View user's profile Send private message
Paul-Jan
Site Admin


Joined: 08 Aug 2004
Posts: 3066
Location: Lage Zwaluwe

PostPosted: Wed Jan 20, 2010 8:20 pm    Post subject: Reply with quote

I say "go". I really appreciate how you took the effort of creating a patch first (gave as a chance to run through the patching process, yay), but I wouldn't mind you committing directly into the code base either. I say we have plenty of experience with your contributions. Smile
Back to top
View user's profile Send private message Visit poster's website
tpascal
Member


Joined: 23 Nov 2009
Posts: 11

PostPosted: Wed Jan 20, 2010 10:42 pm    Post subject: Reply with quote

Quote:

Hi guys,
I have a patch for the current version of DeleD CE (version 6) which should add in y-axis rotation around the world origin or the first selected object origin.


This is simple the most important patch i desired since i saw deled; several 3d modeling programs (like milkshape) suffer from that, they all orbit the camera around the center or the world, which make hard to focus and inspect specific spot in the world.

Quote:

If applying the patch is difficult, then I could supply my executable for people to try the new functionality?


I am using TortoiseSVN 1.6.6, and i am trying to apply your patch, but i was unable to success.

I copy and pasted your quoted patch into a "camera.patch" file, then in the explorer i select my deled source code folder and used tourtoise "apply patch" option, i selected my camera.patch file and i get a message error "unknow line type was found in line 5", actually all lines in your patch with @@ somthing @@ is not working for me, Question

If i remove manually all those lines then it works and i get a two files editor windows, but it looks like not difference are found.

what i am doing wrong?
Back to top
View user's profile Send private message
paul_nicholls
DeleD PRO user


Joined: 05 Dec 2007
Posts: 356
Location: Hobart, Tasmania, Australia

PostPosted: Thu Jan 21, 2010 3:00 am    Post subject: Reply with quote

Paul-Jan wrote:
I say "go". I really appreciate how you took the effort of creating a patch first (gave as a chance to run through the patching process, yay), but I wouldn't mind you committing directly into the code base either. I say we have plenty of experience with your contributions. Smile


ok, thanks PJ Smile

I will try committing the patch so other people can enjoy Smile

cheers,
Paul
_________________
Long live DeleD!

Hi ho...hi ho...it's off 3d modeling I go...
Back to top
View user's profile Send private message
paul_nicholls
DeleD PRO user


Joined: 05 Dec 2007
Posts: 356
Location: Hobart, Tasmania, Australia

PostPosted: Thu Jan 21, 2010 3:01 am    Post subject: Reply with quote

tpascal wrote:
Quote:

Hi guys,
I have a patch for the current version of DeleD CE (version 6) which should add in y-axis rotation around the world origin or the first selected object origin.


This is simple the most important patch i desired since i saw deled; several 3d modeling programs (like milkshape) suffer from that, they all orbit the camera around the center or the world, which make hard to focus and inspect specific spot in the world.

Quote:

If applying the patch is difficult, then I could supply my executable for people to try the new functionality?


I am using TortoiseSVN 1.6.6, and i am trying to apply your patch, but i was unable to success.

I copy and pasted your quoted patch into a "camera.patch" file, then in the explorer i select my deled source code folder and used tourtoise "apply patch" option, i selected my camera.patch file and i get a message error "unknow line type was found in line 5", actually all lines in your patch with @@ somthing @@ is not working for me, Question

If i remove manually all those lines then it works and i get a two files editor windows, but it looks like not difference are found.

what i am doing wrong?


Hmm...not sure why you are getting an error?

If you do an update via tortise, does it say version 6?

I couldn't apply the patch to my other copy of the SVN till tortise had opened the dual window with small overlaying window, and I had selected one of those files, and actually saved the changes from the file menu...

I hope this makes sense, and helps too! Smile

cheers,
Paul
_________________
Long live DeleD!

Hi ho...hi ho...it's off 3d modeling I go...
Back to top
View user's profile Send private message
paul_nicholls
DeleD PRO user


Joined: 05 Dec 2007
Posts: 356
Location: Hobart, Tasmania, Australia

PostPosted: Thu Jan 21, 2010 3:12 am    Post subject: Reply with quote

Hear ye, hear ye...come one, come all....

the initial version of the turn-table 3d rotation has been committed to the DeleD CE codebase, so fee free to check out the code and try it out Smile

https://sourceforge.net/tracker/?func=detail&atid=1241130&aid=2924593&group_id=293758

I have included the instructions as a comment in the tracker item, but here they are again:

Quote:
INSTRUCTIONS
--------------------------
Use CTRL+ALT+right mouse drag left/right in 3d view window to rotate
around y-axis.

If no objects are selected, then the y-axis is the world origin, but if 1
or more objects is selected, then the first selected object is used as the
location of the y-axis to rotate around.


Enjoy! Wink

Please let me know if there are any issues that need fixing Wink

cheers,
Paul
_________________
Long live DeleD!

Hi ho...hi ho...it's off 3d modeling I go...
Back to top
View user's profile Send private message
Jeroen
Site Admin


Joined: 07 Aug 2004
Posts: 5332
Location: The Netherlands

PostPosted: Thu Jan 21, 2010 7:27 am    Post subject: Reply with quote

Excellent work paul - keep it up! Very Happy
_________________
Check out Figuro, our online 3D app! More powerful 3D tools for free.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
tpascal
Member


Joined: 23 Nov 2009
Posts: 11

PostPosted: Thu Jan 21, 2010 5:20 pm    Post subject: Reply with quote

Quote:

the initial version of the turn-table 3d rotation has been committed to the DeleD CE codebase, so fee free to check out the code and try it out


It works excelent Paul, exactly the feature i was looking for, thank you, I even dare to suggest this should be the default rotation mouse control cos it is more useful that current default rotating the camera_AT vector.

May i suggest you should extend the Orbit to the "X" axis too?, so there is more freedom to inspect the target from (Up to down for example), in this case i think the angle rotation cant exced from 180 degree.


good work,
Back to top
View user's profile Send private message
Paul-Jan
Site Admin


Joined: 08 Aug 2004
Posts: 3066
Location: Lage Zwaluwe

PostPosted: Thu Jan 21, 2010 7:10 pm    Post subject: Reply with quote

As an experiment, I have created two groups inside tracker to aid with documentation:
- Next Release - means done and will be present in the next binary release
- Next Release - Needs Doc - means done, will be present in the next binary release, but needs documenting in wiki/help files.

I marked this feature with the second category.

When we do a binary release, we can simple sort on these two groups inside tracker and then either document them (using your text from the comments) fully or a add a single line to the changelog.

We still have to recruit someone to do the actual documenting, but at least we'll be able to actually find the issues inside tracker. Very Happy
Back to top
View user's profile Send private message Visit poster's website
paul_nicholls
DeleD PRO user


Joined: 05 Dec 2007
Posts: 356
Location: Hobart, Tasmania, Australia

PostPosted: Thu Jan 21, 2010 7:43 pm    Post subject: Reply with quote

That's a great idea PJ Smile

I looked for any changes that had happened to the tracker item after I was emailed about changes, but I didn't notice that change.. LOL Wink

This was prior to looking at THIS topic update haha

EDIT: perhaps it might be a good idea for the person who initially adds the feature request does the documentation in the wiki?

How does the help get updated though?

cheers,
Paul
_________________
Long live DeleD!

Hi ho...hi ho...it's off 3d modeling I go...
Back to top
View user's profile Send private message
Paul-Jan
Site Admin


Joined: 08 Aug 2004
Posts: 3066
Location: Lage Zwaluwe

PostPosted: Thu Jan 21, 2010 9:20 pm    Post subject: Reply with quote

I'd really really prefer to decouple writing documentation from requesting and/or coding stuff. I know a lot of developers who can't write proper sensible english if their life depends on it (mostly because their native language is very different) who would much rather write code. Other people (like Nocturn for instance) can write very clear documentation on stuff other people created.

I think the best solution would be
- anyone is encouraged to document their own stuff
- one or two people are end-responsible and check whether everything new/changed is documented properly, and fix/add where necessary.

Now all we need to do is recruit those "one or two" people and we are set. Very Happy

The help files themselves are something we need to discuss. The help files are in sourceforge so anyone can go in and edit them, and we can do a build of the chm each time we update the binaries. Then again, the information in there is more or less a duplicate of what we want to write in the wiki, and the wiki is REALLY REALLY open. I've seen projects where they generate the documentation straight from the wiki, and while I like the idea, that is a lot of work to setup, and the end-results are not always the most practical help files (*cough* delphi 2010 *cough*).
Back to top
View user's profile Send private message Visit poster's website
paul_nicholls
DeleD PRO user


Joined: 05 Dec 2007
Posts: 356
Location: Hobart, Tasmania, Australia

PostPosted: Thu Jan 21, 2010 9:30 pm    Post subject: Reply with quote

Hi PJ,
ok, that's fair enough.

I'm not that good at doing documentation myself (*cough*) LOL

Thanks for the update Smile

cheers,
Paul
_________________
Long live DeleD!

Hi ho...hi ho...it's off 3d modeling I go...
Back to top
View user's profile Send private message
chronozphere
DeleD PRO user


Joined: 20 Jun 2006
Posts: 1010
Location: Netherlands

PostPosted: Thu Jan 21, 2010 10:34 pm    Post subject: Reply with quote

It works great paul! Thanks you for this. Very Happy

You could improve the feature by letting the user go "all around" the model instead of moving in a fixed circle. You could utilize the Y-coordinate of the mouse to achieve vertical movement (this would be a rotation about the X-axis in screen space). I did exactly the same for the first versions of my UV-plugin (now It has a free camera). Smile

About the docs. I'm one of the programmers who is willing to write his own documentation (It will be simple and to the point, so I can concentrate on code). Smile
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    DeleD Community Edition Forum Index -> DeleD Development All times are GMT
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
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
You cannot vote in polls in this forum