Dice and collsion
-
- Competition winner
- Posts: 523
- Joined: Tue Jan 15, 2013 6:36 pm
Re: Dice and collsion
Not really, give it a shot or just try your object format which I don't suggest or look into Irrlicht's other formats.
Re: Dice and collsion
You cast a static mesh to scene::ISkinnedMesh* - that can't work as it's not of that class.Asimov wrote: Strangely when I use the following line on an obj it crashes.Code: Select all
((scene::ISkinnedMesh*)mesh)->convertMeshToTangents();
Also depending on your setting you don't need that line at all. In the last obj you exported the loader already could do (and did) that conversion.
About scaling - it should always use the same factor, so figure it out once (I think in Blender it's 100x as I remember the obj exporter had a button to increase obj files by that value - no idea why...).
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Re: Dice and collsion
Hi CuteAlien,
Which is one of the reasons I started to use x files, plus I needed animation for some objects.
Anyway I tried to export my whole scene as an x file instead, unfortunately it goes wrong. Even though the hand grenade was perfect, if I export the whoe scene, every gets piled in the middle instead of being in it's correct location. Also I had to scale it to 0.2 before I could get the room down to this size. I think it is dark because it is blocking the light, because the light is in the middle of the room.
Hmm I wonder if I attach all the object together if it will. Going to give it a try now.
Grr just when you think you are getting somewhere.
See the problem is that the normalmaps are not showing correctly in obj, even after I rename them, and after I rename them so that they do show, I get very dark walls.Also depending on your setting you don't need that line at all. In the last obj you exported the loader already could do (and did) that conversion.
Which is one of the reasons I started to use x files, plus I needed animation for some objects.
Anyway I tried to export my whole scene as an x file instead, unfortunately it goes wrong. Even though the hand grenade was perfect, if I export the whoe scene, every gets piled in the middle instead of being in it's correct location. Also I had to scale it to 0.2 before I could get the room down to this size. I think it is dark because it is blocking the light, because the light is in the middle of the room.
Hmm I wonder if I attach all the object together if it will. Going to give it a try now.
Grr just when you think you are getting somewhere.
Re: Dice and collsion
Hi,
Well I attached everthing together in max and re exported it.
Now I have found the right scale by scaling it to 0.1f,0.1,f0.1f and it seems spot on.
Now here is the problem. The colours are not right. The fireplace seems too bright and the walls are too dark.
I am not sure if it is my light settings or not, but it was fine when it was an obj.
Here is my light settings, and it situated above the table.
smgr->setAmbientLight(SColor(255, 180, 180, 180));
My other question is this. Is there any way to make a light brighter to dimmer, and can you scale a light?
In the picture attached, the left one is the obj, and the right one is the x file.
Well I attached everthing together in max and re exported it.
Now I have found the right scale by scaling it to 0.1f,0.1,f0.1f and it seems spot on.
Now here is the problem. The colours are not right. The fireplace seems too bright and the walls are too dark.
I am not sure if it is my light settings or not, but it was fine when it was an obj.
Here is my light settings, and it situated above the table.
smgr->setAmbientLight(SColor(255, 180, 180, 180));
Code: Select all
ILightSceneNode* mySpotLight = smgr->addLightSceneNode();
mySpotLight->setPosition(vector3df(0.0f, 145.0f, 0.0f));
mySpotLight->setRotation(vector3df(-90.0f, 0.0f, 0.0f));
SLight spotLightData;
spotLightData.Type = ELT_SPOT;
spotLightData.OuterCone = 300;
spotLightData.InnerCone = 100;
mySpotLight->setLightData(spotLightData);
In the picture attached, the left one is the obj, and the right one is the x file.
Re: Dice and collsion
Hi,
Well I have been at this for hours. I can't understand why there is a purple shade in the texture. It is almost as if it is showing the normalmap as well as the diffuse in this occasion, but it doesn't do this on the grenade.
Ok here is another problem.
I cannot see the normalmap working on the floor until I add the line
Which is stupid because I lose the shadows then. Normally a normalmap works better with shadows.
Here is the full code. Obviously I do want shadows, but I can only see the normalmap if I turn them off, but I can clearly see the map working fine on the wall.
Well I have been at this for hours. I can't understand why there is a purple shade in the texture. It is almost as if it is showing the normalmap as well as the diffuse in this occasion, but it doesn't do this on the grenade.
Ok here is another problem.
I cannot see the normalmap working on the floor until I add the line
Code: Select all
lightData.CastShadows = false;
Here is the full code. Obviously I do want shadows, but I can only see the normalmap if I turn them off, but I can clearly see the map working fine on the wall.
Code: Select all
smgr->setAmbientLight(SColor(255, 255, 255, 255));
ILightSceneNode* Light = smgr->addLightSceneNode();
Light->setPosition(vector3df(0.0f, 200.0f, 0.0f));
// Light->setRadius(150);
SLight lightData;
lightData.DiffuseColor = SColor(255, 255, 255, 255);
lightData.CastShadows = false;
Light->setLightData(lightData);
Re: Dice and collsion
Hi all,
I believe I have solved my purple colour problem. You see even though my room is one x file it is comprised of various meshes.
Apparently you have to add the normalmap code to each individual mesh inside the x file.
eg
I am glad I worked this out on my own.
What really annoys me though. No matter what I do I cannot make the door receive light. It is like the door is constantly lit up, wheras the walls are darker.
Now I am happy with the light, but if I wanted to make the room brighter, how do I make the light brighter?
I believe I have solved my purple colour problem. You see even though my room is one x file it is comprised of various meshes.
Apparently you have to add the normalmap code to each individual mesh inside the x file.
eg
Code: Select all
((scene::ISkinnedMesh*)mesh)->convertMeshToTangents();
//walls
scene::IMeshBuffer* walls = mesh->getMeshBuffer(0);
if (walls)
{
video::SMaterial& mt = walls->getMaterial();
mt.MaterialType = video::EMT_NORMAL_MAP_SOLID;
}
//fire
scene::IMeshBuffer* fire = mesh->getMeshBuffer(5);
if (fire)
{
video::SMaterial& mt = fire->getMaterial();
mt.MaterialType = video::EMT_NORMAL_MAP_SOLID;
}
//1= table
//2= board
//logs
scene::IMeshBuffer* logs = mesh->getMeshBuffer(3);
if (logs)
{
video::SMaterial& mt = logs->getMaterial();
mt.MaterialType = video::EMT_NORMAL_MAP_SOLID;
}
// floor
scene::IMeshBuffer* floor = mesh->getMeshBuffer(4);
if (floor)
{
video::SMaterial& mt = floor->getMaterial();
mt.MaterialType = video::EMT_NORMAL_MAP_SOLID;
}
What really annoys me though. No matter what I do I cannot make the door receive light. It is like the door is constantly lit up, wheras the walls are darker.
Now I am happy with the light, but if I wanted to make the room brighter, how do I make the light brighter?
Re: Dice and collsion
Lights don't really have a "strength". Their apparent strength is determined by the distance and the color at the center. So increase the radius for a stronger light.
Re: Dice and collsion
Hi Hendu,
Well I tried different settings on the light from 10 to 2000, and the light does not change in brightness at all.
Strange in all modelling programs you can give a light a strength, and yet in irrlicht you cannot.
BTW got my door to look right by sticking this code in
Lights don't really have a "strength". Their apparent strength is determined by the distance and the color at the center. So increase the radius for a stronger light.
Code: Select all
Light->setRadius(2000);
Strange in all modelling programs you can give a light a strength, and yet in irrlicht you cannot.
BTW got my door to look right by sticking this code in
Code: Select all
// door
scene::IMeshBuffer* door = mesh->getMeshBuffer(1);
if (door)
{
video::SMaterial& mt = door->getMaterial();
mt.MaterialType= video::EMT_PARALLAX_MAP_SOLID;
}
Re: Dice and collsion
Try changing the attenuation *after* setting the radius.
Re: Dice and collsion
Hi Mongoose,
Ok I didn't know how to do this attenuation thing, so I tried it two ways
and I tried
I am not sure why some setting have to be in the SLight struct and some work directly on the light node. I am learning from peoples posts who might or might not know what they are talking about LOL.
Anyway to cut a long story short. Nothing I do seem to change the way the light works. It always looks the same.
Do you know something. It seems no matter what light settings I change the light always remains the same. I am happy with the way the light looks, but in the interests of learning I want it to change, but nothing I do changes the way the light looks. It pretty much looks like it does in the picture in my previous post.Try changing the attenuation *after* setting the radius.
Ok I didn't know how to do this attenuation thing, so I tried it two ways
Code: Select all
smgr->setAmbientLight(SColor(255, 255, 255, 255));
ILightSceneNode* Light = smgr->addLightSceneNode();
Light->setPosition(vector3df(0.0f, 200.0f, 0.0f));
Light->setRadius(200);
Light->getLightData().Attenuation = vector3df(0,150,0);
SLight lightData;
lightData.Type= ELT_POINT;
Light->setLightData(lightData);
Code: Select all
smgr->setAmbientLight(SColor(255, 255, 255, 255));
ILightSceneNode* Light = smgr->addLightSceneNode();
Light->setPosition(vector3df(0.0f, 200.0f, 0.0f));
Light->setRadius(200);
SLight lightData;
lightData.Attenuation = vector3df(0, 255, 0);
lightData.Type= ELT_POINT;
Light->setLightData(lightData);
Anyway to cut a long story short. Nothing I do seem to change the way the light works. It always looks the same.
Re: Dice and collsion
Try setting the attenuation last, after Light->setLightData(lightData). Try setting the attenuation to (1., 0.001, 0.). Your scene is very big so I think you need a small linear attenuation value. Remember, you can always Google it. For example, http://www.glprogramming.com/red/chapter05.html
Re: Dice and collsion
Hi Mongoose,
Will try it when I get home, but that page is for OpenGL and not directx, which is what I am using.
Will try it when I get home, but that page is for OpenGL and not directx, which is what I am using.
Re: Dice and collsion
Hi mongoose,
Well thanks I now have a brighter room, but it wasn't to do with attenuation, but because of what you said I tried something else. I put the scale at the end, and then I thought it was the attenuation making the room brighter, but it wasn't. It was the scale. I have put various values in attenuation and it changes nothing, but changing the scale does. So now I have a brighter room.
attenuation is commented out because it did nothing.
Now I have a new problem. I changed my houses over to x files instead of obj, and now if I set light as true, they are coming out white instead of green. If I set light to false they are green. This one is really wierd.
Well thanks I now have a brighter room, but it wasn't to do with attenuation, but because of what you said I tried something else. I put the scale at the end, and then I thought it was the attenuation making the room brighter, but it wasn't. It was the scale. I have put various values in attenuation and it changes nothing, but changing the scale does. So now I have a brighter room.
Code: Select all
smgr->setAmbientLight(SColor(255, 255, 255, 255));
ILightSceneNode* Light = smgr->addLightSceneNode();
Light->setPosition(vector3df(0.0f, 200.0f, 0.0f));
SLight lightData;
lightData.Type= ELT_POINT;
Light->setLightData(lightData);
Light->setRadius(200);
// Light->getLightData().Attenuation = vector3df(255,150,0);
Now I have a new problem. I changed my houses over to x files instead of obj, and now if I set light as true, they are coming out white instead of green. If I set light to false they are green. This one is really wierd.