Search Home Members Contacts
About Us
Products
Downloads
Community
Support
Pages: [1]
  Print  
Author Topic: Explanation of TVScene.MousePickEx(...)  (Read 603 times)
Bierstuebl
Customers
Community Member
*****
Posts: 49


« on: January 30, 2008, 11:17:08 AM »

Hi there,

can anybody please tel me what TVScene.MousePickEx(...) ist exactly supposed to do and how it works? Can I e.g. detect all meshes that are in the way of a cast ray up to a certain depth etc.?

Many thanks in advance,
Bierstuebl
Logged
SylvainTV
Administrator
Community Member
*****
Posts: 4479


WWW
« Reply #1 on: January 31, 2008, 05:24:45 PM »

MousePickEx is the advanced version of MousePick.
It just allows to return all collisions from the mousepicking ray instead of the first one only. You must pass an allocated empty array of TV_COLLISIONRESULT structs, and the allocated struct number in the maxhits (maxhits will return the number of collisions in return)

But warning, it returns only one collision/impact per object. If the ray collides a mesh twice, it will return the closest one.
Logged

Regards

Sylvain Dupont
TrueVision3D Developer
sylvain@truevision3d.com

TV3D IRC at http://chat.truevision3d.com or on server irc.truevision3d.com #Truevision3D. Come talk with us !
Bierstuebl
Customers
Community Member
*****
Posts: 49


« Reply #2 on: February 01, 2008, 04:37:26 AM »

Hi Sylvain,

thanks for your answer. Unfortunately I cannot get this method to work correctly. I have searched the forum an found only two other posts concerning MousePickEx. One of it seems to be broken (theres just a blank page coming up) and the other one describes my problem with the method - but there is no answer to it.

The Problem is that iNumberOfHits is always returned as 0, no matter if a collision has happened or not. Also the array of CollisionResult-Structs seems to remain untouched. However, the bool returnvalue seems to work, it detects collisions. I'm using C#, could that cause the problem? Or maybe I'm doing something wrong. Here is my quick textcode:

Code:
int numHits = 5;
TV_COLLISIONRESULT[] collisions = new TV_COLLISIONRESULT[numHits];
// just a test if there is any change if the structs are creatd with "constructor" (but there is no change)
//for(int i=0; i<numHits; i++)
//{
//  collisions[i] = new TV_COLLISIONRESULT();
//}
bool hitDetected = engine.Scene.MousePickEx(mouseCollDetectX, mouseCollDetectY, ref collisions[0], (int)CONST_TV_OBJECT_TYPE.TV_OBJECT_MESH, CONST_TV_TESTTYPE.TV_TESTTYPE_BOUNDINGBOX, ref numHits);


Is there another way to pass the first element of the struct-array (I got no pinters in C# :-). Can anyone see any errors here?

Many thanks again,
Biertuebl
Logged
Bierstuebl
Customers
Community Member
*****
Posts: 49


« Reply #3 on: February 01, 2008, 04:41:41 AM »

The link that is broken is http://www.truevision3d.com/forums/tv3d_sdk_65/scenemousepickex_oddities-t13978.0.html
You can see a preview of it if you use the forum search function and simply type "MousePickEx" :-) Maybe you already explained the problem to Zarkow - but I can't read it.
Logged
Bierstuebl
Customers
Community Member
*****
Posts: 49


« Reply #4 on: February 04, 2008, 05:24:09 AM »

Pushing this up again. Is nobody able to help? Seems like other peole have the same problem too.

Greetz,
Bierstuebl
Logged
vsleepy
Customers
Community Member
*****
Posts: 245


« Reply #5 on: February 04, 2008, 09:52:57 AM »

 try specifing 0 instead of: (int)CONST_TV_OBJECT_TYPE.TV_OBJECT_MESH so all collisions will get hit, and also set the mode to accuratetesting rather than bounding box.
Logged
vsleepy
Customers
Community Member
*****
Posts: 245


« Reply #6 on: February 04, 2008, 09:54:43 AM »

also what are the values specified by mouseCollDetectX and mouseCollDetectY? are these screen coords or scene coords?
Logged
Bierstuebl
Customers
Community Member
*****
Posts: 49


« Reply #7 on: February 04, 2008, 10:42:43 AM »

Hello vsleepy,

MouseCollDetectX etc. are simply the mouse coordinates I get from Input.GetAbsMouseState(...) some lines of code before. I intentionally use boundingbox instead of accurate testing and I only want to detect collisions with meshes :-)

I use Scene.MousePick(...) with these settings and it works well. I just wanted to switch to Scene.MousePickEx(...) to be able to get all the meshes that are in the way of the cast ray. Unfortunately I simply cannot get this method to work, no matter what I do, it always returns  iNumberOfHits as 0. But as I said, the boolean return value clearly states, that the method correctly detects if a collision happened or not - simply the array and the iNumberOfHits do not change..

Greetz, bierstuebl
Logged
SylvainTV
Administrator
Community Member
*****
Posts: 4479


WWW
« Reply #8 on: February 04, 2008, 01:35:00 PM »

OK I will check.

It maybe works in c++ but not C# (wrapper problem)
Logged

Regards

Sylvain Dupont
TrueVision3D Developer
sylvain@truevision3d.com

TV3D IRC at http://chat.truevision3d.com or on server irc.truevision3d.com #Truevision3D. Come talk with us !
MenDAKE
Community Member
*
Posts: 402


« Reply #9 on: September 26, 2008, 05:25:29 PM »

I seem to be having exactly the same problem in C#. Has a solution been found or a fix made?
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by SMF 1.1.3 | SMF © 2006-2007, Simple Machines LLC
Seo4Smf v0.2 © Webmaster's Talks