Game Development Community

Using the Eye node of a mounted image...

by Kirby Webber · in Torque Game Engine · 07/26/2005 (10:25 am) · 13 replies

I've been searching for a way to use the eye node of a mounted image in first person view, rather than the eye node of the control object.

The reason I need this is that the mounted object's eye node will be animated, whereas the control objects' (which si a vehicle) won't.

Ideally, I'd like to just leave the eye noe out of the control objects' mesh altogether and force the engine to use the mounted images eye. - I tried this frst with no script or engine mods, but it (of course) didn't work.

Any thoughts on how to go about something like this?

#1
07/26/2005 (12:14 pm)
Iterate over the mounted images, choose the first one, find the node called eye, and transform the position out to whatever space it needs to be in (world?). Don't forget to call animate where appropriate.
#2
07/26/2005 (12:22 pm)
Ben - I'm not sure I understand what you mean when you say "iterate over mounted images"?

Can this be done from script or will it require source modification?

I'm guessing you mean to locate the section of camera code that attaches the camera entity to the control object?
#3
07/26/2005 (2:09 pm)
This is a C++ level change. There is a Vector that contains references to the images mounted to a ShapeBase. Similarly, you can get the position of different nodes; grep for findNode to get some tea leaves on that.
#4
07/26/2005 (2:13 pm)
Ahhh... gotcha.

I'm on it as soon as I hit the door.

Thanks Ben - as usual. (C;
#5
07/26/2005 (2:21 pm)
No worries. Good luck getting it all taken care of! :)
#6
07/27/2005 (7:04 am)
Wow, has this ever been an exercise in frustration.

Here's my current thinking:

To iterate through the mounted images, I'll need to set a loop and check each image for an eyeNode, i.e.

while (index <= MaxMountedImages){
     if (mMountedImage[index]->findNode("eye"))
          eyeNode = mMountedImage[index]->findNode("eye");

     index++;
}//end while

That code is loosely based on code found elsewhere in shapeBase.cc and shapeImage.cc that seem to be iterating through mounted images themselves.

The problem I'm encounterting is that the eyeNode is assigned it's location in shapBase.cc (around line 274... ish) with the statement: eyeNode = shape->findNode("eye"); (found that because of your help Ben ;-) Images, on the other hand, seem to be handled in shapeImage.cc, which derives from shapeBase.h.

What is making this difficult is that, despite the use of mMountedImages further down in shapeBase.cc, it doesn't recognize the variable when I try to use it. (Bear in mind that I'm a 'C' programmer at heart whose primary exposure to OO programming was Java. o.0)

Furthermore, I get a second error when trying to use that logic (or some reasonable facsimile thereof): "left of findNode() must point to a class struct union."

I believe I've bitten off a bit more than I can chew here, so I need help.

Ideally, if you'd walk me through why it doesn't work as-is and point me in the right direction... I really want ot understand this at least at a basic level. (Give a man a fish and feed him for a day, teach a man to fish and feed him for a lifetime.)

[Edit]

I've been trying to implement this change in the preload function of shapeBase.cc as it seems to be the most logical place.

~ Thought I'd add this just in case...
#7
07/27/2005 (1:45 pm)
I hate having to do this, but...

*bump* =\
#8
07/27/2005 (9:09 pm)
Oh, for pete's sake... It's only been 6 hours since your last post, and my last post was yesterday, less than 48 hours ago. Show a little restraint. :)

shapeImage.cc contains the ShapeBaseImage and related code implementation details, which are partially defined in shapeBase.h. What class are you running that code in? I think you're running into a lack of knowledge of C++, and unfortunately, me combined with this venue is not the best opportunity to increase your knowledge... I'd strongly suggest taking a class, reading a book, reviewing some simpler C++ code, or something similar.

In terms of Torque, findNode is a method of TSShapeInstance (I think - might be TSShape) which returns the ID of a given node in a model. From that node ID you can get the actual transform of the node in object (specifically the mounted image's) space; this can be easily transformed into world space (in our case, from mounted image space to object space to world space), giving you the long sought after eye point. Easier said than done, it's true, but not by much.
#9
07/28/2005 (10:16 am)
~Doh.

After reading your respone (posted at 11:09 PM? - good lord man, get some REST! =P) it occurred to me the the m in mMountedImages is a member variable - just not a member of the class I was working in.

Honestly, I'd have to look at it again when I get home to see exactly where I was at. =\

/Sigh, time to pull "Sam's teach yourself C++" off the shelf.

My memory is starting to jog though, I'm starting to see the same realtionships between classes and objects that I recall seeing in Java (minus the cool, this makes video games thing. ;-).

I'll just have to plug along slowly - it'll start sinking in if I keep at it.

Thanks for your help Ben. I'm sure I'll be hitting you up again in the future.

Incidentally, you should make sure that your Amazon wish list is up to date - I have a feeling I'mgoign to owe you by the time all is said and done. (C;
#10
07/28/2005 (10:51 am)
I'll give it a check. That Daft Punk DVD is looking pretty attractive. ;)

Good luck with the problem; I'm sure with a little work and some help from the community (or the GG Google search) you'll get it sorted out.
#11
07/28/2005 (1:35 pm)
Actually, I think I've found some insight into where this will need to be done.

Digging through the source documentation revealed that getCameraParameters(), getCameraTransform() and mountObject() are all public methods of the rigid body in the vehicle parent class.

I plan to start here. Logic I understand, it's the d@mn syntax that throws me curves every time I turn around. (C;

I think this should give me a solid start.
#12
07/28/2005 (2:08 pm)
Oh man - I could slap myself for not thinking of this before now... it's a hack, but I'd be interested to hear your take on it Ben.

Instead of actually mounting the camera to the shapeImage, what if I duplicated the rider skeleton (only the spine, neck, and head/ eye would really be necessary) and mimicked each frame of the animation?

I believe I'd only be looking at roughly 30-50 frames worth of data (if that) that would ultimately amount to less than 10 seconds of screen time total (probably more like 3 - 5 all told).

Now, it wouldn't necessarily be the most accurate as far as matching the *exact* position of the riders head, but then the player would never be aware of that anyway.

The only question it leaves is what kind of impact on performance would this have? I'm thinking pretty d@mn negligible.
~=|
#13
07/28/2005 (3:11 pm)
Yeah, that sounds like a much more elegant solution. Good thinking! Let us know how it works out.