Java-Gaming.org Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (684)
Games in Android Showcase (196)
games submitted by our members
Games in WIP (752)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  webGL .obj viewer  (Read 2723 times)
0 Members and 1 Guest are viewing this topic.
Offline CyanPrime
« Posted 2012-06-27 16:17:59 »

Just showing you guys something cool I whipped up for fun. Enjoy  Grin:
https://dl.dropbox.com/u/28109593/model-spin-test/webgl.html
Offline CyanPrime
« Reply #1 - Posted 2012-06-27 17:44:04 »

Looking for some help with this. It's easy code to understand.

My makeshift push/pop matrix code seems to have no effect at all, the model doesn't translate to it's position.

1  
2  
3  
4  
5  
    var savedMat = mat4.create();
          savedMat.set(mvMatrix);
             mat4.translate(mvMatrix, [model.x, model.y, model.z]);
             gl.drawArrays(gl.TRIANGLES, 0, model.VertexPositionBuffer.numItems);
          mvMatrix.set(savedMat);


I want the models to be drawn at their position/ and later on rotation, and not affect the mvMatrix (modelview matrix).

sudocode

1  
2  
3  
4  
5  
create temp matrix
set temp matrix to modelview matrix
translate modelview matrix to model position
draw model
set modelview matrix to temp matrix
Offline Riven
Administrator

« JGO Overlord »


Medals: 1228
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #2 - Posted 2012-06-27 17:56:53 »

I have never worked with WebGL, but I googled 5 minutes.

1  
2  
3  
4  
5  
6  
7  
    var savedMat = mat4.create();
          savedMat.set(mvMatrix);
             mat4.translate(mvMatrix, [model.x, model.y, model.z]);
+            gl.uniformMatrix4fv(shaderProgram.pMatrixUniform, false, pMatrix);
+            gl.uniformMatrix4fv(shaderProgram.mvMatrixUniform, false, mvMatrix);
             gl.drawArrays(gl.TRIANGLES, 0, model.VertexPositionBuffer.numItems);
          mvMatrix.set(savedMat);



sudocode
if it doesn't work, switch the user!

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings!
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline CyanPrime
« Reply #3 - Posted 2012-06-27 18:01:09 »

Awesome, Riven! Thank you so much!  Grin Grin Grin Grin

Edit: added in another model, and made it so you can rotate the camera with left and right arrows.
Offline ra4king

JGO Kernel


Medals: 435
Projects: 3
Exp: 5 years


I'm the King!


« Reply #4 - Posted 2012-06-27 20:51:33 »

Runs smoothly on my computer with Chrome 20. Really nice! However, I do see some visual glitches like flickering :S

Offline princec

« JGO Spiffy Duke »


Medals: 786
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Reply #5 - Posted 2012-06-27 21:07:23 »

Flickering just looks like z-fighting on two or more overlapping identical polygons to me.

Cas Smiley

Offline CyanPrime
« Reply #6 - Posted 2012-06-29 09:57:42 »

And now time for something a little different: http://pso2u.com/webgl.php (It's a MS3d viewer, it will be animated later. if you get the error about DataView it means your browser don't support it yet.)
Offline ra4king

JGO Kernel


Medals: 435
Projects: 3
Exp: 5 years


I'm the King!


« Reply #7 - Posted 2012-06-29 19:16:05 »

Chrome 20 on Windows 7, all I see is a black box. Opening up the Chrome console, I see this error:
Quote
webgl.php line 477: Uncaught TypeError: Cannot read property '51' of undefined

Offline BoBear2681

JGO Coder


Medals: 19



« Reply #8 - Posted 2012-06-29 19:23:11 »

DataView is not supported in Firefox 13.  Is the only browser you can view that in Chrome?  Talk about bleeding edge.
Offline CyanPrime
« Reply #9 - Posted 2012-06-30 00:10:25 »

I broke it :<
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 
orrenravid (248 views)
2016-07-16 03:57:23

theagentd (318 views)
2016-07-11 14:28:54

Hydroque (405 views)
2016-07-06 05:56:57

Hydroque (566 views)
2016-07-03 08:52:54

GrandCastle (424 views)
2016-07-01 09:13:47

GrandCastle (416 views)
2016-07-01 09:09:45

CopyableCougar4 (470 views)
2016-06-25 16:56:52

Hydroque (437 views)
2016-06-22 02:17:53

SwampChicken (401 views)
2016-06-20 13:22:57

SwampChicken (309 views)
2016-06-20 13:22:49
Making a Dynamic Plugin System
by Hydroque
2016-06-25 00:13:25

Java Data structures
by BinaryMonkL
2016-06-13 21:22:09

Java Data structures
by BinaryMonkL
2016-06-13 21:20:42

FPS Camera Tutorial
by Hydroque
2016-05-22 05:40:58

Website offering 3D Models specifically for games for free
by vusman
2016-05-18 17:23:09

Website offering 3D Models specifically for games for free
by vusman
2016-05-09 08:50:56

Website offering 3D Models specifically for games for free
by vusman
2016-05-06 11:10:21

Website offering 3D Models specifically for games for free
by vusman
2016-04-29 12:56:17
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!