Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
a999acb
Added modification, including:
Jan 12, 2016
ce4db79
changed Android.mk to the <path-to-osg-gles1-sdk> variant
Jan 12, 2016
b690df5
added license and contribution information
Jan 12, 2016
c178f04
added new compilation files that include 3rdParty libraries and that …
Aug 31, 2016
3930590
added ignore rule for temporary gedit backup files (Ubuntu text editor).
Aug 31, 2016
d2e9722
Changes to be committed:
Aug 31, 2016
ed2f083
Changes to be committed:
Aug 31, 2016
6af4990
Changes to be committed:
Aug 31, 2016
1d7484b
Changes to be committed:
Aug 31, 2016
f0384f7
Changes to be committed:
Aug 31, 2016
bbcc700
Changes to be committed:
Aug 31, 2016
2d6375f
Changes to be committed:
Aug 31, 2016
86e4f5f
Changes to be committed:
Aug 31, 2016
044a9e9
Changes to be committed:
Aug 31, 2016
4c6eb22
Changes to be committed:
Aug 31, 2016
c5d3420
Changes to be committed:
Aug 31, 2016
a32d146
Merge branch 'master' of https://github.com/CKehl/osgAndroid
Aug 31, 2016
1cb6a06
Changes to be committed:
Aug 31, 2016
ba1b51e
Changes to be committed:
Sep 15, 2016
9f9b3a9
stripped underscored variables and unnecessary comments from JNIosg.cpp
Sep 15, 2016
cf58fa0
Added early-fail termination via "if(var==NULL) return;" for array se…
Sep 15, 2016
e5e1d41
removed the as<SuchAndSuch> wrapper functions in JNIosg.cpp
Sep 15, 2016
86d7a82
osg.Core change requests completed.
Sep 15, 2016
a0bd03e
Fixed the in-function defined, which are not needed anymore as it app…
Sep 15, 2016
ca7e184
modified: JNIosgViewer.cpp
Sep 15, 2016
a9f89dc
modified: screenview.cpp
Sep 15, 2016
3f75043
tested and running compilation, ready to be pulled.
Oct 19, 2016
2e67617
cleared local paths from the Android.mk again
Oct 19, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ bin/
libs/
obj/
.metadata/
*.*~
1 change: 1 addition & 0 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,4 +119,5 @@ Contributors (use Name Surname - Company):
+ Julio Campos - Mirage Technologies S.L.
+ Jorge Izquierdo - AI2
+ Jordi Torres - AI2
+ Christian Kehl - Uni Research AS, University of Bergen / Norway

35 changes: 23 additions & 12 deletions org.openscenegraph.android/jni/Android.mk
Original file line number Diff line number Diff line change
@@ -1,19 +1,25 @@
LOCAL_PATH := $(call my-dir)

OSG_SRC_FILES := \
JNIosgViewer.cpp \
OSG_SRC_FILES := \
JNIosg.cpp \
JNIosgDB.cpp \
JNIosgUtil.cpp \
JNIosgGA.cpp \
JNIUtils.cpp \
JNIosgViewer.cpp \
MultiViewNode.cpp \
GLES2ShaderGenVisitor.cpp
GLES2ShaderGenVisitor.cpp \
screenview.cpp

OSG_LDLIBS := \
-losgdb_osg \
-losgdb_ive \
-losgdb_rgb \
-losgdb_bmp \
-losgdb_gif \
-losgdb_jpeg \
-losgdb_tga \
-losgdb_obj \
-losgdb_openflight \
-losgdb_serializers_osgvolume \
-losgdb_serializers_osgtext \
Expand Down Expand Up @@ -57,23 +63,27 @@ OSG_LDLIBS := \
-losgAnimation \
-losgUtil \
-losg \
-lOpenThreads

-lOpenThreads \
-ltiff \
-ljpeg \
-lgif \
-lpng

### GLES1 build
include $(CLEAR_VARS)
OSG_SDK := <path-to-osg-gles1-sdk> #/Users/rgaitan/Projects/OSG/osg-trunk-android-static-gles1-sdk
OSG_SDK_LIB_PATH := $(OSG_SDK)/lib
OSG_SDK_PLUGIN_PATH := $(OSG_SDK_LIB_PATH)/osgPlugins-3.3.8
OSG_HEAD:=<path-to-osg-gles1-sdk>/$(TARGET_ARCH_ABI)
OSG_SDK_LIB_PATH:=$(OSG_SDK)/lib
OSG_SDK_PLUGIN_PATH:=$(OSG_SDK_LIB_PATH)/osgPlugins-3.3.8
ifneq (,$(wildcard $(OSG_SDK)/include/osg/Config))

APP_MODULES := jniosg-gles1
LOCAL_CFLAGS := -Werror -fno-short-enums -fPIC
LOCAL_CPPFLAGS := -DOSG_LIBRARY_STATIC
LOCAL_SRC_FILES := $(OSG_SRC_FILES)
LOCAL_MODULE := libjniosg-gles1
LOCAL_LDLIBS := -llog -lGLESv1_CM -ldl
LOCAL_LDLIBS := -llog -lGLESv1_CM -ldl# -lm
LOCAL_C_INCLUDES := $(OSG_SDK)/include
LOCAL_CPP_INCLUDES := $(OSG_SDK)/include
TARGET_LDLIBS := $(OSG_LDLIBS)
LOCAL_LDFLAGS := -L$(OSG_SDK_LIB_PATH) -L$(OSG_SDK_PLUGIN_PATH)
include $(BUILD_SHARED_LIBRARY)
Expand All @@ -83,17 +93,18 @@ endif

### GLES2 build
include $(CLEAR_VARS)
OSG_SDK := <path-to-osg-gles2-sdk> #/Users/rgaitan/Projects/OSG/osg-trunk-android-static-gles2-sdk
OSG_SDK_LIB_PATH := $(OSG_SDK)/lib
OSG_SDK := <path-to-osg-gles2-sdk>/$(TARGET_ARCH_ABI)
OSG_SDK_LIB_PATH:=$(OSG_SDK)/lib
OSG_SDK_PLUGIN_PATH := $(OSG_SDK_LIB_PATH)/osgPlugins-3.3.8
ifneq ( ,$(wildcard $(OSG_SDK)/include/osg/Config))
APP_MODULES += jniosg-gles2
LOCAL_CFLAGS := -Werror -fno-short-enums -fPIC
LOCAL_CPPFLAGS := -DOSG_LIBRARY_STATIC
LOCAL_SRC_FILES := $(OSG_SRC_FILES)
LOCAL_MODULE := libjniosg-gles2
LOCAL_LDLIBS := -llog -lGLESv2 -ldl
LOCAL_LDLIBS := -llog -lGLESv2 -ldl# -lm
LOCAL_C_INCLUDES := $(OSG_SDK)/include
LOCAL_CPP_INCLUDES := $(OSG_SDK)/include
TARGET_LDLIBS := $(OSG_LDLIBS)
LOCAL_LDFLAGS := -L$(OSG_SDK_LIB_PATH) -L$(OSG_SDK_PLUGIN_PATH)
include $(BUILD_SHARED_LIBRARY)
Expand Down
8 changes: 5 additions & 3 deletions org.openscenegraph.android/jni/Application.mk
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
#ANDROID APPLICATION MAKEFILE
APP_BUILD_SCRIPT := $(call my-dir)/Android.mk
NDK_MODULE_PATH := $(call my-dir)
#APP_PROJECT_PATH := $(call my-dir)

APP_OPTIM := release

APP_PLATFORM := android-8
APP_STL := gnustl_shared
APP_STL := gnustl_shared
APP_CFLAGS := -fexceptions
APP_CPPFLAGS := -fexceptions -frtti
APP_ABI := armeabi
APP_MODULES := jniosg-gles1 jniosg-gles2
APP_ABI := armeabi armeabi-v7a
#APP_MODULES := jniosg-gles1 jniosg-gles2
NDK_TOOLCHAIN_VERSION := 4.9
50 changes: 48 additions & 2 deletions org.openscenegraph.android/jni/JNIUtils.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* @License
-------------------------------------------------------------------------------
| osgAndroid - Copyright (C) 2012 Rafael Gait�n, Mirage Technologies S.L. |
| osgAndroid - Copyright (C) 2012 Rafael Gait�n, Mirage Technologies S.L. |
| |
| This library is free software; you can redistribute it and/or modify |
| it under the terms of the GNU Lesser General Public License as published |
Expand All @@ -22,13 +22,14 @@
#include <string>

#include <osg/Referenced>
#include <osg/Vec2>
#include <osg/Vec3>
#include <osg/Vec4>
#include <osg/Quat>
#include <osg/Image>

extern std::string jstring2string(JNIEnv *env, jstring jstr);


template<class T>
class ReferencedType: public T, public osg::Referenced
{
Expand All @@ -37,6 +38,51 @@ class ReferencedType: public T, public osg::Referenced
protected:
~ReferencedType() { }
};
typedef ReferencedType<osg::Vec2> RefVec2;
typedef ReferencedType<osg::Vec3> RefVec3;
typedef ReferencedType<osg::Vec4> RefVec4;
typedef ReferencedType<osg::Quat> RefQuat;

inline osg::Vec4 Interpolate(osg::Vec2 _texcoord, osg::Image* _img)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't it be "const osg::Vec2 &_texcoord"? Also we tend to use underscore for member class variables, not for parameters.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree Jordi: for efficiency reasons, it can be "const osg::Vec2 &texcoord" - I just needed this function quickly, so I wasn't that picky with the reference. The underscoring: noted and will be changed.

{
osg::Vec4 kernel[3][3];
int l_k, l_l;
float width = _img->s(), height = _img->t();
float xc = _texcoord.x()*(width-1); float yc = (1.0-_texcoord.y())*(height-1);
int xd = int(floor(xc)); int yd = int(floor(yc));

//collect values
for(int k = (xd-1); k < (xd+2); k++)
{
for(int l = (yd-1); l < (yd+2); l++)
{
l_k = k - (xd-1); l_l = l - (yd-1);
if((k<0)||(k>int(width-1))||(l<0)||(l>int(height-1)))
{
kernel[l_k][l_l] = osg::Vec4(0,0,0,0);
}
else
{
kernel[l_k][l_l] = _img->getColor(k,l,0);
}
}
}

float final_colour_r=0, final_colour_g=0, final_colour_b=0, final_colour_a = 0;
float x_offset, y_offset;
x_offset = (xc - (float)xd) - 0.5;
y_offset = (yc - (float)yd) - 0.5;
double dist = 0.0;
for(int k = 0; k < 3; k++)
{
for(int l = 0; l < 3; l++)
{
dist = (sqrt((abs((k-1)+x_offset) * abs((k-1)+x_offset)) + (abs((l-1)+y_offset) * abs((l-1)+y_offset))))/2.121320344;
final_colour_r += (1-dist) * kernel[k][l].x();
final_colour_g += (1-dist) * kernel[k][l].y();
final_colour_b += (1-dist) * kernel[k][l].z();
final_colour_a += (1-dist) * kernel[k][l].w();
}
}
return osg::Vec4(final_colour_r/9.0, final_colour_g/9.0, final_colour_b/9.0, final_colour_a/9.0);
}
Loading