OpenSceneGraph brighten the scene - opengl

I have an .obj textured mesh. I am using OpenSceneGraph for loading and display my mesh.
osg::Node * cytBuilding = osgDB::readNodeFile( "model/level_2_0_0.obj");
osg::Group * root = new osg::Group();
root->addChild( cytBuilding );
osgViewer::Viewer viewer;
viewer.setSceneData( root );
viewer.realize();
viewer.setCameraManipulator(new osgGA::TerrainManipulator());
while( !viewer.done() )
{
viewer.frame();
}
I get a display something like
Which is too dark. I tried to add my own light, it helps a bit. But it is not very bright. How to increase the brightness of the rendered view.
I am aware it depends on material/texture properties. How to manipulate it?
I would also like to add that as I load the mesh I get following messages printed
*** line not handled *** :map_kS
*** line not handled *** :map_Ns
*** line not handled *** :map_bump
*** line not handled *** :bump
*** line not handled *** :map_opacity
*** line not handled *** :map_d
*** line not handled *** :refl
What are some alternate ways?

Since I can't tell which light you tried, I'll give an answer in that direction anyway.
A sun like light is a directional light. You can create one in OSG via a standard light, but you don't give it any position. The easiest way is probably to just give it colors for diffuse, specular and ambient components. The brightness then depends on the colors you choose.
Maybe have a look at this question:
Create Sun light source in OSG

Related

Face Recognizer OpenCV C++ (VS)

I'm not sure if I call this a problem or not but I'm trying to use Face Recognizer from OpenCV tutorial and it works fine.
Steps:
1) load CSV (file containing the path of all image) and train the
algorithm.
2) load the xml file for face detection (Haar Cascade)
3) open camera and crop the face
4) predtect
It works fine when I use a familiar face but when show another face I mean, unknown face, it should give me an (-1) for an unknown face, but it gives me an approximation or the closest face label.
I know it suppose to work like that, it's about proximity for that they put a threshold, but I can't set it , I'm using OpenCV 3.1, I know that because I set the num_components and the threshold in the creation methode:
int num_components = 10;
double threshold = 10.0;
Ptr<FaceRecognizer> model = createEigenFaceRecognizer(num_components,threshold );
printf("thresh= %d", model->getThreshold());
it gives me 0 ,even when I use 0 and 0.0 , it's the same, and I never get (-1), and they are no set("thersh",val) methode in this version.
any ideas or correct me if I'm getting things wrong
thank you in advance.

texturepacker rounded border

I created a rounded rectangle on illustrator and export in to png , then added this image to texturepacker and import to cocos2d here is my rectangle,
Have you any idea why there are white pixels on the corner.
Here is image https://dl.dropboxusercontent.com/u/9018754/Screen%20Shot%202014-07-31%20at%2023.28.52.png
Might be that the image was written as png8 with blending towards a white background in Illustrator.
Can you also post the png you created from Illustrator?
-- update --
The image looks fine. I think we can rule out problems with exporting the image.
In your settings "Premultiply Alpha" is off. When importing the image into cocos2d, did you enabled premultipled alpha?
Both values must be matching. Otherwise you will get some strange behaviour.
If it's on in TexturePacker and off in cocos2d you get black outlines.
If it's off in TexturePacker and on in cocos2d you get white outlines.
So: Try enabling it in TexturePacker.
Yes Premultiply Alpha solved my problem
Changing ccConfig.h to
#ifndef CC_FIX_ARTIFACTS_BY_STRECHING_TEXEL
#define CC_FIX_ARTIFACTS_BY_STRECHING_TEXEL 1
#endif
and setting premultiply alpha + exclude 1 solved my problem ,
It is written in the comment line
**
` If enabled, the texture coordinates will be calculated by using this formula:
- texCoord.left = (rect.origin.x*2+1) / (texture.wide*2);
- texCoord.right = texCoord.left + (rect.size.width*2-2)/(texture.wide*2);
The same for bottom and top.
This formula prevents artifacts by using 99% of the texture.
The "correct" way to prevent artifacts is by using the spritesheet-artifact-fixer.py or a similar tool.
Affected nodes:
- CCSprite / CCSpriteBatchNode and subclasses: CCLabelBMFont, CCTMXLayer
- CCLabelAtlas
- CCParticleSystemQuad
- CCTileMap
To enabled set it to 1. Disabled by default.
**
I couldnt figure out what is going on at the moment but I will check code deeper ,
Thank you Andreas Löw

Crash on Particle Effects

I try to add some particle effects at end of game. in device it worked fine. and in simulator it crashes. i attached the screenshot regarding crash.
it says getting image failed. My Particle str path is firework.plist
in debug its shows correct path.
but i got this error Get data from file(Images/FinishEffect/particleTexture.png) failed!
why its taking wrong path
check screnshot here :- http://postimg.org/image/k97ql9z59/
My code:-
CCParticleSystem *emitter;
char particleStr[64];
sprintf(particleStr,PARTICLE_EFFECT_FINISH_GAME_SCENE);
emitter = CCParticleSystemQuad::create(particleStr);
emitter->setScale(ScreenHelper::getTextureScale());
emitter->setPosition(ccp((m_StartPos.x*PTM_RATIO+RandomInt(-100,100))*ScreenHelper::getCameraZoom(),(m_StartPos.y*PTM_RATIO+RandomInt(-50,150))*ScreenHelper::getCameraZoom())); // setting emitter position
m_ccLayer->getParent()->addChild(emitter,10); // adding the emitter
In this line crash occurs only in simulator. emitter = CCParticleSystemQuad::create(particleStr);
If you check your Firework.plist file you will notice that it has textureFileName. It tells the particle engine which texture to use for your particles. Cocos requires this to work, because it doesn't "draw" the particles itself, it rather uses the provided texture and applies color to it - that's why it generally should be white, but color textures can be used to obtain different results.

Error using OGR to figure out if a pixel center is inside a polygon

I’m trying to develop (using C++ - MSVS 12.0) a function that discover which pixels (from a raster image) have its center inside a polygon (previously populated using a shapefile). I’m using GDAL 1.11.0 (just installed, using devinstall) building from source and using the option INCLUDE_OGR_FRMTS=YES. I can use GDAL and most of OGR functions without problem. However, when I use the following code:
if (polygon->Contains(tmpPoint))
I receive the error message: ERROR 6: GEOS support not enabled
Anybody knows how to solve this issue?
I’m using:
#include "ogrsf_frmts.h"
and my function is declared:
void FindPixels(GDALDataset *image, OGRLayer *poLayer, OGRPolygon *polygon)
and part of my code is:
OGRPoint *tmpPoint = NULL
OGRSpatialReference *spatialReference = NULL;
spatialReference = polygon->getSpatialReference();
tmpPoint = new OGRPoint();
tmpPoint->assignSpatialReference(spatialReference);
loop begin:
tmpPoint->setX(imgTLX + (j * imgRes) + imgResHalf);
tmpPoint->setY(imgTLY - (i * imgRes) - imgResHalf);
if (polygon->Contains(tmpPoint))
Thanks in advance!
MB
Use GDALRasterizeLayers to burn the image of polygon onto a raster. This way you will find all the pixels that fall into the polygon, or not. The default is to burn the pixel only if the centre intersects a polygon.
If the source layer has multiple polygons, you may need to distinguish them by either setting an attribute filter, or using burned attribute ID fields (although this won't work if the polygons overlap).

why D3DXCreateCylinder is not creating a cylinder?

I am trying to make a ball trail.
rBallPos is correctly updating.
Following code is not working creating
a cylinder as ball's trail. How to
solve it?
LPD3DXMESH /*ID3DXMesh*/ ppMeshCylinder = NULL;
hr = D3DXCreateCylinder(g_d3d_device,0.1f,0.1f,0.1f,1,1,&ppMeshCylinder,0);
hr is FAILED here also hr != D3D_OK
D3DXMATRIX cylinder, cylinder2, cylinderRotate, cylinderTrans;
D3DXMatrixRotationX(&cylinderRotate, 1.5f);
D3DXMatrixTranslation(&cylinderTrans, rBallPos.fX, rBallPos.fY, rBallPos.fZ);
D3DXMatrixMultiply(&cylinder, &cylinderRotate, &cylinderTrans);
g_d3d_device->SetTransform(D3DTS_WORLD, &cylinder);
ppMeshCylinder->DrawSubset(0);
Need help.
You need to pass in a pointer to LPD3DXMESH, so your mesh parameter should be &ppMeshCylinder instead of ppMeshCylinder. In fact, your compiler should have already warned you.
Update: Try passing in a larger value for Slices and Stacks, say 5 or 10. It's not possible to create a cylindrical mesh with just 1 polygon.