Reindentation.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@1655 dfc29bdd-3216-0410-991c-e03cc46cb475
master
hybrid 2008-10-27 17:52:41 +00:00
parent 33f3a2da8c
commit d2dca1f1fe
4 changed files with 66 additions and 90 deletions

View File

@ -46,14 +46,15 @@ static const sTemplate Template [] =
{ L"L:", L"0", L"%",180,255, 0, 100 }, { L"L:", L"0", L"%",180,255, 0, 100 },
}; };
//! constructor //! constructor
CGUIColorSelectDialog::CGUIColorSelectDialog( const wchar_t* title, IGUIEnvironment* environment, IGUIElement* parent, s32 id) CGUIColorSelectDialog::CGUIColorSelectDialog(const wchar_t* title, IGUIEnvironment* environment, IGUIElement* parent, s32 id)
: IGUIColorSelectDialog(environment, parent, id, : IGUIColorSelectDialog(environment, parent, id,
core::rect<s32>((parent->getAbsolutePosition().getWidth()-CSD_WIDTH)/2, core::rect<s32>((parent->getAbsolutePosition().getWidth()-CSD_WIDTH)/2,
(parent->getAbsolutePosition().getHeight()-CSD_HEIGHT)/2, (parent->getAbsolutePosition().getHeight()-CSD_HEIGHT)/2,
(parent->getAbsolutePosition().getWidth()-CSD_WIDTH)/2+CSD_WIDTH, (parent->getAbsolutePosition().getWidth()-CSD_WIDTH)/2+CSD_WIDTH,
(parent->getAbsolutePosition().getHeight()-CSD_HEIGHT)/2+CSD_HEIGHT)), (parent->getAbsolutePosition().getHeight()-CSD_HEIGHT)/2+CSD_HEIGHT)),
Dragging(false) Dragging(false)
{ {
#ifdef _DEBUG #ifdef _DEBUG
IGUIElement::setDebugName("CGUIColorSelectDialog"); IGUIElement::setDebugName("CGUIColorSelectDialog");
@ -62,10 +63,9 @@ CGUIColorSelectDialog::CGUIColorSelectDialog( const wchar_t* title, IGUIEnvironm
Text = title; Text = title;
IGUISkin* skin = Environment->getSkin(); IGUISkin* skin = Environment->getSkin();
core::rect<s32> rec;
s32 buttonw = environment->getSkin()->getSize(EGDS_WINDOW_BUTTON_WIDTH); const s32 buttonw = environment->getSkin()->getSize(EGDS_WINDOW_BUTTON_WIDTH);
s32 posx = RelativeRect.getWidth() - buttonw - 4; const s32 posx = RelativeRect.getWidth() - buttonw - 4;
CloseButton = Environment->addButton(core::rect<s32>(posx, 3, posx + buttonw, 3 + buttonw), CloseButton = Environment->addButton(core::rect<s32>(posx, 3, posx + buttonw, 3 + buttonw),
this, -1, L"", skin ? skin->getDefaultText(EGDT_WINDOW_CLOSE) : L"Close"); this, -1, L"", skin ? skin->getDefaultText(EGDT_WINDOW_CLOSE) : L"Close");
@ -94,8 +94,6 @@ CGUIColorSelectDialog::CGUIColorSelectDialog( const wchar_t* title, IGUIEnvironm
CancelButton->setAlignment(EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_UPPERLEFT); CancelButton->setAlignment(EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_UPPERLEFT);
CancelButton->grab(); CancelButton->grab();
core::rect<s32> r;
video::IVideoDriver* driver = Environment->getVideoDriver(); video::IVideoDriver* driver = Environment->getVideoDriver();
ColorRing.Texture = driver->getTexture ( "#colorring" ); ColorRing.Texture = driver->getTexture ( "#colorring" );
if ( 0 == ColorRing.Texture ) if ( 0 == ColorRing.Texture )
@ -104,8 +102,8 @@ CGUIColorSelectDialog::CGUIColorSelectDialog( const wchar_t* title, IGUIEnvironm
Environment->getSkin()->getColor(EGDC_3D_SHADOW).color); Environment->getSkin()->getColor(EGDC_3D_SHADOW).color);
} }
r.UpperLeftCorner.X = 20; core::rect<s32> r(20,20, 0,0);
r.UpperLeftCorner.Y = 20;
ColorRing.Control = Environment->addImage(ColorRing.Texture, r.UpperLeftCorner, true, this); ColorRing.Control = Environment->addImage(ColorRing.Texture, r.UpperLeftCorner, true, this);
ColorRing.Control->setSubElement(true); ColorRing.Control->setSubElement(true);
ColorRing.Control->grab(); ColorRing.Control->grab();
@ -118,7 +116,7 @@ CGUIColorSelectDialog::CGUIColorSelectDialog( const wchar_t* title, IGUIEnvironm
r.UpperLeftCorner.Y = Template[i].y; r.UpperLeftCorner.Y = Template[i].y;
r.LowerRightCorner.X = r.UpperLeftCorner.X + 15; r.LowerRightCorner.X = r.UpperLeftCorner.X + 15;
r.LowerRightCorner.Y = r.UpperLeftCorner.Y + 20; r.LowerRightCorner.Y = r.UpperLeftCorner.Y + 20;
IGUIElement *t = Environment->addStaticText( Template[i].pre, r, false, false, this); IGUIElement *t = Environment->addStaticText(Template[i].pre, r, false, false, this);
t->setSubElement(true); t->setSubElement(true);
} }
@ -162,7 +160,6 @@ CGUIColorSelectDialog::CGUIColorSelectDialog( const wchar_t* title, IGUIEnvironm
} }
//! destructor //! destructor
CGUIColorSelectDialog::~CGUIColorSelectDialog() CGUIColorSelectDialog::~CGUIColorSelectDialog()
{ {
@ -177,47 +174,34 @@ CGUIColorSelectDialog::~CGUIColorSelectDialog()
for ( u32 i = 0; i != Battery.size ();++i ) for ( u32 i = 0; i != Battery.size ();++i )
{ {
Battery[i].Edit->drop (); Battery[i].Edit->drop();
Battery[i].Scrollbar->drop (); Battery[i].Scrollbar->drop();
} }
if ( ColorRing.Control ) if (ColorRing.Control)
{ ColorRing.Control->drop();
ColorRing.Control->drop ();
}
} }
//! renders a antialiased, colored ring //! renders a antialiased, colored ring
void CGUIColorSelectDialog::buildColorRing( const core::dimension2d<s32> & dim, s32 supersample, const u32 borderColor ) void CGUIColorSelectDialog::buildColorRing( const core::dimension2d<s32> & dim, s32 supersample, const u32 borderColor )
{ {
video::CImage *RawTexture; const core::dimension2d<s32> d(dim.Width * supersample, dim.Height * supersample);
video::CImage *RawTexture = new video::CImage(video::ECF_A8R8G8B8, d);
core::dimension2d<s32> d;
d.Width = dim.Width * supersample;
d.Height = dim.Height * supersample;
RawTexture = new video::CImage ( video::ECF_A8R8G8B8, d );
RawTexture->fill ( 0x00808080 ); RawTexture->fill ( 0x00808080 );
u8 * data= (u8*) RawTexture->lock(); u8 * data= (u8*) RawTexture->lock();
const u32 pitch = RawTexture->getPitch (); const u32 pitch = RawTexture->getPitch();
s32 radiusOut = ( d.Width / 2 ) - 4;
const s32 radiusOut = ( d.Width / 2 ) - 4;
const s32 fullR2 = radiusOut * radiusOut; const s32 fullR2 = radiusOut * radiusOut;
video::SColor rgb(0xFF000000);
video::SColorHSL hsl; video::SColorHSL hsl;
video::SColor rgb;
rgb.color = 0xFF000000;
hsl.Luminance = 0.5f; hsl.Luminance = 0.5f;
hsl.Saturation = 1.f; hsl.Saturation = 1.f;
core::position2d<s32> p; core::position2d<s32> p;
u32 *dst; u32 *dst;
for ( p.Y = -radiusOut; p.Y <= radiusOut; p.Y += 1 ) for ( p.Y = -radiusOut; p.Y <= radiusOut; p.Y += 1 )
@ -237,25 +221,24 @@ void CGUIColorSelectDialog::buildColorRing( const core::dimension2d<s32> & dim,
{ {
// dotproduct u ( x,y ) * v ( 1, 0 ) = cosinus(a) // dotproduct u ( x,y ) * v ( 1, 0 ) = cosinus(a)
f32 r = (f32) sqrt ( (f32) r2 ); const f32 r = sqrtf((f32) r2);
// normalize, dotproduct = xnorm // normalize, dotproduct = xnorm
f32 t = (f32) 1.0 / r; const f32 xn = -p.X * core::reciprocal(r);
f32 xn = -p.X * t;
hsl.Hue = (f32) acos ( xn ); hsl.Hue = acosf(xn);
if ( p.Y > 0 ) if ( p.Y > 0 )
hsl.Hue = (2.f * core::PI ) - hsl.Hue; hsl.Hue = (2.f * core::PI ) - hsl.Hue;
hsl.Hue -= core::PI / 2.f; hsl.Hue -= core::PI / 2.f;
f32 rTest = r / radiusOut; const f32 rTest = r / radiusOut;
/* /*
if ( rTest < 0.25f ) if ( rTest < 0.25f )
{ {
hsl.Luminance = rTest / 0.25f; hsl.Luminance = rTest / 0.25f;
hsl.Saturation = 0.f; hsl.Saturation = 0.f;
hsl.settoRGB ( rgb ); hsl.toRGB ( rgb );
*dst = rgb.color; *dst = rgb.color;
} }
else else
@ -264,7 +247,7 @@ void CGUIColorSelectDialog::buildColorRing( const core::dimension2d<s32> & dim,
hsl.Saturation = ( rTest - 0.25f ) / 0.15f; hsl.Saturation = ( rTest - 0.25f ) / 0.15f;
hsl.Luminance = 1.f - ( hsl.Saturation / 2.4f ); hsl.Luminance = 1.f - ( hsl.Saturation / 2.4f );
hsl.Luminance = 0.5f; hsl.Luminance = 0.5f;
hsl.settoRGB ( rgb ); hsl.toRGB ( rgb );
// *dst = rgb.color; // *dst = rgb.color;
} }
else else
@ -272,7 +255,7 @@ void CGUIColorSelectDialog::buildColorRing( const core::dimension2d<s32> & dim,
{ {
hsl.Luminance = 0.5f; hsl.Luminance = 0.5f;
hsl.Saturation = 1.f; hsl.Saturation = 1.f;
hsl.settoRGB ( rgb ); hsl.toRGB ( rgb );
*dst = rgb.color; *dst = rgb.color;
} }
else else
@ -280,7 +263,7 @@ void CGUIColorSelectDialog::buildColorRing( const core::dimension2d<s32> & dim,
{ {
hsl.Luminance = 0.5f - ( ( rTest - 0.75f ) / 0.75f ); hsl.Luminance = 0.5f - ( ( rTest - 0.75f ) / 0.75f );
hsl.Saturation = 1.f; hsl.Saturation = 1.f;
hsl.settoRGB ( rgb ); hsl.toRGB ( rgb );
*dst = rgb.color; *dst = rgb.color;
} }
*/ */
@ -305,10 +288,8 @@ void CGUIColorSelectDialog::buildColorRing( const core::dimension2d<s32> & dim,
alpha = 255 - alpha; alpha = 255 - alpha;
*dst = *dst & 0x00ffffff | (alpha << 24); *dst = *dst & 0x00ffffff | (alpha << 24);
} }
} }
} }
} }
RawTexture->unlock (); RawTexture->unlock ();
@ -316,26 +297,23 @@ void CGUIColorSelectDialog::buildColorRing( const core::dimension2d<s32> & dim,
if ( supersample > 1 ) if ( supersample > 1 )
{ {
video::CImage * filter = new video::CImage(video::ECF_A8R8G8B8, dim ); video::CImage * filter = new video::CImage(video::ECF_A8R8G8B8, dim );
RawTexture->copyToScalingBoxFilter ( filter, 0 ); RawTexture->copyToScalingBoxFilter(filter, 0);
RawTexture->drop (); RawTexture->drop();
RawTexture = filter; RawTexture = filter;
} }
video::IVideoDriver* driver = Environment->getVideoDriver(); video::IVideoDriver* driver = Environment->getVideoDriver();
bool generateMipLevels = driver->getTextureCreationFlag( video::ETCF_CREATE_MIP_MAPS ); bool generateMipLevels = driver->getTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS);
driver->setTextureCreationFlag( video::ETCF_CREATE_MIP_MAPS, false); driver->setTextureCreationFlag( video::ETCF_CREATE_MIP_MAPS, false);
ColorRing.Texture = driver->addTexture ( "#colorring", RawTexture ); ColorRing.Texture = driver->addTexture ("#colorring", RawTexture);
RawTexture->drop (); RawTexture->drop();
driver->setTextureCreationFlag( video::ETCF_CREATE_MIP_MAPS, generateMipLevels);
driver->setTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS, generateMipLevels);
} }
//! called if an event happened. //! called if an event happened.
bool CGUIColorSelectDialog::OnEvent(const SEvent& event) bool CGUIColorSelectDialog::OnEvent(const SEvent& event)
{ {
@ -352,10 +330,8 @@ bool CGUIColorSelectDialog::OnEvent(const SEvent& event)
{ {
if ( event.GUIEvent.Caller == Battery[i].Scrollbar ) if ( event.GUIEvent.Caller == Battery[i].Scrollbar )
{ {
s32 pos = Battery[i].Scrollbar->getPos (); const s32 value = Template[i].range_down + Battery[i].Scrollbar->getPos();
s32 value = Template[i].range_down + ( pos ); Battery[i].Edit->setText(core::stringw(value).c_str());
core::stringw s ( value );
Battery[i].Edit->setText ( s.c_str() );
} }
} }
return true; return true;
@ -385,7 +361,6 @@ bool CGUIColorSelectDialog::OnEvent(const SEvent& event)
case EGET_LISTBOX_SELECTED_AGAIN: case EGET_LISTBOX_SELECTED_AGAIN:
default: default:
break; break;
} }
break; break;
case EET_MOUSE_INPUT_EVENT: case EET_MOUSE_INPUT_EVENT:
@ -437,11 +412,8 @@ void CGUIColorSelectDialog::draw()
return; return;
IGUISkin* skin = Environment->getSkin(); IGUISkin* skin = Environment->getSkin();
core::rect<s32> rect = skin->draw3DWindowBackground(this, true, skin->getColor(EGDC_ACTIVE_BORDER),
core::rect<s32> rect = AbsoluteRect; AbsoluteRect, &AbsoluteClippingRect);
rect = skin->draw3DWindowBackground(this, true, skin->getColor(EGDC_ACTIVE_BORDER),
rect, &AbsoluteClippingRect);
if (Text.size()) if (Text.size())
{ {
@ -453,13 +425,15 @@ void CGUIColorSelectDialog::draw()
font->draw(Text.c_str(), rect, skin->getColor(EGDC_ACTIVE_CAPTION), false, true, font->draw(Text.c_str(), rect, skin->getColor(EGDC_ACTIVE_CAPTION), false, true,
&AbsoluteClippingRect); &AbsoluteClippingRect);
} }
IGUIFont* font = Environment->getBuiltInFont();
if (font)
font->draw(L"+", core::rect<s32>(20,20,50,50), video::SColor(), false, false,
&AbsoluteClippingRect);
IGUIElement::draw(); IGUIElement::draw();
} }
//! sends the event that the file has been selected. //! sends the event that the file has been selected.
void CGUIColorSelectDialog::sendSelectedEvent() void CGUIColorSelectDialog::sendSelectedEvent()
{ {
@ -471,6 +445,7 @@ void CGUIColorSelectDialog::sendSelectedEvent()
Parent->OnEvent(event); Parent->OnEvent(event);
} }
//! sends the event that the file choose process has been canceld //! sends the event that the file choose process has been canceld
void CGUIColorSelectDialog::sendCancelEvent() void CGUIColorSelectDialog::sendCancelEvent()
{ {
@ -482,7 +457,9 @@ void CGUIColorSelectDialog::sendCancelEvent()
Parent->OnEvent(event); Parent->OnEvent(event);
} }
} // end namespace gui } // end namespace gui
} // end namespace irr } // end namespace irr
#endif // _IRR_COMPILE_WITH_GUI_ #endif // _IRR_COMPILE_WITH_GUI_

View File

@ -137,7 +137,7 @@ bool CQ3LevelMesh::loadFile(io::IReadFile* file)
loadBrushes(&Lumps[kBrushes], file); // load the brushes of the BSP loadBrushes(&Lumps[kBrushes], file); // load the brushes of the BSP
loadBrushSides(&Lumps[kBrushSides], file); // load the brushsides of the BSP loadBrushSides(&Lumps[kBrushSides], file); // load the brushsides of the BSP
loadLeafBrushes(&Lumps[kLeafBrushes], file); // load the brushes of the leaf loadLeafBrushes(&Lumps[kLeafBrushes], file); // load the brushes of the leaf
loadShaders(&Lumps[kShaders], file ); // load the shaderes loadShaders(&Lumps[kShaders], file ); // load the shaders
PatchTesselation = 8; PatchTesselation = 8;
@ -1540,7 +1540,7 @@ void CQ3LevelMesh::InitShader()
} }
//!. script callback for shaders //! script callback for shaders
//! i'm having troubles with the reference counting, during callback.. resorting.. //! i'm having troubles with the reference counting, during callback.. resorting..
void CQ3LevelMesh::ReleaseShader() void CQ3LevelMesh::ReleaseShader()
{ {
@ -1552,6 +1552,7 @@ void CQ3LevelMesh::ReleaseShader()
ShaderFile.clear(); ShaderFile.clear();
} }
void CQ3LevelMesh::ReleaseEntity() void CQ3LevelMesh::ReleaseEntity()
{ {
for ( u32 i = 0; i!= Entity.size(); ++i ) for ( u32 i = 0; i!= Entity.size(); ++i )
@ -1559,7 +1560,6 @@ void CQ3LevelMesh::ReleaseEntity()
Entity[i].VarGroup->drop(); Entity[i].VarGroup->drop();
} }
Entity.clear(); Entity.clear();
} }
@ -1571,7 +1571,6 @@ void CQ3LevelMesh::scriptcallback_entity( quake3::SVarGroupList *& grouplist )
if ( grouplist->VariableGroup.size() != 2 ) if ( grouplist->VariableGroup.size() != 2 )
return; return;
element.name = grouplist->VariableGroup[1].get( "classname" ); element.name = grouplist->VariableGroup[1].get( "classname" );
grouplist->grab(); grouplist->grab();
@ -1692,6 +1691,7 @@ void CQ3LevelMesh::loadTextures()
} }
} }
// delete all buffers without geometry in it. // delete all buffers without geometry in it.
void CQ3LevelMesh::cleanMeshes() void CQ3LevelMesh::cleanMeshes()
{ {

View File

@ -247,7 +247,6 @@ void CQuake3ShaderSceneNode::render()
{ {
video::IVideoDriver* driver = SceneManager->getVideoDriver(); video::IVideoDriver* driver = SceneManager->getVideoDriver();
bool isTransparentPass = bool isTransparentPass =
SceneManager->getSceneNodeRenderPass() == scene::ESNRP_TRANSPARENT; SceneManager->getSceneNodeRenderPass() == scene::ESNRP_TRANSPARENT;
@ -270,7 +269,7 @@ void CQuake3ShaderSceneNode::render()
for ( u32 stage = 0; stage < Shader->VarGroup->VariableGroup.size(); ++stage ) for ( u32 stage = 0; stage < Shader->VarGroup->VariableGroup.size(); ++stage )
//for ( u32 stage = 2; stage < 3; ++stage ) //for ( u32 stage = 2; stage < 3; ++stage )
{ {
SQ3Texture &q = Q3Texture [ stage]; SQ3Texture &q = Q3Texture[stage];
// advance current stage // advance current stage
core::matrix4 texture; core::matrix4 texture;
@ -283,7 +282,7 @@ void CQuake3ShaderSceneNode::render()
// current stage // current stage
group = Shader->getGroup( stage ); group = Shader->getGroup( stage );
material.setTexture(0, q.Texture [ q.TextureIndex ]); material.setTexture(0, q.Texture[ q.TextureIndex ]);
material.ZBuffer = quake3::getDepthFunction( group->get( "depthfunc" ) ); material.ZBuffer = quake3::getDepthFunction( group->get( "depthfunc" ) );
if ( group->getIndex( "depthwrite" ) >= 0 ) if ( group->getIndex( "depthwrite" ) >= 0 )
@ -321,7 +320,6 @@ void CQuake3ShaderSceneNode::render()
} }
/*! /*!
*/ */
void CQuake3ShaderSceneNode::vertextransform_wave( f32 dt, quake3::SModifierFunction &function ) void CQuake3ShaderSceneNode::vertextransform_wave( f32 dt, quake3::SModifierFunction &function )

View File

@ -124,7 +124,7 @@ namespace scene
//! \param lookat: Position where the camera will look at. Also known as target. //! \param lookat: Position where the camera will look at. Also known as target.
//! \param parent: Parent scene node of the camera. Can be null. If the parent moves, //! \param parent: Parent scene node of the camera. Can be null. If the parent moves,
//! the camera will move too. //! the camera will move too.
//! \return Returns pointer to interface to camera //! \return Pointer to interface to camera
virtual ICameraSceneNode* addCameraSceneNode(ISceneNode* parent = 0, virtual ICameraSceneNode* addCameraSceneNode(ISceneNode* parent = 0,
const core::vector3df& position = core::vector3df(0,0,0), const core::vector3df& position = core::vector3df(0,0,0),
const core::vector3df& lookat = core::vector3df(0,0,0), s32 id=-1); const core::vector3df& lookat = core::vector3df(0,0,0), s32 id=-1);
@ -147,7 +147,8 @@ namespace scene
//! turned on. (This is the default setting in most scene nodes). //! turned on. (This is the default setting in most scene nodes).
virtual ILightSceneNode* addLightSceneNode(ISceneNode* parent = 0, virtual ILightSceneNode* addLightSceneNode(ISceneNode* parent = 0,
const core::vector3df& position = core::vector3df(0,0,0), const core::vector3df& position = core::vector3df(0,0,0),
video::SColorf color = video::SColorf(1.0f, 1.0f, 1.0f), f32 range=100.0f, s32 id=-1); video::SColorf color = video::SColorf(1.0f, 1.0f, 1.0f),
f32 range=100.0f, s32 id=-1);
//! Adds a billboard scene node to the scene. A billboard is like a 3d sprite: A 2d element, //! Adds a billboard scene node to the scene. A billboard is like a 3d sprite: A 2d element,
//! which always looks to the camera. It is usually used for things like explosions, fire, //! which always looks to the camera. It is usually used for things like explosions, fire,
@ -258,7 +259,7 @@ namespace scene
//! of all scene nodes. The root scene node is a special scene node which //! of all scene nodes. The root scene node is a special scene node which
//! only exists to manage all scene nodes. It is not rendered and cannot //! only exists to manage all scene nodes. It is not rendered and cannot
//! be removed from the scene. //! be removed from the scene.
//! \return Returns a pointer to the root scene node. //! \return Pointer to the root scene node.
virtual ISceneNode* getRootSceneNode(); virtual ISceneNode* getRootSceneNode();
//! Returns the current active camera. //! Returns the current active camera.
@ -272,7 +273,7 @@ namespace scene
//! creates a rotation animator, which rotates the attached scene node around itself. //! creates a rotation animator, which rotates the attached scene node around itself.
//! \param rotationPerSecond: Specifies the speed of the animation //! \param rotationPerSecond: Specifies the speed of the animation
//! \return Returns the animator. Attach it to a scene node with ISceneNode::addAnimator() //! \return The animator. Attach it to a scene node with ISceneNode::addAnimator()
//! and the animator will animate it. //! and the animator will animate it.
virtual ISceneNodeAnimator* createRotationAnimator(const core::vector3df& rotationPerSecond); virtual ISceneNodeAnimator* createRotationAnimator(const core::vector3df& rotationPerSecond);