Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - AGP

Pages: 1 ... 4 5 [6] 7 8 ... 16
76
Bones / OgreMax
« on: May 11, 2014, 07:02:25 am »
Either the developer of OgreMax really doesn't like me (can't think of any reason for that) or I have cause for concern that OgreMax might not be getting updated. If that happens, could you, raft, be persuaded to support another 3ds Max-exportable format?

77
Support / Collision Trouble
« on: May 04, 2014, 02:02:12 am »
I'm trying to have my character collide against walls without getting stuck or ever going through them. The following code is problematic. My question is broad, I know, but maybe I'm doing something wrong...

Code: [Select]
     private SimpleVector collide(SimpleVector directionToHead) {
silmaria.collisionObject.setVisibility(true);
SimpleVector direction = hero.get(0).checkForCollisionEllipsoid(directionToHead, new SimpleVector(.15f, 2f, .15f), 5);//.5f, 2f, .5f), 5
silmaria.collisionObject.setVisibility(false);
if (directionToHead.x != direction.x || directionToHead.z != direction.z) {
     collidedThisFrame = true;
     float multiplier = -2f;
     if (currentAnimation == WALKS)
multiplier = -3.5f;
     direction.x = multiplier*directionToHead.x;
     direction.z = multiplier*directionToHead.z;
}
else collidedThisFrame = false;
return direction;
     }

78
I'm writing a simple particle system, but World.renderScene(FB) is crashing with an ArrayIndexOutOfBoundsException. The following is my console.

Quote
C:\MyPrograms\3D\Algorithms\ParticleSystems\Flames>java -classpath jpct.jar;. MyFrame
Java version is: 1.7.0_51
-> support for BufferedImage
Version helper for 1.5+ initialized!
-> using BufferedImage
Software renderer (OpenGL mode) initialized
Loading Texture...Flames.jpg
New WorldProcessor created using 1 thread(s) and granularity of 1!
Creating new world processor buffer for thread main
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: -1
        at com.threed.jpct.Object3D.render(Object3D.java:9315)
        at com.threed.jpct.WorldProcessor.processInternal(WorldProcessor.java:21
6)
        at com.threed.jpct.WorldProcessor.process(WorldProcessor.java:110)
        at com.threed.jpct.World.renderScene(World.java:1569)
        at MyFrame.loop(MyFrame.java:35)
        at MyFrame.<init>(MyFrame.java:27)
        at MyFrame.main(MyFrame.java:56)
Terminate batch job (Y/N)?
^C
C:\MyPrograms\3D\Algorithms\ParticleSystems\Flames>

By the way, if I don't call    camera.moveCamera(Camera.CAMERA_MOVEOUT, 2f), it doesn't crash (but I still don't see anything).

79
Support / How do I do Object3D.rotate(SimpleVector)
« on: March 27, 2014, 03:40:47 am »
Surely, the equivalent (I'm porting code from the old irrlicht engine) isn't:
Code: [Select]
someObject3D.rotateX(sv.x);
someObject3D.rotateY(sv.y);
someObject3D.rotateZ(sv.z);

Is it?

80
Feedback / Feature Requests
« on: March 22, 2014, 10:34:08 pm »
You could have a message board just for feature requests. :- )

Anyway, here are mine: cube-mapping and update for newer shader grammar (lines like layout (location = 0) in vec3 VertexPosition don't currently compile).

81
When I rotateMesh() and clearRotation() of a plane acquired by Primitives.getPlane(40, 1), my vertex shader doesn't work in the proper axis. If I leave the rotation in its matrix, it works fine. That has to be considered a bug, right?

82
Only some of my computers produce this error (a laptop with both an NVidia graphics chip and an Intel one and a desktop using onboard graphics), but when I get this the screen starts blinking and the game doesn't run. This is for the hardware renderer. I'm using lwjgl 2.9.1, for whatever it's worth.

83
Support / When does getTransformedCenter() not work?
« on: February 11, 2014, 06:19:43 pm »
In that same town whose parts are its children, which gets rotated and translated into place, so are the waterfall particles its children. At the end of the waterfall loop, I try to reposition each particle at their origin. But with each new spin of the loop they get farther and farther away from each other. The following is the simple method that should put each individual particle in its origin, but doesn't.

Code: [Select]
     public void returnToOrigin() {
this.calcCenter();
SimpleVector position = this.getTransformedCenter();
this.translate(initialPosition.x-position.x, initialPosition.y-position.y, initialPosition.z-position.z);
     }

84
Support / Per-Polygon Transparency
« on: February 06, 2014, 07:21:37 pm »
I'm exporting a little particle waterfall splash from 3ds max as a sequence of OBJs. Each OBJ has several triangles with different values for visibility. I have two problems: the first, naturally, is to export these values per-polygon (a simple MaxScript should produce a companion text file describing their visibilty), and the second, of course, is to apply these visibilities per-polygon in jpct (lest I have to have an Object3D per polygon, which seems bizarre memory-wasteful). Is this possible?

85
Support / Robombs Source
« on: February 01, 2014, 11:18:59 pm »
I'm having a look at the Robombs source code. I'm trying to steal your explosions. Actually, I did steal it. :- ) I just don't understand what I'm seeing. At the center of my scene is a simple, untextured, gray sphere. That is what I pass to the simplified addExplosion (which now takes Object3Ds and no ClientEventQueue). The following is just one of several fairly incomprehensible states of the explosion:


And here I hoped for a nice particle explosion...

86
Support / Negative Y Isn't Going Up
« on: January 26, 2014, 09:57:36 pm »
I have a scene that's completely aligned with its SkyBox. Yet when I translate an object with mainGate.translate(0, -deltaTime, 0), it moves on what I think is the x/z plane. What gives?

87
Support / Shader Problem
« on: January 22, 2014, 04:58:53 pm »
Sorry about the shader question. I made a slight change to this in order to update it with the camera's position. Ray, of course, is always the center of the ocean plane. All I get is a black plane in jpct. The first method is how I update the shader (once per gameloop iteration, naturally).

Code: [Select]
     public void update(SimpleVector cameraPosition) {
shader.setUniform("iGlobalTime", (timeF+=.1f));
shader.setUniform("pos", cameraPosition);
     }

Code: [Select]
// License Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.

uniform vec3 iResolution;
uniform vec3 iChannelResolution[4];
uniform vec3 pos;
uniform vec3 ray;
uniform float iGlobalTime;
uniform float iChannelTime[4];
uniform sampler2D iChannel0;
uniform sampler2D iChannel1;
uniform sampler2D iChannel2;
uniform sampler2D iChannel3;

const float tau = 6.28318530717958647692;

// Gamma correction
#define GAMMA (2.2)

vec3 ToLinear( in vec3 col ) {
// simulate a monitor, converting colour values into light values
return pow( col, vec3(GAMMA) );
}

vec3 ToGamma( in vec3 col ) {
// convert back into colour values, so the correct light will come out of the monitor
return pow( col, vec3(1.0/GAMMA) );
}

vec3 localRay;

// Set up a camera looking at the scene.
// origin - camera is positioned relative to, and looking at, this point
// distance - how far camera is from origin
// rotation - about x & y axes, by left-hand screw rule, relative to camera looking along +z
// zoom - the relative length of the lens
void CamPolar( out vec3 pos, out vec3 ray, in vec3 origin, in vec2 rotation, in float distance, in float zoom ) {
// get rotation coefficients
vec2 c = vec2(cos(rotation.x),cos(rotation.y));
vec4 s;
s.xy = vec2(sin(rotation.x),sin(rotation.y)); // worth testing if this is faster as sin or sqrt(1.0-cos);
s.zw = -s.xy;

// ray in view space
ray.xy = gl_FragCoord.xy - iResolution.xy*.5;
ray.z = iResolution.y*zoom;
ray = normalize(ray);
localRay = ray;

// rotate ray
ray.yz = ray.yz*c.xx + ray.zy*s.zx;
ray.xz = ray.xz*c.yy + ray.zx*s.yw;

// position camera
pos = origin - distance*vec3(c.x*s.y,s.z,c.x*c.y);
}

// Noise functions, distinguished by variable types

vec2 Noise( in vec3 x ) {
    vec3 p = floor(x);
    vec3 f = fract(x);
f = f*f*(3.0-2.0*f);
// vec3 f2 = f*f; f = f*f2*(10.0-15.0*f+6.0*f2);

vec2 uv = (p.xy+vec2(37.0,17.0)*p.z) + f.xy;

// hardware interpolation lacks precision
// vec4 rg = texture2D( iChannel0, (uv+0.5)/256.0, -100.0 );
vec4 rg = mix( mix(
texture2D( iChannel0, (floor(uv)+0.5)/256.0, -100.0 ),
texture2D( iChannel0, (floor(uv)+vec2(1,0)+0.5)/256.0, -100.0 ),
fract(uv.x) ),
  mix(
texture2D( iChannel0, (floor(uv)+vec2(0,1)+0.5)/256.0, -100.0 ),
texture2D( iChannel0, (floor(uv)+1.5)/256.0, -100.0 ),
fract(uv.x) ),
fract(uv.y) );
 

return mix( rg.yw, rg.xz, f.z );
}

vec4 Noise( in vec2 x ) {
    vec2 p = floor(x.xy);
    vec2 f = fract(x.xy);
f = f*f*(3.0-2.0*f);
// vec3 f2 = f*f; f = f*f2*(10.0-15.0*f+6.0*f2);

vec2 uv = p.xy + f.xy;
return texture2D( iChannel0, (uv+0.5)/256.0, -100.0 );
}

vec4 Noise( in ivec2 x ) {
return texture2D( iChannel0, (vec2(x)+0.5)/256.0, -100.0 );
}

vec2 Noise( in ivec3 x ) {
vec2 uv = vec2(x.xy)+vec2(37.0,17.0)*float(x.z);
return texture2D( iChannel0, (uv+0.5)/256.0, -100.0 ).xz;
}

float Waves( vec3 pos ) {
pos *= .2*vec3(1,1,1);

const int octaves = 6;
float f = 0.0;

// need to do the octaves from large to small, otherwise things don't line up
// (because I rotate by 45 degrees on each octave)
pos += iGlobalTime*vec3(0,.1,.1);
for ( int i=0; i < octaves; i++ ) {
pos = (pos.yzx + pos.zyx*vec3(1,-1,1))/sqrt(2.0);
f  = f*2.0+abs(Noise(pos).x-.5)*2.0;
pos *= 2.0;
}
f /= exp2(float(octaves));

return (.5-f)*1.0;
}

float WavesDetail( vec3 pos ) {
pos *= .2*vec3(1,1,1);

const int octaves = 8;
float f = 0.0;

// need to do the octaves from large to small, otherwise things don't line up
// (because I rotate by 45 degrees on each octave)
pos += iGlobalTime*vec3(0,.1,.1);
for ( int i=0; i < octaves; i++ ) {
pos = (pos.yzx + pos.zyx*vec3(1,-1,1))/sqrt(2.0);
f  = f*2.0+abs(Noise(pos).x-.5)*2.0;
pos *= 2.0;
}
f /= exp2(float(octaves));

return (.5-f)*1.0;
}

float WavesSmooth( vec3 pos ) {
pos *= .2*vec3(1,1,1);

const int octaves = 2;
float f = 0.0;

// need to do the octaves from large to small, otherwise things don't line up
// (because I rotate by 45 degrees on each octave)
pos += iGlobalTime*vec3(0,.1,.1);
for ( int i=0; i < octaves; i++ ) {
pos = (pos.yzx + pos.zyx*vec3(1,-1,1))/sqrt(2.0);
//f  = f*2.0+abs(Noise(pos).x-.5)*2.0;
f  = f*2.0+sqrt(pow(Noise(pos).x-.5,2.0)+.01)*2.0;
pos *= 2.0;
}
f /= exp2(float(octaves));

return (.5-f)*1.0;
}

float WaveCrests( vec3 ipos ) {
vec3 pos = ipos;
pos *= .2*vec3(1,1,1);

const int octaves1 = 6;
const int octaves2 = 16;
float f = 0.0;

// need to do the octaves from large to small, otherwise things don't line up
// (because I rotate by 45 degrees on each octave)
pos += iGlobalTime*vec3(0,.1,.1);
vec3 pos2 = pos;
for ( int i=0; i < octaves1; i++ ) {
pos = (pos.yzx + pos.zyx*vec3(1,-1,1))/sqrt(2.0);
f  = f*1.5+abs(Noise(pos).x-.5)*2.0;
pos *= 2.0;
}
pos = pos2 * exp2(float(octaves1));
pos.y = -.05*iGlobalTime;
for ( int i=octaves1; i < octaves2; i++ ) {
pos = (pos.yzx + pos.zyx*vec3(1,-1,1))/sqrt(2.0);
f  = f*1.5+pow(abs(Noise(pos).x-.5)*2.0,1.0);
pos *= 2.0;
}
f /= 1500.0;

f -= Noise(ivec2(gl_FragCoord.xy)).x*.01;

return pow(smoothstep(.4,-.1,f),6.0);
}


vec3 Sky( vec3 ray ) {
return vec3(.4,.45,.5);
}


float OceanDistanceField( vec3 pos ) {
return pos.y - Waves(pos);
}

float OceanDistanceFieldDetail( vec3 pos ) {
return pos.y - WavesDetail(pos);
}

vec3 OceanNormal( vec3 pos ) {
vec3 norm;
vec2 d = vec2(.01*length(pos),0);

norm.x = OceanDistanceFieldDetail( pos+d.xyy )-OceanDistanceFieldDetail( pos-d.xyy );
norm.y = OceanDistanceFieldDetail( pos+d.yxy )-OceanDistanceFieldDetail( pos-d.yxy );
norm.z = OceanDistanceFieldDetail( pos+d.yyx )-OceanDistanceFieldDetail( pos-d.yyx );

return normalize(norm);
}

float TraceOcean( vec3 pos, vec3 ray ) {
float h = 1.0;
float t = 0.0;
for ( int i=0; i < 100; i++ ) {
if ( h < .01 || t > 100.0 )
break;
h = OceanDistanceField( pos+t*ray );
t += h;
}

if ( h > .1 )
return 0.0;

return t;
}

vec3 ShadeOcean( vec3 pos, vec3 ray ) {
vec3 norm = OceanNormal(pos);
float ndotr = dot(ray,norm);

float fresnel = pow(1.0-abs(ndotr),5.0);

vec3 reflectedRay = ray-2.0*norm*ndotr;
vec3 refractedRay = ray+(-cos(1.33*acos(-ndotr))-ndotr)*norm;
refractedRay = normalize(refractedRay);

const float crackFudge = .0;

// reflection
vec3 reflection = Sky(reflectedRay);

vec3 col = vec3(0,.04,.04); // under-sea colour

col = mix( col, reflection, fresnel );

// foam
col = mix( col, vec3(1), WaveCrests(pos) );

return col;
}

void main(void) {
// vec2 camRot = vec2(.5,.5)+vec2(-.35,4.5)*(iMouse.yx/iResolution.yx);
// vec3 pos, ray;
// CamPolar( pos, ray, vec3(0), camRot, 3.0, 1.0 );

float to = TraceOcean( pos, ray );

vec3 result;
if ( to > 0.0 )
result = ShadeOcean( pos+ray*to, ray );
else result = Sky( ray );

// vignette effect
result *= 1.1*smoothstep( .35, 1.0, localRay.z );

gl_FragColor = vec4(ToGamma(result),1.0);
}

88
Support / How to move U/V Coordinates...
« on: January 21, 2014, 04:35:18 am »
...so as to animate river water? The following doesn't work, for some reason:

Code: [Select]
     public void moveRiverWater(float deltaTime) {
Matrix matrix = river.getTextureMatrix();
if (matrix == null) {
     matrix = new Matrix();
     river.setTextureMatrix(matrix);
}
matrix.translate(river.getXAxis().x*100*deltaTime, river.getXAxis().y*100*deltaTime, river.getXAxis().z*100f*deltaTime);
river.setTextureMatrix(matrix);//WITH OR WITHOUT THIS SEEMINGLY UNNECESSARY CALL, IT DOESN'T WORK
     }

I get absolutely nothing whether or not the object is compiled.

89
Support / Checking for triangle strip... and More
« on: January 20, 2014, 09:21:36 pm »
What does the following message mean?

Quote
Checking for triangle strip...
Not a triangle strip at position 1!
Subobject of object 35/object37 compiled to indexed data using 23997/4599 vertic
es in 46ms!

Also, what does it mean when you get

Quote
Loading file Silmaria\FastOceanShader\vertexshader.glsl
Text file Silmaria\FastOceanShader\vertexshader.glsl loaded...100 bytes
Loading file Silmaria\FastOceanShader\fragmentshader.glsl
Text file Silmaria\FastOceanShader\fragmentshader.glsl loaded...6865 bytes
Loading Texture...Silmaria\FastOceanShader\Noise.png

but then get neither a "shader compiled" nor a "failed to compile" message? I am, of course, doing the following. Alas, I'm getting no input from jpct.

Code: [Select]
shader = new GLSLShader(vertex, fragment);
shader.setUniform("iChannel0", 1);
shader.setUniform("iGlobalTime", 0f);
shader.setStaticUniform("iResolution", new SimpleVector(1024, 768, 24));
waterPlane.setRenderHook(shader);

90
Support / Vertices in Worldspace
« on: January 09, 2014, 10:06:55 pm »
Does the following method make sense? If not, how would I go about getting all vertices in worldspace?

Code: [Select]
     private SimpleVector wsVertices(Object3D obj) {
GenericVertexController vertexController = new GenericVertexController();
vertexController.init(obj.getMesh());
SimpleVector[] vertices = vertexController.getSourceMesh();
for (int i = 0; i < vertices.length; i++)
     vertices[i] *= obj.getTranslation(); //OR MAYBE obj.getTransformedCenter()?
return vertices;
     }

Pages: 1 ... 4 5 [6] 7 8 ... 16