예제 #1
0
LObject NewObjectArray(jsize length,const AbstractObject& elementClass,const AbstractObject& initialElement) {
    jclass jElementClass=(jclass)elementClass.GetJObject();
    jobject jInitialElement=initialElement.GetJObject();
    jobject array=GetEnv()->NewObjectArray(length,jElementClass,jInitialElement);
    TranslateJavaException();
    return LObject::WrapLocal(array);
}
예제 #2
0
AbstractObjectPtr
ObjectFactory::createObject(
    const QString &aName,
    const Position aPosition,
    const qreal aWidth,
    const qreal anHeight)
{
    const ObjectFactory *myFactoryPtr = theFactoryListPtr->getFactoryPtr(aName);
    DEBUG5("ObjectFactory::createObject(\"%s\") Factory=%p", ASCII(aName), myFactoryPtr);
    if (myFactoryPtr == nullptr) {
        DEBUG1("There is no factory for Object type '%s'", ASCII(aName));
        return nullptr;
    }
    AbstractObject *myObjectPtr = myFactoryPtr->createObject();
    assert (myObjectPtr != nullptr);
    AbstractObjectPtr mySharedOPtr = AbstractObjectPtr(myObjectPtr);
    myObjectPtr->theThisPtr = mySharedOPtr;
    DEBUG5("  object created = %p, i18n name = '%s'", myObjectPtr, ASCII(myObjectPtr->getName()));
    assert (aName.contains(" ") == false);
    myObjectPtr->theInternalName = aName;
    myObjectPtr->theCenter = aPosition;
    if (aWidth != 1.0)
        myObjectPtr->theWidth = aWidth;
    if (anHeight != 1.0)
        myObjectPtr->theHeight = anHeight;
    // finally, get rid of the actual pointer and return the shared_ptr
    assert (nullptr != mySharedOPtr);
    return mySharedOPtr;
}
예제 #3
0
void DDEngine::SceneTransformator::setObjects(const std::vector<AbstractObject*> objects)
{
	SceneTransformatorStatic::objects = objects;

	for (size_t i = 0; i < objects.size(); i++) {
		AbstractObject* o = objects[i];
		Picker item;
		item.index = i;
		item.name = o->getName();
		selections.push_back(item);
	}

}
예제 #4
0
void ObjectPool::pushObj(QString objID, QStringList objLinks, QStringList props,QStringList type)
{
    AbstractObject *obj = new AbstractObject(objID);

    for (QString s : props)
    {
      obj->addProp(s);
    }
    obj -> addStrLink(objLinks); // тексто-ссылки на др. объекты.
    obj -> addLinksType(type);
    this -> pool.push_back(obj);

}
예제 #5
0
// ------------------------------------
std::vector<AbstractObject* > DumbObjectHandler::GetCollidableObjects()
// ------------------------------------
{
	std::vector<AbstractObject* > objs;
	std::vector<AbstractObject* >::iterator it;
	for (it = m_objects.begin(); it != m_objects.end(); it++)
	{
		AbstractObject* obj = *it;
		if (obj->RespondsTo(EMSG_COLLISION))
			objs.push_back(obj);
	}
	
	return objs;
}
예제 #6
0
void Throw(const AbstractObject& throwable) {
    jthrowable jThrowable=(jthrowable)throwable.GetJObject();
    int error=GetEnv()->Throw(jThrowable);
    if (error) {
        FatalError("Throw() failed with %d error.",error);
    }
}
예제 #7
0
void ReleaseBoolArrayElements(const AbstractObject& array,bool* elements,jint mode) {
    jbooleanArray jArray=(jbooleanArray)array.GetJObject();
    if (JBooleanIsBool) {
        GetEnv()->ReleaseBooleanArrayElements(jArray,(jboolean*)elements,mode);
    } else {
        FatalError("jni::ReleaseBoolArrayElements is not implemented yet.");
    }
}
예제 #8
0
void SetBoolArrayRegion(const AbstractObject& array,jsize start,jsize length,const bool* buffer) {
    jbooleanArray jArray=(jbooleanArray)array.GetJObject();
    if (JBooleanIsBool) {
        GetEnv()->SetBooleanArrayRegion(jArray,start,length,(const jboolean*)buffer);
    } else {
        FatalError("jni::SetBoolArrayRegion is not implemented yet.");
    }
}
예제 #9
0
void DDEngine::SceneTransformatorStatic::selectObject(const int index)
{
	SceneTransformatorStatic::selectedObject = index;
	updateSelection(index);
	AbstractObject* o = objects.at(index);

	XMVECTOR rotationQuat;
	XMVECTOR scaleVec;
	XMVECTOR translateVec;

	XMMatrixDecompose(&scaleVec, &rotationQuat, &translateVec, o->getWorldMatrix());

	XMStoreFloat4(&rotationQuaternions, rotationQuat);
	XMStoreFloat4(&scaleVector, scaleVec);
	XMStoreFloat3(&translationVector, translateVec);

	scaleVector.w = 0.0f;
}
예제 #10
0
AbstractObject::AbstractObject(const AbstractObject& ao,const CopyOp& copyop) :
MatrixTransform(ao,copyop) {
	AbstractObjectParams aop;
	ao.getParams(aop);
	setParams(aop);
	m_bIsTargetPick = ao.m_bIsTargetPick;

	s_nAbstractObjectNo += 1;
}
예제 #11
0
	void Attribute::set(void* owner, AbstractObject o) const{
		if(!extension->mutator){
			Byte* adress = (Byte*)owner + offset;
			//ASSERT(o.getDescriptor() == descriptor);
			descriptor->copy(o.getAdress(),adress);
		}
		else{
			std::vector<AbstractObject> s;
			s.push_back(o);
			extension->mutator->execute(owner,s);
		}
	}
예제 #12
0
AbstractObject* ObjectFactory::CreateObject (ObjectParameters parameters)
{
	AbstractObject* newObject = nullptr;

	switch (parameters._objectType)
	{
	case SHIP  : newObject = new Ship  ; break;
	case PLANET: newObject = new Planet; break;

	default  : newObject = nullptr;
	}

	ObjectInfo* objectInfo = APPLICATION->_manager->objectManager. Get(parameters._mainParametersPath);

	Model*           model = APPLICATION->_manager->modelManager.  Get (objectInfo->_modelPath);
	GLuint         texture = APPLICATION->_manager->textureManager.Get (objectInfo->_texturePath);
	ShaderProg* shaderProg = APPLICATION->_manager->shaderManager. Get (objectInfo->_shaderPaths);

	newObject->SetModel      (model     );
	newObject->SetTexture    (texture   );
	newObject->SetShaderProg (shaderProg);

	newObject->SetWorldPos   (parameters._worldPos);
	newObject->SetScale      (parameters._scale);

	return newObject;
}
예제 #13
0
void DDEngine::SceneTransformator::transform(const DDERenderPackage pkg)
{
	if (selectedObject > -1 && enableTransformFlag) {

		AbstractObject* o = objects.at(selectedObject);

		XMMATRIX rot = XMMatrixRotationQuaternion(DirectX::XMLoadFloat4(&rotationQuaternions));
		XMMATRIX scale = XMMatrixScalingFromVector(DirectX::XMLoadFloat4(&scaleVector));
		XMMATRIX translation = XMMatrixTranslationFromVector(DirectX::XMLoadFloat3(&translationVector));

		XMFLOAT4X4 rotMat;
		XMFLOAT4X4 scaleMat;
		XMFLOAT4X4 transMat;

		DirectX::XMStoreFloat4x4(&rotMat, rot);
		DirectX::XMStoreFloat4x4(&scaleMat, scale);
		DirectX::XMStoreFloat4x4(&transMat, translation);

		o->setRotationMatrix(rotMat);
		o->setScaleMatrix(scaleMat);
		o->setTranslationMatrix(transMat);
	}
}
void test_join_meet(const AbstractObject& foo,
                    const AbstractObject& bar,
                    const AbstractObject& generic) {
  EXPECT_TRUE(generic.leq(generic));
  EXPECT_FALSE(generic.leq(foo));
  EXPECT_FALSE(generic.leq(bar));
  EXPECT_TRUE(foo.leq(generic));
  EXPECT_TRUE(foo.leq(foo));
  EXPECT_FALSE(foo.leq(bar));
  EXPECT_TRUE(bar.leq(generic));
  EXPECT_FALSE(bar.leq(foo));
  EXPECT_TRUE(bar.leq(bar));

  auto join_with_foo = [&foo](auto&& obj) { return obj.join_with(foo); };
  auto join_with_bar = [&bar](auto&& obj) { return obj.join_with(bar); };
  auto join_with_generic = [&generic](auto&& obj) {
    return obj.join_with(generic);
  };
  test_operation(generic, join_with_generic, generic);
  test_operation(generic, join_with_foo, generic);
  test_operation(generic, join_with_bar, generic);
  test_operation(foo, join_with_generic, generic);
  test_operation(foo, join_with_foo, foo);
  test_operation(foo, join_with_bar, generic);
  test_operation(bar, join_with_generic, generic);
  test_operation(bar, join_with_foo, generic);
  test_operation(bar, join_with_bar, bar);

  auto meet_with_foo = [&foo](auto&& obj) { return obj.meet_with(foo); };
  auto meet_with_bar = [&bar](auto&& obj) { return obj.meet_with(bar); };
  auto meet_with_generic = [&generic](auto&& obj) {
    return obj.meet_with(generic);
  };
  test_operation(generic, meet_with_generic, generic);
  test_operation(generic, meet_with_foo, foo);
  test_operation(generic, meet_with_bar, bar);
  test_operation(foo, meet_with_generic, foo);
  test_operation(foo, meet_with_foo, foo);
  test_operation(bar, meet_with_generic, bar);
  test_operation(bar, meet_with_bar, bar);
  auto foo_copy = foo;
  EXPECT_EQ(foo_copy.meet_with(bar), sparta::AbstractValueKind::Bottom);
  auto bar_copy = bar;
  EXPECT_EQ(bar_copy.meet_with(foo), sparta::AbstractValueKind::Bottom);
}
예제 #15
0
bool IsAssignableFrom(const AbstractObject& clazz,const AbstractObject& clazzFrom) {
    jclass jClazz=(jclass)clazz.GetJObject();
    jclass jClazzFrom=(jclass)clazzFrom.GetJObject();
    return GetEnv()->IsAssignableFrom(jClazz,jClazzFrom)==JNI_TRUE;
}
예제 #16
0
				bool legal(const KDTree::Ray &ray, const KDTree::Triangle& tri, const float dist) const{
					AbstractObject *intersectObject = scene->objects[((Scene::ObjSourceInfo*)tri.sourceInformation)->objID];
					uint fi = ((Scene::ObjSourceInfo*)tri.sourceInformation)->triID;
					bool in = ray.direction.dot(intersectObject->getWorldNormal(fi, ray.origin + ray.direction*dist))<0;
					return in;
				}
예제 #17
0
	Ray HeterogeneousVolume::scatter(Ray &inRay) const{
		Ray outRay;
		outRay.isDeltaDirection = false;

		bool go_in_vol = inRay.intersectObj == this && inRay.insideObj != this;
		bool be_in_vol = inRay.insideObj == this;

		// CASE1: Go in volume.
		if(go_in_vol){
			vec3f position = inRay.origin + inRay.direction*inRay.intersectDist;
			vec3f normal = inRay.intersectObj->getWorldNormal(inRay.intersectTriangleID, position);

			outRay.origin = position;
			outRay.direction = inRay.direction;

			vec3f reflDir = -normal.dot(inRay.direction)*normal*2 + inRay.direction;
			reflDir.normalize();
			float theta = acos(inRay.direction.dot(normal));

			AbstractObject* currentInsideObject = inRay.insideObj;
			AbstractObject* outSideObject = (AbstractObject*)this;

			float current_n = currentInsideObject ? currentInsideObject->getIOR() : 1;
			float next_n = outSideObject ? outSideObject->getIOR() : 1;
			float sin_phi = current_n / next_n * sin(theta);

			outRay.intersectObj = NULL;
			outRay.radiance = vec3f(1, 1, 1);
			outRay.directionProb = 1;
			outRay.contactObj = (AbstractObject*)this;
			outRay.contactTriangleID = inRay.intersectTriangleID;

			if(sin_phi > 1){
				outRay.direction = reflDir;
				outRay.insideObj = inRay.insideObj;
				outRay.directionProb = 1;
				outRay.isDeltaDirection = true;
				outRay.photonType = Ray::NOUSE;
			}
			else{
				float phi = asin(sin_phi);
				if(theta > PI/2)	phi = PI - phi;
				vec3f axis = normal.cross(inRay.direction);
				axis.normalize();
				outRay.direction = vec3f(RotateMatrix(axis, phi) * vec4f(normal, 0));
				outRay.direction.normalize();

				float cos_theta = abs(cos(theta));
				float cos_phi = abs(cos(phi));
				float esr = powf(abs(current_n*cos_theta-next_n*cos_phi)/(current_n*cos_theta+next_n*cos_phi),2);
				float epr = powf(abs(next_n*cos_theta-current_n*cos_phi)/(next_n*cos_theta+current_n*cos_phi),2);
				float er = (esr+epr)/2;
				float p = er;

				if(rng->genFloat() < p)
				{
					outRay.direction = reflDir;
					outRay.radiance *= er / outRay.cosineTerm();
					outRay.directionProb = p;
					outRay.insideObj = inRay.insideObj;
					outRay.isDeltaDirection = true;
					outRay.photonType = Ray::NOUSE;
				}
				else
				{
					outRay.radiance *= (1-er) / outRay.cosineTerm();
					outRay.directionProb = 1-p;
					outRay.contactObj = outRay.insideObj = (AbstractObject*)this;
					outRay.isDeltaDirection = true;
					outRay.photonType = Ray::HITVOL;
				}
				outRay.direction.normalize();
			}
			return outRay;
		}

		float p_medium, P_surface, sampleDist;

		bool samplingState = sampleDistance(inRay, sampleDist, p_medium, P_surface);

		bool out_of_vol = samplingState == false;//sampleDist >= inRay.intersectDist;

		// CASE2: Be in volume.
		if(be_in_vol && !out_of_vol){
			outRay.origin = inRay.origin + inRay.direction * sampleDist;
			outRay.radiance = bsdf->sampleBSDF(inRay.direction, outRay.direction, vec3f(), *rng, &outRay.directionProb);
			outRay.insideObj = (AbstractObject*)this;
			outRay.contactTriangleID = inRay.intersectTriangleID;
			float albedo = isSubsurface ? getAlbedo(outRay.origin) : getAlbedo();
			float rander = rng->genFloat();	
			if(rander < albedo){
				outRay.contactObj = NULL;
				outRay.directionProb *= albedo;
				outRay.originProb = p_medium;//  pMedium(inRay, sampleDist);// 
				outRay.isDeltaDirection = false;
				outRay.radiance *= isSubsurface ? lookUpSubSurfaceVolumeData(outRay.origin, SCATTERING) : scatteringCoeff * lookUpDensity(outRay.origin);
				outRay.photonType = Ray::INVOL;
			}
			else{
				// terminate
				outRay.direction = vec3f(0, 0, 0); 
				outRay.radiance = vec3f(0, 0, 0);  
				outRay.directionProb = 1; 
				outRay.originProb = p_medium;//pMedium(inRay, sampleDist);//
				outRay.insideObj = NULL;
				outRay.contactObj = NULL;
				outRay.isDeltaDirection = false;
				outRay.photonType = Ray::INVOL; //Ray::NOUSE;//
			}
			return outRay;
		}

		// CASE3: Go out of volume.
		if(be_in_vol && out_of_vol){
			outRay = inRay;
			outRay.direction = inRay.direction;
			outRay.origin = inRay.origin + inRay.intersectDist * inRay.direction;
			outRay.contactObj = inRay.intersectObj;
			outRay.contactTriangleID = inRay.intersectTriangleID;
			outRay.insideObj = (AbstractObject*)this;
			outRay.directionProb = 1; 
			outRay.radiance = vec3f(1,1,1);
			bool going_out = (inRay.intersectObj == this);
			if(going_out){
				vec3f normal = inRay.intersectObj->getWorldNormal(inRay.intersectTriangleID, outRay.origin);
				vec3f reflDir = -normal.dot(inRay.direction)*normal*2 + inRay.direction;
				reflDir.normalize();
				float theta = acos(inRay.direction.dot(normal));

				AbstractObject* currentInsideObject = (AbstractObject*)this;
				AbstractObject* outSideObject = scene->findInsideObject(outRay, (AbstractObject*)this);

				float current_n = currentInsideObject ? currentInsideObject->getIOR() : 1;
				float next_n = outSideObject ? outSideObject->getIOR() : 1;
				float sin_phi = current_n / next_n * sin(theta);

				outRay.intersectObj = NULL;
				if(sin_phi > 1){
					outRay.direction = reflDir;
					outRay.insideObj = inRay.insideObj;
					outRay.contactObj = (AbstractObject*)this;
					outRay.originProb = P_surface;// PSurface(inRay, inRay.intersectDist);//
					outRay.photonType = Ray::NOUSE;
					outRay.isDeltaDirection = true;
				}
				else{
					float phi = asin(sin_phi);
					if(theta > PI/2)	phi = PI - phi;
					vec3f axis = normal.cross(inRay.direction);
					axis.normalize();
					outRay.direction = vec3f(RotateMatrix(axis, phi) * vec4f(normal, 0));
					outRay.direction.normalize();

					float cos_theta = abs(cos(theta));
					float cos_phi = abs(cos(phi));
					float esr = powf(abs(current_n*cos_theta-next_n*cos_phi)/(current_n*cos_theta+next_n*cos_phi),2);
					float epr = powf(abs(next_n*cos_theta-current_n*cos_phi)/(next_n*cos_theta+current_n*cos_phi),2);
					float er = (esr+epr)/2;
					float p = er;

					if(rng->genFloat() < p)
					{
						outRay.direction = reflDir;
						outRay.radiance *= er / outRay.cosineTerm();
						outRay.directionProb = p;
						outRay.originProb = P_surface;// PSurface(inRay, inRay.intersectDist);//
						outRay.insideObj = inRay.insideObj;
						outRay.isDeltaDirection = true;
						outRay.photonType = Ray::NOUSE;
					}
					else
					{
						outRay.radiance *= (1-er) / outRay.cosineTerm();
						outRay.directionProb = (1-p);
						outRay.originProb = P_surface;//PSurface(inRay, inRay.intersectDist);// 
						outRay.insideObj = outSideObject;
						outRay.isDeltaDirection = true;
						outRay.photonType = Ray::NOUSE;
					}
					outRay.direction.normalize();
				}	
			}
			else{
				outRay.contactObj = NULL;
				outRay.intersectDist = 0;
				outRay = inRay.intersectObj->scatter(outRay);
				outRay.originProb *= P_surface;//PSurface(inRay, inRay.intersectDist);// 
				outRay.photonType = inRay.intersectObj->isVolume() ? Ray::NOUSE : Ray::OUTVOL;
			}
			return outRay;
		}
		return outRay;
	}
예제 #18
0
LObject GetSuperclass(const AbstractObject& clazz) {
    jclass jClazz=(jclass)clazz.GetJObject();
    return LObject::WrapLocal(GetEnv()->GetSuperclass(jClazz));
}
예제 #19
0
LObject GetObjectClass(const AbstractObject& object) {
    jobject javaObject=object.GetJObject();
    return LObject::WrapLocal(GetEnv()->GetObjectClass(javaObject));
}
예제 #20
0
void SetObjectArrayElement(const AbstractObject& array,jsize index,const AbstractObject& value) {
    jobjectArray jArray=(jobjectArray)array.GetJObject();
    jobject jValue=value.GetJObject();
    GetEnv()->SetObjectArrayElement(jArray,index,jValue);
    TranslateJavaException();
}
예제 #21
0
LObject GetObjectArrayElement(const AbstractObject& array,jsize index) {
    jobjectArray jArray=(jobjectArray)array.GetJObject();
    jobject object=GetEnv()->GetObjectArrayElement(jArray,index);
    TranslateJavaException();
    return LObject::WrapLocal(object);
}
예제 #22
0
bool IsSameObject(const AbstractObject& object1,const AbstractObject& object2) {
    jobject jObject1=object1.GetJObject();
    jobject jObject2=object2.GetJObject();
    return GetEnv()->IsSameObject(jObject1,jObject2)==JNI_TRUE;
}
예제 #23
0
jsize GetArrayLength(const AbstractObject& array) {
    jarray jArray=(jarray)array.GetJObject();
    return GetEnv()->GetArrayLength(jArray);
}
예제 #24
0
jfieldID GetStaticFieldID(const AbstractObject& clazz,const char* name,const char* signature) {
    jclass jClazz=(jclass)clazz.GetJObject();
    jfieldID result=GetEnv()->GetStaticFieldID(jClazz,name,signature);
    TranslateJavaException();
    return result;
}