void CLightSceneNode::doLightRecalc()
	{
		if ((LightData.Type == ELT_SPOT) || (LightData.Type == ELT_DIRECTIONAL))
		{
			LightData.Direction = Vector3(.0f, .0f, 1.0f);
			//getAbsoluteTransformation().rotateVect(LightData.Direction);
			Matrix4 mat = getAbsoluteTransformation();
			LightData.Direction = mat.rotateVect(LightData.Direction);
			LightData.Direction.normalize();
		}
		if ((LightData.Type == ELT_SPOT) || (LightData.Type == ELT_POINT))
		{ 
			const FLOAT32 r = LightData.Radius * LightData.Radius * 0.5f;
			//BBox.MaxEdge.set(r, r, r);
			//BBox.MinEdge.set(-r, -r, -r);
			BBox.setMaximum(Vector3(r, r, r));
			BBox.setMinimum(Vector3(-r, -r, -r));
			//setAutomaticCulling( scene::EAC_BOX );
			setAutomaticCulling(EAC_OFF);
			LightData.Position = getAbsolutePosition();
		}
		if (LightData.Type == ELT_DIRECTIONAL)
		{
			BBox.reset(Vector3(0, 0, 0));
			setAutomaticCulling(EAC_OFF);
		}
	}
//! Constructor.
IAtmosphereStarSceneNode::IAtmosphereStarSceneNode(scene::ISceneNode* parent, scene::ISceneManager* mgr, s32 id,
    video::ITexture* sun, video::ITexture* moon, const core::dimension2df& size)
	: scene::ISceneNode(parent, mgr, id)
{
    #ifdef _DEBUG
	setDebugName("IAtmospherStarSceneNode");
	#endif

    setSize(size);

	setAutomaticCulling(scene::EAC_OFF);

	BufferSun = new scene::SMeshBuffer();
	BufferSun->Material.Lighting = false;
	BufferSun->Material.ZBuffer = video::ECFN_NEVER;
	BufferSun->Material.ZWriteEnable = false;
	BufferSun->Material.AntiAliasing = video::EAAM_OFF;
	BufferSun->Material.setTexture(0, sun);
    BufferSun->Material.MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL;

    BufferMoon = new scene::SMeshBuffer();
    BufferMoon->Material.Lighting = false;
    BufferMoon->Material.ZBuffer = video::ECFN_NEVER;
	BufferMoon->Material.ZWriteEnable = false;
	BufferMoon->Material.AntiAliasing = video::EAAM_OFF;
    BufferMoon->Material.setTexture(0, moon);
    BufferMoon->Material.MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL;

    generateMesh();
}
Esempio n. 3
0
WieldMeshSceneNode::WieldMeshSceneNode(scene::ISceneManager *mgr, s32 id, bool lighting):
	scene::ISceneNode(mgr->getRootSceneNode(), mgr, id),
	m_material_type(video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF),
	m_lighting(lighting)
{
	m_enable_shaders = g_settings->getBool("enable_shaders");
	m_anisotropic_filter = g_settings->getBool("anisotropic_filter");
	m_bilinear_filter = g_settings->getBool("bilinear_filter");
	m_trilinear_filter = g_settings->getBool("trilinear_filter");

	// If this is the first wield mesh scene node, create a cache
	// for extrusion meshes (and a cube mesh), otherwise reuse it
	if (!g_extrusion_mesh_cache)
		g_extrusion_mesh_cache = new ExtrusionMeshCache();
	else
		g_extrusion_mesh_cache->grab();

	// Disable bounding box culling for this scene node
	// since we won't calculate the bounding box.
	setAutomaticCulling(scene::EAC_OFF);

	// Create the child scene node
	scene::IMesh *dummymesh = g_extrusion_mesh_cache->createCube();
	m_meshnode = SceneManager->addMeshSceneNode(dummymesh, this, -1);
	m_meshnode->setReadOnlyMaterials(false);
	m_meshnode->setVisible(false);
	dummymesh->drop(); // m_meshnode grabbed it
}
Esempio n. 4
0
WieldMeshSceneNode::WieldMeshSceneNode(
		scene::ISceneNode *parent,
		scene::ISceneManager *mgr,
		s32 id,
		bool lighting
):
	scene::ISceneNode(parent, mgr, id),
	m_meshnode(NULL),
	m_lighting(lighting),
	m_bounding_box(0.0, 0.0, 0.0, 0.0, 0.0, 0.0)
{
	// If this is the first wield mesh scene node, create a cache
	// for extrusion meshes (and a cube mesh), otherwise reuse it
	if (g_extrusion_mesh_cache == NULL)
		g_extrusion_mesh_cache = new ExtrusionMeshCache();
	else
		g_extrusion_mesh_cache->grab();

	// Disable bounding box culling for this scene node
	// since we won't calculate the bounding box.
	setAutomaticCulling(scene::EAC_OFF);

	// Create the child scene node
	scene::IMesh *dummymesh = g_extrusion_mesh_cache->createCube();
	m_meshnode = SceneManager->addMeshSceneNode(dummymesh, this, -1);
	m_meshnode->setReadOnlyMaterials(false);
	m_meshnode->setVisible(false);
	dummymesh->drop(); // m_meshnode grabbed it
}
Esempio n. 5
0
CSkyDomeSceneNode::CSkyDomeSceneNode(video::ITexture* sky, u32 horiRes, u32 vertRes,
		f32 texturePercentage, f32 spherePercentage, f32 radius,
		ISceneNode* parent, ISceneManager* mgr, s32 id)
	: ISceneNode(parent, mgr, id), Buffer(0),
	  HorizontalResolution(horiRes), VerticalResolution(vertRes),
	  TexturePercentage(texturePercentage),
	  SpherePercentage(spherePercentage), Radius(radius)
{
	#ifdef _DEBUG
	setDebugName("CSkyDomeSceneNode");
	#endif

	setAutomaticCulling(scene::EAC_OFF);

	Buffer = new SMeshBuffer();
	Buffer->Material.Lighting = false;
	Buffer->Material.ZBuffer = video::ECFN_NEVER;
	Buffer->Material.ZWriteEnable = false;
	Buffer->Material.AntiAliasing = video::EAAM_OFF;
	Buffer->Material.setTexture(0, sky);
	Buffer->BoundingBox.MaxEdge.set(0,0,0);
	Buffer->BoundingBox.MinEdge.set(0,0,0);

	Buffer->Vertices.clear();
	Buffer->Indices.clear();

	// regenerate the mesh
	generateMesh();
}
Esempio n. 6
0
CSkyDomeSceneNode::CSkyDomeSceneNode(video::ITexture* sky, u32 horiRes, u32 vertRes,
                                     f32 texturePercentage, f32 spherePercentage, f32 radius,
                                     ISceneNode* parent, ISceneManager* mgr, s32 id)
    : ISceneNode(parent, mgr, id), Buffer(0),
      HorizontalResolution(horiRes), VerticalResolution(vertRes),
      TexturePercentage(texturePercentage),
      SpherePercentage(spherePercentage), Radius(radius)
{
#ifdef _DEBUG
    setDebugName("CSkyDomeSceneNode");
#endif

    setAutomaticCulling(scene::EAC_OFF);

    Buffer = new CMeshBuffer<video::S3DVertex>(mgr->getVideoDriver()->getVertexDescriptor(0));
    Buffer->getMaterial().Lighting = false;
    Buffer->getMaterial().ZBuffer = video::ECFN_DISABLED;
    Buffer->getMaterial().ZWriteEnable = false;
    Buffer->getMaterial().AntiAliasing = video::EAAM_OFF;
    Buffer->getMaterial().setTexture(0, sky);
    Buffer->getBoundingBox().MaxEdge.set(0, 0, 0);
    Buffer->getBoundingBox().MinEdge.set(0,0,0);

    // regenerate the mesh
    generateMesh();
}
Esempio n. 7
0
CcAudioSceneNode::CcAudioSceneNode(cAudio::IAudioManager* audioManager, scene::ISceneNode* parent, scene::ISceneManager* smgr, s32 id) :
    scene::ISceneNode(parent, smgr, id), audioManager(audioManager) {

    setAutomaticCulling(scene::EAC_OFF);

    deleteWhenFinished = true;
    MinDistance = 20.0f; // a usual good value for irrlicht engine applications
    MaxDistance = -1.0f;
    PlayMode = EPM_RANDOM;
    TimeMsDelayFinished = 0;
    MaxTimeMsInterval = 5000;
    MinTimeMsInterval = 1000;
    PlayedCount = 0;


    if (audioManager)
    {
        audioSource = audioManager->create("","",false);
    }
    else
    {
        // There must be an error handler ...
    }

    cube = smgr->addCubeSceneNode(0.5f);
    cube->setMaterialTexture(0,smgr->getVideoDriver()->getTexture("data/misc/square.jpg"));
    text = smgr->addTextSceneNode(smgr->getGUIEnvironment()->getBuiltInFont(), L"", video::SColor(0xFF00AF00));

}
CSkyDomeSceneNode::CSkyDomeSceneNode(video::IVirtualTexture* sky, uint32_t horiRes, uint32_t vertRes,
		float texturePercentage, float spherePercentage, float radius,
		IDummyTransformationSceneNode* parent, ISceneManager* mgr, int32_t id)
	: ISceneNode(parent, mgr, id), Buffer(0),
	  HorizontalResolution(horiRes), VerticalResolution(vertRes),
	  TexturePercentage(texturePercentage),
	  SpherePercentage(spherePercentage), Radius(radius)
{
	#ifdef _DEBUG
	setDebugName("CSkyDomeSceneNode");
	#endif

	setAutomaticCulling(scene::EAC_OFF);

	Buffer = new video::IGPUMeshBuffer();
	Buffer->getMaterial().ZBuffer = video::ECFN_NEVER;
	Buffer->getMaterial().BackfaceCulling = false;
	Buffer->getMaterial().ZWriteEnable = false;
	Buffer->getMaterial().setTexture(0, sky);
	BoundingBox.MaxEdge.set(0,0,0);
	BoundingBox.MinEdge.set(0,0,0);

	// regenerate the mesh
	generateMesh();
}
Esempio n. 9
0
//! constructor
CEmptySceneNode::CEmptySceneNode(ISceneNode* parent, ISceneManager* mgr, s32 id)
: ISceneNode(parent, mgr, id)
{
	#ifdef _DEBUG
	setDebugName("CEmptySceneNode");
	#endif

	setAutomaticCulling(scene::EAC_OFF);
}
//! constructor
CDummyTransformationSceneNode::CDummyTransformationSceneNode(
	ISceneNode* parent, ISceneManager* mgr, s32 id)
	: IDummyTransformationSceneNode(parent, mgr, id)
{
	#ifdef _DEBUG
	setDebugName("CDummyTransformationSceneNode");
	#endif

	setAutomaticCulling(scene::EAC_OFF);
}
VoxelSceneNode::VoxelSceneNode(irr::scene::ISceneNode * parent, irr::scene::ISceneManager * manager, s32 id) : irr::scene::IMeshSceneNode(parent, manager, id)
{
	Material.Wireframe = false;
	Material.Lighting = false;
	threads = 0;

	Mesh = new irr::scene::SMesh();

	setAutomaticCulling(scene::EAC_OFF);
}
Esempio n. 12
0
GPUParticle::GPUParticle(scene::ISceneNode *parent, scene::ISceneManager* mgr, ITexture *tex)
    : scene::ISceneNode(parent, mgr, -1) {
    initGL();
	fakemat.Lighting = false;
	fakemat.ZWriteEnable = false;
	fakemat.MaterialType = irr_driver->getShader(ES_RAIN);
	fakemat.Thickness = 200;
	fakemat.setTexture(0, tex);
	fakemat.BlendOperation = video::EBO_NONE;
	setAutomaticCulling(0);
  }
Esempio n. 13
0
// ----------------------------------------------------------------------------
IRoad::IRoad(ISceneNode* parent, ISceneManager* mgr, s32 id, ISpline* s, stringw n)
                                                       :ISceneNode(parent, mgr, id)
{
    setName(n);
    m_spline            = s;
    m_detail            = 0.25f;
    m_width             = 16.0f;

    setAutomaticCulling(EAC_OFF);

} // IRoad
//! constructor
CShadowVolumeSceneNode::CShadowVolumeSceneNode(const IMesh* shadowMesh, ISceneNode* parent,
		ISceneManager* mgr, s32 id, bool zfailmethod, f32 infinity)
: IShadowVolumeSceneNode(parent, mgr, id),
	ShadowMesh(0), IndexCount(0), VertexCount(0), ShadowVolumesUsed(0),
	Infinity(infinity), UseZFailMethod(zfailmethod)
{
	#ifdef _DEBUG
	setDebugName("CShadowVolumeSceneNode");
	#endif
	setShadowMesh(shadowMesh);
	setAutomaticCulling(scene::EAC_OFF);
}
Esempio n. 15
0
void CLightSceneNode::doLightRecalc()
{
	if ((LightData.Type == video::ELT_SPOT) || (LightData.Type == video::ELT_DIRECTIONAL))
	{
		LightData.Direction = core::vector3df(.0f,.0f,1.0f);
		getAbsoluteTransformation().rotateVect(LightData.Direction);
		LightData.Direction.normalize();
	}
	if ((LightData.Type == video::ELT_SPOT) || (LightData.Type == video::ELT_POINT))
	{
		const f32 r = LightData.Radius * LightData.Radius * 0.5f;
		BBox.MaxEdge.set( r, r, r );
		BBox.MinEdge.set( -r, -r, -r );
		setAutomaticCulling( scene::EAC_BOX );
		LightData.Position = getAbsolutePosition();
	}
	if (LightData.Type == video::ELT_DIRECTIONAL)
	{
		BBox.reset( 0, 0, 0 );
		setAutomaticCulling( scene::EAC_OFF );
	}
}
Esempio n. 16
0
        CEntity::CEntity(game::CWorld* world, scene::ISceneManager* scene,
            const core::vector3df& position,
            const core::vector3df& rotation,
            const core::vector3df& scale)

            :ISceneNode(scene->getRootSceneNode(), scene, -1, position, rotation, scale),
            Acceleration(0,0,0), Velocity(0,0,0), AngularVelocity(0,0,0),
            Type(GenericEntity),
            World(world),
            Node(0), Width(0), Height(0)
        {
            setAutomaticCulling(scene::EAC_OFF);
        }
Esempio n. 17
0
//! constructor
Sky::Sky(scene::ISceneNode* parent, scene::ISceneManager* mgr, s32 id, LocalPlayer* player):
		scene::ISceneNode(parent, mgr, id),
		m_visible(true),
		m_fallback_bg_color(255,255,255,255),
		m_first_update(true),
		m_brightness(0.5),
		m_cloud_brightness(0.5),
		m_bgcolor_bright_f(1,1,1,1),
		m_skycolor_bright_f(1,1,1,1),
		m_cloudcolor_bright_f(1,1,1,1),
		m_player(player)
{
	setAutomaticCulling(scene::EAC_OFF);
	Box.MaxEdge.set(0,0,0);
	Box.MinEdge.set(0,0,0);

	// create material

	video::SMaterial mat;
	mat.Lighting = false;
	mat.ZBuffer = video::ECFN_NEVER;
	mat.ZWriteEnable = false;
	mat.AntiAliasing=0;
	mat.TextureLayer[0].TextureWrapU = video::ETC_CLAMP_TO_EDGE;
	mat.TextureLayer[0].TextureWrapV = video::ETC_CLAMP_TO_EDGE;
	mat.BackfaceCulling = false;

	m_materials[0] = mat;

	m_materials[1] = mat;
	//m_materials[1].MaterialType = video::EMT_TRANSPARENT_VERTEX_ALPHA;
	m_materials[1].MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL;

	m_materials[2] = mat;
	m_materials[2].setTexture(0, mgr->getVideoDriver()->getTexture(
			getTexturePath("sunrisebg.png").c_str()));
	m_materials[2].MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL;
	//m_materials[2].MaterialType = video::EMT_TRANSPARENT_ADD_COLOR;

	for(u32 i=0; i<SKY_STAR_COUNT; i++){
		m_stars[i] = v3f(
			myrand_range(-10000,10000),
			myrand_range(-10000,10000),
			myrand_range(-10000,10000)
		);
		m_stars[i].normalize();
	}

	m_directional_colored_fog = g_settings->getBool("directional_colored_fog");
}
//! constructor
CShadowVolumeSceneNode::CShadowVolumeSceneNode(ISceneNode* parent,
        ISceneManager* mgr, s32 id,
        bool zfailmethod, f32 infinity)
    : IShadowVolumeSceneNode(parent, mgr, id), Indices(0), Vertices(0),
      Adjacency(0), FaceData(0), UseZFailMethod(zfailmethod),
      IndexCountAllocated(0), VertexCountAllocated(0),
      IndexCount(0), VertexCount(0), ShadowVolumesUsed(0),
      Edges(0), EdgeCount(0), Infinity(infinity)
{
#ifdef _DEBUG
    setDebugName("CShadowVolumeSceneNode");
#endif

    setAutomaticCulling(scene::EAC_OFF);
}
Esempio n. 19
0
//! constructor
CBillboardTextSceneNode::CBillboardTextSceneNode(ISceneNode* parent, ISceneManager* mgr, s32 id,
	gui::IGUIFont* font,const wchar_t* text,
	const core::vector3df& position, const core::dimension2d<f32>& size,
	video::SColor colorTop,video::SColor shade_bottom )
: IBillboardTextSceneNode(parent, mgr, id, position),
	Font(0), ColorTop(colorTop), ColorBottom(shade_bottom), Mesh(0)
{
	#ifdef _DEBUG
	setDebugName("CBillboardTextSceneNode");
	#endif

	Material.MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL;
	Material.MaterialTypeParam = 1.f / 255.f;
	Material.BackfaceCulling = false;
	Material.Lighting = false;
	Material.ZBuffer = video::ECFN_LESSEQUAL;
	Material.ZWriteEnable = false;

	if (font)
	{
		// doesn't support other font types
		if (font->getType() == gui::EGFT_BITMAP)
		{
			Font = (gui::IGUIFontBitmap*)font;
			Font->grab();

			// mesh with one buffer per texture
			Mesh = new SMesh();
			for (u32 i=0; i<Font->getSpriteBank()->getTextureCount(); ++i)
			{
				SMeshBuffer *mb = new SMeshBuffer();
				mb->Material = Material;
				mb->Material.setTexture(0, Font->getSpriteBank()->getTexture(i));
				Mesh->addMeshBuffer(mb);
				mb->drop();
			}
		}
		else
		{
			os::Printer::log("Sorry, CBillboardTextSceneNode does not support this font type", ELL_INFORMATION);
		}
	}

	setText(text);
	setSize(size);

	setAutomaticCulling ( scene::EAC_BOX );
}
Esempio n. 20
0
//! constructor
CLightSceneNode::CLightSceneNode(ISceneNode* parent, ISceneManager* mgr, s32 id,	
	const core::vector3df& position, video::SColorf color,f32 radius)
: ILightSceneNode(parent, mgr, id, position)
{
	#ifdef _DEBUG
	setDebugName("CLightSceneNode");
	#endif

	setAutomaticCulling(false);
	LightData.Radius = radius;
	LightData.DiffuseColor = color;
	LightData.Position = position;

	// set some useful specular color
	LightData.SpecularColor = color.getInterpolated(video::SColor(255,255,255,255),0.5f);
}
//! constructor
CTextSceneNode::CTextSceneNode(ISceneNode* parent, ISceneManager* mgr, s32 id,
                               gui::IGUIFont* font, scene::ISceneCollisionManager* coll,
                               const core::vector3df& position, const wchar_t* text,
                               video::SColor color)
    : ITextSceneNode(parent, mgr, id, position), Font(font), Coll(coll), Color(color)
{
#ifdef _DEBUG
    setDebugName("CTextSceneNode");
#endif

    Text = text;
    setAutomaticCulling(false);

    if (Font)
        Font->grab();
}
CSkyDomeSceneNode::CSkyDomeSceneNode(CSkyDomeSceneNode* other,
		IDummyTransformationSceneNode* parent, ISceneManager* mgr, int32_t id)
	: ISceneNode(parent, mgr, id), Buffer(0),
	  HorizontalResolution(other->HorizontalResolution), VerticalResolution(other->VerticalResolution),
	  TexturePercentage(other->TexturePercentage),
	  SpherePercentage(other->SpherePercentage), Radius(other->Radius)
{
	#ifdef _DEBUG
	setDebugName("CSkyDomeSceneNode");
	#endif

	setAutomaticCulling(scene::EAC_OFF);

	Buffer = other->Buffer;
	Buffer->grab();
}
Esempio n. 23
0
// ----------------------------------------------------------------------------
Terrain::Terrain(ISceneNode* parent, ISceneManager* mgr, s32 id,
                 float x, float z, u32 nx, u32 nz)
    :ISceneNode(parent, mgr, id), m_nx(nx), m_nz(nz)
{

    m_valid        = true;
    m_visible      = true;
    m_bounding_box = aabbox3d<f32>(0, 0, 0, x, 0, z);

    setAutomaticCulling(EAC_OFF);

    m_tile_num_x = 10;
    m_tile_num_z = 10;

    m_mesh.vertex_count = nx * nz;
    m_mesh.vertices = new S3DVertex2TCoords[m_mesh.vertex_count];

    m_mesh.quad_count = (nx - 1) * (nz - 1);
    m_mesh.indices = new u16[m_mesh.quad_count * 6];

    for (u32 j = 0; j < nz; j++)
    for (u32 i = 0; i < nx; i++)
    {
        m_mesh.vertices[j * nx + i].Pos = vector3df(x / nx * i, 0, z / nz *j);
        m_mesh.vertices[j * nx + i].Color = SColor(255, 255, 255, 255);
        m_mesh.vertices[j * nx + i].TCoords  =
            vector2df(i / (float)nx * m_tile_num_x, j / (float)nz * m_tile_num_z);
        m_mesh.vertices[j * nx + i].TCoords2 = vector2df(i / (float)nx, j / (float)nz);
    }

    createIndexList(m_mesh.indices, nx, nz);

    m_x = x;
    m_z = z;

    recalculateNormals();

    m_highlight_mesh.vertices = 0;
    m_highlight_mesh.indices = 0;

    initMaterials();

    m_highlight_visible = false;

} // Terrain
Esempio n. 24
0
CIrrKlangSceneNode::CIrrKlangSceneNode(irrklang::ISoundEngine* soundEngine,
									   scene::ISceneNode* parent,
									   scene::ISceneManager* mgr, s32 id)
	: scene::ISceneNode(parent, mgr, id), SoundEngine(soundEngine)
{
	setAutomaticCulling(scene::EAC_OFF);

	MinDistance = 20.0f; // a usual good value for irrlicht engine applications
	MaxDistance = -1.0f;
	PlayMode = EPM_RANDOM;
	TimeMsDelayFinished = 0;
	DeleteWhenFinished = false;
	MaxTimeMsInterval = 5000;
	MinTimeMsInterval = 1000;
	Sound = 0;
	PlayedCount = 0;

	if (SoundEngine)
		SoundEngine->grab();
}
Esempio n. 25
0
// ----------------------------------------------------------------------------
IRoad::IRoad(ISceneNode* parent, ISceneManager* mgr, s32 id, FILE* fp)
                                          :ISceneNode(parent, mgr, id)
{
    u8 size;
    c8* cc;
    fread(&size, sizeof(u8), 1, fp);
    if (size > 40)
    {
        m_valid = false;
        return;
    }
    cc = new c8[size];
    fread(cc, sizeof(c8), size, fp);
    setName(cc);
    delete[] cc;

    fread(&m_closed, sizeof(bool), 1, fp);
    fread(&m_detail, sizeof(f32), 1, fp);
    fread(&m_width, sizeof(f32), 1, fp);

    if ( m_detail < 0 || m_width < 0 || m_detail > MAX_DETAIL || m_width > MAX_WIDTH)
    {
        m_valid = false;
        return;
    }

    stringw type;
    wchar_t* c;
    fread(&size, sizeof(u8), 1, fp);
    c = new wchar_t[size];
    fread(c, sizeof(wchar_t), size, fp);
    type = c;
    delete[] c;

    ISceneManager* sm = Editor::getEditor()->getSceneManager();
    if (type == L"TCR")
        m_spline = new TCR(sm->getRootSceneNode(), sm, 0, fp);
    else m_spline = new Bezier(sm->getRootSceneNode(), sm, 0, fp);
    setAutomaticCulling(EAC_OFF);
    m_valid = m_spline->isValid();
} // IRoad
Esempio n. 26
0
PerCameraNode::PerCameraNode(scene::ISceneNode* parent, scene::ISceneManager* mgr, s32 id,
                             scene::ICameraSceneNode* camera, scene::ISceneNode *node)
    : IDummyTransformationSceneNode(parent, mgr, id)
{
#ifdef DEBUG
    if (camera)
        setName(camera->getName());
#endif

    m_camera = camera;

    node->setParent(this);
    m_child = node;

    //m_child = mgr->addCubeSceneNode(0.5f, this, -1, core::vector3df(0,0,0), core::vector3df(0,0,0), core::vector3df(3.0f,0.2f,3.0f));
    //RelativeTransformationMatrix.setTranslation( core::vector3df(-0.5,-1,3) );

    setAutomaticCulling(scene::EAC_OFF);

    parent->addChild(this);
}
Esempio n. 27
0
            Jungle::Jungle(u32 dimension, u32 chunkSize, u32 treeDimension, u8 verticesDetail, ITerrainSceneNode* heightRef, ISceneManager* mgr, s32 id):
                scene::ISceneNode(0, mgr, id)
            {
                //ctor
                Box.reset(core::vector3df(-2000,-2000,-2000));
                Box.addInternalPoint(core::vector3df(2000,2000,2000));

                refNode = heightRef;

                setAutomaticCulling(EAC_OFF);

                //calculating configuration
                CHUNK_SIZE = chunkSize;
                TREE_DIMENSION = treeDimension;
                u32 totalPossibleTreeRooted = dimension / treeDimension;
                WORLD_SIZE = totalPossibleTreeRooted / CHUNK_SIZE;
                CHUNK_RENDER_DIMENSION = f32(dimension) / f32(WORLD_SIZE);
                NUM_VERTICES = verticesDetail;
                normalScale = 500.0f;

                chunks = new JungleChunk*[WORLD_SIZE];
                for(u8 i = 0; i < WORLD_SIZE; i++)
                {
                    chunks[i] = new JungleChunk[WORLD_SIZE];
                }//j

                //set chunks positions
                for(u8 x = 0 ; x < WORLD_SIZE; x ++)
                {
                    for(u8 y = 0 ; y < WORLD_SIZE; y ++)
                    {
                        chunks[x][y].X = x * CHUNK_RENDER_DIMENSION;
                        chunks[x][y].Y = 0;
                        chunks[x][y].Z = y * CHUNK_RENDER_DIMENSION;
                        chunks[x][y].heightRef = heightRef;
                        chunks[x][y].jungle = this;
                        chunks[x][y].setup();
                    }
                }
            }
Esempio n. 28
0
void ParticleSystemProxy::setEmitter(scene::IParticleEmitter* emitter)
{
	CParticleSystemSceneNode::setEmitter(emitter);
	if (!emitter || !isGPUParticleType(emitter->getType()))
		return;
	has_height_map = false;
	flip = false;
	// Pass a fake material type to force irrlicht to update its internal states on rendering
	setMaterialType(irr_driver->getShader(ES_RAIN));
	setAutomaticCulling(0);

	count = emitter->getMaxParticlesPerSecond() * emitter->getMaxLifeTime() / 1000;
	switch (emitter->getType())
	{
	case scene::EPET_POINT:
		generateParticlesFromPointEmitter(emitter);
		break;
	case scene::EPET_BOX:
		generateParticlesFromBoxEmitter(static_cast<scene::IParticleBoxEmitter *>(emitter));
		break;
	case scene::EPET_SPHERE:
		generateParticlesFromSphereEmitter(static_cast<scene::IParticleSphereEmitter *>(emitter));
		break;
	default:
		assert(0 && "Wrong particle type");
	}

	glBindBuffer(GL_ARRAY_BUFFER, 0);

	texture = getTextureGLuint(getMaterial(0).getTexture(0));
	normal_and_depth = getTextureGLuint(irr_driver->getRTT(RTT_NORMAL_AND_DEPTH));

	if (SimpleSimulationShader::Program && SimpleParticleRender::Program && FlipParticleRender::Program && HeightmapSimulationShader::Program)
		return;
	SimpleSimulationShader::init();
	HeightmapSimulationShader::init();
	SimpleParticleRender::init();
	FlipParticleRender::init();
}
Esempio n. 29
0
CIrrKlangSceneNode::CIrrKlangSceneNode(irrklang::ISoundEngine* soundEngine, 
									   scene::ISceneNode* parent,
									   scene::ISceneManager* mgr, s32 id)
	: scene::ISceneNode(parent, mgr, id), SoundEngine(soundEngine)
{
	setAutomaticCulling(scene::EAC_OFF);

	MinDistance = 20.0f; // a usual good value for irrlicht engine applications
	MaxDistance = -1.0f;
	PlayMode = EPM_RANDOM;
	TimeMsDelayFinished = 0;
	DeleteWhenFinished = false;
	MaxTimeMsInterval = 5000;
	MinTimeMsInterval = 1000;
	Sound = 0;
	PlayedCount = 0;

	if (SoundEngine)
		SoundEngine->grab();

    cube = mgr->addCubeSceneNode(0.5f);
    cube->setMaterialTexture(0,mgr->getVideoDriver()->getTexture("data/misc/square.jpg"));
    text = mgr->addTextSceneNode(mgr->getGUIEnvironment()->getBuiltInFont(), L"", video::SColor(0xFF00AF00));
}
Esempio n. 30
0
//! constructor
CSkyBoxSceneNode::CSkyBoxSceneNode(video::ITexture* top, video::ITexture* bottom, video::ITexture* left,
			video::ITexture* right, video::ITexture* front, video::ITexture* back, ISceneNode* parent, ISceneManager* mgr, s32 id)
: ISceneNode(parent, mgr, id)
{
	#ifdef _DEBUG
	setDebugName("CSkyBoxSceneNode");
	#endif

	setAutomaticCulling(false);
	Box.MaxEdge.set(0,0,0);
	Box.MinEdge.set(0,0,0);

	// create indices

	Indices[0] = 0;
	Indices[1] = 1;
	Indices[2] = 2;
	Indices[3] = 3;

	// create material

	video::SMaterial mat;
	mat.Lighting = false;
	mat.ZBuffer = false;
	mat.ZWriteEnable = false;

	/* Hey, I am no artist, but look at that
	   cool ASCII art I made! ;)

       -111         111
          /6--------/5        y
         /  |      / |        ^  z
        /   |   11-1 |        | /
  -11-1 3---------2  |        |/
        |   7- - -| -4 1-11    *---->x
        | -1-11   |  /       3-------|2
        |/        | /         |    //|
        0---------1/          |  //  |
     -1-1-1     1-1-1         |//    |
	                         0--------1
	*/

	f32 onepixel = 0.0f;

	video::ITexture* tex = front;
	if (!tex) tex = left;
	if (!tex) tex = back;
	if (!tex) tex = right;
	if (!tex) tex = top;
	if (!tex) tex = bottom;

	if (tex)
	{
		core::dimension2d<s32> dim = tex->getSize();
		onepixel = 1.0f / (dim.Width * 1.5f);
	}

	f32 l = 10.0f;
	f32 t = 1.0f - onepixel;
	f32 o = 0.0f + onepixel;

	Material[0] = mat;
	Material[0].Texture1 = front;
	Vertices[0] = video::S3DVertex(-l,-l,-l, 0,0,1, video::SColor(255,255,255,255), o, t);
	Vertices[1] = video::S3DVertex( l,-l,-l, 0,0,1, video::SColor(255,255,255,255), t, t);
	Vertices[2] = video::S3DVertex( l, l,-l, 0,0,1, video::SColor(255,255,255,255), t, o);
	Vertices[3] = video::S3DVertex(-l, l,-l, 0,0,1, video::SColor(255,255,255,255), o, o);

	// create left side

	Material[1] = mat;
	Material[1].Texture1 = left;
	Vertices[4] = video::S3DVertex( l,-l,-l, -1,0,0, video::SColor(255,255,255,255), o, t);
	Vertices[5] = video::S3DVertex( l,-l, l, -1,0,0, video::SColor(255,255,255,255), t, t);
	Vertices[6] = video::S3DVertex( l, l, l, -1,0,0, video::SColor(255,255,255,255), t, o);
	Vertices[7] = video::S3DVertex( l, l,-l, -1,0,0, video::SColor(255,255,255,255), o, o);

	// create back side

	Material[2] = mat;
	Material[2].Texture1 = back;
	Vertices[8]  = video::S3DVertex( l,-l, l, 0,0,-1, video::SColor(255,255,255,255), o, t);
	Vertices[9]  = video::S3DVertex(-l,-l, l, 0,0,-1, video::SColor(255,255,255,255), t, t);
	Vertices[10] = video::S3DVertex(-l, l, l, 0,0,-1, video::SColor(255,255,255,255), t, o);
	Vertices[11] = video::S3DVertex( l, l, l, 0,0,-1, video::SColor(255,255,255,255), o, o);

	// create right side

	Material[3] = mat;
	Material[3].Texture1 = right;
	Vertices[12] = video::S3DVertex(-l,-l, l, 1,0,0, video::SColor(255,255,255,255), o, t);
	Vertices[13] = video::S3DVertex(-l,-l,-l, 1,0,0, video::SColor(255,255,255,255), t, t);
	Vertices[14] = video::S3DVertex(-l, l,-l, 1,0,0, video::SColor(255,255,255,255), t, o);
	Vertices[15] = video::S3DVertex(-l, l, l, 1,0,0, video::SColor(255,255,255,255), o, o);

	// create top side

	Material[4] = mat;
	Material[4].Texture1 = top;
	Vertices[16] = video::S3DVertex( l, l, l, 0,-1,0, video::SColor(255,255,255,255), o, o);
	Vertices[17] = video::S3DVertex(-l, l, l, 0,-1,0, video::SColor(255,255,255,255), o, t);
	Vertices[18] = video::S3DVertex(-l, l,-l, 0,-1,0, video::SColor(255,255,255,255), t, t);
	Vertices[19] = video::S3DVertex( l, l,-l, 0,-1,0, video::SColor(255,255,255,255), t, o);

	// create bottom side

	Material[5] = mat;
	Material[5].Texture1 = bottom;
	Vertices[20] = video::S3DVertex(-l,-l, l, 0,1,0, video::SColor(255,255,255,255), o, o);
	Vertices[21] = video::S3DVertex( l,-l, l, 0,1,0, video::SColor(255,255,255,255), o, t);
	Vertices[22] = video::S3DVertex( l,-l,-l, 0,1,0, video::SColor(255,255,255,255), t, t);
	Vertices[23] = video::S3DVertex(-l,-l,-l, 0,1,0, video::SColor(255,255,255,255), t, o);
}