PDA

View Full Version : How to make a 3D model "interactive"



roxlu
08-28-2009, 02:12 AM
Hi, I'm working on a 3D model of a simple block-like building with a couple of windows on each floor. I created this model in blender. Now I want to load this model in my c++/opengl application and change the colors of the windows dynamically.

I've totally no idea what options I have to do this, like:
- how can I get the correct vertices
- what export/import format should I use
- what other options do I have to make my model 'interactive'

All suggestions are welcome.

roxlu

zeoverlord
08-28-2009, 03:13 AM
well i would first suggest that you use the wavefront obj format.
It's probably the easiest to load and it can export material groups which would make it easier to find the vertices's your looking for.

other options, well you can make it texture based or you could use multiple objects or maybe even animations, but that's way to advanced for you.

k_szczech
08-28-2009, 03:52 AM
The question you should be asking is how to design a 3d model so you can change it's window colors dynamically.

Simplest way is, as mentioned above - dynamic texture.

Another way is to make separate object of every window.
Go back to Blender and open your 3d model.
Make a duplicate of entire object, then switch to vertex editing mode. In one object delete window polygons, and in other object delete everything except for window polygons.
Do that for all windows.

Now you must give every object a distinct name ("walls", "door", "window01", "window02", etc.).

When you load this model in your application you can do whatever you want. You can even open the door :)


In general - it's the 3D artist that has to make the model interactive in the first place. If correct information isn't put in the model, then application can do nothing about it.

roxlu
08-28-2009, 06:45 AM
Hi k_szczech,

Thanks for your reply, this clears up some things. I'm starting with opengl/3d and did create a "deformable" worm-creature by code. But that was something different.

I want to use openCV to detect motion which change the colors of the windows, so I'm not sure if this would be a job for the designer, or would it?

And how would I get the object vertices based on their name? Is that part of the OBJ format?

Thanks, Roxlu

ZbuffeR
08-28-2009, 07:26 AM
Simplest for your job would be to output a different file for each model, so that you can easily glColor each object separately.

k_szczech
08-28-2009, 07:41 AM
Just do what I said - split your building model into separate parts. Then export it to .obj - you will see that every part has it's own section in the file. That's all the information you need to know which vertices belong to which window.

It doesn't matter what method you want to use to decide which windows are lit and which are dark. You still need a way to lit one exact window, right?

Just imagine what ZbuffeR wrote - every window is in separate .obj file. This way your application doesn't need to worry about which vertices must change color because entire object changes color.
Luckily you can have multiple objects nicely separated in one .obj file and that's what I was saying.