Jump to content

A big problem with hidden parented objects and raycasts


ArBuZ
 Share

Recommended Posts

If I have an object (for example Cube called "mesh") parented to some other object (another cube called "ground"). In main loop I make ray-cast (camera pick). The both cubes are visible and they are visible for ray-cast.

 

Now I hide the cube "mesh" (the child). And it is still visible for ray-cast!!!

 

Its not a big problem in the example. But I want to hide different parts of some model, and make this parts unavailable for ray-casting, but the rest of the model should be visible and available for ray-casting.

 

As I understand this problem is consequence of new octree culling system in the engine. But I really need the way as raycasting worked before. Or I will need to do a lot of tricks to make things to work.

 

Here is simple example of the problem.

 

Space - hide the cube.

//	====================================================================
//	This file was generated by Leadwerks C++/LEO/BlitzMax Project Wizard
//	Written by Rimfrost Software
//	http://www.rimfrost.com 
//	====================================================================

#include "leo.h"
using namespace LEO ;

int WINAPI WinMain( HINSTANCE hInstance,
				HINSTANCE hPrevInstance,
				LPSTR lpCmdLine,
				int nShowCmd ) 
{
Engine engine( "VectorTest", 800, 600 ) ;
Engine::SetAbstractPath( "C:/Leadwerks Engine SDK" ) ;
Engine::SetFilters() ;

World world( CREATENOW ) ;
if( !world.IsValid() ) 
{
	MessageBoxA(0,"Error","Failed to create world.",MB_OK);
	return engine.Free() ;
}

Buffer gbuffer( Engine::GetWidth(), Engine::GetHeight() );

Camera camera( CREATENOW );
camera.SetPosition( 0, 0, -2 );

Material material("abstract::cobblestones.mat") ;
Cube	 mesh( CREATENOW ) ;
mesh.Paint( material ) ;
mesh.SetKey("Name","Cube");

Cube ground( CREATENOW ) ;
ground.SetScale( 10, 1, 10 );
ground.SetPosition( 0, -2, 0 );
ground.Paint( material ) ;

mesh.SetParent(ground);
DirectionalLight light( CREATENOW ) ;
light.SetRotation( 45 , 45, 45 );

Source source;

//myClass myC("abstract::gunshot.ogg");
//myClass myC2("abstract::reload.ogg");

std::string name="";
TVec3 pos;
Pick picked;


// Game loop
while( !Keyboard::I****() && !Engine::IsTerminated() )
{
	if( !Engine::IsSuspended() ) // We are not in focus!
	{
		pos=Mouse::GetPosition();
		pos.Z=50;
		if (camera.GetPick(picked,pos))
		{
			name=GetEntityKey(picked.entity,"Name");
		}
		else
			name="";


		if (Keyboard::I****(KEY_SPACE))
		{
			if (mesh.IsHidden()) 
				mesh.Show();
			else
				mesh.Hide();
		}

		// Rotate cube
		//mesh.Turn( Vec3( 0.5f*AppSpeed() ) ) ;

		// Update timing and world
		Engine::UpdateTime();
		World::Update( Engine::GetSpeed()) ;

		// Render
		gbuffer.Set();
		World::Render() ;
		Engine::GetBackBuffer().Set() ;
		World::RenderLights(gbuffer);

		// Send to screen
		Draw::Text(0,0,"%s",name.c_str());
		Engine::Flip(0) ;
	}
}

// Done
return engine.Free() ;
}

Q6600@2.4GHz - 9600GT - 4GB DDR2@800MHz - Windows7 x64

3ds max / photoshop CS3 / C++

http://www.arbuznikov.com

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...