Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
PyGTK Track Editor - Round 2
03-26-2008, 11:04 AM,
#1
PyGTK Track Editor - Round 2
I've updated PyGTK Track Editor to use the new scene graph engine. This time I used SWIG to export vdrift to python. The SWIG interface file is vdrift/src/vdrift.i.

When you select an object in the objects list, the camera will move and focus on the object selected. I've not yet decided how to highlight the object in the 3D view. Ideas?
Reply
03-26-2008, 02:29 PM,
#2
 
Excellent, sounds like good progress. How about highlighting the object red or blue or something?
Reply
03-26-2008, 03:30 PM,
#3
Re: PyGTK Track Editor - Round 2
rookie1 Wrote:I've updated PyGTK Track Editor to use the new scene graph engine. This time I used SWIG to export vdrift to python. The SWIG interface file is vdrift/src/vdrift.i.

can you actually add the file and commit it to the repository? thanks.

--alex--
Reply
03-26-2008, 08:35 PM,
#4
Re: PyGTK Track Editor - Round 2
alex25 Wrote:can you actually add the file and commit it to the repository? thanks.

--alex--

It's there in the repo - vdrift r1969 and vdrift track editor r62 (in pygtk-trackeditor branch)

joevenzon Wrote:How about highlighting the object red or blue or something?

Do I need to manipulate the object texture to achieve that? Or is there a simple way?
Reply
03-26-2008, 09:03 PM,
#5
 
Oops, forgot to add vdrift.i in my last commit. It's in the repo now.
Reply
03-26-2008, 11:51 PM,
#6
 
Just wondering - you changed settings.h to remove the definition of the unused function GetConfigFileVersion - was this just because it wasn't used?
http://svn.vdrift.net/viewvc.cgi/trunk/i...35&r2=1969
Reply
03-27-2008, 08:13 AM,
#7
 
Function GetConfigFileVersion() has declaration without implementation. Seems SWIG has problem with such cases.
Reply
03-27-2008, 11:25 AM,
#8
Re: PyGTK Track Editor - Round 2
rookie1 Wrote:Do I need to manipulate the object texture to achieve that? Or is there a simple way?

Hmm... if you're using the VDrift scenegraph interface to do you drawing, then you could probably use DRAWABLE::SetAdditiveMap1(const TEXTUREINFO & tex) and DRAWABLE::SetSelfIllumination(bool newsi). The "additive map" just gets added to the texture, so make the additive map in the gimp or something as a small image with a constant color like RGB (0,0,50). A call to SetSelfIllumination(true) will render with the additive map applied, false with it not applied... it's how the brake lights are done.

Now that I look at the code more, this might only work if shaders are enabled. Doh. Another simple way to do this would be to make a simple "selected object" type texture in the gimp and just replace the diffuse texture of the selected object with this texture.
Reply
03-27-2008, 11:37 AM,
#9
 
I didn't get a chance to play with this last night, hopefully I will look at it some tonight.

On object highlighting, whatever you do, I think it would be best to provide a light source so that the object can be easily seen, and not change the texture of the object. Another texture could be overlayed or something, but changing the texture totally would make it look funny.
Reply
03-27-2008, 11:39 AM,
#10
 
I've pretty much came to the same solution as your first suggestion. Unfortunately it doesn't seem to work. I"m using data/textures/effects/white.png as the additive texture. There is no visible difference however. Did I miss a step? Here is the python code,
Code:
#highlight selected object
    texinfo = vdrift.TEXTUREINFO()
    texinfo.SetName("textures/effects/white.png")
    pyobj.drawable.GetPtr().SetAdditiveMap1(texinfo)
    pyobj.drawable.GetPtr().SetSelfIllumination(True)
    self.trackwindow.queue_draw()

On a side note, why do we need shader=on to have brakelight?
Reply
03-27-2008, 06:44 PM,
#11
 
rookie1 Wrote:Oops, forgot to add vdrift.i in my last commit. It's in the repo now.

i got a chance to play with it a little bit, looks good. one problem i have is that is usually build vdrift without nls support so when it tries to load vdrift i get:

Code:
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "../vdrift/build/vdrift.py", line 7, in ?
    import _vdrift
ImportError: ../vdrift/build/_vdrift.so: undefined symbol: _ZN8SETTINGS12GetLocaleDirEv

i got around this by building vdrift with nls support but i was wondering if there is a way to disable nls support for the track editor as well. thanks.

--alex--
Reply
03-27-2008, 09:32 PM,
#12
 
This is the same issue as SETTINGS::GetConfigFileVersion(). If NLS is not enabled, GetLocaleDir() will have a declaration without implementation. I think what we need to do is add #ifdef ENABLE_NLS around GetLocaleDir() in settings.h. I don't have access to my developement pc right now. Can someone go ahead and commit this change?
Reply
03-27-2008, 09:54 PM,
#13
 
rookie1 Wrote:This is the same issue as SETTINGS::GetConfigFileVersion(). If NLS is not enabled, GetLocaleDir() will have a declaration without implementation. I think what we need to do is add #ifdef ENABLE_NLS around GetLocaleDir() in settings.h. I don't have access to my developement pc right now. Can someone go ahead and commit this change?

indeed, that did the trick. i've committed the change to the svn repository.

--alex--
Reply
03-28-2008, 10:35 AM,
#14
 
It turns out my additive texture calls do work as expected. It's the camera code that's screwed up. The camera is not looking at the object when it's selected.

I've committed my changes to svn. The selected object should have a redish tone.

Now I need help on the camera math. This is the code to position the camera,
Code:
obj_pos = vdrift.VERTEX(pyobj.model.jmodel.GetBBOX().GetCenter())
    cam_pos = vdrift.VERTEX(obj_pos)
    cam_pos.x -= 20
    cam_pos.y += 10
    cam_pos.z -= 20
    vdrift.game.cam.SetPosition(cam_pos)
    vdrift.game.cam.dir.LookAt(cam_pos.x, cam_pos.y, cam_pos.z, obj_pos.x, obj_pos.y, obj_pos.z, 0,1,0)
What it does is take the object's bounding box center as object position, and add some offset to get the camera position. Then cam.dir.LookAt() is called to point the camera at the object. From my test, the camera is not exactly pointing at the object though.

So,

1. How do we decide the camera position? Ideally, it should not be too near nor too far. And it should not be obstructed by other objects.

2. Is there anything wrong in the above code to calculate camera direction?
Reply
03-28-2008, 01:46 PM,
#15
 
rookie1 Wrote:It turns out my additive texture calls do work as expected. It's the camera code that's screwed up. The camera is not looking at the object when it's selected.

I've committed my changes to svn. The selected object should have a redish tone.

the latest changes seem to have broken object selection. when i try to select an object i get:
Code:
Traceback (most recent call last):
  File "vdrift-track-editor.py", line 139, in select_obj
    texinfo = vdrift.TEXTUREINFO()
AttributeError: 'module' object has no attribute 'TEXTUREINFO'
and the view doesn't change at all. not that it worked previously, as you correctly pointed out the camera was pointing in random directions but at least it was doing something.

--alex--
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)