"walking" through 3D space in perspective mode

A forum dedicated to the Draft, Arch and BIM workbenches development.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
User avatar
Szzer
Posts: 71
Joined: Wed Dec 26, 2018 1:26 pm

"walking" through 3D space in perspective mode

Post by Szzer »

I'm creating my house using Freecad (have a topic in the user showcase), and are wondering if it is possible to "walk" through a model, as if you were a human looking around in a house.

I currently use a lot of zooming and rotating+panning at the moment, Maybe there is a better way.
So I'm wondering how you (more experienced) guys and girls do it.
paullee
Veteran
Posts: 5118
Joined: Wed May 04, 2016 3:58 pm

Re: "walking" through 3D space in perspective mode

Post by paullee »

I hope there is something in FC too :) Seems other viewing applications have this feature ?
User avatar
johnwang
Veteran
Posts: 1382
Joined: Sun Jan 27, 2019 12:41 am

Re: "walking" through 3D space in perspective mode

Post by johnwang »

Maybe you could try to export as obj file. Then view it with other software. There are a lot.
hfc series CAE workbenches for FreeCAD (hfcNastran95, hfcMystran, hfcFrame3DD, hfcSU2 and more)
User avatar
Szzer
Posts: 71
Joined: Wed Dec 26, 2018 1:26 pm

Re: "walking" through 3D space in perspective mode

Post by Szzer »

I see that Blender can do it. "fly/ walk" navigation.
Also all games can do it ,navigating in "first person".

It would be awesome though to be able to have a feature or macro that can do it in Freecad, to be able to have a perfect view while editing the model. Maybe something similar like the FCCamera macro...
User avatar
Szzer
Posts: 71
Joined: Wed Dec 26, 2018 1:26 pm

Re: "walking" through 3D space in perspective mode

Post by Szzer »

I just found this forum post from way, way back:
https://forum.freecadweb.org/viewtopic.php?f=24&t=8437
JMG wrote: Fri Nov 14, 2014 11:20 pm Hi everyone!

I want to share with you a new animation, but this time, what is moving is you!
Little video: Tour Camera

Quick start guide:
Download the model here
Open it, switch to "Perspective View", toggle the visibility of one of the sketches called "track..", select one line of the sketch and paste this code:

Code: Select all

from pivy import coin
import time
from FreeCAD import Base
cam = FreeCADGui.ActiveDocument.ActiveView.getCameraNode()
trajectory = Gui.Selection.getSelectionEx()[0].Object.Shape.Edges
for edge in trajectory:
  startPoint = edge.valueAt( 0.0 )
  endPoint = edge.valueAt( edge.Length )
  dirVector = ( endPoint - startPoint ).normalize()
  currentPoint = startPoint
  while (currentPoint - startPoint).Length < edge.Length:
    currentPoint = currentPoint + dirVector
    cam.position.setValue(currentPoint + Base.Vector( 0,0, 10) )
    cam.pointAt( coin.SbVec3f( endPoint[0], endPoint[1], endPoint[2]+10) , coin.SbVec3f( 0, 0, 1 ) )
    Gui.updateGui()
    time.sleep(0.005)

More info and improved version in my blog.

P.D.: I've already posted this at the FreeCAD google+ page, but I don't know up to which point is connected with the forum, if this feels like spam, please tell me and I will post only here or there ;)
Maybe it's a base to start from....
User avatar
Szzer
Posts: 71
Joined: Wed Dec 26, 2018 1:26 pm

Re: "walking" through 3D space in perspective mode

Post by Szzer »

Offcourse I'm not the first to think about this 8-) :

https://forum.freecadweb.org/viewtopic. ... 8&start=10
https://www.youtube.com/watch?v=QX85ya_GJTw

Made by the same guy. I'm going to try if it still works in 0.19...
cadcam
Posts: 276
Joined: Thu Apr 02, 2020 10:39 am

Re: "walking" through 3D space in perspective mode

Post by cadcam »

Nice idea, especially if it could be extended to
include drag bar so user can be in control of
the location along the trajectory.

Not investigated what else FC can offer, but extensions seen on other CAD packages
(Mech and Arch) inc

: Manual rotation/inclination change when motion along trajectory stopped

: Recording of manual controls against time to produce a controlled
playback

: Input of playback information to rendering engine

Would be interested to see where you get to with
trying the coded on 0.19pre

Best Wishes
User avatar
Szzer
Posts: 71
Joined: Wed Dec 26, 2018 1:26 pm

Re: "walking" through 3D space in perspective mode

Post by Szzer »

I'll give it a try. I have never programmed a macro for freecad though, have some python experience.
let's see how it will go.
Don't expect too much though.
cadcam
Posts: 276
Joined: Thu Apr 02, 2020 10:39 am

Re: "walking" through 3D space in perspective mode

Post by cadcam »

Does the original code work on your version of 0.19? It fails at line 4 on my version!

Regards
User avatar
Szzer
Posts: 71
Joined: Wed Dec 26, 2018 1:26 pm

Re: "walking" through 3D space in perspective mode

Post by Szzer »

No it does not work, It was written in Python 2.
Ill try to get it back working, thus making it suitable for Python 3.

for some reason I need to do other work now (to pay the bills), will give it a go fixing the code in the coming days.
Post Reply