Game Development Community

RC3 - Object not showing up using .pickPoint

by Richard Foge · in Torque Game Builder · 06/15/2006 (4:33 pm) · 12 replies

I'm having an issue with $mainScene.pickPoint() not returning all of the objects that it should be.

I create the objects with:
%obj = new t2dStaticSprite(%pieceName) { config = "AquaPiece"; sceneGraph = $mainScene; };

and then have my sceneWindow2D::mouseUp:
%objList = $mainScene.pickPoint(%xPos, %yPos);
echo("%objList: " @ %objList);

$mainScene is set to sceneWindow2D.

%objList has a couple of objects in it, but not the objects that were created in the example above.

This setup was working in the beta builds, I just got RC3 and it no longer works. Any tips on what I need to do to fix this?

Thanks!
Richard

#1
06/15/2006 (4:49 pm)
Also, when creating the objects I get this in output:

t2dPhysics::setCollisionPolyCustom() - Polygon is defined counter-clockwise! Changing to clockwise!
#2
06/15/2006 (4:52 pm)
That definitely could be related. If you re-define you collision polygon in a clockwise order of the nodes, does the problem go away?
#3
06/15/2006 (7:03 pm)
I didn't define the collision for these AFAIK, they're pretty much just image maps...

And if you could tell me how to re-define the poly I'd be grateful. :)

Thanks for the help!
#4
06/15/2006 (8:08 pm)
Select a sprite and select the 1st icon in the mini-toolbar - "edit this object's collision polygon". Maybe one got defined by accident? You can also look at your level.t2d file to see if there is a collision poly list for the object there.
#5
06/15/2006 (8:17 pm)
Hrm...

These pieces aren't in the level until run-time, so I really don't see where they could be getting collision polygons defined for them in the first place unless it's something that's happening automagically.
#6
06/15/2006 (8:19 pm)
You are right that is weird
#7
06/15/2006 (8:22 pm)
I think you are correct that this is probably the problem though, it's the only thing that appears to have changed since the last time I got a new build. I'm going to keep looking in this direction, thanks for your help!
#8
06/16/2006 (2:59 am)
Richard,

could you post some more information on this? What does the config datablock look like. Do you flip objects, maybe post the whole creation code.

Quote:
$mainScene is set to sceneWindow2D.

Does that mean $mainScene is your scene window or your scenegraph?

-Michael
#9
06/16/2006 (8:20 am)
I have problems with %t2dObj.getIsPointInObject() not working or when it does work the bounds of the object are really weird (tiny sliver of area, sometimes in multiple places on the screen for a single object). There's some definite bugs in that whole set of functionality.

With these kinds of bugs still in the engine, it would be wise to release RC4 before going final.

Edit: I don't think it's the counter-clockwise bug, since I don't define a custom polygon on my objects.
#10
06/16/2006 (8:29 am)
@Jason: as of RC3 are you still having problems with getIsPointInObject() ?
#11
06/16/2006 (8:30 am)
Quote:$mainScene is set to sceneWindow2D.

shouldn't $mainScene be set to the scenegraph and not sceneWindow2D.?
#12
06/16/2006 (4:19 pm)
Datablock is set up like so:
new t2dSceneObjectDatablock(PuzzlePiece){
	// misc values
	size = "2.5 2.5";
	speed = 20;
	dropSpeed = 50;
	isSelectable = true;
};

// aqua piece
new t2dSceneObjectDatablock(AquaPiece : PuzzlePiece){
	superClass = PuzzlePiece;

	// misc values
	color = $Aqua;
	imageMap = PieceAquaImageMap;
	matchImageMap = PieceAquaMatchImageMap;
};

The scenegraph setup uses this in startGame():
if( isFile( %level ) )
$mainScene = sceneWindow2D.loadLevel(%level);

My understanding was that loadLevel returns the scenegraph. I was having some trouble with this in the previous build and this ended up working. I don't understand scenegraph manipulation by a long shot, but this was working all right until I grabbed RC3, (the build I had before that was beta 3).

The creation code is pertty much exactly what I posted up top, I make the object with:
I create the objects with:
%obj = new t2dStaticSprite(%pieceName) { config = "AquaPiece"; sceneGraph = $mainScene; };

Then I set a few other fields. Basically I loop through each piece with this:
// randomize piece from $Aqua(1) to $Yellow(8)
	%randomPiece = getRandom($Aqua,$Yellow);
	%pieceName = "Piece" @ %columnIndex @ %i;

	if(%randomPiece == $Aqua)
		%obj = new t2dStaticSprite(%pieceName) { config = "AquaPiece"; sceneGraph = $mainScene; };
	else if(%randomPiece == $Black)
		%obj = new t2dStaticSprite(%pieceName) { config = "BlackPiece"; sceneGraph = $mainScene; };
	else if(%randomPiece == $Blue)
		%obj = new t2dStaticSprite(%pieceName) { config = "BluePiece"; sceneGraph = $mainScene; };
	else if(%randomPiece == $Green)
		%obj = new t2dStaticSprite(%pieceName) { config = "GreenPiece"; sceneGraph = $mainScene; };
	else if(%randomPiece == $Orange)
		%obj = new t2dStaticSprite(%pieceName) { config = "OrangePiece"; sceneGraph = $mainScene; };
	else if(%randomPiece == $Purple)
		%obj = new t2dStaticSprite(%pieceName) { config = "PurplePiece"; sceneGraph = $mainScene; };
	else if(%randomPiece == $Red)
		%obj = new t2dStaticSprite(%pieceName) { config = "RedPiece"; sceneGraph = $mainScene; };
	else if(%randomPiece == $Yellow)
		%obj = new t2dStaticSprite(%pieceName) { config = "YellowPiece"; sceneGraph = $mainScene; };


	// fill object fields
	%obj.column = %columnIndex;
	%obj.row = $MaxRows - (%i + 1);

	// calculate/set the position of the object
	%pos = ($BoardStartX + ($PieceSize * %columnIndex)) SPC $UpEdgeOff;
	%obj.setPosition(%pos);

	// set the image map of the sprite
	%obj.setImageMap(%obj.imagemap);
	// set the size of the object
	%obj.setSize(%obj.size);
	// set the layer of the object
	%obj.setLayer(10);

	// add the card to the column indicated by %columnIndex
	%evalString = "ColumnSim" @ %columnIndex @ ".add(%obj);";
	eval(%evalString);

	// schedule to drop the piece into the gameboard
	%obj.schedule(%waitTime * $PieceWait, "DropPiece");

	// mark the object as moved so that it is checked properly
	%obj.moved = true;

	// increment %waitTime
	%waitTime++;