Ejemplo n.º 1
0
JNIEXPORT void JNICALL Java_org_openscenegraph_osg_core_Vec3_nativeSet(JNIEnv *, jclass, jlong cptr,
		jfloat x, jfloat y, jfloat z)
{
	RefVec3 *v = reinterpret_cast<RefVec3 *>(cptr);
	if(v != 0)
	{
		v->set(x,y,z);
	}
}
Ejemplo n.º 2
0
JNIEXPORT jlong JNICALL Java_org_openscenegraph_osg_core_AnimationPathCallback_nativeGetPivotPoint(JNIEnv *, jclass, jlong cptr)
{
	osg::AnimationPathCallback *cb = reinterpret_cast<osg::AnimationPathCallback *>(cptr);
	if(cb != 0)
	{
		osg::Vec3 ret = cb->getPivotPoint();
		RefVec3 *refRet = new RefVec3();
		refRet->set(ret.x(),ret.y(),ret.z());
		refRet->ref();
		return reinterpret_cast<jlong>(refRet);
	}
	return 0L;
}
Ejemplo n.º 3
0
JNIEXPORT jfloat JNICALL Java_org_openscenegraph_osg_core_Vec3_nativeNegation(JNIEnv *, jclass, jlong cptr)
{
	RefVec3 *v = reinterpret_cast<RefVec3 *>(cptr);
	if(v != 0)
	{
		osg::Vec3 res = -(*v);
		RefVec3 *refRes = new RefVec3();
		refRes->set(res);
		refRes->ref();
		return reinterpret_cast<jlong>(refRes);
	}
	return 0l;
}
Ejemplo n.º 4
0
JNICALL jlong JNICALL Java_org_openscenegraph_osg_viewer_OffScreenViewer_nativeRaycast(JNIEnv* env, jclass, jlong viewer_cptr, jlong camera_ptr, jlong vec2array_cptr)
{
	osg::Vec3Array* v3a = new osg::Vec3Array();
	v3a->ref();

	osgViewer::View* viewer = reinterpret_cast<osgViewer::View*>(viewer_cptr);
	osg::Camera* cam = reinterpret_cast<osg::Camera*>(camera_ptr);
	osg::Vec2Array* va = reinterpret_cast<osg::Vec2Array*>(vec2array_cptr);
	osgUtil::LineSegmentIntersector::Intersections intersections;
	for(uint i = 0; i < va->size(); i++)
	{
		if(i==0)
		{
			osg::Matrixf cmat = cam->getViewMatrix();
			float* data = (float*)(cmat.ptr());
			LOGI("[%f,%f,%f,%f]",data[0],data[1],data[2],data[3]);
			LOGI("[%f,%f,%f,%f]",data[4],data[5],data[6],data[7]);
			LOGI("[%f,%f,%f,%f]",data[8],data[9],data[10],data[11]);
			LOGI("[%f,%f,%f,%f]",data[12],data[13],data[14],data[15]);
	    	osg::Vec3 eye, center, up;
	    	cam->getViewMatrixAsLookAt(eye,center,up);
	    	LOGI("Eye: (%f,%f,%f) - Center: (%f,%f,%f) - Up: (%f,%f,%f)",eye.x(), eye.y(), eye.z(), center.x(), center.y(), center.z(), up.x(), up.y(), up.z());
		}
		viewer->computeIntersections(const_cast<const osg::Camera*>(cam), osgUtil::Intersector::WINDOW, va->at(i).x(), va->at(i).y(), intersections);
		RefVec3 *refRes = new RefVec3();
		if(intersections.empty() == false)
		{
			refRes->set(intersections.begin()->getWorldIntersectPoint().x(), intersections.begin()->getWorldIntersectPoint().y(), intersections.begin()->getWorldIntersectPoint().z());
		}
		else
		{
			refRes->set(DBL_MAX,DBL_MAX,DBL_MAX);
		}
		refRes->ref();
		v3a->push_back(*refRes);
	}

	return reinterpret_cast<jlong>(v3a);
}
Ejemplo n.º 5
0
JNIEXPORT jlong JNICALL Java_org_openscenegraph_osg_core_Vec3_nativeEscalarProduct(JNIEnv *, jclass, jlong cptr,
		jfloat value)
{
	RefVec3 *v = reinterpret_cast<RefVec3 *>(cptr);
	if(v != 0)
	{
		osg::Vec3 res = (*v)*value;
		RefVec3 *refRes = new RefVec3();
		refRes->set(res);
		refRes->ref();
		return reinterpret_cast<jlong>(refRes);
	}
	return 0l;
}
Ejemplo n.º 6
0
JNIEXPORT jlong JNICALL Java_org_openscenegraph_osg_core_Vec3_nativeSub(JNIEnv *, jclass, jlong cptr,
		jlong lrhs)
{
	RefVec3 *v = reinterpret_cast<RefVec3 *>(cptr);
	RefVec3 *rhs = reinterpret_cast<RefVec3 *>(lrhs);
	if(v != 0 && rhs !=0)
	{
		osg::Vec3 res = (*v)-(*rhs);
		RefVec3 *refRes = new RefVec3();
		refRes->set(res);
		refRes->ref();
		return reinterpret_cast<jlong>(refRes);
	}
	return 0l;
}