### Recent Posts

Pages: 1 ... 5 6 [7] 8 9 10
61
##### Bones / Re: Scale Problem?
« Last post by AGP on August 31, 2017, 03:07:27 pm »
Sorry, I hadn't realized that you replied.

No, they were both attempts to fix the incomprehensible problem. scaleBones looks like this (where SCALE is currently set to 1.00f):

Code: [Select]
`    private static void scaleBones(ArrayList<Bone> bones) {        for (int i = 0; i < bones.size(); i++) {            Bone aBone = bones.get(i);            scaleBonePosition(aBone);            scaleBoneMatrix(aBone);        }    }    private static void scaleBonePosition(Bone aBone) {        aBone.position.x *= SCALE;        aBone.position.y *= SCALE;        aBone.position.z *= SCALE;    }        private static void scaleBoneMatrix(Bone aBone) {        aBone.transform.scalarMul(SCALE);    }`
invertBones just multiplies all values by -1. Neither attempts at solutions either help or hurt the problem.
62
##### Bones / Re: Scale Problem?
« Last post by EgonOlsen on August 30, 2017, 09:05:54 am »
Looking at the code, I would expect that one these methods screws it up:

Code: [Select]
`scaleBones(bones);invertBonesCoords(bones);`
What are these doing and can you check if your bones are still correct afterwards?
63
##### Support / Re: JPCT-ae + GoogleTango = Occlusion/Stencil
« Last post by EgonOlsen on August 30, 2017, 09:01:59 am »
A stencil buffer? No, there's no support for this.
64
##### Bones / Scale Problem?
« Last post by AGP on August 29, 2017, 10:04:27 pm »
I have a class called Bone, as defined in the following code. It's used as a bridge between the JSON-serialized format I created and Bones.

Code: [Select]
`class Bone {    protected String name;    protected SimpleVector position;    protected Matrix transform;    protected int index, parentIndex;    public Bone(String name, SimpleVector position, Matrix transform, int index, int parentIndex) {        this.name = name;        this.position = position;        this.transform = transform;        this.index = index;        this.parentIndex = parentIndex;    }    public boolean hasParent () {        return this.parentIndex >= 0;    }    public String toString () {        return this.name + ": " + this.position;    }}`
When I print its values as follows, I get perfectly reasonable numbers (values ranging from -30 to +120).

Code: [Select]
`System.out.println(newBone.toString() +": "+newBone.index);`
But, after creating my AnimatedGroup, as follows, the values range between -Infinity to +Infinity, with NaNs thrown in there for good measure.

Code: [Select]
`    public static AnimatedGroup loadGroup(JsonLoader jsonLoader) {        MaxBonesClip[] clips = Importer.getMaxBonesClips(jsonLoader);        MaxBonesImporter jImporter = new MaxBonesImporter(jsonLoader, clips);        ArrayList<ArrayList> objects = jImporter.getList();        ArrayList<Bone> bones = jImporter.getBones();        ArrayList<ArrayList> objectsBonesReferences = jImporter.getBonesReferences(); // for all objects, respects the same order of objects        Animated3D anObject = null;        SimpleVector center = null;        scaleBones(bones);        invertBonesCoords(bones);        Skeleton skeleton = Importer.makeSkeleton(bones);        SkeletonPose pose = new SkeletonPose(skeleton);        pose.updateTransforms();                Animated3D[] list = new Animated3D[objects.size()];        for (int i = 0; i < objects.size(); i++) {            ArrayList<ArrayList> theObject = objects.get(i);            if (bones == null || bones.size() <= 0) {                Logger.log("Problem: no bones. Try loadObject(String) instead.");                java.awt.Toolkit.getDefaultToolkit().beep();                return null;            }            anObject = makeAnimated3D(pose, objectsBonesReferences.get(i), theObject, new File(jsonLoader.getMainFileName()).getParent());            anObject.build();            list[i] = anObject;        }        System.out.println("To test: "+bones.get(JSONFrame.BONE_INDEX_TO_TEST));        AnimatedGroup asGroup = new AnimatedGroup(list);        asGroup.setSkinClipSequence(getSkinClipSequence(jImporter, anObject.getSkeleton()));        return asGroup;    }    private static Animated3D makeAnimated3D(SkeletonPose pose, ArrayList<BoneReference> boneRefs, ArrayList<ArrayList> theImportedObject, String absolutePath) {        ArrayList<ArrayList> vertices = theImportedObject.get(0);        ArrayList<String> diffuseAndNormal = theImportedObject.get(3);        int verticesCount = vertices.size();                //skeletonDebugger = new SkeletonDebugger(pose, 0f, 1f);                float[][] weights = new float[verticesCount][Importer.MAX_JOINTS_PER_VERTEX];        short[][] jointIndices = new short[verticesCount][Importer.MAX_JOINTS_PER_VERTEX];        int[] verticesCounters = new int[verticesCount];        for (int i = 0; i < verticesCount; i++) verticesCounters[i] = 0;                for (BoneReference aBoneRef: boneRefs) {            int vertexRef = aBoneRef.vertexIndexReference;                        int verticesCounter = verticesCounters[vertexRef];            if (verticesCounter < Importer.MAX_JOINTS_PER_VERTEX) {                weights[vertexRef][verticesCounter] = aBoneRef.vertexWeight;                jointIndices[vertexRef][verticesCounter] = aBoneRef.boneIndexReference;                verticesCounters[vertexRef]++;            }        }        SkinData skin = new SkinData(weights, jointIndices);        if (!TextureManager.getInstance().containsTexture(diffuseAndNormal.get(0)))        TextureManager.getInstance().addTexture(diffuseAndNormal.get(0), new Texture(absolutePath +File.separator+diffuseAndNormal.get(0)));                MeshData meshData = makeMeshData(theImportedObject);        Animated3D anAnimated = new Animated3D(meshData, skin, pose);        anAnimated.setTexture(diffuseAndNormal.get(0));        return anAnimated;    }`
These prints produce NaNs, and the infinities:
Code: [Select]
`        for (int h = 0; h < asGroup.getSize(); h++) {            Animated3D temp = asGroup.get(h);                        Skeleton s = asGroup.get(h).getSkeletonPose().getSkeleton();            for (int i = 0; i < s.getNumberOfJoints(); i++) {                System.out.println(temp.getSkinClipSequence().getClip(0).getSkeleton().getJoint(i).getBindPose().toString());                //temp.applySkeletonPose();                //temp.animateSkin(frame, sequence);                //temp.applyAnimation();            }        }`
65
##### Support / Re: JPCT-ae + GoogleTango = Occlusion/Stencil
« Last post by ares91x on August 29, 2017, 08:16:52 pm »
mmm yes this could work

Exists a way do create stencil in jpct?
66
##### Support / Re: Environment reflection on a textured objects
« Last post by Promyclon on August 29, 2017, 03:56:40 pm »
Knowing that objects always have a texture was all I needed. Just adding environment to the second channel should does the job. Thank you!
67
##### Support / Re: Environment reflection on a textured objects
« Last post by EgonOlsen on August 28, 2017, 02:11:58 pm »
I'm not sure, if that's what you actually want...but you can obtain a texture-ID for a polygon via the PolygonManager and then go to the TextureManager and ask for the name of that texture. Textures created from color materials follow a specific naming convention (you'll notice it when you it). Maybe that helps...
68
##### Support / Environment reflection on a textured objects
« Last post by Promyclon on August 28, 2017, 01:33:51 pm »
Hi,

I managed so far to write couple of shaders for my model. Some of them add environment reflection to plain color element and it looks fine. I'm trying to find a way to to the same with textured elements.

Even this wasn't easy. I added environment texture to materials (.mtl) to make it accessible in fragment shader and found that an object loaded from .obj loses its color information from Kd field, that was available in color attribute. Color was got from (I guess) left top pixel of the texture. This color I had to hardcode in shaders and I could because I have distinct shader for every material that needs a non-different one.  I got to the point where I'd like to add a reflection to textured elements.

I open .obj and .mtl files in Java on PC to serialize it and use on Android. I decided to put my processing here to feed model's elements with additional data. I've extracted texture ID from elements to replace it with TextureInfo containing original texture and reflection texture. But as I could get texture using PolygonManager, I cannot find how can I get a vertex color. I think putting it in the additionalColor would preserve this color and I could have .mtl colored elements back.

But I cannot find how to extract from Object3D a Kd color from .mtl. How to preserve Kd color when a texture is added to an object?

At the moment of converting objects I don't know which ones will be reflective - this depends on their shaders in apk. So I'd add environment texture to all of them and remove the texture from map_Kd in .mtl. It's overfluous for sure (I know the map id is assigned to every polygon), but is there another way? Could I inject env map into the shaders in some other way?
69