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 - MichaelJPCT

Pages: 1 2 3 [4] 5
Support / questions about render-to-texture
« on: July 10, 2016, 04:43:22 pm »
i am new to RTT, and i am now using FrameBuffer.setRenderTarget() to render into textures. (the FrameBuffer is the same one as the main window)

1) i blit white text into a texture after clearing FB with black color. when the texture is applied to a transparent Object3D, the black part is visible. but i have another texture loaded from a grayscale PNG file, where the black part is invisible. why isn't the RTT texture tranparent?
2) the doc says RTT must not use mipmaping. but if a texture will never be rendered into again after the first time, can it have mipmaping afterwards?
3) if a texture has size of 32x32 while the FB is 1280x800, when rendering into the texture, is the renderer doing work on 32x32 pixels or 1280x800 pixels? i mean the workload, is it small or large.

Support / full screen mask with continuous changing alpha?
« on: July 07, 2016, 07:30:09 am »
i am trying to use Overlay to make a full screen mask. the mask must be able to change alpha from zero to full opacity, continuously.
i applied a black texture with alpha to the Overlay.
i tried different combination of alpha value(Texture) and transparency(Overlay), i just couldn't have it changing continuously.

1) Texture.setAlpha() has no effect on the Overlay, maybe an texture upload per frame is required.
2) i tried Texture.overrideTexelData(), it seemed to work. but it requires texture uploading, it clearly slows down the program.
3) the argument to Overlay.setTransparency() isn't the same thing as alpha, when i tried, 0 resulted in full transparency, 4 resulted in full opacity. and it's in integer, not float.

what else can i try?

Support / suggestion on API, setTranslation, setMatrix, setOrigin
« on: July 06, 2016, 09:23:12 am »
when i want to position an Object3D, if the object has children, i can't use setOrigin(), i must set the translation.
but there is no setTranslation(), there is translate() which requires relative position.
but most of the time i don't directly know how much should i move the object, instead i know the current position of the object. so i call clearTranslation() then translate(), or set the Matrix of the object. in case i just need to position an object at a certain position, i don't need a Matrix, isn't setTranslation() a better method?
and if Object3D has a setMatrix method like this, setMatrix(float[] matrixFloatArray), that can be convenient too.

and some APIs require a SimpleVector as argument, such as setOrigin(SimpleVector vec), why not a method like setOrigin(float x,float y,float z) ?

Support / trying to make an LOD system
« on: July 01, 2016, 10:14:25 am »
i plan to have an LOD system in my graphics module. basically in a class of mine there is an array of Object3D or Mesh, and i can choose which LOD should show up. the problem is , should i use an array of Object3D or Mesh?
i originally planned to use Mesh, and use setMesh() to switch Mesh when i need another LOD. but later i read the forum and saw that UV data were stored in Object3D, not Mesh.

on the other hand, the downside of using array of Object3D, is that:
i have an object tree, each object can have multiple children that inherit its transformation. when i switch LOD, i have to call Object3D.removeParent, Object3D.addParent, world.removeObject, world.addObject... on multiple Object3D's.
Java performance is quite good, and these calls should not cost much, but it just looks like some trouble.
i can also do it without the parent system from JPCT, meaning that i do all transformation in my code, and use setOrigin, setOrientation, setTranslationMatrix etc to position the Object3D's. then i don't need to call removeParent,addParent, but my code for transformation would grow large, that's some trouble too.

is there a simpler way to make an LOD system?

Support / problem regarding Texture blitting
« on: June 12, 2016, 08:34:34 am »
i tried to make a small 2D app on Android with JPCT, mainly using Texture blitting to show a background and text font. (i know this is not a normal way to make 2D app, but my java code can be reused)

i made a desktop version of the app with JPCT without problem, but on Android the text doesn't show. the only difference (in my codes) between desktop version and Android version is BitmapFactory is used to load texture on Android.

my texture for font is sized 2048x32.  the JPCT doc says "If a texture with a different width/height is used, it will be scaled to a width/height of 256 automatically" for desktop version, and "If a texture with a different width/height is used, an error will be raised Textures are managed by the TextureManager." for Android version.
but in my desktop app the fonts show clearly, no evidence of the texture being scaled. in my Android app i don't use TextureManager.
strangely, my app uses a 512x1024 texture for background and it shows clearly on both desktop and Android.

i don't know what makes the Android version fail. the test device has 1GB of ram so ram size shouldn't be the cause.

Projects / is there any DOOM remake or QUAKE remake project with JPCT?
« on: January 10, 2016, 04:49:31 pm »
it would be fun to play these games with newer graphics engine  :)

Support / problem with texture tile
« on: January 05, 2016, 10:18:44 am »
i found texture tile to be not precisely repeating:
i have a plane created by

plane=ExtendedPrimitives.createPlane(4096,20); ExtendedPrimitives.transformUVCoords(plane,0,0,256,256,0,0);
tex.setClamping(0); plane.setTexture(tex); plane.compileAndStrip();;

texture image size is 256x256.
say i look at position (0,0,0) of the plane, i see some part of the texture. then i translate the plane to (4096,0,0), in theory i should see the same texture, but i saw the texture changed. no matter what parameter i put into the transformUVCoords call. i don't know why.

Support / Near plane clipping (was: techniques for displaying text)
« on: January 03, 2016, 02:12:42 pm »
i am trying to do multipass rendering of a single world, dividing a world into near/middle/far parts. render far parts before rendering near parts,  like this:

world.setClippingPlanes(250.0 , 20000.0); world.renderScene(framebuffer); world.draw(framebuffer); framebuffer.clearZBufferOnly(); world.setClippingPlanes(5.0 , 250.0); world.renderScene(framebuffer); world.draw(framebuffer); framebuffer.clearZBufferOnly();
world.setClippingPlanes(0.1 , 5.0); world.renderScene(framebuffer); world.draw(framebuffer)

but the end result is not what i expect. is my method wrong? how can i achieve the multipass effect i described?

Support / naming the vertex attributes
« on: January 03, 2016, 10:29:06 am »
say i created a plane with ExtendedPrimitives.createPlane,
in the object3d there is a mesh, and the mesh has vertex positions, uv coords, etc.
they are like vertex attributes, but they are not in VertexAttribute objects.

if i want to use shader with this plane and i need to access vertex position, normal, uv coords... how can i access them?

Support / can i change min max fov?
« on: January 02, 2016, 02:08:59 pm »
i get 0.5 and 1.5 for minfov and maxfov, those are about 30 and 75 degree in horizontal direction. but i want larger range.

Bugs / cant use softward n hardware renderer on the same framebuffer
« on: January 01, 2016, 02:47:09 pm »
javadoc says "It is possible to use the software renderer as well as the OpenGL renderer on a single framebuffer at the same time"

i tried this:

buffer.disableRenderer(2); buffer.enableRenderer(1)
buffer.disableRenderer(1); buffer.enableRenderer(2)

then "array index out of bound exception" was reported at buffer.clear().

i was trying to use software renderer to render a large model with per-pixel fog, since my GPU can't do per-pixel fog.

Feedback / new way to develop with JPCT - Jython
« on: December 30, 2015, 03:13:01 pm »
i am more familiar with Python than with Java and after writing some java code i still think Python code is much faster to write, although Python runs much slower than Java. and for a beginner, the oppotunity to type in functions or change states when the program is running, then see the effects immediately (this is so called "interactive mode", as oppose to modify code -> compile -> test run) is a great help.
Jython is Python which runs on Java Virtual Machine, and it is possibly compatible with any Java libraries, so a JPCT game could be written mostly in Python code, although some parts should be written in Java or even C language to keep a high running performance.

now let's see how a JPCT program can be written with Jython.

to start up the program, create a shortcut such as start.bat.
-i means interactive mode, pause to let yourself read any error messages.
Code: [Select]
@c:\jythonpath\jython.exe -Djava.library.path=jar_path -i

minimal example of a JPCT program, save as
Code: [Select]
import sys,time; sys.path+=['jar_path','jar_path/jpct.jar','jar_path/lwjgl.jar','jar_path/lwjgl_util.jar']
from com.threed.jpct import *; from com.threed.jpct.util import *; from org.lwjgl.opengl import Display

timeToSleep=0.01 # 0.01 second

def sleepSomeTime(): time.sleep(timeToSleep) # or calculate a value to make framerate constant

def GameLogic(): return
def pollKeyboard(): return

def mainLoop():
    global running
    while running:
        GameLogic(); fb.clear(); fb.update(); sleepSomeTime(); fb.display(); pollKeyboard()
        # if some key event: running=0
        if Display.isCloseRequested(): Display.destroy(); break

if "some key event" happens and interactive mode is used, mainLoop stops and you can type in commands, such as change timeToSleep to 0.02, then call mainLoop again after changing running back to 1. this is an example of the benefit of interactive mode.

to import your own java class, put class files in jar_path or append another path to sys.path, then import YourJavaClass

if you know both Python language and Java, you may find this approach has some advantages.

Support / techniques for displaying text
« on: December 28, 2015, 03:38:19 pm »
right now i am looking into text rendering. after some research i found several ways to put text onto screen:
1) texture blitting as the way jpct examples do
2) billboard object3D placed in front of camera
3) using overlay class of jpct
4) make rectangles to hold texture of each character and render these rectangles with ortho projection and depth-test off

i would like to know whether blitting is the fastest method (runtime performance) and whether the 4th method can be done in jpct - i need to manipulate opengl states manually such as calling glDisable, glMatrixMode at a specific time in the rendering process.

i like to write something like:
Code: [Select]
import org.lwjgl.opengl;
class { method() { opengl.Display.setTitle("abc"); } }
but no matter what i tried:
import org.lwjgl;
import org.lwjgl.opengl.*
jave doens't compile.
do i have to write { org.lwjgl.opengl.Display.method(); } every time?

Support / non standard window size and OPENGL renderer?
« on: December 26, 2015, 04:02:52 pm »
hello i just started to try jpct the desktop version. so far i created a non fullscreen window with non standard size , but can't get OPENGL hardward renderer.
another problem is, if i set the window size to a standard size, the OPENGL renderer opens another window that i don't want.
how to setup the window correctly?

my current code is like this:

GraphicsEnvironment e=GraphicsEnvironment.getLocalGraphicsEnvironment();
gDevice=e.getDefaultScreenDevice(); GraphicsConfiguration gc=gDevice.getDefaultConfiguration();
gwin=new Frame(gc); gwin.setUndecorated(true); gwin.setIgnoreRepaint(true); gwin.setResizable(false);
gwin.pack(); Dimension d=new Dimension(1280,766); gwin.setSize(d);
gwin.setVisible(true); gfx=gwin.getGraphics();
gbuf=new FrameBuffer(1280,766,FrameBuffer.SAMPLINGMODE_NORMAL);
gbuf.enableRenderer(IRenderer.RENDERER_OPENGL); gbuf.optimizeBufferAccess();

and in the mainloop:
gbuf.clear(); gbuf.update(); gbuf.display(gfx);

note that i want the window to have no border/title, and sized 1280x766 (766=800-34, the height of taskbar)
in my experience at other 3D engine, non standard window size is achievable.
i am new to java and jpct, so can't find out what's wrong in my code. could someone help me? thanks.

Pages: 1 2 3 [4] 5