ambiera home ambiera home

Ambiera Forum

Discussions, Help and Support.

Create a new account, Search, or Login:
Name:  Password:
Ambiera Forum > CopperLicht
How could I automate this?
Author Text

sagh0900
Registered User
Quote
2012-11-08 14:54:01

My Vertex Shader:


<script id="vshader" type="x-shader/x-vertex" >
ifdef GL_ES
precision highp float;
endif

uniform mat4 worldviewproj;

attribute vec4 vPosition;
attribute vec4 vNormal;
attribute vec2 vTexCoord1;

varying vec2 v_texCoord;

void main() {
gl_Position = worldviewproj * vPosition;
v_texCoord = vTexCoord1.st;
}
</script>


My Fragment Shader:


<script id="fshader" type="x-shader/x-fragment">
ifdef GL_ES
precision highp float;
endif

uniform sampler2D uSampler;
varying vec2 v_texCoord;
varying vec3 vLightWeighting;
void main()
{
vec4 textureColor = texture2D(uSampler, vec2(v_texCoord.s, v_texCoord.t));
gl_FragColor = textureColor;
}
</script>


My JS Code:



<script type="text/javascript">

var Distance = 30;
var Triliza = new Array();
var engine = null;
function CopperlichtStart() {

engine = new CL3D.CopperLicht('glcanvas', true, 60, true);
if (!engine.initRenderer())
return;
scene = new CL3D.Scene();
engine.addScene(scene);
scene.setBackgroundColor(CL3D.createColor(1, 0, 0, 0));
scene.setRedrawMode(CL3D.Scene.REDRAW_EVERY_FRAME);
var cam = new CL3D.CameraSceneNode();
cam.Pos.X = 0;
cam.Pos.Y = 0;
cam.Pos.Z = -200;
var canvas = document.getElementById("glcanvas");
var AR = canvas.width / canvas.height;
cam.setAspectRatio(AR);
cam.setFov(45);
scene.getRootSceneNode().addChild(cam);
scene.setActiveCamera(cam);
var vshaderScript = document.getElementById("vshader");
var fshaderScript = document.getElementById("fshader");
var newMaterialType = engine.getRenderer().createMaterialType(vshaderScript.text, fshaderScript.text);
initCube(scene, newMaterialType);
}

function initCube(scene, newMaterialType)
{
var z = -Distance;
for (var j = 0; j < 3; j++) {
var x = -Distance;
var y = -Distance;
for (var i = 0; i < 9; i++) {
Triliza[i + 9 * j] = new CubeSceneNode();
Triliza[i + 9 * j].getMaterial(0).Tex1 = engine.getTextureManager().getTexture("resources/crate.jpg", true);
scene.getRootSceneNode().addChild(Triliza[i + 9 * j]);
Triliza[i + 9 * j].Pos = new Vect3d(x, y, z);
Triliza[i + 9 * j].addAnimator(new CL3D.AnimatorRotation(new CL3D.Vect3d(0.0, 0.15, -0.15)));
x += Distance;
if (x == Distance * 2) {
x = -Distance;
y += Distance;
}

if (newMaterialType != -1)
Triliza[i + 9 * j].getMaterial(0).Type = newMaterialType;
else
alert('can't create Shaders');
}
z += Distance;
}

}
</script>
</head>


My Html Code:


<body ="CopperlichtStart()">
<canvas id="glcanvas" width="720" height="405" style="background-color:000000"></canvas>
</body >


My intention was to display and rotate the cubescenenodes on the screen which I couldn't able to do that. It shows whole blank screen just. But point to note is, I was able to see the FPS variations although canvas was whole black. Please could you help with this @niko.


Create reply:


Posted by: (you are not logged in)


Enter the missing letter in: "Internatio?al" (you are not logged in)


Text:

 

  

Forum Codes


Feature Code
Link [url] www.example.com [/url]
Bold [b]bold text[/b]
Image [img]http://www.example.com/image.jpg[/img]
Quote [quote]quoted text[/quote]
Code [code]source code[/code]

Emoticons


   





Software: Ambiera Light Forum. © 2008-2019 Nikolaus Gebhardt, Ambiera e.U.