Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (477)
Games in Android Showcase (107)
games submitted by our members
Games in WIP (536)
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 1674 times)
0 Members and 1 Guest are viewing this topic.
Offline CyanPrime
« Posted 2012-06-27 18: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 19: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
« League of Dukes »

JGO Overlord


Medals: 746
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #2 - Posted 2012-06-27 19: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 20: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: 338
Projects: 2
Exp: 5 years


I'm the King!


« Reply #4 - Posted 2012-06-27 22: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 Kernel


Medals: 343
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Reply #5 - Posted 2012-06-27 23: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 11: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: 338
Projects: 2
Exp: 5 years


I'm the King!


« Reply #7 - Posted 2012-06-29 21: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: 18



« Reply #8 - Posted 2012-06-29 21: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 02:10:25 »

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

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

Riven (18 views)
2014-07-29 18:09:19

Riven (13 views)
2014-07-29 18:08:52

Dwinin (12 views)
2014-07-29 10:59:34

E.R. Fleming (31 views)
2014-07-29 03:07:13

E.R. Fleming (12 views)
2014-07-29 03:06:25

pw (42 views)
2014-07-24 01:59:36

Riven (41 views)
2014-07-23 21:16:32

Riven (28 views)
2014-07-23 21:07:15

Riven (29 views)
2014-07-23 20:56:16

ctomni231 (60 views)
2014-07-18 06:55:21
HotSpot Options
by dleskov
2014-07-08 03:59:08

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:58:24

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:47:22

How do I start Java Game Development?
by ra4king
2014-05-17 11:13:37

HotSpot Options
by Roquen
2014-05-15 09:59:54

HotSpot Options
by Roquen
2014-05-06 15:03:10

Escape Analysis
by Roquen
2014-04-29 22:16:43

Experimental Toys
by Roquen
2014-04-28 13:24:22
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!