Stream: Google Code-in

Topic: QT Project Tasks


view this post on Zulip Mahdi (Dec 01 2017 at 15:20):

Hey @Sean , is there a reason why I can't get CMake to find the brlcad libraries? I've been at this for a while now and can't get it to work.

cmake_minimum_required(VERSION 2.8)

# Project name: V1(BRL-CAD-QTGUI)
project(BRL-CAD-QTGUI)

# Find includes in corresponding build directories
set(CMAKE_INCLUDE_CURRENT_DIR ON)

# Instruct CMake to run moc automatically when needed
set(CMAKE_AUTOMOC ON)

# Find the QtWidgets library
find_package(Qt5Widgets)

# Find BRLCAD library
find_library(brlcadlib brlcad)

# include our .h files located in /include
include_directories(include)

# Find all source files located in /src
file(GLOB SOURCES "src/*.cpp")

# Tell CMake to create the executable
# TIP: ${SOURCES> are all the .cpp files
# TIP: Listing all include files is not necessary but
# will enable a preview for your IDE
add_executable(${PROJECT_NAME}
    ${SOURCES}
    include/window.h
    include/splashscreen.h
    )

# Tell CMake to use the QT 5 Widget module as an external library
target_link_libraries(${PROJECT_NAME}
    Qt5::Widgets
    ${brlcadlib})

Errors :

CMake Error: The following variables are used in this project, but they are set to NOTFOUND.

view this post on Zulip Sean (Dec 01 2017 at 15:24):

Hey @Sean , is there a reason why I can't get CMake to find the brlcad libraries? I've been at this for a while now and can't get it to work.

# Find BRLCAD library
find_library(brlcadlib brlcad)

You probably should use find_package(brlcad) ... I'm not sure about brlcadlib

view this post on Zulip Sean (Dec 01 2017 at 15:26):

@Mahdi check the CMakeFiles/CMakeError.log to see what's failing

view this post on Zulip Sean (Dec 01 2017 at 15:28):

you can also totally punt and just manually add BRL-CAD's include directories and libraries to the link line if you need to

view this post on Zulip Mahdi (Dec 01 2017 at 15:28):

I've tried the find_package method before and it ends up failing at:
Linking CXX executable BRL-CAD-QTGUI.exe [33%]
because it can't find -lbrlcad.

view this post on Zulip Mahdi (Dec 01 2017 at 15:29):

That would suck if I chose to expand on this project :\

view this post on Zulip Sean (Dec 01 2017 at 15:30):

Mahdi, can you link me to your task?

view this post on Zulip Mahdi (Dec 01 2017 at 15:31):

I'm currently having another task reviewed but I'm looking at BRL-CAD Alternative GUI 2: Hook in a BRL-CAD Library

view this post on Zulip Daniel Rossberg (Dec 01 2017 at 15:35):

The whole task is about finding out how to include an external library with CMake.

view this post on Zulip Daniel Rossberg (Dec 01 2017 at 15:41):

That's why I hesitate to tell you the answer. You have somehow to add an import library with CMake. Asking Google should be helpful, or the CMake manual.

view this post on Zulip Daniel Rossberg (Dec 01 2017 at 15:48):

BTW, there is more than one solution, even one with only minimal changes to the CMakeLists.txt.

view this post on Zulip Sean (Dec 01 2017 at 15:57):

ah, my bad @Mahdi that's why I wanted to know which task -- so yeah... figure it out ;)

view this post on Zulip Mahdi (Dec 01 2017 at 16:12):

Ah, fair enough ;)

view this post on Zulip Daniel Rossberg (Dec 01 2017 at 16:17):

If you get stuck I'll provide you with some more help, but first you should do some own investigations.

view this post on Zulip Mahdi (Dec 01 2017 at 17:49):

Hey @Daniel Rossberg , I've been looking around and I still can't figure out what I'm doing wrong. It's probably something really obvious and I'm just missing it. Could you perhaps point me in the right direction? Like, a clue or hint that wouldn't take away from the integrity of the task but would still allow me to progress. Currently I'm getting this error:

CMakeFiles\BRL-CAD-QTGUI.dir/objects.a(window.cpp.obj):window.cpp:(.text+0xba): undefined reference to `BRLCAD::ConstDatabase::ConstDatabase()'

Which is probably an issue with the linker.

target_link_libraries(${PROJECT_NAME} ${CMAKE_CURRENT_SOURCE_DIR}/libs/brlcad.lib)

Could I receive some guidance on how to go about completing this?

view this post on Zulip Daniel Rossberg (Dec 01 2017 at 19:49):

Hi @Mahdi I'm not sure how your project looks like. However, including the BRL-CAD library in target_link_libraries() is right. But, you should use it this way: target_link_libraries(${PROJECT_NAME} brlcad)
Then, there is another CMake command which allows you to specify the directory where it should search for the lib.

view this post on Zulip Mahdi (Dec 01 2017 at 21:04):

My project is sectioned like so:
Bin
- brlcad.dll
db
- *.g files
doc
- doc files
include
- brlcad
- *.h files
- QT *.h files
lib
- brlcad.lib
src
- *.cpp files
CMakeLists

view this post on Zulip Mahdi (Dec 01 2017 at 21:07):

I've tried using find_package, find_library, link_directories, etc...

view this post on Zulip Daniel Rossberg (Dec 01 2017 at 21:10):

link_directories(lib) should do it, or?

view this post on Zulip Mahdi (Dec 01 2017 at 21:13):

I receive a series of "undefined reference" errors through that method.

view this post on Zulip Daniel Rossberg (Dec 01 2017 at 21:20):

Can you upload a zip file with your project to the task?

view this post on Zulip Mahdi (Dec 01 2017 at 21:22):

I sent it

view this post on Zulip Daniel Rossberg (Dec 01 2017 at 21:29):

And you are working with MS Visual Studio? And your compiler and the DLL have the "same number of bits"?

view this post on Zulip Mahdi (Dec 01 2017 at 21:30):

I'm using the MinGW Compiler with QT Creator. I've chosen the 32 bit version of the DLL as MinGW is 32 bit aswell

view this post on Zulip Daniel Rossberg (Dec 01 2017 at 21:32):

OK, that's the reason: The handling of C++ is different between Visual Studio and MinGW. They aren't binary compatible. The DLL works only with Visual Studio or other Microsoft compatible compilers.

view this post on Zulip Daniel Rossberg (Dec 01 2017 at 21:36):

Now, you could whether use Visual Studio (like you did with PrintTitle,) or build and use the brlcad C++ core interface (which is in principle the same as the brlcad.dll). See the "Build the libbrlcad.so" task. You may want to do this first.

view this post on Zulip Mahdi (Dec 01 2017 at 21:41):

What exactly does "core interface" mean? Is it just the source files that were used to create the .dll?

view this post on Zulip Daniel Rossberg (Dec 01 2017 at 21:42):

It's an C++ interface layer on top of the BRL-CAD core libraries. And yes, these are the source files which create the DLL, together with the usual BRL-CAD core libraries around librt.

view this post on Zulip Daniel Rossberg (Dec 01 2017 at 21:46):

The library with this interface layer can be created on every BRL-CAD OS (e.g. Windows, Linux, FreeBSD, MacOS). For MS Visual Studio there is a compiled compact library, the brlcad.dll. For other environments you have to build it by yourself.

view this post on Zulip Mahdi (Dec 01 2017 at 21:46):

Thanks, I've learned a lot today! Which path would you personally recommend? Should I transfer my work to visual studio or use the core interface?

view this post on Zulip Daniel Rossberg (Dec 01 2017 at 21:51):

Well, do you work with Windows? If I remember right, Visual Studio was the only compiler which was able to build BRL-CAD on Windows. Therefore, it could be hard (but maybe not impossible) to build the brlcad.dll with MingW. However, you could try it - it's only the one DLL but not the whole BRL-CAD.
On the other side, if you can build Qt programs with Visual Studio too...

view this post on Zulip Mahdi (Dec 01 2017 at 21:59):

The main incentive for using QT Creator was how light weight and specialized the IDE was but I suppose it won't be too hard to transition to Visual Studio. Also, I have a linux and ms workstation but I would prefer to keep gui related files on microsoft. I'll take a look at using Visual Studio :P

view this post on Zulip Daniel Rossberg (Dec 01 2017 at 22:07):

You could still use the Qt Creator for the layout, but then compile the program with Visual Studio.

view this post on Zulip Mahdi (Dec 01 2017 at 22:10):

That's actually what I was just working except I'm running in to even more issues. Have you ever been able to use the visual studio compiler with qt creator?

view this post on Zulip Daniel Rossberg (Dec 01 2017 at 22:13):

I build the Qt Creator with Visual Studio because I build my whole Qt with it, but I've never used the Creator. It's not my way of programming ;)

view this post on Zulip Mahdi (Dec 01 2017 at 22:19):

;) fair enough. How would I go about integrating my old CMake with visual studio? With QT Creator it allowed me to autorun it with a defined configuration -- can I do that with visual studio? I guess I'm just wondering how to port everything over as smoothly as possible.

view this post on Zulip Mahdi (Dec 02 2017 at 01:45):

Update: Everything is good now.

view this post on Zulip Daniel Rossberg (Dec 02 2017 at 16:52):

@Mahdi That's good to hear. I've just commented your work. There happened probable a mistake when you uploaded the source code.

view this post on Zulip Daniel Rossberg (Dec 02 2017 at 18:13):

To give you an idea where this could lead to: https://univemo.iabg.de/Download/BrlCadViewer30_setup.exe
But this isn't the only application we think of.

view this post on Zulip Mahdi (Dec 02 2017 at 18:28):

Do some tasks disappear after a certain number of completions?

view this post on Zulip Daniel Rossberg (Dec 02 2017 at 18:30):

Yes. Every task has a maximum number of instances. Are you looking for a special one?

view this post on Zulip Mahdi (Dec 02 2017 at 18:32):

I was just about to do the Splash Screen one since I wanted to implement it for the QT Projects. Unfortunately it was removed moments after my last task was completed.

view this post on Zulip Mahdi (Dec 02 2017 at 18:34):

Also, given the repetitive nature of some tasks, is there some mechanism which prevents a competitor from saving tasks from previous years and handing them in?

view this post on Zulip Daniel Rossberg (Dec 02 2017 at 18:46):

I increased the number of splash screen task instances. You could choose it now if you want.

view this post on Zulip Mahdi (Dec 02 2017 at 18:47):

Thanks!

view this post on Zulip Mahdi (Dec 03 2017 at 20:47):

Hey, so I'm on QT Task #4 and was wondering what kind of information we have to display after selecting an element? So far I've built the gui to view the database and nodes but as I'm not familiar with BRL-CAD I'm not quite sure what else it needs me to look for. Any tips?

view this post on Zulip Mahdi (Dec 03 2017 at 21:01):

@Daniel Rossberg Is there any documentation for the Core Interface?

view this post on Zulip Daniel Rossberg (Dec 03 2017 at 21:29):

@Mahdi You could look at https://brlcad.org/wiki/BRL-CAD%27s_core_C%2B%2B_interface
The source code is (e.g.) at https://sourceforge.net/p/brlcad/code/HEAD/tree/rt%5E3/trunk/include/brlcad/ and https://sourceforge.net/p/brlcad/code/HEAD/tree/rt%5E3/trunk/src/coreInterface/

view this post on Zulip Mahdi (Dec 03 2017 at 21:29):

Thank you!

view this post on Zulip Daniel Rossberg (Dec 03 2017 at 21:30):

Maybe you want to "Learn basic 3D modeling using BRL-CAD..." before continuing programming it?

view this post on Zulip Mahdi (Dec 03 2017 at 21:33):

Hm, that's probably a good idea. I'll put the project on hold for now.

view this post on Zulip Mahdi (Dec 03 2017 at 21:38):

Just out of curiosity: Why did some of the mentors, such as yourself, decide to work on BRL-CAD?

view this post on Zulip Naseef (Dec 03 2017 at 22:46):

Just figured out CMake is actually easier than make.
I think CMake is the best choice for large projects.

But make is still better for small projects with just a few source files and headers.

view this post on Zulip Sean (Dec 04 2017 at 03:31):

Just out of curiosity: Why did some of the mentors, such as yourself, decide to work on BRL-CAD?

What a great question.

view this post on Zulip Sean (Dec 04 2017 at 04:14):

Without getting too philowaxical, I believe solid modeling CAD tools are in their infancy, mired in an entrenched overpricing, and the best way to revolutionize that industry is via Open Source. To me, BRL-CAD is not yet up to the task of implementing all the complexity required, but it's the best foundation, an amazing codebase, and a great community.

view this post on Zulip Naseef (Dec 04 2017 at 14:27):

@Daniel Rossberg : If a Qt GUI will become part of a BRL-CAD distribution it will be linked to Qt 5. We won't build on an old/outdated version.

I did this Qt 4 because it was already installed on my system. I'll use a new version for other tasks.

view this post on Zulip Daniel Rossberg (Dec 04 2017 at 14:50):

Your main.cpp should compile with Qt 5 as well. I.e., you haven't missed something.

view this post on Zulip Naseef (Dec 04 2017 at 16:37):

So I just have to update the CMake file.

view this post on Zulip Mahdi (Dec 05 2017 at 23:23):

@Daniel Rossberg Do you know of a good way to structure the keys & values of a map into a tree?

view this post on Zulip Daniel Rossberg (Dec 06 2017 at 07:53):

@Mahdi Do you mean something like QTreeView?

view this post on Zulip Mahdi (Dec 06 2017 at 20:32):

@Daniel Rossberg Are there plans for more QT tasks? I remember Sean saying there were going to be more as the Code-In progresses.

view this post on Zulip Daniel Rossberg (Dec 06 2017 at 21:15):

Yes.

view this post on Zulip Daniel Rossberg (Dec 07 2017 at 07:43):

@Mahdi Please don't use OpenGL. It has never worked for me, and wouldn't provide any benefit here.

view this post on Zulip Naseef (Dec 08 2017 at 21:36):

@Daniel Rossberg Well, I know QString is part of Qt(All begins with a Q), CoreInterface know nothing about it (Why it should?). OpenFileDIalog returns the file's location as a QString. I have to parse it to load function which requires a char* , I had no idea how to do that,
I first used ByteArray to solve this, So I had that comment to describe what I am doing, And then I discorverd c_str(), It made it a lot easier
I deleted the ByteArray code but kept the comment there. I didn't even knew CoreInterface is in C++, I just thought it was in C like BRL-CAD itself.

view this post on Zulip Naseef (Dec 08 2017 at 21:37):

BTW It's a really fun task, At first it was very hard. But after working in it for a while, It became so easy. (Maybe because this is my first QT5 application).

view this post on Zulip Naseef (Dec 08 2017 at 22:09):

pass not parse

view this post on Zulip Daniel Rossberg (Dec 09 2017 at 18:15):

@Naseef The translation of a QString (Unicode) to ab byte sequence can indeed be an issue. This is usually be done by selecting explicitly a conversion with one of the to~() methods. They return usually a buffer which manages the memory of the converted string. That's why you see often these QByteArray there. It's mainly a character array with methods which take care of its memory.
Therefore, filename.toLocal8Bit().data() or filename.toUtf8().data() could be what you want.

view this post on Zulip Daniel Rossberg (Dec 09 2017 at 19:57):

How I plan to proceed with the "BRL-CAD alternative GUI" etc. tasks:
One direction is to implement more visualization features in the Qt GUI. These could be zooming, moving, and rotating the view and selecting the elements to display from a tree. Before I make these tasks, I want to see however how you are doing the "BRL-CAD Alternative GUI 6: Draw a Ray-Trace". I want to adjust the tasks descriptions accordingly.

The other direction is the (Lua) scripting. Michal came up with the idea to have an interface similar to OpenSCAD: A scripting window where you can edit a text which describes the geometry and a viewing window where you can see the scripted geometry.
This scripting could be possibly done with the BRL-CAD ASCII file description, with the shortfall of the absence of the usual scripting elements (variables, operators, loops, ...), or TCL, which is a mighty programming language and not easy to deploy (if you want to do it right). That's why I want to do an experiment with Lua. This is a small scripting language, not so powerful as TCL, but possibly with exactly the features we need for this kind of project.
So, watch out for "Lua" tasks there. Integrating BRL-CAD in Lua requires a steep learning curve, but after implementing the first few functions you'll see that it becomes mostly copy-n-paste. I plan to divide the tasks there in two steps: Implementing a new feature and testing it. This gives you the possibility to rethink your implementations and fix bugs if there are one.

Any comments?

view this post on Zulip Naseef (Dec 09 2017 at 19:58):

Why lua?

view this post on Zulip Naseef (Dec 09 2017 at 20:02):

Okay, So after some googling, Lua looks like the perfect option. It's lightweight, fast, MIT licensed. So yeah, Why not?

view this post on Zulip Daniel Rossberg (Dec 09 2017 at 20:41):

To be honest, this isn't my first Lua binding project. That's why Lua was a natural option for me.
And, see it as an experiment: How far can we go during this GCi?

view this post on Zulip Mahdi (Dec 10 2017 at 17:06):

@Sean @Daniel Rossberg am I not supposed to use OpenGL with QT? I'm so confused about the task... I understand that I have to create a raytrace but there are many ways that could be achieved. I was told that I had to use OpenGL but then told not to... what exactly do I have to use?

view this post on Zulip Daniel Rossberg (Dec 10 2017 at 17:17):

For this task a simple 2D widged will do it. A ray-traced image is a simple 2D bitmap.

view this post on Zulip Mahdi (Dec 10 2017 at 17:19):

Would I fail if I used a 3D widget?

view this post on Zulip Daniel Rossberg (Dec 10 2017 at 17:27):

It wouldn't mean a fail but I wouldn't use it in the future because OpenGL causes to much trouble for me. It's simple an unnecessary overhead here.

view this post on Zulip Mahdi (Dec 10 2017 at 17:31):

I've dedicated so much time trying to learn it so that's a bit disappointing.

view this post on Zulip Mahdi (Dec 10 2017 at 17:33):

What did Sean mean by using the OpenGL widgets then?

view this post on Zulip Mahdi (Dec 10 2017 at 17:33):

Did I just misinterpret him?

view this post on Zulip Daniel Rossberg (Dec 10 2017 at 17:33):

I commented it here already on December 7th. I.e. this isn't new.

view this post on Zulip Daniel Rossberg (Dec 10 2017 at 17:34):

Sean loves OpenGL. Maybe he has a computer where it works.

view this post on Zulip Sean (Dec 10 2017 at 17:34):

hehe

view this post on Zulip Sean (Dec 10 2017 at 17:35):

wasn't clear to me which the task intended -- I apparently assumed incorrectly

view this post on Zulip Mahdi (Dec 10 2017 at 17:37):

ah...

view this post on Zulip Mahdi (Dec 10 2017 at 17:39):

lol there goes 3 days worth of code

view this post on Zulip Daniel Rossberg (Dec 10 2017 at 18:23):

@Mahdi Don't be sorry. Now, you may know more about OpenGL than I do. I've fixed some bugs in OpenGL code over the years but never wrote something from scratch.

My first contact with OpenGL was a rotating cube. It needed some seconds for every step in the rotation (Pentium 90, probable no support by the graphics driver). Now, my new computer has a recent Nvidia graphic card and OpenGL windows on Linux are broken. The driver is known to be not perfect. Similar on another Linux machine. If I activate the desktop effects there some texts are illegible.
And, I've more such stories ...

view this post on Zulip Daniel Rossberg (Dec 10 2017 at 18:30):

But nevertheless the task description of GUI 5 is unclear written. Maybe I should precise it to 2D drawing area.

BTW, using an acceleration structure would be very useful here, at least in the future: Draw to an image and flash this to the widged. This way there isn't another ray-trace necessary when the program window want's a refresh. But this isn't required for this task - maybe this is something for an own task.

view this post on Zulip Mahdi (Dec 10 2017 at 18:43):

Reviewing the extensions of 2D graphics with QT I stumbled upon a new module called QT3D which attempts to provide a high-level option for 3D graphics. I believe we could use this new technology to take advantage of the accelerated graphics of OpenGL without having to get our hands dirty by coding it. Do you think this might be an alternative to the 2D task? It might be a lot more maintainable as QT is moving towards QML and we may need to futureproof.

view this post on Zulip Mahdi (Dec 10 2017 at 18:43):

QT3D has frameworks for c++ and qml so that might be advantageous

view this post on Zulip Daniel Rossberg (Dec 10 2017 at 18:59):

If you have 3D data to display this could be a good abstraction layer which hides the OpenGL, Direct 3D, ... behind.

However, the goal is here to create a 2D image. I'm afraid that this won't become easier with QT3D.

view this post on Zulip Mahdi (Dec 10 2017 at 19:01):

aren't the QT tasks supposed to be about rendering 3D graphics? Similar to what Archer does?

view this post on Zulip Daniel Rossberg (Dec 10 2017 at 19:03):

Yes, but the rendered image is 2D. It's a picture.

view this post on Zulip Daniel Rossberg (Dec 10 2017 at 19:05):

Another situation would be with the wireframe representation. But I'm afraid that this would go to far for this GCi.

view this post on Zulip Mahdi (Dec 10 2017 at 19:06):

But if we render it in 3D and then calculate the pixel values to create a 2D representation with pixmap it would work, right?

view this post on Zulip Mahdi (Dec 10 2017 at 19:08):

I would love to tackle the challenge if you considered breaking it down into smaller tasks: like getting qt3d setup, simple image rendering, etc... and then eventually reaching more advanced low-level methods.

view this post on Zulip Daniel Rossberg (Dec 10 2017 at 19:08):

Ah, I think you don't know what "render" means.

view this post on Zulip Mahdi (Dec 10 2017 at 19:09):

Sorry I wasn't referring to it in a graphical context I just meant a general render

view this post on Zulip Mahdi (Dec 10 2017 at 19:09):

as in just displaying it visually

view this post on Zulip Daniel Rossberg (Dec 10 2017 at 19:11):

It's already broken in small parts. GUI 5 requires you to add a QtView (I have no Qt manual at hand to check this), which is trivial, and a function for coordinate transformation.

view this post on Zulip Mahdi (Dec 10 2017 at 19:12):

Oh I see I was just suggesting qt3d as a new task sequence

view this post on Zulip Mahdi (Dec 10 2017 at 19:14):

With the GUI 5 it's just a graphicsscene, graphicsview, and then simple conversion of coordinates. I was just thinking about it and thought the QT3D might make for some fun tasks so that's why I suggested it

view this post on Zulip Daniel Rossberg (Dec 10 2017 at 19:15):

Then, in GUI 6, you should create a ray-traced image in this widged. I.e. in GUI 5 you don't need to draw anything.

The result of the ray-tracing in GUI 6 should look similar to the result of rt in the frame buffer.

view this post on Zulip Mahdi (Dec 10 2017 at 19:15):

There's no drawing in GUI 5?

view this post on Zulip Daniel Rossberg (Dec 10 2017 at 19:18):

No, only the widged and a function. I tried to make the tasks small :wink:
Such that you can do a lot of them.

view this post on Zulip Mahdi (Dec 10 2017 at 19:20):

That's probably for the best :) Do you think you'll consider adding a QT3D task for GUI 7 or whatever?

view this post on Zulip Daniel Rossberg (Dec 10 2017 at 19:24):

I haven't planned it yet. I want to make more for the Lua binding.
3D would only make sense with the wireframe representation where I haven't prepared anything yet.

view this post on Zulip Daniel Rossberg (Dec 10 2017 at 19:25):

Thinking about it would require some time.

view this post on Zulip Mahdi (Dec 10 2017 at 21:10):

Hold up, if the task isn't to create a wire frame what coordinates am I converting? The bounding box? I think I keep over thinking this

view this post on Zulip Mahdi (Dec 10 2017 at 21:18):

Or is it the object coordinates

view this post on Zulip Daniel Rossberg (Dec 10 2017 at 21:23):

The image is like a projection of the 3D model. A 2D coordinate from the image plane corresponds to a 3D line in the model space. The directions of all these lines are the same.

To make it easier you can choose any fixed projection you like. It would be a future task to let the user choose one.

view this post on Zulip Mahdi (Dec 10 2017 at 21:31):

I sort of get how to display the coordinates as an image but what I don't get is how to actually obtain the model coordinates. Say someone decides to choose demonstrations/ant

view this post on Zulip Mahdi (Dec 10 2017 at 21:33):

How would you get the coordinates of the ant? I get how you can get the boundingbox and other attributes like region, color, etc but how do you get the individual coordinates forming the object?

view this post on Zulip Mahdi (Dec 10 2017 at 22:09):

Ah, nvm we have to get the coordinates from the hit/miss -- I see now.

view this post on Zulip Sean (Dec 11 2017 at 06:33):

ah...

not necessarily -- there are other tasks that are very explicitly qt-opengl so if you did work there, feel free to claim those tasks and get credit for the work. it should requires minimal effort on your part. I believe you can find the tasks if you search on qt or possibly opengl as keywords.

view this post on Zulip Daniel Rossberg (Dec 11 2017 at 09:05):

Ah, nvm we have to get the coordinates from the hit/miss -- I see now.

Not really. The goal is to create a ray-trace image. I.e., you have a 2D array which entries are called pixel and want to know the color of each of it. The colours of the pixels are determined by a kind of "what you see when you project the model viewing plane". The projection goes from your eye "through" the model on the projection plane. And for the moment, we can assume that all these projection rays are parallel.

Furthermore, GUI 5 doesn't tell you which projection you shall choose. It's your decision, so take an easy one as the projection on the (x-y) ground plane. Then, your rays are (0, 0, -1) and you only have to determine their start points.

BTW, QWidged is all you need from Qt to have something where you can draw at.

view this post on Zulip Mahdi (Dec 11 2017 at 20:44):

I just can't seem to get how you obtain any type of coordinate information from the Object class ;|

view this post on Zulip Daniel Rossberg (Dec 11 2017 at 20:46):

You don't need to.

view this post on Zulip Mahdi (Dec 12 2017 at 00:16):

projperspective.gif

view this post on Zulip Mahdi (Dec 12 2017 at 00:16):

Something like this?

view this post on Zulip Daniel Rossberg (Dec 12 2017 at 08:19):

Not really. First, I would recommend to use a parallel projection. It's easier to start with.

Then you need to understand how the image generation works. If we talk about a projection one could think of taking a point from the model and searching its image on the projection surface. Unfortunately, it doesn't work this way. Doing so e.g. it would be hard to ensure that every pixel of the drawing surface is covered once.

It works rather the other way round. You take a pixel from the drawing surface and ask: Which colour has it? I.e., searching for a function like Colour(x, y). (STOP! This is not the function GUI 5 ask for.) So, how do you get the colour of a pixel? The geometry is somehow floating above the projection surface, and from the projection you get a line starting from the pixel through the geometry. In case of a parallel projection all these lines are parallel, i.e. have the same direction. Now, lines, ray-trace, do you see where this will lead to?

view this post on Zulip Mahdi (Dec 12 2017 at 14:47):

So the raytrace would be something like:
for each pixel {
shoot ray
get level of light in that pixel
project pixel onto an image
}

view this post on Zulip Mahdi (Dec 12 2017 at 14:51):

I'm still unsure of what coordinates the task refers to

view this post on Zulip Mahdi (Dec 12 2017 at 14:52):

Would you get the shape formed by the boundingbox and shoot rays inside its area?

view this post on Zulip Daniel Rossberg (Dec 12 2017 at 15:02):

You are getting closer.
For every pixel you shoot a ray. This ray hits some component which has a colour which you can assign to the pixel.

Now you need a function which gives you for each pixel a ray. With parallel projection the direction of the rays is always the same. Left the ray start points.

BTW, there is no "project pixel onto an image". The pixel IS in the image. The image is build from pixels.

view this post on Zulip Mahdi (Dec 12 2017 at 15:10):

Hm, so by setting up a camera which can be transformed or just manually inputting a direction value for the ray you can get different raytraces

view this post on Zulip Mahdi (Dec 12 2017 at 15:13):

So you need a ray origin and direction, right

view this post on Zulip Daniel Rossberg (Dec 12 2017 at 15:15):

Exactly. But for GUI 5 it is even easier: You can have a fixed projection (direction) here. No user interaction is required here. The only issue you have to take care for is that the geometry (enclosing box) fits somehow well on the drawing area (QWidged).

view this post on Zulip Daniel Rossberg (Dec 12 2017 at 15:16):

To debug this and get this working is GUI 6.

view this post on Zulip Mahdi (Dec 12 2017 at 15:16):

So in the end GUI 5 just has to do with the box formed by the min and max bounding?

view this post on Zulip Daniel Rossberg (Dec 12 2017 at 15:17):

In principle yes.
The ray direction can be a hard coded one.

view this post on Zulip Mahdi (Dec 12 2017 at 15:18):

I can't believe I've spent an entire week on just that ...

view this post on Zulip Daniel Rossberg (Dec 12 2017 at 15:18):

I would recommend to use rays along a coordinate axis.

view this post on Zulip Daniel Rossberg (Dec 12 2017 at 15:19):

This task seems to be much more about understanding how 3D geometry, projection, and ray-trace works than I thought.

view this post on Zulip Daniel Rossberg (Dec 12 2017 at 15:21):

If it consoles you: You are the first student who went into these regions :simple_smile:

view this post on Zulip Mahdi (Dec 12 2017 at 15:23):

I woke up this morning adamant that I was too dumb for these tasks and should just give up. That really gives me some comfort

view this post on Zulip Daniel Rossberg (Dec 12 2017 at 15:28):

No need to be feel bad. You are outstanding. And, I plan to put your work in our repository, well in the experimental rt^3 branch first.

view this post on Zulip Daniel Rossberg (Dec 12 2017 at 15:29):

And, when you are stuck again keep talking with the mentors.

view this post on Zulip Michal Hanus (Dec 12 2017 at 21:27):

Hi @Daniel Rossberg. May I have a hint for QT task 4, what is meant by "element extends" and how to get them? I can list all the top level elements in Qt window and read their attributes from *.g database (mostly rgb colors) but I could not find any readable dimensions in it. Shall I convert it to ascii first and recalculate all the included .r and .s elements to get the overall size of the object or is there a simpler way I could not see? Thank you.

view this post on Zulip Daniel Rossberg (Dec 12 2017 at 21:44):

@Michal Hanus BoundingBoxMinima(), BoundingBoxMaxima() (after selecting the object)

view this post on Zulip Sean (Dec 13 2017 at 05:13):

@Mahdi you're tackling one of the hardest and most valuable projects -- you should be proud of what you've already accomplished. You're doing well. :)

view this post on Zulip Naseef (Dec 23 2017 at 11:34):

Can you help me on "BRL-CAD Alternative GUI 4: Selection of a Combination"? I don't understand what I have to do.

view this post on Zulip Naseef (Dec 23 2017 at 11:36):

What should be on the window?

view this post on Zulip Daniel Rossberg (Dec 23 2017 at 12:04):

From the previous task you already have a filled ConstDatabase. Iterate over the top objects (start with FirstTopaObject()) and build a list of them. Select() one of them, get the bounding box minima and maxima, and print these numbers on the window.

view this post on Zulip Naseef (Dec 23 2017 at 12:52):

Is there a way to keep history of my code edits? Like SVN, GIT ( Locally)? I frequently get everything messed up, Especially when I have no idea what I am doing.

view this post on Zulip Daniel Rossberg (Dec 23 2017 at 16:01):

For local, private use I would recommend git because there is less overhead. Type git init in your base directory and you are ready to start.

view this post on Zulip Jeff Sieu (Dec 23 2017 at 18:42):

help, getting undefined references when trying to make :confused: . On QT#2.

view this post on Zulip Daniel Rossberg (Dec 23 2017 at 19:21):

You have to link with the coreinterface library.


Last updated: Oct 09 2024 at 00:44 UTC